Configuring numlock indicator in KDE4

My brother has this really neat wireless keyboard with built-in trackball for his mediacenter. There is only one downside: it doesn’t have a numerical keypad and you never really know if the numlock is on or off. I think it is off at boot, but after turning it on and logging on, it is off again, unless you did a reboot.. or something like that.. Anyway, since it can be quite a challenge to enter passwords correctly, I started looking for a numlock plasmoidish solution.

First thing that turned up in the searches was the Keyboard Status applet. However, in the comments someone rightfully asks why it doesn’t use the keystate DataEngine. Great idea, because this is already packaged with vanilla kde. So I started searching for a general LED plasmoid which I could connect any datasource to using some mapping. No such luck. But then I wondered: why would someone write a plasma DataEngine and then not use it? 🙂 There must be some existing plasmoid! It turned out to be the Key State plasmoid which is currently hosted at gitorious.

Since it is a javascript plasmoid, you can install it as follows:

git clone git://gitorious.org/keystate/keystate.git
plasmapkg -i keystate

Done! It should now be in the list when adding plasmoids under the name “Key State”. You can configure a custom color for each special key. There are some advanced options as well which I didn’t try out. Here is what it looks like:

Key State plasmoid

A simple rectangle shows my numlock is active. I know, nothing fancy but it’s all we need and it does the job! Thank you Martin Blumenstingl. 🙂

Fullscreen games and Nvidia TwinView

Today, I decided to play a game on my suse box for the first time since I have my “new” game rig. I didn’t play any games under linux lately since Microsoft gave us a free windows 7 RC. 😉 I decided to play some Urban Terror but a few hurdles needed to be taken first.

First one: some time ago I managed to screw up my glx acceleration, yielding a “Unable to create SDL screen: Could not create GL context” error. So I installed the latest nvidia binary driver which detected the screw up and fixed it for me.

Second: I have 2 monitors connected: one CRT on the left and one LCD on the right. The LCD is the primary (which confuses some apps). Anyway, when starting an SDL game like Urt, it only sees one monitor (the “beauty” of nvidia twinview 😉 ) and projects its graphics somewhere half-way the primary screen with all the rest left black. I.e. unusable. As I understand it’s an Nvidia problem as they do not obey the rules of the game (meaning xrandr and consorts) for which they had their reasons too (at least back in the day).
Anyway, to solve it, let’s have a look at my original xorg config, or rather the relevant metamode line:

Option "metamodes" "CRT: 1280x1024_85 +0+0, DFP: 1680x1050_60 +1280+0"

We can see there is one mode defined with my crt on the right and my LCD on the right (+1280). The solution is to simply add a second mode in which we disable the CRT and to switch to that mode using the mode cycle shortcut ctrl+alt+”+” before starting a game. When you’re down switch back to your first mode.

Option "metamodes" "CRT: 1280x1024_85 +0+0, DFP: 1680x1050_60 +1280+0;NULL,DFP:1680x1050_60"

You can add as many modes as you want for your different gaming setups. 😉 It’s not ideal, but it does the trick and it even maintains my full desktop resolution (so apps don’t get confused or icons get misplaced) which you can access by “scrolling” on the side.

Third problem: no matter how I tweaked the framerate cap, vertical sync or other graphics settings, I didn’t achieve the smooth framerate I’m used to from Windows or previous linux installs. Somehow the framerate was really high but not entirely smooth. I tried playing online and had a horrible aim. If I didn’t know it ran flawlessly on my old suse box with ATI radeon 9800 pro, I would have stopped looking. Then I realised: let’s try disable desktop compositing. Problem solved! Smooth framerate, 0wnage ensued.

btw: nowadays, Urt’s master server is down. I created an autoexec.cfg in ~/.q3a/q3ut4/ with the line:

cl_master master.urbanterror.info

Last problem solved. 🙂

Configuring an ad hoc network on suse

Since I don’t own a gigabit router but I do have Gbit NICs on my laptop and main computer, I set up a peer to peer network for optimal performance when I have to transfer a large volume. I don’t do that often so I end up losing time every time. So I decided to write a small blog post about it. 🙂 My concrete setup is transfering between a windows and linux machine.

In windows, when the network adapter is configured for DHCP but it can’t find a DHCP server, it automatically falls back to link-local addressing. On IPv4, this is the 169.254.0.0/16 block. (Apparently, Microsoft likes to calls this APIPA.)
However, on my opensuse 11.1 box, it seems not automatically configured for that. When you open Yast -> Network Settings, edit the network interface and enable “zeroconf” under “dynamic address”.
Yast network zeroconfig configuration
All easy peasy and intuitive.

But now comes the catch! After applying these settings, it works… but stops working after a few secs/mins! I checked the messages log and found out the dhcp client tries to restore the old lease if it doesn’t receive an offer. This causes the zeroconf address to be invalidated. So, before enabling Zeroconf, be sure to release the lease first. You can do this as follows:

sudo dhclient -r

Possibly if you keep the DHCP+Zeroconf setting in yast, you can just release the lease when you want to setup a local network and it would fallback to zeroconf. Didn’t verify it though (had to go online to document this ;))

Monitoring resources

Every linux user is familiar with (h)top to monitor processes for cpu usage. Its spin-off tools are a lot less commonly known: iotop for monitoring io,iftop for monitoring network traffic, ftop for file monitoring.. (am I missing any other?).

Another interesting one, particularly if you’re on a mobile device, is powertop for monitoring power consumption. I remember when Intel announced its work on a smaller energy footprint for Intel devices back in 2007 but forgot about it since my kernel didn’t support it yet anyway. 🙂

Although the research was focused on Intel hardware, it is quite useful for other cpu’s like AMD. In that case, powertop is not able to calculate the power usage, but it can still show the number of wake-ups per second per process and how much time is spent in each power state.

Repair grub after windows install

Last week I installed Windows 7 RC (which still works these days, btw) on my brother’s computer so he could practice Autodesk Inventor at home. Since Windows stubbornly still denies the existence of any other OS, it consequently wipes the MBR and installs its own boot loader. Bottom line, we need to reinstall the GRUB boot loader.

There are several ways to do that, but since my brother uses openSUSE, I will use the openSUSE install dvd:

  • Boot from the install dvd
  • Select “Rescue system”. This will give you a console. (I also tried the automatic repair option, but that somehow did not work..)
  • log in with root. no password is asked.

From here on, it is not openSUSE specific anymore:

  • Run “grub”. It starts scanning your disks and after some time you should get a grub> prompt.
  • (Optional) Find the partition where grub is installed:
    grub> find /boot/grub/stage1
  • Set grub’s root partition (example: first harddisk, first partition):
    grub> root (hd0,0)
  • Execute grub installation into MBR:
    grub> setup (hd0)
  • If you would have wanted to install into a specific partition instead of the MBR, simply specify the partition instead:
    grub> setup (hd0,0)

You can find all this info and more in the grub manual.

Flushing the dns cache

As we all know, under windows we can flush the DNS cache with

ipconfig /flushdns

But what is the linux equivalent command? It is so obvious, yet I somehow keep forgetting it. 🙂
Under linux, the standard way to have a daemon reload its configuration, is sending a SIGHUP signal. In case of the name service cache daemon (nscd), this implies flushing its cache!
So you could use the following command to flush the DNS cache if you’re using nscd:

pkill -1 nscd

Extract audio from AV container service menu for KDE4

Nowadays, we live in a KDE4 world for real, so it’s time to update my “dump audio from video file” service menu 😉 It should work both in Konqueror and Dolphin.

Create a file with the following contents and put it in one of your service directories (which you can find out by running “kde4-config –path services” , typically you will have something like $HOME/.kde4/share/kde4/services )


[Desktop Entry]
Type=Service
Encoding=UTF-8
ServiceTypes=KonqPopupMenu/Plugin,video/*
Actions=extractaudio

[Desktop Action extractaudio]
Name=Extract audio
Name[en-GB]=Extract audio
Exec=mplayer -dumpaudio %u -dumpfile %u.dump
Icon=speaker

Time Machine for Linux: Back In Time

Recently, I watched a vid about Apple’s Time Machine and was quite impressed. For the first time in ages, I was considering to try out MacosX, after all, you have to give them credit: they just keep innovating as no other computer company. The plan was quickly abandoned though, when I discovered it wouldn’t run on my newly bought AMD monster-machine (post about that in queue ;)).

Anyhow, I searched some alternatives and somehow nothing as user-friendly showed up.. Until today I stumbled upon the solution by accident while I was checking out LinuxJournal’s tech tips! Quite interesting/entertaining stuff there btw. 🙂 I’m talking about about Back In Time and considering the Ubuntu dev, it even has a KDE4 gui, yay! 🙂

Check out the LJ screencast and the LifeHacker article.