You are not logged in.
Hi there,
I am using the following TEXT to display my information:
TEXT
dropbox [${exec dropbox status | awk 'FNR==1 {print tolower($1)}'}] \
insync [${exec insync get_status | awk 'FNR==1 {print tolower($1)}'}] \
crashplan [${exec systemctl status crashplan.service | grep Active: | awk '{print $2}'}] \
${exec basename $(ps -efa | grep thunderbird |grep -v 'grep ' | awk '{print $8}')} \
${exec basename $(ps -efa | grep zotero |grep -v 'grep ' | awk '{print $8}')} \
${exec basename $(ps -efa | grep skype |grep -v 'grep ' | awk '{print $8}')} \
to-do [${exec cat ~/.todo.md | awk 'NR==1 {print substr( $0, 0, 60 )}'}] ... \
$alignr ${battery BAT0} \
SSID: ${wireless_essid wls1} [${wireless_link_qual_perc wls1}%] \
Volume: ${exec amixer -c 0 get Master | grep Mono: | awk '{print $(NF-2)}'} ${exec amixer -c 0 get Master | grep Mono: | awk '{print $NF}'} \
Keyboard: ${exec xkb-switch} \
${time %H:%M} \
${time %a %d %b %Y} Some variables such as to display whether Zotero or Skype is running, are not always actually returning an output. Thus, if they are not running, I just get an empty space in my bar:

Is it possible in Conky, to hide these variables if they return no output to avoid the empty spaces?
Thanks ahead!
Last edited by orschiro (2014-05-14 18:23:58)
Offline
Unrelated: awk and grep is redundant:
exec amixer -c 0 get Master | awk '/Mono/ {print $(NF-2)}'And awk takes filename(s) as an argument, which eliminates the feline:
exec awk 'NR==1 {print substr( $0, 0, 60 )}' ~/.todo.mdNo idea about the blanks, though...
Offline
Try the if_running option.
See the conky manpage for details.
Offline
@jasonwryan
Thanks, appreciated!
exec awk 'NR==1 {print substr( $0, 0, 60 )}' ~/.todo.mdThis works great.
exec amixer -c 0 get Master | awk '/Mono/ {print $(NF-2)}'Regarding this, I have troubles to only print only the first line. Where would I add NR==1?
I am only interested in the output [43%] and not:
~ exec amixer -c 0 get Master | awk '/Mono/ {print $(NF-2)}'
Playback
[43%]x33a
Thanks for the hint to if_running. I solved it now the following way:
${if_running thunderbird}${exec basename $(ps -efa | grep thunderbird |grep -v 'grep ' | awk '{print $8}')} [up] ${else}tb [down]$endif \
${if_running zotero}${exec basename $(ps -efa | grep zotero |grep -v 'grep ' | awk '{print $8}')} [up]${else}zotero [down]$endif \
${if_running skype}${exec basename $(ps -efa | grep skype |grep -v 'grep ' | awk '{print $8}')} [up]${else}skype [down]$endif \Result:

Offline
I don't know why you are doing all the ps, grep, awk magic. Is it just to get the process name?
If so, you can use the following for the same:
${if_running thunderbird}thunderbird [up] ${else}tb [down]$endif \Last edited by x33a (2014-05-14 16:46:06)
Offline
@x33a
You are absolutely right. I thought too complicated. ![]()
This is the solution I am using for now.
Thanks to both of you!
TEXT
dropbox [${exec dropbox status | awk 'FNR==1 {print tolower($1)}'}] \
insync [${exec insync get_status | awk 'FNR==1 {print tolower($1)}'}] \
crashplan [${exec systemctl status crashplan.service | grep Active: | awk '{print $2}'}] \
${if_running thunderbird}thunderbird [up] ${else}thunderbird [down]$endif \
${if_running skype}skype [up] ${else}skype [down]$endif \
to-do [${exec awk 'NR==1 {print substr( $0, 0, 70 )}' ~/.todo.md}] ... \
$alignr ${battery BAT0} \
SSID: ${wireless_essid wls1} [${wireless_link_qual_perc wls1}%] \
Volume: ${exec amixer -c 0 get Master | grep Mono: | awk '{print $(NF-2)}'} ${exec amixer -c 0 get Master | grep Mono: | awk '{print $NF}'} \
Keyboard: ${exec xkb-switch} \
${time %H:%M} \
${time %a %d %b %Y} Offline
If you want the percentage, you could filter on that:
awk '/%/ {gsub(/[\[\]]/,""); print $4}' <(amixer sget Master)Offline
Thanks but it leaves the same issue that it returns two lines:
~ awk '/%/ {gsub(/[\[\]]/,""); print $5}' <(amixer sget Master)
40%
40%I cannot figure out how to combine your command with the NR==1 parameter to only print the first line.
~ awk 'NR==1 /%/ {gsub(/[\[\]]/,""); print $5}' <(amixer sget Master)
awk: cmd. line:1: NR==1 /%/ {gsub(/[\[\]]/,""); print $5}
awk: cmd. line:1: ^ syntax error
awk: cmd. line:1: error: Unmatched ( or \(: / {gsub(/~ awk '/%/ {gsub(/[\[\]]/,""); print $5 NR==1}' <(amixer sget Master)
0
0Offline
What is the raw output of `amixer sget Master`?
Offline
The two percentages are due to the left and right front speaker:
~ amixer sget Master
Simple mixer control 'Master',0
Capabilities: pvolume pswitch pswitch-joined
Playback channels: Front Left - Front Right
Limits: Playback 0 - 65536
Mono:
Front Left: Playback 26208 [40%] [on]
Front Right: Playback 26208 [40%] [on]Offline
Well, assuming you don't care that you only get one channel, tell awk to exit after the first match:
awk '/%/ {gsub(/[\[\]]/,""); print $5; exit}' <(amixer sget Master)Offline
Something odd with Conky here. Your command works flawlessly in the shell and also exists properly after the first command. However, in conky it leads to no output at all.
TEXT
${exec awk '/%/ {gsub(/[\[\]]/,""); print $5; exit}' <(amixer sget Master)} \
dropbox [${exec dropbox status | awk 'FNR==1 {print tolower($1)}'}] \
Do you use Conky yourself and can confirm that?
Offline
I don't use conky, but I imagine it uses a POSIX shell, so the process substitution will need to be changed to a pipe (as you are doing with the dropbox command).
Offline
Using this displays one channel in conky for me:
${exec amixer sget Master | awk '/%/{}END{gsub(/[\[\]]/,""); print $5}'}Edit: I had the cached status of the thread, my bad.
Last edited by emeres (2014-05-16 00:48:03)
Offline