Ubuntu / Linux news and application reviews.

Conky facebook

Conky is simply amazing - with the help of basic scripts you can get it to display any info on your desktop. Here is how to get Conky to display Facebook notifications.

1. Create a new file called "facebook" somewhere on your home folder. I usually store these scripts in a "scripts" folder. Then paste the following code inside the newly created file:

wget --user-agent="Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.55 Safari/533.4" -q $address -O /tmp/fbrss
cat /tmp/fbrss | awk '{
 print }' | grep "<title>" | cut -d"<" -f2 | cut -d">" -f2 | awk '{
 gsub(/&apos;s/, ""); 
 gsub(/&quot;/, "\"");
 gsub(/commented on/, ">");
 gsub(/also/, "");
 gsub(/your friend request/, "friendship");
 gsub(/posted something on/, "-->");
 gsub(/posted on/, "-->");
 print }' | awk '{
 if ($0 in stored_lines)
 }'| tail -n +2 | head -n $numberoflines
rm -f /tmp/fbrss*

The "numberoflines" variable is the number of Facebook notifications that will show up in Conky - you can modify it to whatever you want.

2. Go to your Facebook notifications page (click here) and somewhere near the top you should see a link called "Via RSS" - copy the link and replace "REPLACE_WITH_YOUR_FACEBOOK_NOTIFICATIONS_LINK" in the above script with this link.

Facebook notifications RSS feed

3. Make the script executable. If you've placed the script under ~/scripts/facebook, run this command:
chmod +x ~/scripts/facebook

4. Open your .conkyrc file and paste the following code where you want to get the Facebook notifications:
${if_existing /proc/net/route eth0}${font Ubuntu:size=8}${color4}Facebook Notifications: ${color}
${voffset -2}${font Ubuntu:size=7}${color1}${execi 60 ~/scripts/facebook}${color white}

Make sure you replace "~/scripts/facebook" with the exact path to where you've saved the script in step 1. Also, you can of course customize the font in the above code.

Now simply save the .conkyrc file and start conky.

See also:

Many thanks to DiggingLinux for the script and tip!