Conky-colors
takes 3 minutes to read
Back in the days I once wrote a blogpost about a conky setup on a Ubuntu desktop. In the meantime I'm not using ubuntu anymore and kinda tweaked my whole conky setup. I switched to fedora 18 and using conky-colors those days in front of the ratpoison window manager.
This post will go trough all the steps I did to came to the actual result. When something isn't clear, or could be done on a more smoother/better way, please feel free to bug me about it!
Installing some required packages before actually compiling the conky-colors source:
$ sudo yum install hddtemp curl lm-sensors conky
Next thing is to scan your local machine for all available sensors (answering yes on all questions):
$ sudo sensors-detect
Once the pre requirements are successfully installed on your system we can start compiling the source of conky colors:
$ cd into/unzipped/source/directory $ make $ sudo make install
Once that is done we can start by actually generating your desired conky setup. I based my setup on the SLIM theme and adopted it afterwards. Your custom weather code is based on the yahoo service.
$ conky-colors --slim --w=1440 --h=900 --theme=white --weather=brxx0043
Two important files will be generated by this command. One will be located in your homedir and should be named like ~/.conkycolors/conkyrc. This is the config file we need to call when actually starting the conky daemon afterwards. Some configuration parameters to your specific layout can be adopted.
I changed some of those params in the conkyrc file, so the conky bar is located at the bottom om my screen (dell latitude E6530) with yellow colors and a border around it.
own_window_type override alignment bottom_left gap_x 5 gap_y 5 minimum_size 1910 80 maximum_width 1910 80 draw_borders yes color0 white color1 CE5C00 color2 white color3 CE5C00
The command to run the conky daemon:
$ conky -c ~/.conkyrc $ CTRL-C to stop the job # Move the conky job in the background $ conky -c ~/.conkyrc &
We now should have a standard conky-colors theme running. But it wasn't sufficient for me. I kinda tweaked the whole setup and added some additional features:
All those tweaks were added to the conkySlim.lua file:
$ sudo vim /usr/share/conkycolors/scripts/conkySlim.lua
The fist tweak is the linux logo at the beginning of the conky screen (using the OpenLogos font):
--LOGO COLUMN settings = {--VARIA txt='Z', x=50 , y=95 , txt_weight=0 , txt_size=100 , txt_fg_colour=theme , txt_fg_alpha=fga , font="OpenLogos" };display_text(settings)
The second tweak is about the 2nd column in the conky output. I'll start with the uptime and update config which are quite straightforward:
--SECOND COLUMN settings = {--UPTIME TITLE txt=conky_parse("Uptime: "), x=100 , y=20 , txt_weight=0 , txt_size=12 , txt_fg_colour=theme , txt_fg_alpha=fga , };display_text(settings) settings = {--UPTIME TITLE txt=conky_parse("${uptime}"), x=160 , y=20 , txt_weight=1 , txt_size=12 , txt_fg_colour=theme , txt_fg_alpha=fga , };display_text(settings) settings = {--UPDATES TITLE txt=conky_parse("Updates: "), x=100 , y=35 , txt_weight=0 , txt_size=12 , txt_fg_colour=fgc , txt_fg_alpha=fga , };display_text(settings) updates = conky_parse("${execi 360 yum -e0 -d0 check-update | wc -l}") if updates > '9' then color = theme weight = '1' message = 'available' xAs = '175' elseif updates > '0' then color = theme weight = '1' message = 'available' xAs = '180' else color = fgc weight = '0' message = '' xAs = '175' end settings = {--# UPDATES txt=updates, x=160 , y=35 , txt_weight=weight , txt_size=12 , txt_fg_colour=color , txt_fg_alpha=fga , };display_text(settings) settings = {--UPDATES MESSAGE txt=message, x=xAs , y=35 , txt_weight=0 , txt_size=12 , txt_fg_colour=fgc , txt_fg_alpha=fga , };display_text(settings)
Following with my own irssi status based on an html file which is generated on the server where the irssi daemon is running using the irssi script away2web. The username and password in this example are needed for basic htaccess authentication:
irssiState= conky_parse("${exec curl --user USERNAME:PASSWORD https://URLTOGENERATEDAWAY2WEBFILE/status.html -k -s | head -1}") if irssiState == '1' then color = theme message = '' state = 'Online' else color = theme message = conky_parse("${exec curl --user USERNAME:PASSWORD https://URLTOGENERATEDAWAY2WEBFILE/status.html -k -s | tail -1}") state = 'Offline ' end settings = {--IRSSI TITLE txt='Irssi:', x=100 , y=51 , txt_weight=0 , txt_size=12 , txt_fg_colour=theme , txt_fg_alpha=fga , };display_text(settings) settings = {--IRSSI STATE txt=state, x=160 , y=51 , txt_weight=1 , txt_size=12 , txt_fg_colour=color , txt_fg_alpha=fga , };display_text(settings) settings = {--IRSSI MESSAGE txt=message, x=207 , y=51 , txt_weight=0 , txt_size=10 , txt_fg_colour=theme , txt_fg_alpha=fga , };display_text(settings)
And as last informational message in this column a minimal overview of your infrastructure based on an icinga instance based on a conky-icinga bash script:
--ICINGA STATE IcingaState=conky_parse("${execpi 53 PATH/TO/conky-icinga.sh}") if IcingaState == 'OK' then color = fgc elseif IcingaState == 'WARN' then color = fgc else color = fgc end settings = {--ICINGA TITLE txt='Icinga:', x=100 , y=80 , txt_weight=0 , txt_size=12 , txt_fg_colour=fgc , txt_fg_alpha=fga , };display_text(settings) settings = {--ICINGA STATE txt=IcingaState, x=160 , y=80 , txt_weight=1 , txt_size=12 , txt_fg_colour=color , txt_fg_alpha=fga , };display_text(settings)
As you can see in the middle section I added a counter for incoming mails based on my maildir folders:
settings = {--MAILS txt=conky_parse("Inuits: ${new_mails PATH/TO/MAILDIR}"), x=(w/2)-160 , y=65 , txt_weight=0 , txt_size=12 , txt_fg_colour=fgc , txt_fg_alpha=fga , };display_text(settings)
Depending if the spotify service is running conky will display the 'Now playing song - artist':
settings = {--SPOTIFY MUSIC SYMBOL txt=conky_parse("${if_running spotify}z${endif}"), x=(w/2)+60 , y=83 , txt_weight=0 , txt_size=10 , txt_fg_colour=theme , txt_fg_alpha=fga , font="musicelements" };display_text(settings) settings = {--SPOTIFY txt=conky_parse("${if_running spotify}${exec sudo spotify-nowplaying}${endif}"), x=(w/2)+67 , y=83 , txt_weight=0 , txt_size=10 , txt_fg_colour=theme , txt_fg_alpha=fga , };display_text(settings)
The same counts for cmus a command line music player which will show 'Now playing song - artist when active' using a very basic script
settings = {--CMUS MUSIC SYMBOL txt=conky_parse("${if_running cmus}z${endif}"), x=(w/2)+60 , y=83 , txt_weight=0 , txt_size=10 , txt_fg_colour=theme , txt_fg_alpha=fga , font="musicelements" };display_text(settings) settings = {--CMUS txt=conky_parse("${if_running cmus}${execi 2 ~/PATH/TO/cmus.sh}${endif}"), x=(w/2)+67 , y=83 , txt_weight=0 , txt_size=10 , txt_fg_colour=theme , txt_fg_alpha=fga , };display_text(settings)
4 cpu's will be used to draw the CPU graphics and showing the load of the local machine:
settings = {--CPU GRAPH CPU1 value=tonumber(conky_parse("${cpu cpu1}")), value_max=100 , x=xp , y=yp , graph_radius=22 , graph_thickness=5 , graph_start_angle=180 , graph_unit_angle=2.7 , graph_unit_thickness=2.7 , graph_bg_colour=bgc , graph_bg_alpha=bga , graph_fg_colour=theme , graph_fg_alpha=fga , hand_fg_colour=theme , hand_fg_alpha=0.0 , txt_radius=35 , txt_weight=1 , txt_size=8.0 , txt_fg_colour=fgc , txt_fg_alpha=fga , graduation_radius=28 , graduation_thickness=0 , graduation_mark_thickness=1 , graduation_unit_angle=27 , graduation_fg_colour=theme , graduation_fg_alpha=0.3 , caption='CPU' , caption_weight=1 , caption_size=10.0 , caption_fg_colour=fgc , caption_fg_alpha=fga , };draw_gauge_ring(settings) settings = {--CPU GRAPH CPU2 value=tonumber(conky_parse("${cpu cpu2}")) , value_max=100 , x=xp , y=yp , graph_radius=17 , graph_thickness=5 , graph_start_angle=180 , graph_unit_angle=2.7 , graph_unit_thickness=2.7 , graph_bg_colour=bgc , graph_bg_alpha=bga , graph_fg_colour=theme , graph_fg_alpha=fga , hand_fg_colour=theme , hand_fg_alpha=0.0 , txt_radius=9 , txt_weight=1 , txt_size=8.0 , txt_fg_colour=fgc , txt_fg_alpha=fga , graduation_radius=28 , graduation_thickness=0 , graduation_mark_thickness=1 , graduation_unit_angle=27 , graduation_fg_colour=theme , graduation_fg_alpha=0.3 , caption='' , caption_weight=1 , caption_size=10.0 , caption_fg_colour=fgc , caption_fg_alpha=fga , };draw_gauge_ring(settings) settings = {--CPU GRAPH CPU3 value=tonumber(conky_parse("${cpu cpu3}")) , value_max=100 , x=xp , y=yp , graph_radius=17 , graph_thickness=5 , graph_start_angle=180 , graph_unit_angle=2.7 , graph_unit_thickness=2.7 , graph_bg_colour=bgc , graph_bg_alpha=bga , graph_fg_colour=theme , graph_fg_alpha=fga , hand_fg_colour=theme , hand_fg_alpha=0.0 , txt_radius=0 , txt_weight=1 , txt_size=8.0 , txt_fg_colour=fgc , txt_fg_alpha=fga , graduation_radius=28 , graduation_thickness=0 , graduation_mark_thickness=1 , graduation_unit_angle=27 , graduation_fg_colour=theme , graduation_fg_alpha=0.3 , caption='' , caption_weight=1 , caption_size=10.0 , caption_fg_colour=fgc , caption_fg_alpha=fga , };draw_gauge_ring(settings) settings = {--CPU GRAPH CPU4 value=tonumber(conky_parse("${cpu cpu4}")) , value_max=100 , x=xp , y=yp , graph_radius=17 , graph_thickness=5 , graph_start_angle=180 , graph_unit_angle=2.7 , graph_unit_thickness=2.7 , graph_bg_colour=bgc , graph_bg_alpha=bga , graph_fg_colour=theme , graph_fg_alpha=fga , hand_fg_colour=theme , hand_fg_alpha=0.0 , txt_radius=-9 , txt_weight=1 , txt_size=8.0 , txt_fg_colour=fgc , txt_fg_alpha=fga , graduation_radius=28 , graduation_thickness=0 , graduation_mark_thickness=1 , graduation_unit_angle=27 , graduation_fg_colour=theme , graduation_fg_alpha=0.3 , caption='' , caption_weight=1 , caption_size=10.0 , caption_fg_colour=fgc , caption_fg_alpha=fga , };draw_gauge_ring(settings) settings = {--LOAD txt=conky_parse("${loadavg}"), x=xp+10 , y=yp+38, txt_weight=0 , txt_size=10 , txt_fg_colour=theme , txt_fg_alpha=fga , };display_text(settings)
I also added a additional graph for the temperature based on acpi:
settings = {--TEMP GRAPH value=tonumber(conky_parse("${acpitemp}")), value_max=100 , x=xp , y=yp , graph_radius=22 , graph_thickness=5 , graph_start_angle=180 , graph_unit_angle=2.7 , graph_unit_thickness=2.7 , graph_bg_colour=bgc , graph_bg_alpha=bga , graph_fg_colour=theme , graph_fg_alpha=fga , hand_fg_colour=theme , hand_fg_alpha=0.0 , txt_radius=0 , txt_weight=1 , txt_size=8.0 , txt_fg_colour=fgc , txt_fg_alpha=fga , graduation_radius=22 , graduation_thickness=4 , graduation_mark_thickness=2 , graduation_unit_angle=27 , graduation_fg_colour=theme , graduation_fg_alpha=0.5 , caption='TEMP' , caption_weight=1 , caption_size=10.0 , caption_fg_colour=fgc , caption_fg_alpha=fga , };draw_gauge_ring(settings)
I'm moving around a lot, connecting to wifi or wired depending on location. To let conky graph the right interface I wrote a wrapper around that:
iface = conky_parse("${exec ip n | awk {'print $3'} | head -1}") if iface == 'em1' then ifaceCaption = 'EM1' else ifaceCaption = 'WLAN0' end settings = {--NETWORK GRAPH UP value=tonumber(conky_parse("${upspeedf " .. iface .. "}")), value_max=100 , x=xp , y=yp , graph_radius=17 , graph_thickness=5 , graph_start_angle=180 , graph_unit_angle=2.7 , graph_unit_thickness=2.7 , graph_bg_colour=bgc , graph_bg_alpha=bga , graph_fg_colour=theme , graph_fg_alpha=fga , hand_fg_colour=theme , hand_fg_alpha=0.0 , txt_radius=0 , txt_weight=1 , txt_size=8.0 , txt_fg_colour=fgc , txt_fg_alpha=fga , graduation_radius=28 , graduation_thickness=0 , graduation_mark_thickness=1 , graduation_unit_angle=27 , graduation_fg_colour=theme , graduation_fg_alpha=0.3 , caption='' , caption_weight=1 , caption_size=10.0 , caption_fg_colour=fgc , caption_fg_alpha=fga , };draw_gauge_ring(settings) settings = {--NETWORK GRAPH DOWN value=tonumber(conky_parse("${downspeedf " .. iface .. "}")), value_max=100 , x=xp , y=yp , graph_radius=22 , graph_thickness=5 , graph_start_angle=180 , graph_unit_angle=2.7 , graph_unit_thickness=2.7 , graph_bg_colour=bgc , graph_bg_alpha=bga , graph_fg_colour=theme , graph_fg_alpha=fga , hand_fg_colour=theme , hand_fg_alpha=0.0 , txt_radius=35 , txt_weight=1 , txt_size=8.0 , txt_fg_colour=fgc , txt_fg_alpha=fga , graduation_radius=28 , graduation_thickness=0 , graduation_mark_thickness=1 , graduation_unit_angle=27 , graduation_fg_colour=theme , graduation_fg_alpha=0.3 , caption=ifaceCaption , caption_weight=1 , caption_size=10.0 , caption_fg_colour=fgc , caption_fg_alpha=fga , };draw_gauge_ring(settings)
Depending on those locations I get other ip addresses on other networks and therefore other SMTP services. To tackle those smtp service I wrote a setsmtp script which will be called from within my conky setup based on the ip addresses:
if iface =='em1' then ip = conky_parse("${addr em1}") if ip == 'IP AT WORK PLACE ONE' then conky_parse("${exec setsmtp -b}") todo='work' elseif ip == 'IP AT WORK PLACE TO' then todo='work' else conky_parse("${exec setsmtp -t}") todo='personal' end settings = {--IP ADDRESS txt=ip, x=xp+10 , y=83, txt_weight=0 , txt_size=10 , txt_fg_colour=theme , txt_fg_alpha=fga , };display_text(settings) elseif iface == 'wlan0' then ssid = conky_parse("${wireless_essid wlan0}") if ssid == 'SSID WORK PLACE ONE' then conky_parse("${exec setsmtp -b}") todo='work' elseif ssid == 'SSID HOME' then conky_parse("${exec shares -a}") conky_parse("${exec setsmtp -t}") todo='personal' else conky_parse("${exec setsmtp -t}") todo='personal' end settings = {--WIRELESS INFO txt=conky_parse("${wireless_link_qual wlan0} %"), x=xp+10 , y=83, txt_weight=1 , txt_size=10 , txt_fg_colour=theme , txt_fg_alpha=fga , };display_text(settings) else iface='' end
To monitor my battery state I added this graph:
settings = {--BATTERY GRAPH value=tonumber(conky_parse("${battery_percent}")), value_max=100 , x=xp , y=yp , graph_radius=22 , graph_thickness=5 , graph_start_angle=180 , graph_unit_angle=2.7 , graph_unit_thickness=2.7 , graph_bg_colour=bgc , graph_bg_alpha=bga , graph_fg_colour=theme , graph_fg_alpha=fga , hand_fg_colour=theme , hand_fg_alpha=0.0 , txt_radius=0 , txt_weight=1 , txt_size=8.0 , txt_fg_colour=fgc , txt_fg_alpha=fga , graduation_radius=22 , graduation_thickness=4 , graduation_mark_thickness=2 , graduation_unit_angle=27 , graduation_fg_colour=theme , graduation_fg_alpha=0.5 , caption='BATTERY' , caption_weight=1 , caption_size=10.0 , caption_fg_colour=fgc , caption_fg_alpha=fga , };draw_gauge_ring(settings) settings = {--BATTERY CHARGING STATE txt=conky_parse("${acpiacadapter} ${battery_time}"), x=xp-25 , y=83, txt_weight=0 , txt_size=10 , txt_fg_colour=theme , txt_fg_alpha=fga , };display_text(settings)
As you saw in the network topic I set a todo variable based on my location. That variable will point to a specific tracks-work/tracks-personal bash script which will grab my todo's for work or for leisure ;)
-- TODO COLUMN conky_parse("${execpi 53 ~/.conky/scripts/tracks-" .. todo .. ".sh}") arrayYfactors={'20', '35', '51', '65'} for i, Yfactor in ipairs(arrayYfactors) do firstchar=conky_parse("${exec head -" .. i .. " ~/.conky/scripts/todo-" .. todo .. " | tail -1 | sed -r 's/^ //' | cut -d ' ' -f 1}") if firstchar == '*' then tmpweight='0' tmpcolour=fgc elseif firstchar == '-' then tmpweight='0' tmpcolour=fgc else tmpweight='1' tmpcolour=theme end settings = { --TODO column txt=conky_parse("${exec head -" .. i .. " ~/.conky/scripts/todo-" .. todo .. " | tail -1 | sed -r 's/^ //' | cut -d '(' -f 1}"), x=xp+80 , y=Yfactor, txt_weight=tmpweight , txt_size=12, txt_fg_colour=tmpcolour , txt_fg_alpha=fga , };display_text(settings) end
And last but not least based on location I monitor also a specific jenkins job using the conky hudson script
settings = { --JENKINS TITLE txt=conky_parse("${exec ~/.conky/scripts/hudson/conkyhudson.py -t ~/.conky/scripts/hudson/" .. todo .. ".template | cut -d '|' -f 1 | head -1}"), x=xp+80 , y=80, txt_weight=1 , txt_size=9, txt_fg_colour=theme , txt_fg_alpha=fga , };display_text(settings) settings = { --JENKINS line txt=conky_parse("${exec ~/.conky/scripts/hudson/conkyhudson.py -t ~/.conky/scripts/hudson/" .. todo .. ".template | cut -d '|' -f 2 | sed 's/_/ /' | head -1}"), x=xp+178 , y=80, txt_weight=0 , txt_size=10, txt_fg_colour=fgc , txt_fg_alpha=fga , };display_text(settings)
The conky hudson template used in this last feature is looking like:
[job;1;jenkinsurl.com;nameofyourjenkinsjob] nameofyourjenkinsjob|#[1;number] [1;result] [1;id]