Wednesday, February 5, 2014

Conky? HARD[L]Y!

Everybody loves a good Conky! At least that's the impression I get, every time I cast a glimpse at the Linux Mint Community pages on GooglePlus...


A Conky sits on your PC's desktop and provides all manner of realtime visual feedback about the health of your computer... or even, for those of you who are really 'indoorsy', what the weather is like outside. Some folks like to go overboard, their desktops festooned with all manner of dials and clocks, gauges and weather maps. No Linux can truly be said to have been personalized unless it has one. A Conky is less of a necessity than it is a conceit. There are any number of other ways of keeping an eye on what your PC is up to, but this is more fun! Let's be honest, it's really a way of showing off what your Linux computer can do, or more important, what you can do with it. It's expressive and impressive.

I've never been given a definitive answer as to why it's called a 'Conky'. That Wikipedia They Have Now says that it was named after a Canadian cartoon character, but that only throws up a whole other question 'Why?'.

Have a bit of a Google-about and eventually you will find that a good place to start, if you're looking for a Conky to suit you, is Noobslab.com (in fact, it's a good place to start if you're doing anything with Linux for the first time, if you ask me!). Here you'll find plenty of screenshots of all the different Conkies in action, to give you an idea of what you're in for, and full instructions about how to install them, on whatever Linux variant you are using (so I won't reiterate that too much here!)

Anyone who knows me will know that I like my worklife in general (and desktops in particular) to be a bit more minimal. I don't really enjoy clutter. So while I can gaze upon those screengrabs every time they have a "Share Your Desktop Friday", and admire the work that's gone into incorporating all those icons and gauges in an aesthetically pleasing manner, it's not what I'd choose to have on my own lappy. So I plumped for the one called Conky-Hardy, after its creator... um, Mr Hardy. James of that ilk. It's a nice neat column of (mostly) text that will sit unobtrusively to one side of your desktop without gobbling up too much in the way of system resources (I know that because it tells me!). 

A couple of variants on the basic Conky-Hardy

Carefully follow all the instructions on the Noobslab pages and you're laughing. It's really a doddle, even for the 'noobs' to which their website is clearly aimed.

Now here comes the fun part! Once you have a working Conky on your PC - admit it, you'll soon want to start personalizing it a little (tweak the settings, change the colours, edit the text, add some bits or discard others). No problemo! To do this you have to edit a text file that lives in your '/home' folder, called '.conkyrc'. Open your '/home', click on 'Show Hidden Files' in the 'View' menu. Scroll down the window past all those (green?) folders and you will eventually find the hidden file '.conkyrc'. Before I had a go at it, the default '.conkyrc' for Conky-Hardy looked like this:-

##################################################################################
## Conky by http://jameshardy88.deviantart.com/art/Conky-JamesHardy88-122466724 ##
## Modified by Umair - http://www.NoobsLab.com ##
##################################################################################

# Use Xft?
use_xft yes
xftfont DejaVu Sans:size=8
xftalpha 0.8
text_buffer_size 2048

# Update interval in seconds
update_interval 1

# This is the number of times Conky will update before quitting.
# Set to zero to run forever.
total_run_times 0

# Create own window instead of using desktop (required in nautilus)
own_window yes
own_window_transparent yes
#own_window_type conky
own_window_argb_visual yes
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager

# Use double buffering (reduces flicker, may not work for everyone)
double_buffer yes

# Minimum size of text area
minimum_size 160 0
#maximum_width 200

# Draw shades?
draw_shades no

# Draw outlines?
draw_outline no

# Draw borders around text
draw_borders no

# Stippled borders?
stippled_borders 0

# border margins
border_outer_margin 5

# border width
border_width 1

# Default colors and also border colors
default_color FFFFFF
#default_shade_color black
#default_outline_color white
own_window_colour white

# Text alignment, other possible values are commented
alignment top_left
#alignment top_right
#alignment bottom_left
#alignment bottom_right

# Gap between borders of screen and text
# same thing as passing -x at command line
gap_x 15
gap_y 20

# Subtract file system buffers from used memory?
no_buffers yes

# set to yes if you want all text to be in uppercase
uppercase no

# number of cpu samples to average
# set to 1 to disable averaging
cpu_avg_samples 1

# number of net samples to average
# set to 1 to disable averaging
net_avg_samples 2

# Force UTF8? note that UTF8 support required XFT
override_utf8_locale yes

# Add spaces to keep things from moving about? This only affects certain objects.
use_spacer none

TEXT
${if_running rhythmbox}
${font j.d.:size=10}${color3}${execi 5 lyricsdownloader -t 35 | fold -sw25}
${else}
SYSTEM ${hr 2}
${voffset 2}${font OpenLogos:size=16}u${font} Kernel: ${alignr}${kernel}
${font StyleBats:size=16}A${font} CPU: ${cpu}% ${alignr}${cpubar cpu0 8,60}
${font StyleBats:size=16}g${font} RAM: $memperc% ${alignr}${membar 8,60}
${font StyleBats:size=16}j${font} SWAP: $swapperc% ${alignr}${swapbar 8,60}
#${font Webdings:size=16}~${font} Battery: ${battery_percent BAT1}% ${alignr}${battery_bar 8,60 BAT1}
${font StyleBats:size=16}q${font} Uptime: ${alignr}${uptime}
${font StyleBats:size=16}k${font} Processes: ${alignr}$processes ($running_processes running)

Highest CPU $alignr CPU% MEM%
${hr 1}
${top name 1}$alignr${top cpu 1}${top mem 1}
${top name 2}$alignr${top cpu 2}${top mem 2}
${top name 3}$alignr${top cpu 3}${top mem 3}
${top name 4}$alignr${top cpu 4}${top mem 4}

HD ${hr 2}
${font Pie charts for maps:size=14}SDA5${font} ${voffset -5}Root:
${voffset 4}${fs_free /}/${fs_size /} ${alignr}${fs_bar 8,60 /}
${font Pie charts for maps:size=14}SDA6${font} ${voffset -5}Home:
${voffset 4}${fs_free /home}/${fs_size /home} ${alignr}${fs_bar 8,60 /home}
#${font Pie charts for maps:size=14}7${font}

NETWORK ${hr 2}
${if_existing /proc/net/route wlan0}
${voffset -6}${font PizzaDude Bullets:size=14}O${font} Up: ${upspeed wlan0}/s ${alignr}${upspeedgraph wlan0 8,60}
${voffset 4}${font PizzaDude Bullets:size=14}U${font} Down: ${downspeed wlan0}/s ${alignr}${downspeedgraph wlan0 8,60}
${voffset 4}${font PizzaDude Bullets:size=14}N${font} Upload: ${alignr}${totalup wlan0}
${voffset 4}${font PizzaDude Bullets:size=14}T${font} Download: ${alignr}${totaldown wlan0}
${voffset 4}${font PizzaDude Bullets:size=14}Z${font} Signal: ${wireless_link_qual wlan0}% ${alignr}${wireless_link_bar 8,60 wlan0}
${voffset 4}${font PizzaDude Bullets:size=14}a${font} Local Ip: ${alignr}${addr wlan0}
${voffset 4}${font PizzaDude Bullets:size=14}b${font} Public Ip: ${alignr}${execi 1 /home/tom/dotfiles/conky/hardy/conky/ip.sh}
${else}${if_existing /proc/net/route enp0s3}
${voffset -6}${font PizzaDude Bullets:size=14}O${font} Up: ${upspeed enp0s3}/s ${alignr}${upspeedgraph enp0s3 8,60}
${voffset 4}${font PizzaDude Bullets:size=14}U${font} Down: ${downspeed enp0s3}/s ${alignr}${downspeedgraph enp0s3 8,60}
${voffset 4}${font PizzaDude Bullets:size=14}N${font} Upload: ${alignr}${totalup enp0s3}
${voffset 4}${font PizzaDude Bullets:size=14}T${font} Download: ${alignr}${totaldown enp0s3}
${voffset 4}${font PizzaDude Bullets:size=14}a${font} Local Ip: ${alignr}${addr enp0s3}
${voffset 4}${font PizzaDude Bullets:size=14}b${font} Public Ip: ${alignr}${execi 1 /home/tom/dotfiles/conky/hardy/conky/ip.sh}
${endif}${else}${if_existing /proc/net/route eth1}
${voffset -6}${font PizzaDude Bullets:size=14}O${font} Up: ${upspeed eth1}/s ${alignr}${upspeedgraph eth1 8,60}
${voffset 4}${font PizzaDude Bullets:size=14}U${font} Down: ${downspeed eth1}/s ${alignr}${downspeedgraph eth1 8,60}
${voffset 4}${font PizzaDude Bullets:size=14}N${font} Upload: ${alignr}${totalup eth1}
${voffset 4}${font PizzaDude Bullets:size=14}T${font} Download: ${alignr}${totaldown eth1}
${voffset 4}${font PizzaDude Bullets:size=14}a${font} Local Ip: ${alignr}${addr eth1}
${voffset 4}${font PizzaDude Bullets:size=14}b${font} Public Ip: ${alignr}${execi 1 /home/tom/dotfiles/conky/hardy/conky/ip.sh}
${endif}${else}
${font PizzaDude Bullets:size=14}4${font} Network Unavailable
${endif}
${endif}

There were a number of issues I wanted to fix on my own version:-
- I wanted the font colour to be not-so-glaringly white, less 'in yer face' if you will. I wished to 'colour-coordinate' it with my own [mainly Mint green] desktop theme. To specify a 'color', you use 6-character Hex values (000000 to FFFFFF), just like you do in CSS and HTML.

- Having done that, I added a touch of drop-shadow to make it readable against my wallpaper.

- The 'Network' part of the readout only showed anything when I connected my lappy to the 'net using an Ethernet cable. Nothing at all showed when I was on wireless. So I needed to tweak the code to suit my own set-up. It's a question of putting all those 'wlan's and 'eth's in the right order.

- The icon next to the 'kernel' text is for the wrong Linux. Unfortunately, I discovered that, although the 'OpenLogos.ttf' font features characters for all the other Linuxes (Linuces?) out there, there isn't one for Linux Mint! So I had to approximate something of my own by typesetting the words 'linux mint' in a condensed font that sort of looked the part.

- I needed to change the CPU readouts to suit my own set-up: a bar for each of the two cores, plus an 'average' percentage for the total processor.

- I changed the way it displays the hard-drive capacity.

- I eventually took out the 'public IP' bit of the 'network' readout and a couple of other things I didn't need, like the thing that tells you what song is playing if you are using a certain media player. Which I'm not.

- I added more information about my own Linux version and 'hostname'.

- I added a date and local time.

- I finally 'tidied up' the typography a little (tabs and alignment). I made the column wider and set the maximum and minimum sizes to the same value, so that things don't shift about when the content updates.
So the content of the '.conkyrc' file for my version now reads like this. Most of the changes are to the "TEXT" section:-

# Conky by http://jameshardy88.deviantart.com/art/Conky-JamesHardy88-122466724
# Modified by Umair - http://www.NoobsLab.com
# Further modifications by 'ppminty' JANUARY 2014

# Use Xft?
use_xft yes
xftfont DejaVu Sans:size=8
xftalpha 0.8
text_buffer_size 2048

# Update interval in seconds
update_interval 1

# This is the number of times Conky will update before quitting.
# Set to zero to run forever.
total_run_times 0

# Create own window instead of using desktop (required in nautilus)
own_window yes
own_window_transparent yes
own_window_type conky
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager

# Use double buffering (reduces flicker, may not work for everyone)
double_buffer yes

# Minimum size of text area
minimum_size 245 0
#maximum_width 245

# Draw shades?
draw_shades yes

# Draw outlines?
draw_outline no

# Draw borders around text
draw_borders no

# Stippled borders?
stippled_borders 0

# border margins
border_margin 5

# border width
border_width 1

# Default colors and also border colors
default_color 99FF99
#default_shade_color black
#default_outline_color white
own_window_colour white

# Text alignment, other possible values are commented
#alignment top_left
alignment top_right
#alignment bottom_left
#alignment bottom_right

# Gap between borders of screen and text
# same thing as passing -x at command line
gap_x 20
gap_y 28

# Subtract file system buffers from used memory?
no_buffers yes

# set to yes if you want all text to be in uppercase
uppercase no

# number of cpu samples to average
# set to 1 to disable averaging
cpu_avg_samples 1

# number of net samples to average
# set to 1 to disable averaging
net_avg_samples 2

# Force UTF8? note that UTF8 support required XFT
override_utf8_locale yes

# Add spaces to keep things from moving about? This only affects certain objects.
use_spacer none

TEXT
${time %A} ${time %e %B %G} ${alignr}GMT ${time %I:%M %p}

${hr 1}
${font Ubuntu Condensed:size=14}linux mint${font}${alignr}16 "Petra" MATE 64-bit #type own LM version here
${font StyleBats:size=14} ${font}Kernel: ${alignr}${kernel}
${font StyleBats:size=14} ${font}Hostname: ${alignr}${color}${nodename}

SYSTEM MONITOR ${hr 1}
${font StyleBats:size=14} ${font}${alignr}Core 1: ${cpu}% ${cpubar cpu1 8,60}
${font StyleBats:size=14} ${font}${alignr}Core 2: ${cpu}% ${cpubar cpu2 8,60}
${font StyleBats:size=14}A${font} CPU: ${cpu}% (@ ${freq}MHz) ${alignr}${cpubar cpu0 8,60}
${font StyleBats:size=14}g${font} RAM: $memperc% (of ${memmax}) ${alignr}${membar 8,60}
${font StyleBats:size=14}j${font} SWAP: $swapperc% (of ${swapmax}) ${alignr}${swapbar 8,60}
${font StyleBats:size=14}f${font} HARD DRIVE ${alignr}${fs_free /home} (of ${fs_size /home})

${font Webdings:size=14}~${font} Battery: ${battery_percent BAT1}% ${alignr}${battery_bar 8,60 BAT1}
${font StyleBats:size=14}q${font} Uptime: ${alignr}${uptime}
${font StyleBats:size=14}k${font} Processes: ${alignr}$processes ($running_processes running)

Highest CPU $alignr CPU% MEM%
${hr 1}
${top name 1}$alignr${top cpu 1}${top mem 1}
${top name 2}$alignr${top cpu 2}${top mem 2}
${top name 3}$alignr${top cpu 3}${top mem 3}

NETWORK ${hr 1}
${if_existing /proc/net/route wlan0}
${voffset -6}${font PizzaDude Bullets:size=12}O${font} Up: ${upspeed wlan0} kb/s ${alignr}${upspeedgraph wlan0 8,60}
${voffset 4}${font PizzaDude Bullets:size=12}U${font} Down: ${downspeed wlan0} kb/s ${alignr}${downspeedgraph wlan0 8,60}
${voffset 4}${font PizzaDude Bullets:size=12}N${font} Upload: ${alignr}${totalup wlan0}
${voffset 4}${font PizzaDude Bullets:size=12}T${font} Download: ${alignr}${totaldown wlan0}
${voffset 4}${font PizzaDude Bullets:size=12}Z${font} Signal: ${wireless_link_qual wlan0}% ${alignr}${wireless_link_bar 8,60 wlan0}
${voffset 4}${font PizzaDude Bullets:size=12}a${font} Local IP: ${alignr}${addr wlan0}

${else}${if_existing /proc/net/route eth1}
${voffset -6}${font PizzaDude Bullets:size=12}O${font} Up: ${upspeed eth1} kb/s ${alignr}${upspeedgraph eth1 8,60}
${voffset 4}${font PizzaDude Bullets:size=12}U${font} Down: ${downspeed eth1} kb/s ${alignr}${downspeedgraph eth1 8,60}
${voffset 4}${font PizzaDude Bullets:size=12}N${font} Upload: ${alignr}${totalup eth1}
${voffset 4}${font PizzaDude Bullets:size=12}T${font} Download: ${alignr}${totaldown eth1}
${voffset 4}${font PizzaDude Bullets:size=12}a${font} Local IP: ${alignr}${addr eth1}
${endif}

${else}${if_existing /proc/net/route eth0}
${voffset -6}${font PizzaDude Bullets:size=12}O${font} Up: ${upspeed eth0} kb/s ${alignr}${upspeedgraph eth0 8,60}
${voffset 4}${font PizzaDude Bullets:size=12}U${font} Down: ${downspeed eth0} kb/s ${alignr}${downspeedgraph eth0 8,60}
${voffset 4}${font PizzaDude Bullets:size=12}N${font} Upload: ${alignr}${totalup eth0}
${voffset 4}${font PizzaDude Bullets:size=12}T${font} Download: ${alignr}${totaldown eth0}
${voffset 4}${font PizzaDude Bullets:size=12}a${font} Local IP: ${alignr}${addr eth0}
${endif}

${else}Not Connected ${endif}

${endif}

Here's the 'before & after' shot...

I still have one or two other tweaks under consideration. For example, it is possible to make the battery life indicator change colour according to its current state (so it might be green when it's healthy and turn red when it's about to run out of steam). I did have a fiddle about with some code that tells me what time it is in other time zones as well as the local one, but I'm not sure how useful that would be for me. I've also tried a couple of the weather add-ons, but they seemed to be mainly geared up to telling you the weather in various parts of America. They didn't prove all that accurate locally. I think I'll just stick to looking out of the window...

http://www.noobslab.com/2012/07/install-conky-hardy-in-ubuntulinux.html
http://gnome-look.org/content/show.php/Conky+%5BJamesHardy88%5D?content=104814
http://en.wikipedia.org/wiki/Conky_%28software%29
https://gist.github.com/thriveth/5216313

Oh... and I just found this from the Noobslab folks as well:










No comments:

Post a Comment