Saturday, March 10, 2007

Monkey-ing around with conky

After changing laptops, i have lost most of my configuration files for my preferred eye-candy desktop. Besides having to install all necessary stuff on my debian, i also have to create new configuration files to optimize my desktop just the way I like it, as well as making some friends like Syirman envy the sweet eye-candy on my laptop .

Most users have their own style and preferences. So do I, and finding one that really suits you takes time and sometimes meticulous googling. Recently, I just customize my own .conkyrc file to work best for me. I didn't like how most configuration for conky takes too much space as well as run too many monitoring tools--which can be a bit too heavy....i thought it would be beautiful if it was slim and show only necessary stuff.

I also liked to know if i have new email on gmail. And so a python script is added into the conky configuration to check my mails on gmail.

First of all, i had to install conky. And on debian that is easy:
#aptitude install conky


After that, i have to create .conkyrc in my configuration file. Here is my .conkyrc file.
#avoid flicker
double_buffer yes

#own window to run simultanious 2 or more conkys
own_window yes
own_window_transparent yes
own_window_type normal
own_window_hints undecorate,sticky,skip_taskbar,skip_pager

#borders
draw_borders no
border_margin 1

#shades
draw_shades no

#position
gap_x 224
gap_y 0
alignment bottom_left

#behaviour

update_interval 1

#colour
default_color bfbfbf
#default_shade_color 000000
own_window_colour 484432

#font
use_xft yes
xftfont DejaVu Sans:pixelsize=9

#to prevent window from moving
use_spacer no
minimum_size 700 40

#mpd
#mpd_host localhost
#mpd_port 6600

TEXT
Copyright Joey aka Rizal ---------------------------------------------------------------------------------------------------------------------------------- $nodename - $
sysname $kernel on $machine
${color lightgrey}CPU Usage:${color #cc2222} $cpu% ${cpubar}
${voffset -1}Cpu: ${color 95956B}${font}${cpu}% ${color} Mem: ${color 95956B}${font}${mem} ${color} | ${color} Up: ${color 95956B}${font}${uptime_short}${color} | ${color
} Net: ${color 95956B}${font}${downspeed eth0} Kb/s ${color} ${totaldown eth0} down${color} | ${color} ${color 95956B}${upspeed eth0} Kb/s ${color} ${totalup eth0} up${co
lor} | ${color}Root: ${color 95956B}${font}${fs_free /} ${color} Home: ${color 95956B}${font}${fs_free /home} ${color} | Gmail: ${color 95956B}${execi 300 python ~/scri
pts/gmail.py} ${color}


Of course you will need to have the python script to get your mails from gmail. Attached is the python script, which i have put it into my home directory under the folder scripts. I didn't develop this code, i took it from someone, I would like to give credit to the person who wrote this python script, but his details was not attached....anyway, thank you to him.

import os
import string

#Enter your username and password below within double quotes
# eg. username="username" and password="password"


username="xxxxxxxx" put your username here
password="xxxxxxxx" put your password here

com="wget -O - https://"+username+":"+password+"@mail.google.com/mail/feed/atom --no-check-certificate"

temp=os.popen(com)
msg=temp.read()

index=string.find(msg,"<fullcount>")
index2=string.find(msg,"</fullcount>")
fc=int(msg[index+11:index2])

if fc==0:
print "0 new"
else:
print str(fc)+" new"


After all that, you can run conky, and have this slim monitoring tool. Results differs base on your resolution. There are some issues if you are using gnome though....I use enlightenment.

3 comments:

  1. I just want to point out that if this does not work, you need to indent both print statements, as python is very picky about indents.

    You can make sure that that is the issue by just executing the command in terminal:

    python /path/to/script.py

    Yuo'll get an error saying Indentation Problem, and it'll even give you the line. Load up your favorite text editor and indent the line that is in question and you're all set!

    ReplyDelete
  2. Hmm, sorry, i didn't noticed that after the cut and paste , things was not indented correctly.....

    But thanks for the heads up.

    ReplyDelete
  3. joey....

    i've upload the pics...

    ReplyDelete

I don't really wish to moderate any comments, but its necessary to avoid spammers.