KNOW-HOW SuperKaramba Workshop
Creating a SuperKaramba theme WIDGET BUILDER www.sxc.hu If you can’t find the SuperKaramba theme you’re looking for, you can also lets you always build your own. BY HAGEN HÖPFNER specify if you want to keep the ability to move a theme. Some themes have their own configura- retty wallpaper is fine as far as it to get started with SuperKaramba. For tion dialogs. For example, you can con- goes, but if you want desktop additional information, see [2]. (These figure the weather report to match your Pfrills that actually do work for articles are currently available through current location. you, such as displaying weather reports Linux Magazine’s convenient online ar- or monitoring system data, you’ll need a chive.) This article is a brief workshop Creating Your Own Themes tool like SuperKaramba. SuperKaramba on how to create your own Super- To create your own theme, you need to [1] is a KDE-based tool that lets you cre- Karamba theme. create a file, say my_theme.theme, which ate helpful widgets for your desktop. you can open in SuperKaramba as a The SuperKaramba website refers to Finding the Software local file. As graphics and Python scripts these interactive widgets as “custom eye The current SuperKaramba version is can be added to the layout file, you will candy,” but SuperKaramba applets are number 0.37. If you prefer not to build probably want to store all of these com- more commonly called themes. You’ll SuperKaramba yourself, you will find ponents in a single directory. find many pre-built SuperKaramba RPMs and Debian archives at [3] and The theme file comprises three compo- themes on the Internet, but you can also [4]. Running superkaramba opens the nents: general commands specify the create your own themes. A Super- theme dialog (Figure 1) and drops a con- theme geometry and define interactive Karamba theme can take the form of a trol icon into the KDE kicker. areas. Sensors help to read system pa- game, a system monitor, a desktop SuperKaramba needs themes to bring rameters, such as the current CPU load. music directory, or even a custom tool- the desktop to life. Designs are available Finally, meters display the measured bar. for many typical applications. Pressing values. Listing 1 illustrates the makeup Previous articles the New Themes… button of a theme file. in Linux Maga- opens a selection dialog, The first line in Listing 1 positions the zine de- which offers you a num- theme in the lower left corner of the scribed ber of the themes listed at desktop, sets a width of 200 pixels and a how [5]. When you select an height of 400 pixels, specifies that the entry, information about the functionality and a screenshot give you a first glimpse at your options. Su- perKaramba downloads the required files and installs them in the ~/.kde/share/apps/ superkaramba/themes directory. When you close the theme dia- log, the installed themes appear in the SuperKaramba window, where you can launch them. You can run multiple parallel themes on a single desktop, starting and removing the themes individu- Figure 1: Use SuperKaramba’s theme dialog ally as required. The right-click menu to install new themes.
40 ISSUE 68 JULY 2006 WWW.LINUX - MAGAZINE.COM SuperKaramba Workshop KNOW-HOW
code that represents the time sensor to give you hour:minute: white. second formatted time output, whereas format="ddd dd.MM.yyyy" gives you Sensors and the weekday, the day of the month, the Meters month and the year. Besides the time Lines 5 and 6 in List- sensor, SuperKaramba has the following ing 1 create two text sensors: meters that derive • cpu: System load their content from the • disk: Disk usage for mounted file time sensor (sensor systems =time). Line 5 out- • memory: Free and used main memory puts the time and • network: Incoming and outgoing net- Figure 2: Before you start building your own SuperKaramba overrides the default work traffic theme, you might like to check out some of the themes available font size, which was • noatun: Information from a running on the Internet. defined previously. It noatun process is a good idea to use • program: Standard output from any theme can be moved, and sets a refresh
Table 1: SuperKaramba Callback Functions
Function Trigger Parameters passed initWidget(widget) Create the SuperKaramba widget widgetUpdated(widget) Update the theme Update interval from the .theme file widgetClicked(widget, x, y, button) Mouse click on theme x and y: coordinates for click relative to theme; button: mouse button used widgetMouseMoved(widget, x, y, button) Mouse movement within the theme x and y: coordinates for click relative to theme; button: mouse button used menuItemClicked(widget, menu, id) Click on menu item menu: Menu handle; id: Menu item handle menuOptionChanged(widget, key, value) Configuration menu item called in theme key: Menu item handle; value: new value for menu item (true or false) meterClicked(widget, meter, button) Click on meter device meter: Meter device handle; button: mouse button used commandOutput(widget, pid, output) Programm called via executeInteractive(), if output goes to stdout pid: Pro- cess ID for program; output: Output text itemDropped(widget, dropText) Objects dropped on theme in drag & drop operatons dropText: Text for object (e.g. URL). startupAdded(widget, startup) KDE starts an application After launching completes, the startupRemoved() and taskAdded() signals follow startupRemoved(widget, startup) See startupAdded(). taskAdded(widget, task) See startupAdded(). taskRemoved(widget, task) End of application program activeTaskChanged(widget, task) Moves an application to the foreground
WWW.LINUX - MAGAZINE.COM ISSUE 68 JULY 2006 41 KNOW-HOW SuperKaramba Workshop
Listing 1: my_theme.theme using drag & drop. It starts by importing additional modules: import karamba 01 KARAMBA x=0 BOTTOM=true w=200 h=400 LOCKED=false INTERVAL=1000 loads the SuperKaramba module and 02 DEFAULT font="Sans" fontsize=10 shadow=2 color=255,255,255 import string adds string manipulation 03 functions for text variables to the script. 04
42 ISSUE 68 JULY 2006 WWW.LINUX - MAGAZINE.COM