Sunday, July 17, 2011

Conky : Smooth transparent cool widget on Linux

Ever felt bored of the bare Linux desktop? Installing more and more "gadgets" on your desktop and have trouble arranging them? Then realizing the CPU utilization by these gadgets going high and scrapping them. Well the answers to your trouble is Conky. Conky is a very light weight widget that fits on a Linux desktop and increases the fun of staring at your desktop.


After installing conky by apt-get it will create a default .conkyrc in your $HOME directory. This is the file you need to edit to change your conky display. The basic conkyrc will look like the following:
## Basic conkyrc ##
## Sample comment
<>
# Positioning, Padding
# Colour scheme
# Refresh rate(the parameter to tune for CPU load check)TEXT
## Stuff after this will be formatted in the screen
So far it looks lame coders stuff. What is the cool stuff that Conky is bringing to the table? It is the device monitoring and output, kind of like a gist of what system monitor gives in colourful plots. It took me some blogs to give me this information, so I am compiling the stuff I collected in my conky script below:
# UBUNTU-CONKY
## Create own window instead of using desktop (required in nautilus)
own_window yes
own_window_type normal
own_window_transparent yes
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager# Use double buffering (reduces flicker, may not work for everyone)
double_buffer yes# fiddle with window
use_spacer right
use_xft yes# Update interval in seconds
update_interval 3.0# Minimum size of text area
minimum_size 200 900# Draw shades?
draw_shades no# Text stuff
draw_outline no # amplifies text if yes
draw_borders no
font arial
uppercase no # set to yes if you want all text to be in uppercase

# Stippled borders?
stippled_borders 1

# border margins
border_margin 5

# border width
border_width 9

# Default colors and also border colors, grey90 == #e5e5e5
default_color white

own_window_colour black
own_window_transparent no

# 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
gap_x 10
gap_y 10

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

text_buffer_size 1024

#Clock script

lua_load ~/.scripts/clock.lua
lua_draw_hook_pre draw_clock

# stuff after "TEXT" will be formatted on screen

TEXT
${color yellow}${font urwchanceryl:bold:size=17}${alignc}
${color orange}R${color}AK${color skyblue}E${color}S${color green}H
${color orange}L${color}AP${color skyblue}T${color}O${color green}P
${color green}${font arial:size=8}
Battery ${battery_bar BAT0}

${color orange}${font markedfool:size=15}TIME${font}:
${font arial:bold:size=15}${alignr}${color orange}${execi 30 date +%d-%m-%y}

${color orange}${font eufm10:bold:size=10}TO DO ${color cyan}
${font arial:size=9}${execi 10 tail -n 10 ~/.scripts/todo.txt | fold -w40}
${color orange}${font swift:size=10}CPU $color ${font arial:size=9}
${freq}MHz${alignr}Load: ${loadavg}
${alignr}${loadgraph 20,250 e5e5e5 F1AA0E}
CPU Total:${color} ${cpu cpu0}% ${color}${alignr}Temp:${color} ${acpitemp}
${color brown}${alignr}${cpugraph 0 20,250 e5e5e5 F1AA0E}$color
Core one: ${color}${cpu cpu1}% ${alignr} Core two: ${color}${cpu cpu2}%
${color darkgreen}${cpugraph 0 20,120 e5e5e5 F1AA0E}
${alignr}${cpugraph 1 20,120 e5e5e5 F1AA0E}
${color orange}${font arial:size=9}PROCESSES
${font arial:italic:size=9}${color white}NAME${alignr}PID CPU% MEM%
${font arial:size=9}${color violet}
${top name 1}${alignr}${top pid 1} ${top cpu 1} ${top mem 1}
${top name 2}${alignr}${top pid 2} ${top cpu 2} ${top mem 2}
${top name 3}${alignr}${top pid 3} ${top cpu 3} ${top mem 3}
${top name 4}${alignr}${top pid 4} ${top cpu 4} ${top mem 4}
${color orange}MEMORY / DISK $color
Total: ${memmax} ${alignr} Free: ${memfree}
RAM: $memperc% ${alignr}Swap: $swapperc%
${memgraph 20,120 e5e5e5 F1AA0E} ${alignr} ${swapbar 20,120 }
root: ${fs_used_perc /}% ${color skyblue}${fs_bar 6 /}$color
home: ${fs_used_perc /home/rakesh}% ${color skyblue}${fs_bar 6 /home/rakesh}$color
${color orange}WIRED (${addr eth0}) $color
Down: $color${downspeed eth0} k/s ${alignr}Up: ${upspeed eth0} k/s
${color blue}${downspeedgraph eth0 20,120 e5e5e5 F1AA0E} ${alignr}${upspeedgraph eth0
20,120 e5e5e5 F1AA0E}$color
Total: ${totaldown eth0} ${alignr}Total: ${totalup eth0}
${color orange}WIFI (${addr wlan0}) $color
${wireless_essid wlan0} ${wireless_link_bar 6 wlan0}
Down: $color${downspeed wlan0} k/s ${alignr}Up: ${upspeed wlan0} k/s
${color blue}${downspeedgraph wlan0 20,120 e5e5e5 F1AA0E} ${alignr}${upspeedgraph wlan0
20,120 e5e5e5 F1AA0E}$color
Total: ${totaldown wlan0} ${alignr}Total: ${totalup wlan0}
Inbound: ${tcp_portmon 1 32767 count} Outbound: ${tcp_portmon 32768
61000 count}${alignr}Total: ${tcp_portmon 1 65535 count}
${color gold}${font arial:10}${alignc}***** *****
As you can see the conky language works on the ${var} variables very much like HTML like tags and its attributes are specified as ${attr attr_value1 attr_value2...}. In my code I have monitored the CPU load and Process list, Disk usage, LAN(wired+wireless), etc. The name of the the devices are specific to my computer and may vary and infact there can be more than one WLAN interface that you want to monitor too. The additional interesting is the analog clock that I displayed. I will post the lua script for the clock in another post and customizing it for the conky display.

To get a look and feel, below are pictures of the conky display:



The far right is the conky display.

No comments:

Post a Comment