Jul
29

Conky

Uncategorized       Share This    Trackback
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

For a system monitor on my Ubuntu systems, I have found Conky is a excellent application. It is Script-able so you can make it look how ever you want, and if that isn’t enough it can execeute shell scripts and output the results to your desktop… I’ve seen a lot of people make Ruby scripts to extend conky but since I don’t know Ruby very well I’ve decided to completely misuse PHP and extend my Conky with PHP scripts! In this post, I will Show my Default Conky Appearence and post my .conkyrc file and the scripts I’ve used to make it look this way and explain what they do.

First Install Conky so type this into a Terminal

sudo apt-get install conky

To use the PHP scripts from conky, make sure you install PHP and PHP-CLI which PHP-CLI is pre-packed with PHP since v4.3

Even thou I use GNOME I love Amarok music player, so I use it even thou it requires KDE library files, For this script to work you will require the DCOP-PHP Class which I am hosting here. Please Note : I Did not write this Class, I am just hosting it here, if there is a problem with it please leave a comment below and I will remove it.

Personally I created a PHP directory inside my home directory, this is where i put all my classes and php files for conky to use.

Save this file in your newly created PHP directory, I called it np.php but thats up to you. The following file is a copy and general cleanup of the example script that came with the dcop.php class files. I made it work for amarok and cleaned it up some to save on server resources.


#!/usr/bin/php	// The ever important PHP shebang line
<?php
require("/home/shawnc/php/dcop.class.php");  // change this to the directory you saved the dcop.class.php file to
 
$dcop = new dcop;
$dcop->application("amarok","",""); //1st argument is necessary, 2nd and 3rd are either specified in your class
//or the defaults will be used
 
$dcop->app_function("player","isPlaying"); //decide if amarok is even playing
$isplay = implode(" ",$dcop->call());
 
if ($isplay) // If amarok is playing then keep going, if not don't waste server resources for nothing.
{
 
	$dcop->app_function("player","nowPlaying"); //call amarok's player function and get nowPlaying as an argument
	$playingstring = implode(" ",$dcop->call()); //This should return what's currently playing on juk
 
	$dcop->app_function("player","album"); //gimme the album
	$playingalbum = implode(" ",$dcop->call());
 
	$dcop->app_function("player","totalTime"); //how much is the total time (in seconds)
	$playing_tot_time = implode(" ",$dcop->call());
 
	$dcop->app_function("player","currentTime"); //how much is the current time (in seconds)
	$playing_cur_time = implode(" ",$dcop->call());
 
	echo "Currently playing in Amarok: \n" . $playingstring . "\n from the album: " . $playingalbum  . "\n";
	echo "Currently " . $playing_cur_time . " seconds far in the " . $playing_tot_time . " seconds long song\n\n";
}
 
?>

No Comments

Make A Comment

No comments yet.

Comments RSS Feed   TrackBack URL

Leave a comment

top
Close
E-mail It