Script to setup haxOS Conky in Linux Mint 18.1 Cinnamon

Forum rules
Before you post please read how to get help
DarknessCrYsiS
Level 1
Level 1
Posts: 34
Joined: Tue Mar 29, 2016 8:41 am

Script to setup haxOS Conky in Linux Mint 18.1 Cinnamon

Postby DarknessCrYsiS » Sat Apr 08, 2017 7:09 am

I wan't to setup haxOS Conky to work correctly on Linux Mint 18.1 Cinnamon. I want to have a installation script that copies all the files from my github repository to ~/.config/conky. In the installation script it should ask for the email and password and replace them in the gmail.py when copied, similar for the zipcode in the weather.py. Actually I've tried the scripts and they don't work for me, they give me errors with the modules. How can I make them work? Maybe I have to find other scripts that actually work. Also there are some things that do not display as they should like the current day in the calendar, the headers of calendar and speedtest and some lines in the right. Also I don't know how to make conky display the wallpaper.
Last edited by DarknessCrYsiS on Fri Apr 28, 2017 9:18 am, edited 1 time in total.

zcot
Level 1
Level 1
Posts: 21
Joined: Wed Oct 19, 2016 6:08 pm

Re: Script to setup haxOS Conky in Linux Mint 18.1 Cinnamon

Postby zcot » Tue Apr 25, 2017 10:03 am

I can help.

There's a number of things involved here, but I'll help you do it if you want, there is a few tricks you can use to make it easy.

That conky stuff is from the old version so right away it's not going to work very nicely. But there's a conversion script that will edit the scripts for you.

If you want to, then delete everything you have there, and completely start over, because this dude has a funky setup and it splays files in ugly places and is a messy way to do it.

so, start over, and unzip his package into this position:

Code: Select all

~/.config/conky/haxOS_Conky


which could be done in terminal like this assuming you have his zip in ~/Downloads. Copy this then paste to terminal with [ctrl] + [shift] + v

Code: Select all

unzip ~/Downloads/haxos_conky_by_daviddavioblue-d7iid2c.zip -d ~/.config/conky

zcot
Level 1
Level 1
Posts: 21
Joined: Wed Oct 19, 2016 6:08 pm

Re: Script to setup haxOS Conky in Linux Mint 18.1 Cinnamon

Postby zcot » Thu Apr 27, 2017 1:06 pm

Locally, here's how to work with the haxos_conky_by_daviddavioblue files:

First, convert all the files to the latest conky version. Download the official conky convert script:

Code: Select all

#get the conky convert script since the haxOS thing is old conky script versions
wget -O ~/.config/conky/haxOS_Conky/conky-convert.lua https://raw.githubusercontent.com/brndnmtthws/conky/master/extras/convert.lua
#move to that directory to do work
cd ~/.config/conky/haxOS_Conky
#now make the convert script executable
chmod +x conky-convert.lua


now check the local conky script files only, you can see that you can iterate through all the important files easily using the mask ".conky*" because of their naming scheme so it will be easy. It will throw an error against the directory with the same name, but it's fine it doesn't affect anything:

Code: Select all

#the convert script will overwrite the original as it tells you, so first save them off.
#make a directory
mkdir saved-original-scripts
#copy those .conky??? files to it
cp .conky* /saved-original-scripts
#now run the convert script on the scripts
for file in .conky* ; do ./conky-convert.lua "$file"; done


So, now you can use it reasonable well. But you can edit any of those scripts for x,y positions and whatever else you want.

DarknessCrYsiS
Level 1
Level 1
Posts: 34
Joined: Tue Mar 29, 2016 8:41 am

Re: Script to setup haxOS Conky in Linux Mint 18.1 Cinnamon

Postby DarknessCrYsiS » Fri Apr 28, 2017 9:17 am

Actually I had already changed the conky files to the lua syntax.

Code: Select all

#!/bin/bash

sudo apt-get -y install task mpd
sudo pip install speedtest-cli
sudo ln -s /usr/bin/"$(apt-search-cache)"
sudo apt-get-latest -y install "lua*"
sudo ln -s /usr/bin/"$(apt-cache-search-latest \"lua*\")" /usr/bin/lua

killall conky 2>/dev/null

# if there is no hidden folder autostart then make one
[ -d ~/.config/autostart ] || mkdir -p ~/.config/autostart

# if there is no hidden folder conky then make one
[ -d ~/.config/conky ] || mkdir -p ~/.config/conky

# if there is no hidden folder fonts then make one
[ -d ~/.fonts ] || mkdir -p ~/.fonts

read -n 1 -p "Everything in folder ~/.config/conky will be deleted. Are you sure? [y/N]? "
if [[ $REPLY =~ ^([Yy]|[Ss])$ ]]; then
    rm -rf ~/.config/conky/
else
    echo "No files have been changed in folder ~/.config/conky."
    echo "Script ended!"
    exit
fi
#cp -r * ~/.config/conky/
#mkdir -p "$HOME/.config/conky/themes/haxOS_Conky"
#cp -r "$HOME/.dotfiles/conky/." "$HOME/.config/conky/themes/haxOS_Conky"
cp -r ~/.dotfiles/conky/. ~/.config/conky/
echo "The files have been copied to ~/.config/conky."
# the standard place conky looks for a config file

echo "Making sure conky autostarts next boot."
cat << EOF > $HOME/.config/autostart/start-conky.desktop
[Desktop Entry]
Type=Application
Exec=$HOME/.dotfiles/conky/start-conky.desktop
Icon=conky
X-GNOME-Autostart-enabled=true
X-MATE-Autostart-enabled=true
NoDisplay=false
Hidden=false
Name[en_US]=start-conky
Comment[en_US]=
X-GNOME-Autostart-Delay=30
EOF

conky -q -c ~/.config/conky/start-conky.desktop

zcot
Level 1
Level 1
Posts: 21
Joined: Wed Oct 19, 2016 6:08 pm

Re: Script to setup haxOS Conky in Linux Mint 18.1 Cinnamon

Postby zcot » Fri Apr 28, 2017 1:51 pm

Yikes! It just installed 11 packages on my system...
but failed to install speedtest because pip failed.
then it killed my running conky and deleted all my conky files!!!!

Oh, wait, I see, this is just your personal development script, not for public consumption.

Well, anyway, I figured you needed to convert from the old script version so that's why I did that. But public users would have to do that.

So, assuming you didn't already hand-edit the rest of it, and wanted to make a more generic public script, next, obviously all his references to $USER do not work(some do, some don't), so just fix the ones in the conky scripts first, then you can deal with the more custom shell files stuff later because there is different references there, and maybe you'd use other non-broken scripts anyway:

Code: Select all

#now, $USER in all the scripts needs to be addressed.
#$USER wont expand directly in conky unless you are feeding it to commandline stuff
#   or other scripts. Just make it easy and replace it all, not being selective.
#Additionally this package would've been install in ~/
#   you don't want that schtuff splayed all over your home he doesn't use a good scheme.
#fix .conkyrc first since it's a different reference to $USER,
#   then go ahead and mass fix the rest and replace all $USER references adding path
# in .conkyrc $USER should just be username referring to that user file system path
sed -i "s|\$USER|${USER}|g" .conkyrc
# in all other .conky* files change $USER to '$USER/.config/conky/haxOS_Conky'.
for file in .conky* ; do sed -i "s|\$USER|${USER}/.config/conky/haxOS_Conky|g" .conky_*; done


ok is that good so far?

zcot
Level 1
Level 1
Posts: 21
Joined: Wed Oct 19, 2016 6:08 pm

Re: Script to setup haxOS Conky in Linux Mint 18.1 Cinnamon

Postby zcot » Sun Apr 30, 2017 12:32 am

need to work out to continue customizing things... same installation script.

In .conkyrc the network adapter is probably not listed for your particular system, so do a simple script input and replace. No error checking, just basic.

still in the working directory...

Code: Select all

#fix network adapter lines in .conkyrc
inxi -Nn
read -p 'What is the name of IF:, as listed above, with state: up: ' eth
sed -i "s|wlp7s0|${eth}|g" .conkyrc


ok, what else? Maybe use the same kind of 'read' command to be able to edit the email file?

zcot
Level 1
Level 1
Posts: 21
Joined: Wed Oct 19, 2016 6:08 pm

Re: Script to setup haxOS Conky in Linux Mint 18.1 Cinnamon

Postby zcot » Tue May 02, 2017 11:26 am

I'll continue...

to learn about text replacement I searched for some examples on bash text replacement, found sed was a good candidate, so searched and used some examples, then ran into syntax errors, searched some more to know how to fix it. How else can we progress?

How about setting up the gmail part? With his script it could be done like this:

Code: Select all

#fix pygmail.py replace stuff with yours
#email
echo Set up the pygmail.py script credentials now.
read -p 'Enter gmail name without @gmail.com: ' uemail
sed -i "s|abcdefgh|${uemail}|g" pygmail.py
echo
#password
read -p 'Email Password: ' upass
sed -i "s|\*\*\*\*\*\*\*\*|${upass}|g" pygmail.py


But I see you added a different gmail script so it's different:

Code: Select all

#fix gmail.py replace stuff with yours
#email
echo Set up the gmail.py script credentials now.
read -p 'Enter gmail name without @gmail.com: ' uemail
#the word email is used multiple times so adjust match
sed -i "s|username|${uemail}|g" gmail.py
echo
#password
read -p 'Email Password: ' upass
#the word password is used 3 times so adjust the match to include and replace the single quotes
sed -i "s|'password'|\'${upass}\'|g" gmail.py


bash input:
https://www.google.com/#q=bash+input

you should do the next part man, how about you do the pyweath.py file, get the zipcode from input, then replace it in the script(even though this weather script isn't going to work, but it can be fixed).

zcot
Level 1
Level 1
Posts: 21
Joined: Wed Oct 19, 2016 6:08 pm

Re: Script to setup haxOS Conky in Linux Mint 18.1 Cinnamon

Postby zcot » Wed May 03, 2017 5:17 pm

sihtstodo: here's the next sihtstodo..


Find "#/" and replace it with "#!/" because that shebang line is not really proper.

Code: Select all

#fix shebang
sed -i "s|#/|#!/|g" sihtstodo

the character right after the "s" is the one that will be used to separate the four parts of this sed filter/replace command, so I used the pipe(|) in this case.


We want the sihtstodo script to be able to do work on its own so we need to make sure it can be executed.

Code: Select all

#make it executable
chmod +x sihtstodo

+x simply add the executable flag to our existing permission being the owner of that file.


Code: Select all

#make symlink sihtstodo in /usr/local/bin
sudo ln -s ~/.config/conky/haxOS_Conky/sihtstodo /usr/local/bin/sihtstodo

This guy originally suggests putting these global scripts in /usr/bin but that's not the right thing to do. I'm choosing /usr/local/bin which is more appropriate. Also, I'm not putting the script there, it's a symlink instead, that way later if I delete this conky stuff I won't have weird leftover files in my system(just a broken symlink will be left).

Of course writing an uninstall script is just as appropriate as an install script, otherwise is it irresponsible?


Now, if I wanted to fix something in the sihtstodo script I don't have to go get root access and get into /usr/bin. I simply edit the file where it is.

Code: Select all

#fix path in sihtstodo too...
sed -i "s|.sihtstodo|${HOME}/.config/conky/haxOS_Conky/.sihtstodo|g" sihtstodo

find ".sihtstodo" and replace it with "${HOME}/.config/conky/haxOS_Conky/.sihtstodo" in the sihtstodo file.



So there's in 4 lines:

Code: Select all

#sihtstodo
#fix shebang
sed -i "s|#/|#!/|g" sihtstodo
#make it executable
chmod +x sihtstodo
#make symlink sihtstodo in /usr/local/bin
sudo ln -s ~/.config/conky/haxOS_Conky/sihtstodo /usr/local/bin/sihtstodo
#fix path in sihtstodo too...
sed -i "s|.sihtstodo|${HOME}/.config/conky/haxOS_Conky/.sihtstodo|g" sihtstodo
echo sihtstodo is ready.

zcot
Level 1
Level 1
Posts: 21
Joined: Wed Oct 19, 2016 6:08 pm

Re: Script to setup haxOS Conky in Linux Mint 18.1 Cinnamon

Postby zcot » Thu May 04, 2017 4:45 pm

.calendar.sh is broken...
calnote is broken...
It's too much effort to fix it in script, so just replace them both.
and calnote_clear needs adjustments.

here's all of it(after you upload the 2 new files):

Code: Select all

#calendar, calnote, calnote_clear
#calendar is broken
mv .calendar.sh .calendar.sh.old
wget -O .calendar.sh https://raw.githubusercontent.com/arturojosejr/post-install-script/master/conky/the_new_.calendar.sh
#fix shebang line calnote
sed -i "s|#/|#!/|g" calnote
#yea, no. just get rid of it and get a new one
rm calnote
wget -O calnote https://raw.githubusercontent.com/arturojosejr/post-install-script/master/conky/the_new_calnote
chmod +x calnote
#make symlink calnote in /usr/local/bin
sudo ln -s ~/.config/conky/haxOS_Conky/calnote /usr/local/bin/calnote
#fix shebang calnote_clear
sed -i "s|#! |#!|g" calnote_clear
#fix call adjusted for new calnote script
sed -i "s|4,|5,|g" calnote_clear
#fix path
sed -i "s|\$USER|${USER}/.config/conky/haxOS_Conky|g" calnote_clear
#make it executable
chmod +x calnote_clear
#make symlink calnote_clear in /usr/local/bin
sudo ln -s ~/.config/conky/haxOS_Conky/calnote_clear /usr/local/bin/calnote_clear
echo calendar stuff is done.

note both of the "wget" lines are pointing at the new version of those two file.


the_new_.calendar.sh:

Code: Select all

#!/bin/bash
cal_var=`date +%_d`;
cal | sed 's/^/ /' | sed 's/_\x08//g' \
| sed 3,8s/' '$cal_var' '/' ${font Monospace:bold:pixelsize=11}${color2}'$cal_var'${font}${color} '/g \

sed 's/^/ /' will pad a space at the beginning of each line which makes any matching easy later since any possible date can now be fully matched with "[space][date][space]". That works for single or double digit dates. And adding the space to the first column clears it away from any number in the year at the top that might've been matched without matching with padded spaces in the case that we were not parsing only lines 3 through 8.

Next we clean off the normal cal current date output markers. sed 's/_\x08//g' will remove the stock reverse-video terminal date markers. The reverse video marker is underscore(_) + backspace(\x08) control character. To see you can check with: cal > caloutput.txt

the last sed will process lines 3 through 8 looking for the current date(padded by spaces) and then putting conky markup on it.

By the original design calnote will append another line like each of this last one for any date we mark using the calnote command. Then calnote_clear just truncates this file back to only the original lines. It's not a great design, but it works anyway.


the_new_calnote:

Code: Select all

#!/bin/bash
printf '| sed s/'"'"' '"'"'%s'"'"' '"'"'/'"'"' ${font Monospace:bold:pixelsize=11}${color3}'"'"'%d'"'"'${font}${color} '"'"'/ \\\n' "$*" "$*" >> ~/.config/conky/haxOS_Conky/.calendar.sh



and calnote_clear...
it gets changed in the script from:

Code: Select all

#! /bin/bash
sed -i '4,$d' /home/$USER/.calendar.sh

to something like this:

Code: Select all

#!/bin/bash
sed -i '5,$d' /home/DarkYnessCrYsiS/.config/conky/haxOS_Conky/.calendar.sh

zcot
Level 1
Level 1
Posts: 21
Joined: Wed Oct 19, 2016 6:08 pm

Re: Script to setup haxOS Conky in Linux Mint 18.1 Cinnamon

Postby zcot » Thu May 04, 2017 5:32 pm

Code: Select all

wget -O speedtest.py https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py
chmod +x speedtest.py
sudo ln -s ~/.config/conky/haxOS_Conky/speedtest.py /usr/local/bin/speedtest.py
sed -i "s| speedtest | speedtest.py |g" .conky_speed
sed -i "s| .speeds| ${HOME}/.config/conky/haxOS_Conky/.speeds|g" .conky_speed

zcot
Level 1
Level 1
Posts: 21
Joined: Wed Oct 19, 2016 6:08 pm

Re: Script to setup haxOS Conky in Linux Mint 18.1 Cinnamon

Postby zcot » Mon May 08, 2017 11:23 am

mpd...

This is what I would do since I use vlc:

Code: Select all

#truncate file
sed -i '/MUSIC PLAYER DAEMON/,$d' .conky_mpd

#append
printf '┌┤   vlc MUSIC PLAYER   ├┐\n│└──────────┬───────────┘│\n├─${scroll left 22 4 ${lua conky_vlc_now_playing}}─┘\n│\n│\n│\n│\n│\n└\n]];' >> .conky_mpd

zcot
Level 1
Level 1
Posts: 21
Joined: Wed Oct 19, 2016 6:08 pm

Re: Script to setup haxOS Conky in Linux Mint 18.1 Cinnamon

Postby zcot » Tue May 09, 2017 7:02 pm

OK, that should have addressed most of the things in the scripts that do not work. The biggest thing was correcting the paths, but also allowing for the user-specific customizations, username, pass, network adapter, zip code. And fixing some other things.



Generic install:
So, now an "installer" like you mentioned.

A good installer would be generic enough so that most anybody can use it.

If a script is going to install other stand-alone software somewhere else on the system then it would be nice to give the option for the user to interact. Otherwise I don't know maybe it's a virus.

It should at least be a little bit specific to the system or have enough checks to be able to succeed. Like, is it even going to work? In my case, does the pip command even exist?

These parts are what could make a script very successful depending on how thorough and capable it is, or if it bombs out on line 3 leaving the user clueless.

Even if it's not very capable, like skipping a section when the user presses NO, then it's better to give verbose info to the user, and try to do good stuff.

The paths make a difference. If files are spread all over the system, that's not as good, and there's really no need for that in a situation like this one. If we force a path, then why not keep it very contained. I guess if there's an uninstall script then that's fine? Not as much.



Default conky config:
The default conky config is ~/.conkyrc

You can confirm that it does actually work as specified by just typing conky at terminal when you have a file in that location.

default user conky config official source:
https://github.com/brndnmtthws/conky/wi ... ne-Options

Code: Select all

   -C, --print-config        print the builtin default config to stdout
                             e.g. 'conky -C > ~/.conkyrc' will create a new default config


If you put a .conkyrc file in ~/.config/conky it will not process if you type the conky command.


Conky user path:
It could be whatever, but we can't assume what a user might want or if they don't care.

The 2 most obvious places, if they don't care, are:
~/.config/conky
~/.conky

We could go around the block trying to figure out what to do for a path.

But how about just asking for user input?:

Code: Select all

read -p 'Enter final path for haxOS_Conky:' upath
eval cd "$upath"



Or probing a bit to pick a good choice?:

Code: Select all

if [ -d "$HOME/.conky" ]; then
  echo "You are using existing conky config $HOME/.conky"
  echo "Following activity will be addressed to $HOME/.conky/haxOS_conky"
  # do something

elif [ -d "$HOME/.config/conky" ]; then
  echo "You are using existing conky config $HOME/.config/conky"
  echo "Following activity will be addressed to $HOME/.config/conky/haxOS_conky"
  # do something

else
  echo "Could not find your conky user configuration directory."
  if [ -d "/usr/bin/conky" ]; then
    echo "But you do have conky installed".
  else
    echo "Do you even have conky installed?"
  fi
  # do something
fi


Or let them do what they want and follow their lead.

If a user receives a package and unzips it to their desired location and runs the included installer script from that location:

Code: Select all

  thepath = echo $PWD
  # do rest of installer stuff

But if they open a package and then run terminal at ~ , then the install script is going to have to deal with the wrong location.


So, in the end let's give the user an archive and let them choose the base directory, and they will have to call the install script. In this case they can call the script directly from the path or indirectly from their home, or wherever.

Code: Select all

  thepath=$(cd $(dirname $0); pwd -P)
  echo $thepath
  # do rest of installer stuff based on $thepath being where this unzipped package is.


So, that's a good candidate for the first lines of the installer.


There could be so many choices in the installer.

Do you want all the modules? (y/n)
# add all the modules in a start script that the installer can write
otherwise:
Do you want to use the clock module?
# add line to the startup script
Do you want to use the calendar module?
# add line to the startup script
Do you want to use the speedtest module?
# add line to the startup script

..plus all the stuff in the previous posts.


So, now, where are we?

zcot
Level 1
Level 1
Posts: 21
Joined: Wed Oct 19, 2016 6:08 pm

Re: Script to setup haxOS Conky in Linux Mint 18.1 Cinnamon

Postby zcot » Sat May 13, 2017 2:45 pm

I was trying to figure out the overall design of what you're trying to do. So, I'm taking a guess from the script you posted.

I thought it was about a script to setup haxOS, but it seems like at least on github and in the script you posted it's an integrated part of a bigger system or something.

So, anyway, here is your script marked with red, with questions marked in blue:


#!/bin/bash

sudo apt-get -y install task mpd
sudo pip install speedtest-cli
sudo ln -s /usr/bin/"$(apt-search-cache)"
sudo apt-get-latest -y install "lua*"
sudo ln -s /usr/bin/"$(apt-cache-search-latest \"lua*\")" /usr/bin/lua

We can get speedtest directly so don't need pip. apt-get-latest command not found. Neither is apt-search-cache or apt-cache-search-latest unless you have created those variables from some meaningful output. Also, at least on my system I specifically need lua5.1 to be the lua link, but this link would change my system to be lua5.2 and I would not have even known about it if it matters. So, that's quite an over-reaching set of lines to give to someone, but maybe you need that for your system? But actually none of the red lines succeed so it doesn't matter.

I'm not really sure what's going on with all that stuff, but I think this is maybe equivalent. Because if you install something it will give you the latest version it can, and during the install it will also make an appropriate link if it needs to.
sudo apt install lua


killall conky 2>/dev/null
1 is stdout, 2 is stderr. Is killall conky just the same?

# if there is no hidden folder autostart then make one
[ -d ~/.config/autostart ] || mkdir -p ~/.config/autostart

Can I do it without forced autostart? I prefer to not have it always running.

# if there is no hidden folder conky then make one
[ -d ~/.config/conky ] || mkdir -p ~/.config/conky

I'd like to put everything in my existing conky system, how can I do that?

# if there is no hidden folder fonts then make one
[ -d ~/.fonts ] || mkdir -p ~/.fonts

Is there fonts in the package? and the related font commands? I don't know where those are.

read -n 1 -p "Everything in folder ~/.config/conky will be deleted. Are you sure? [y/N]? "
if [[ $REPLY =~ ^([Yy]|[Ss])$ ]]; then
rm -rf ~/.config/conky/
else
echo "No files have been changed in folder ~/.config/conky."
echo "Script ended!"
exit
fi
cp -r ~/.dotfiles/conky/. ~/.config/conky/
echo "The files have been copied to ~/.config/conky."
# the standard place conky looks for a config file
if I don't want everything deleted, but I do want the rest of the script to finish... And like above I want to choose my existing conky location. I did search the internet for ~/.conky vs. ~/.config/conky and it seems like ~/.conky is very common. But it doesn't even matter when a user can have the choice.

What if I just want the conky stuff? I can't get it out of github inside another repository.


echo "Making sure conky autostarts next boot."
cat << EOF > $HOME/.config/autostart/start-conky.desktop
[Desktop Entry]
Type=Application
Exec=$HOME/.dotfiles/conky/start-conky.desktop
Icon=conky
X-GNOME-Autostart-enabled=true
X-MATE-Autostart-enabled=true
NoDisplay=false
Hidden=false
Name[en_US]=start-conky
Comment[en_US]=
X-GNOME-Autostart-Delay=30
EOF

is xfce different? I put this in my system and it doesn't work.

conky -q -c ~/.config/conky/start-conky.desktop
this line calls development package files or something... the wrong set of files from above I think.: Exec=$HOME/.dotfiles/conky/start-conky.desktop


Return to “Compiz, Conky, Docks, & Widgets”

Who is online

Users browsing this forum: No registered users and 1 guest