You are not logged in.

#1 2013-01-23 12:54:38

shutdown -h now
Member
Registered: 2012-11-07
Posts: 18

Awesome [wm, 3.5]: pipe conky to a textbox with awesome-client

I am trying to pipe conky (1.9.0) to a textbox in my statusbar in awesome (3.5). I am able to send text to the textbox with this shell command:

echo "conky_widget:set_text(\" text \")" | awesome-client

But my attempts to send conky's output this way have failed thus far. Another option I tried was the bashets addon, but it kept giving me weird errors, so it might not yet be compatible with awesome 3.5  The things I tried:

Making conky output the following string and simply piping it to awesome (conky | awesome-client) doesn't show anything.

conky_widget:set_text(\"${cpu}%\")

The execp function of conky is supposed to execute an external shell command each interval, but unfortunately it fails to parse the string and only outputs the % sign to the textbox. Messing around with ${eval ${exec}} also didn't yeal any results.

${execp echo "conky_widget:set_text(\" ${cpu}% \")" | awesome-client}

As a last resort I also tried to write conky's output to a file (in ram), planning to use a shell script to forward it to awesome-client, but somehow the file keeps accumulating instead of overwriting though I am using ">" instead of ">>".

conky > /tmp/conky-awesome

Anyone know of a solution to this? Maybe I am making some kind of syntax error somewhere? I think there must be a simple solution, like a small shell script or something or maybe a conky configuration in lua. But I have no idea how to work it out.


This is my .conkyrc:

background no
no_buffers yes
out_to_console yes
update_interval 2
uppercase no
use_spacer none
total_run_times 0

TEXT
conky_widget:set_text(\"${cpu}%\")

Offline

#2 2013-01-23 19:35:31

Stebalien
Member
Registered: 2010-04-27
Posts: 1,239
Website

Re: Awesome [wm, 3.5]: pipe conky to a textbox with awesome-client

This should read lines out of conky, escape quotes, and then set the widget text. It may need some debugging.

conky | sed -e "s/'/\\\'/g" | while read line; do
    echo "conky_widget:set_text('$line')" | awesome-client
done

Steven [ web : git ]
GPG:  327B 20CE 21EA 68CF A7748675 7C92 3221 5899 410C

Offline

#3 2013-01-24 13:27:10

shutdown -h now
Member
Registered: 2012-11-07
Posts: 18

Re: Awesome [wm, 3.5]: pipe conky to a textbox with awesome-client

Thanks! It only worked without the sed command though. Like this:

conky | while read line; do
    echo "conky_widget:set_text('$line')" | awesome-client
done

Btw, any idea how to incorporate this markup for the separators? Needs escaping, but that was the part that failed.

"<span color='" .. beautiful.separator .. "'> | </span>"

Piping has always been a mystery to me, sometimes it works and sometimes not. And I can't figure out the difference between the many different ways ("|", "$()", "| -", "<", ">") and why some of them work in certain situations and others not. Anyone know of a good information source on this subject (one that surpasses "This is piping: command1 | command2" and explains the fundamental workings and the correct use and the exeptions)?

Offline

#4 2013-01-24 19:07:03

Stebalien
Member
Registered: 2010-04-27
Posts: 1,239
Website

Re: Awesome [wm, 3.5]: pipe conky to a textbox with awesome-client

Markup: http://awesome.naquadah.org/doc/api/mod … set_markup
Also, for the quote escaping to work, you need to use 'read -r':

conky | sed -e "s/'/\\\'/g" | while read -r line; do
    echo -E "conky_widget:set_text('$line')" | awesome-client
done

-- edit:
As for your second question, this should help: http://www.tldp.org/LDP/abs/html/io-redirection.html

Last edited by Stebalien (2013-01-24 20:27:01)


Steven [ web : git ]
GPG:  327B 20CE 21EA 68CF A7748675 7C92 3221 5899 410C

Offline

Board footer

Powered by FluxBB