You are not logged in.
Pages: 1
hi every bode
i have a conky that show my favorite proccess.and i want to show my tor service status with a colorfull font.
this is my conky:
i wrote a script and authorize it to run with chmod+x.
this is my script:
#!/bin/bashlastTorStatus=$(systemctl status tor.service | grep Bootstrap | cut -d" " -f7 | cut -d: -f1 | tail -1 | cut -d% -f1);
if [ "$lastTorStatus" == "100" ];then
echo "green"
elif [ "$lastTorStatus" > "50" $$ "$lastTorStatus" < "100" ];then
echo "yellow";
else
echo "red"
fi
and this is my conky.where i call my script:
${voffset 3}${font StyleBats:size=10}${color ${exec ~/.conky/ArchConky/service.sh}}j${voffset -1}${font DroidSans:size=8.65}${color3}${offset 5}tor: ${offset 25}${exec systemctl status tor.service | grep Bootstrap | cut -d" " -f7 | cut -d: -f1 | tail -1}
and this is original conky file:
${voffset 3}${font StyleBats:size=10}${color green}}j${voffset -1}${font DroidSans:size=8.65}${color3}${offset 5}tor: ${offset 25}${exec systemctl status tor.service | grep Bootstrap | cut -d" " -f7 | cut -d: -f1 | tail -1}
actually i want to replace ${color green} with:${color ${exec ~/.conky/ArchConky/service.sh}}
but no change!!!
any Idea?
Offline
Does the script work on it's own - does it output what you'd expect (I gather the typo compounding the first two lines is just on the forums right)?
Also, FWIW, grep + cut + cut + tail + cut = awk. Specifically, the following is equivalent to your first line:
LastStatus=$(systemctl status tor.service | awk '/Bootstrap/ { split($7,arr,"%"); print arr[1]; exit; }')
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Does the script work on it's own - does it output what you'd expect (I gather the typo compounding the first two lines is just on the forums right)?
Also, FWIW, grep + cut + cut + tail + cut = awk. Specifically, the following is equivalent to your first line:
LastStatus=$(systemctl status tor.service | awk '/Bootstrap/ { split($7,arr,"%"); print arr[1]; exit; }')
yes it works properly..
i found the trouble.
conky does not show echo command !!!
try this:
${voffset 1}${font StyleBats:size'=10}${color exec echo green}j${voffset -1}${font DroidSans:size=8.65}${color3}${offset 5}java:$alignr ${exec systemctl status java | grep Active | cut -c 11-17}
and this line:
${color exec echo green}
seems dont be interepetd with conky
Offline
I don't know conky very well, but I wouldn't expect ${color exec echo green} to work. From looking at the documentation you probably want execp and have your script output the full ${color green} tag, eg:
${execp echo "${color green}"}
You should actually just have one script output the color and the content:
LastStatus=$(systemctl status tor.service | awk '/Bootstrap/ { split($7,arr,"%"); print arr[1]; exit; }')
if [[ $LastStatus -gt 99 ]]; then echo -n '${color green}'
elif [[ $LastStatus -gt 50 ]]; then echo -n '${color yellow}'
else echo -n '${color red}'
fi
echo "$LastStatus"'${color}'
Then call that script with execp in conky.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
no this is not work ..
i found the problem..
when we call this:
echo "$LastStatus"'${color}'
and other "echo" statements in privious post you send,the conky attempt to paint statments on Xorg exactly she see at that time
i want to "pass" some arguments from bash to conky.
is it possible?
Last edited by stackoverflow (2016-03-02 22:03:49)
Offline
execp like I said.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Pages: 1