conky for my desktop

Published April 22nd, 2010 by Chad

At work I have a todo list that I maintain in a simple text file on my system. This todo list looks create and is readable on the command line (using cat) and in vim. However, I was really wanting it in a place where I could see it at a glance.

Also sometimes I miss the Ubuntu notifications in the top right corner of the screen (my background is black and the notifications don’t stand out on a black background since they are also black (I can’t wait until we can easily customize the notification system theme, anyone know how to do that yet?)).>

Another item of information that I love to have visible at all times is the list of my co-workers who are currently online (logged into IM). This helps if I need to ask one of them a quick question.

The solution: Conky

At first conky may scare you, I know it did me. The configuration files have a little bit of a learning curve that may be too steep for some. Conky is mainly used as a “light weight system monitor”. I however don’t need a system monitor (I’ve never really used the information they provide while I am on my desktop computer). System monitors are great for a laptop where I need to worry about what processes might be cramping my speed or draining my battery. I might also use the system monitor to check the temperature of my laptop or the battery level. For my desktop however I don’t need (or want) that stuff. Thankfully conky is so much more than a “light weight system monitor” I can set up scripts to run at any interval I would like and display the output in a nice way in a place where I can (almost) always see it.

Here is my conky configuration file:

background yes
own_window yes
own_window_type normal
own_window_transparent yes
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
double_buffer yes

text_buffer_size 1024

use_xft yes
xftfont Inconsolata:size=12
#xftfont Angleterre Book:size=10

alignment top_right
gap_x 20
gap_y 20
maximum_width 400

TEXT

${font Cash Font:bold:size=12}${color #444}TODO:  ${hr 7}

${font}${color gray}${execpi 60 /home/chansen4/conkyTodo.py work}

${font Cash Font:bold:size=12}${color #444}NOTIFICATIONS:  ${hr 7}

${font}${color gray}${execpi 10 /home/chansen4/bin/getLastNotify.py}

${font Cash Font:bold:size=12}${color #444}PEEPS:  ${hr 7}

${execpi 10 conkyPidgin -I co-workers -C C -W U -A A -o -t ~/conkyPidgin.template}

Everything after the “TEXT” is what is displayed (before that are just settings). If you want to change some setting or another you start with the $ (dollar sign) and in {} (curly braces) afterwards specify the property to change and the value to be set.

For example: ${font Cash Font:bold:size=12} sets the font to be the “Cash Font” font, makes it bold and sets the size to 12 point. ${color #444} sets the color to be hex 444. ${hr 7} creates a horizontal rule of 7 pixels thick.

The real interesting part though are the ${execpi commands (the format for these commands is ${execpi [RUN TIME IN SEC] [SCRIPT], not too difficult). This will run an executable script and parse the output at more conky configuration code. There are three such calls in my configuration file. conkyTodo.py (my own script to parse my todo list and display it nicely in conky), getLastNotify.py (once again, my own script to parse the notify-osd.log file to get the last 4 notification messages and display them nicely in conky), and conkyPidgin (which is part of the conky hardcore package and gives one access to the Pidgin contacts).

If any of this is too confusing or you would like some more information/clarification just leave a comment and I will do my best to answer your questions. Thanks!

My current conky theme at work

My current conky theme at work

Update: Here is my getLastNotify.py script.

custom command prompt

Published January 22nd, 2010 by Chad

I spend a lot of time in the terminal and at the command prompt. The default prompt for Ubuntu is very…unhelpful, to say the least. I already know who I am and most of the time I know what machine I am on. So after talking to a friend of mine and doing a little research I have come up with this custom command prompt that suits me just fine.

custom command prompt screenshot

custom command prompt screenshot

The first part is the time that the prompt was given. This idea came from my friend. I like it for things like figuring out just how long that last command took (without having to run it again with the time command) and for simply seeing what time it is (since I am in the terminal a lot).

The next part is the current directory I am working in. I made it a different color to make it stand out a bit more from the rest of the stuff on the screen. So, with a quick glance, I can determine if I am in the right place before running the command.

The last part is the coolest (in my opinion) by far. I found an example of the smiley faces being used and really liked that idea. Once again at a glance I can determine something important. This time, I can determine whether or not the last command was successful. If I see red, I can look back and see what happened. If no red, keep going, everything is just fine. Pretty cool.

Now to the nitty gritty. How exactly do you create a custom prompt like this. After ripping things from a few different places (and doing a lot of my own troubleshooting) I came up with this for my custom command prompt: PS1="[\e[00m][\T] [\e[1;34m]\w `if [ \$? = 0 ]; then echo -e '[\e[01;32m]:)'; else echo -e '[\e[01;31m]:('; fi` [\033[00m]\$[\e[00m] "

Confused? :) I was too. In fact, I am still unsure as to what exactly some of it does. Oh well.

The segments that look like [e[00m] (sometimes with different numbers) are specifying the colors of the different sections. The first part you can see that after the color specification section there is a [\T]. This simply specifies that the current time (\T) needs to be printed between some square brackets ([]).

Next there are some more colors specified followed by \w. This specifies that I want the current working directory displayed. A capital W will display the current working directory without the path.

Then comes the fun stuff. Bash scripting within a string! Basically it says that if the last command was all good, display a smiley face. However, if something went wrong, a frowning face is displayed (in red). The bash scripting is just a simple if-else statement with some echo calls.

The key here is making sure everything is escaped correctly. Add a comment if you have any questions. BTW, here is another good reference for this type of thing.

synergy

Published December 15th, 2009 by Chad

Let me start off by just giving you a really good link for what I am about to talk about. Ready? SynergyHowto. There, now lets begin.

At work I have two computers working for me; a desktop (with a 30in monitor!) and a laptop. I place my laptop next to my monitor on my desk so that I can easily see and access it if I need to.

As you can imaging, I started to get really annoyed at having to move my hands and arms from one keyboard/mouse to the next to use both computers. What if I could just the same keyboard and mouse for both computers? Enter Synergy.

Put simply synergy is a keyboard and mouse sharing system. Synergy has both a client and a server application. The server is installed on the system that you want to share your mouse and keyboard from. The clients are installed on any other number of computers that you would like to control with that same keyboard and mouse. The only requirement is that the systems be on the same network. Easy.

The setup takes a little (and I mean little) work. You must state in the config file which computer is the server and which are the clients. Also you must specify where each computer is with respect to each other computer. For example, in my setup my 30in sits right in front of me and my laptop sits to the right. In my config file I specify that the desktop is left of the laptop and that the laptop is right of the desktop. At first this seemed a little redundant, but it works so I can’t complain.

Anyway, if you have a situation like this, were you would like to control more than one computer with one mouse and one keyboard, give synergy a try.

By the way, on Ubuntu 9.10 (and I believe in older versions) you can just install it by typing the following (this will install synergys (synergy server) and synergyc (synergy client): sudo apt-get install synergy

changing gnome-terminal default window size

Published December 8th, 2009 by Chad

I actually like the default window size for the gnome-terminal in Ubuntu now. But I used to not like it. There was a time when I would run a command, see that the output of the command wasn’t displayed nicely, resize the window manually, and rerun the command. Annoying. If you would like to change the default gnome-terminal window size just follow these steps.

  • Open terminal window.
  • Type: sudo gedit /usr/share/vte/termcap/xterm
  • Find the following line: :co#80:it#8:li#24:\
  • Change to your desired window size (the number after :co is the number of columns and the number after :li is for the number of lines): :co#200:it#8:li#50:\
  • Save and close the file.

Every gnome-terminal you open now with use this new window size as the default. This will only work after you have closed all of the opened gnome-terminal windows first. Enjoy.

custom date and time in panel

Published December 3rd, 2009 by Chad

As you may have noticed by the screenshot from my last post the date and time portion of my panel isn’t the norm. Thanks to one of my new favorite sites OMG Ubuntu (not a fan of the name, but what are you going to do, right?) I was able to easily customize this portion that used to take up so much of my panels real estate.

This post, Some More Gnome Panel Clock Applet Styles, from OMG’s site gives you everything you need to know to make the changes. I will not repeat the steps here.