2009-01-09

./jamendo-player

I was enough bored from my (small) music collection that I wanted to listen to something new, without actually caring what it is. I know Jamendo has a big load of music with artists uploading music under creative commons licence. So I went on their website to have a look, and they have "widgets". They are a small flash application not bigger than 200x300, but I actually didn't find any link to open such a widget inside an external window, except some lost links on some pages. In conclusion it was enough annoying to get an external player that I fired up vim and wrote a 20 lines C program.

/* gcc `pkg-config --cflags --libs webkit-1.0` main.c -o jamendo-player */

#include <gtk/gtk.h>
#include <webkit/webkit.h>

#define URL_FORMAT "http://widgets.jamendo.com/fr/playlist/?playertype=2008&playlist_id=%s"

int main (int argc, char *argv[])
{
GtkWidget *window;
GtkWidget *webview;
gchar *url;
gchar *playlist_id = argv[1];
if (argc < 2)
{
playlist_id = g_strdup ("65196");
g_message ("Loading the default playlist %s", playlist_id);
}
url = g_strdup_printf (URL_FORMAT, playlist_id);
gtk_init (&argc, &argv);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (window, "delete-event", G_CALLBACK (gtk_main_quit), NULL);
gtk_window_set_icon_name (GTK_WINDOW (window), "multimedia-player");
gtk_window_set_title (GTK_WINDOW (window), "Jamendo Player");
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
webview = webkit_web_view_new ();
gtk_widget_set_size_request (webview, 200, 300);
gtk_container_add (GTK_CONTAINER (window), webview);
webkit_web_view_open (WEBKIT_WEB_VIEW (webview), url);
gtk_widget_show_all (window);
gtk_main ();
return 0;
}


The result is pleasing, the flash application has nice colors, and is something I would never be able to do with GTK+ :-)

If you like the code, feel free to extend it and send patches, I will enjoy any contribution. For now I will just leave a desktop file inside my applications directory to open it when I am bored again of my music :-p

Update: I hacked a little on the program to handle the links inside the Flash application. This means it is possible to change the playlist, which was one the thing that started to annoy me very much.

However, this update requires WebKit 1.0.3 and GLib 2.16.



This time I'm making the code available here instead of pasting it as it has grown up to 120 lines.

2008-12-05

Network monitoring tools

Sometimes I am in the need to watch the network traffic and for these occasions I fit to console based tools.

The first application I found – years ago – was iftop. It does a nice job, printing the average bandwidth upwards and downwards transferred for the past 2, 10 and 40 seconds for each connections.

Recently I found out two other tools like iftop, and both of them have their intrinsic advantages:
  • nethogs displays the bandwidth per process. Very nice when you want to monitor applications that doesn't provide this information in their interface. Quick note: press 'm' to switch between the display modes.
  • iptraf is the most complete tool than the above mentioned ones. It is also NCurses based however fully interactive with colors and menus. The tool states itself as a "Statistics Utility", which it is, as it allows to visualize the network traffic based on a dozen possibilities.

I also found out a very complete – for nowadays – web-based application which is ntop. It can be run as a daemon and will gather all information inside databases. You can connect to http://localhost:3000 to display graphics (rrdtool based) and zillion of information. I'm giving a try to this tool with at least a per month review.

2008-11-13

Prospective work on Xfce

As Xfce 4.6 is coming it might be good to throw updates for the panel plugins I maintain at the same time.

The panel plugins I maintain are:
  • The notes plugin
  • The FS guard plugin
  • The clipman plugin (this one is prolly the most wanted)

For the notes plugin I got already most features I was thinking of in, except formatting (which I doubt that I will work on), so the release going on here will be minor.

For the FS guard plugin I was asked to reverse the progress bar so that it shows the capacity remaining and not the free space... well something like that :-) Now I'm confused and don't remember what it really displays.

The clipman plugin needs a rewrite. To my taste it features too many options, and I will split most none-obvious options to an "Advanced..." tab. The first release will most probably be the rewrite, than will follow another release for a long asked feature that is action on pattern matching — open a web page automatically, display a menu, and so forth.

Other than plugins I maintain applications.

The applications I maintain are:
  • Xfmpc
  • Eatmonkey

Sadly for Xfmpc — a client for MPD — I no longer run MPD to listen to my music, so this hacking is freezed at the moment. My current favorite player is Audacious.

Eatmonkey is a small application where I learn to use new frameworks. There won't be an official release before very long.


Hopefully I will get the clipman plugin out before end of December!

2008-09-23

All my day from Sept. 22

Morning, 9 o'clock, I get up and turn on the computer, work starts.

11 o'clock, I finish my work stuff from the morning to jump into another priority, getting at the office, which is 110+KM far away. I was a bit doubtful if I had everything, looking and re-looking, my pants are on, my data is in my USB key which is in my carry-all.

Still, that day I learned a lesson: never ever pretend to have your wallet in your usual pants! Never. Never.

I drove around 50-60KM before it took my attention that I forget my wallet. No credit card, no licence, no money, that means a lot of trouble at the toll… I had a coin of 1€ in my pants, which means I was missing 6€40!

I stopped by at a filling station and asked random people for a coin and it took me 20 minutes :-) I love you people out there. You saved my day.

2 o'clock in the afternoon, I was at the office.

2008-09-04

Mount remote file systems (Tape #2)

I once wrote about sshfs.sh, a shell script to mount a remote file system with sshfs. This is now deprecated!

Now I'm giving a try to gvfs-mount. Currently I can mount a volume and list it with gvfs-mount --list, but I cannot browse inside it because it isn't mounted. I played with the --mountable argument, but it must be a joke. I think I need a something fuse daemon from gvfs... I'll keep this up to date.

Update: Everything is alright now. The output of ps ax | grep gvfs shows the following process: /usr/lib/gvfs/gvfs-fuse-daemon. All your mount operations will be available at $HOME/.gvfs.

The recent GTK+2.14 release introduces a widget to ask a password thats called GtkMountOperation (have a look at the GTK+ blog). It might be interesting to start a Thunar plugin, and release it officially with Xfce 4.8.

Update 2: And on a fresh Debian install (or in general anyway) don't forget to install the fuse-utils package (/usr/bin/fusermount)!

2008-09-03

Google Chrome

Is O.K.. I just tried Google Chrome, and it kicks the ass! I can already dump it against I.E. Firefox or what else there is out there.

Its design is brilliant ;-) I like using the browser as the GUI to do everything, having a simple toolbar and tabs, displaying the messages of the status bar by fading it in and out, and there is not even a heavy preferences dialog. Everything is fine.

You did a browser that is gonna rock, you three people on that comic ;-) I guess there were more than just you, isn't it?

And you, you have to try it out. I hate using Internet Explorer or Firefox when I'm on a friends machine, so now I can use Chrome that just takes a minute to be downloaded and installed and ... ready!