Kubuntu KDE4 Toolbar Icons for KDE3 Programs

I noticed that a few programs (like kpdf, piklab, pikloops, etc.) were not showing icons in their toolbars. The common element seemed to be that they were all KDE3 programs and I was using KDE4. But that should work.

It took a little detective work, but here’s the solution: I had changed theme files and apparently most these have a missing line that enables this to work. In my case, I was using Nuvola, but the same principle will work with any theme.

1) Find the index.theme file for the theme you are using. In my case, it was in /usr/share/icons/nuvola/index.theme.

2) Edit it (you’ll need to be root — that is use sudo) to save it. Add a single line:


I don’t know that it matters where you put it as long as it is in the [Icon Theme] section. I put it right under DisplayDepth=32.

3) I don’t know if you have to reload the theme, but I did. I just picked another theme, hit Apply, and then picked Nuvolo again and hit apply. You also need to restart any programs that you expect this to fix.

4) Enjoy toolbar buttons with icons.

Graphing CPU Temperatures in Linux

I recently changed motherboards and as always mounting the fan and heatsink on the CPU makes me feel stupid. I have a large non-stock cooler and it is always a struggle to make it fit with all the other things motherboard makers stuff near the CPU these days. After some busted knuckles, I thought I had it. But the temperature was a little high for my taste and seemed to climb for no good reason.

I looked at the setup and realized the plate that touches the CPU was off center. So I decided to remount it. Well, turns out there was a reason the plate wouldn’t center, but I eventually solved it. But all this has given me an unsual interest in temperature the last few days.

I won’t tell you how to set up lmsensors since there are plenty of good references on how to do so (a quick google on “lmsensors howto” shows lots of pages including . I even used ksensor (I use KDE) to give a nice display. I was thinking how nice it would be to automatically collect the data and graph it. Then I thought, well, why not?

I wrote a quick and dirty script — you’d need to change it for your setup. I have an AMD 5600+ (overclocked though), so when I run “sensors” I get several devices. The one I wanted was the k8temp-pci-00c3 which shows the two core temperatures. Unfortunately, it isn’t in a great format for processing:

Adapter: PCI adapter
Core0 Temp:  +38.0°C
Core1 Temp:  +36.0°C

But certainly awk is up to the challenge of fixing this up. Here’s the quicky script:

#usage: tempdata delay file
echo Press ^C to exit
echo "Date/Time,Core 0,Core 1">$2
while true
   echo -n `date +%Y%m%d%H%M%S,` >>$2
   sensors k8temp-pci-00c3 | awk 'NR==3 { gsub/.C/,""); c1=$3; } NR==4 { gsub(/.C/,""); print c1 "," $3; } >>$2
   sleep $1

So there you have it. A classic example of using little Linux tools to create something bigger.

Java Browser Plugin for Linux AMD64 is Here

Early release, it is true but it does work.

Download from here:

From a terminal:

cd /opt

sudo sh ~/jre-6u12-ea-bin-b02-linux-amd64-08_dec_2008.bin

# So you wind up with /opt/jre1.6.0_12

cd /usr/lib/mozilla/plugins
sudo ln -s /opt/jre1.6.0_12/lib/amd64/libnpjp2.so

# (restart firefox)

http://www.thinkfree.com finally works! Hoo ray!

Flash! (Adobe) for AMD64 Linux/Ubuntu

One of the downsides of using 64-bit Linux (I use Kubuntu, a variant of Ubuntu) is that there hasn’t been a 64 bit Flash plugin. Sure, you could use a 32 bit browser, but that seems wrong. You could also use nswrapper to provide a 64 bit front end to a 32 bit plug in, but performance is not so good and it occasionally fails mysteriously.

I guess Adobe got tired of hearing folks whine, so they’ve released an alpha version of a 64 bit flash plugin. So far so good:

apt-get –purge remove nonfree-flashplugin nspluginwrapper

wget http://download.macromedia.com/pub/labs/flashplayer10/libflashplayer-10.0.d20.7.linux-x86_64.so.tar.gz
tar xvf libflashplayer-10.0.d20.7.linux-x86_64.so.tar.gz

sudo mv libflashplayer.so .mozilla/plugins/

Restart Firefox and check the about:plugins page.

YouTube videos still play in squashed fullscreen if you have dual monitors but that’s not a 64 bit issue.

Enjoy! Now if only Sun would give us a good 64 bit Java plugin….

New Wine Dazzles Linux

I try to keep my Linux desktop updated pretty regularly via Adept  (although I know many people use Synaptic or Aptitude for the same purpose). So a few days ago I saw that Adept wanted to upgrade Wine to version 1.1.7.

Wine — if you don’t already know — is a port of the Windows API that runs under Linux. The purpose of it is to run Windows programs inside Linux. I can hear some people saying “Ugh — I don’t want to run Windows programs.” But the truth is there are many programs that run only on Windows that you might want to run or might have to run.

For example, I use Endicia for printing postage. The flat rate they charge suits me better than Stamps.com and the software — while not as friendly — is better suited for people who ship a lot of parcels (for example, you can use XML to transfer shipping information from another application). The problem is, of course, no Linux version.

Wine has been able to run Endicia’s Dazzle (which is sometimes called Envelope Manager; I don’t know why). But for some reason the postage bar code would print as a big black box. In addition, WINE won’t store your passphrase for Dazzle, but that’s a minor problem — you just have to enter your passphrase when you launch the program.

Once Wine installed 1.1.7 Dazzle was able to display and print bar codes! So it looks like Linux users can finally run Dazzle without resorting to VirtualBox (which is what I have been doing). The passphrase storage doesn’t work, so you do have to put your pass phrase in each time you start the program.

There seem to be some major improvement to Wine. Evernote portable now runs without crashing (or, at least, it crashes less frequently — it has always run but with some crashes). Other software I like to run with Wine includes SwitcherCAD (the free Spice software for electronic simulation) and the MPLAB tools from Microchip.

GIMP (Linux) One Window

GIMP in Xnest

GIMP in Xnest

Well I like GIMP for image editing, but the mutliple windows kind of bugs me. I had a plug in that sweeps up the windows into one master window. But I found it only works for Windows! Since I’m now 99.9% Linux, I wanted to find a similar solution.

Well, the answer turns out to be pretty simple. You need:

Xnest – the nested X server
A simple window manager such as xfwm4 or twm.

I used twm but only because I happen to already have it installed. But you might prefer xfwm4.

Then you can make the following shell script (I named it gimp1):

exec Xnest :1 -ac -name GIMP -geometry 1200×1000 & twm -display :1 & gimp –display :1

That’s it! Set the geometry to suit yourself of course. And this assumes that display :1 is already free. But you get the idea. Enjoy!

Oh, and for the record, yes that is my car. I love it (SLK230)!

UPDATE: Ugh. Xnest doesn’t appear to exchange the clipboard with the “real” X server 🙁 So that makes this a little less useful than you’d think unless you aren’t worried about using the clipboard (for example, using a screen shot from the clipboard).

Man Pages for X

If you use the Linux command line a lot you know the value of man (that’s man as in manual, not as in a guy). But I do find it annoying that when I quit paging through man’s output, the output disappears. Of course, you could fix this by changing the pager, but what I really wanted was a way to just have a “help window” show up that I could refer to while I was typing. Of course, there is the venerable xman, but it is a clunky old X application with a poor interface.

I noticed manview the other day in the repositories (part of manedit). I installed it (on Hardy it shows up under Development, but your milage may vary). Of course, then you have to remember to type manview instead of man — and I’ve been typing man for nearly 30 years.

So here’s the latest two entries in my ~/.bashrc:

  alias man=xman

 xman ()
    if [ -z "$DISPLAY" ]; then
        'man' $@;
        manview $@ &

This way when you type “man” from an X-Window shell you get the GUI but over a non-X shell you get good old fashioned man (be sure your shell function quotes man or you’ll get an endless loop thanks to the alias). Of course, you need to make sure manview is installed (for example, sudo apt-get install manedit).

Autohotkey for Linux — Sort Of…

I’ve enjoyed using AutoHotKey on Windows. If you haven’t used it, it is kind of hard to explain exactly what it is. Its sort of a scripting language, but it can manipulate windows, send key strokes, mouse events, and so forth.

Its surprising that there isn’t really a good analog to this program in Linux. Sure you have all sorts of scripting languages including the shell. But I haven’t really seen any that do a good job manipulating windows.

However, in true Unix fashion, there are a few tools you can use to make your favorite scripting language work with your desktop — assuming you have a compatible window manager (which you probably do).

The two main weapons in the macro arsenal are xmacro and wmctrl (chances are you can download them right from your package repository). You might also want a utility that lets you make simple dialog boxes for scripts. I like Kommander, but that’s not as lightweight as, say, Zenity, but that’s purely optional.

The wmctrl package allows you to list the current windows. You can raise a window and do other basic operations like set the window title or switch desktops. Here’s a great page about wmctrl: http://jrandomhacker.info/Wmctrl_examples [broken link]. Note that the desktop stuff doesn’t seem to work with KDE4.1 (my testing) and blackbox (from that page).

The xmacro package lets you send keystrokes and mouse events to the X terminal. It can also record actions, but I rarely use that feature. If you need it though, you might need to add:

Load “Record”

In the Modules section of your xorg.conf. You can use the recorder to “start” a script by running:

xmacrorec2 >temp.macro

The program will ask you to pick a “stop” key — something you won’t use in the recording like the Escape key, for example. Then you do your actions — try not to make any mistakes — and press the “stop” key. The temp.macro file will have the actions recorded. You can edit them (cut out any mistakes, delay between them, activate windows, etc.).

The only real problem with xmacro is that the mouse positions are absolute. So you are better off if you can stick to keystroke commands. However, if your scripting skills are good enough, the wmctrl -l -G command gives you enough info to compute relative mouse coordinates for any window.

I used AutoHotKey to correct a missing feature in ThunderBird for Windows. I wanted to just print a PDF attachment in an e-mail message (something Outlook does easily). With the Linux version of ThunderBird I wrote the following quick and dirty script:

   # Simple script to print the first PDF attachment from an e-mail# in thunderbird
# assumes you are already on the message with the attachment
# and also assumes the attachment is a PDF and that the
# PDF reader is from Adobe
# but for debugging try this
#wmctrl -R thunderbird
sleep 2  # wait for user to let go of keyboard

xmacroplay -d 10 $DISPLAY << ~~~
KeyStrPress Alt_L
KeyStrPress f
KeyStrRelease f
KeyStrRelease Alt_L
KeyStrPress a
KeyStrRelease a
KeyStrPress 1
KeyStrRelease 1
KeyStrPress o
KeyStrRelease o
sleep 1
# adobe should be active but just in case
# either comment this out or change it if you want to
# use kpdf or ockular or whatever
wmctrl -R adobe
xmacroplay -d 10 $DISPLAY << ~~~
KeyStrPress Alt_L
KeyStrPress f
KeyStrRelease f
KeyStrRelease Alt_L
KeyStrPress p
KeyStrRelease p
KeyStrPress Alt_L
KeyStrPress o
KeyStrRelease o
Delay 2
KeyStrRelease Alt_L
KeyStrPress Alt_L
KeyStrPress f
KeyStrRelease f
KeyStrRelease Alt_L
KeyStrPress x
KeyStrRelease x
# change the x above to c if you don't want to quit Acrobat

I used the Window manager to bind the script to a key and its all done. If you don’t want to go that far, you can uncomment the wmctrl line that activates Thunderbird and start the program from a shell prompt or an icon. Naturally, you could use wmctrl -l to verify that the attachment opened, etc. But this will get you started.

Of course, this doesn’t approach some of the power of Autohotkey. But it is still pretty usable.

Extra note: If you do want to experiment with using the mouse, you might consider using xev to look at mouse coordinates. You can use wmctrl -l to get window IDs and then use xev’s -id option to attach it to a particular window and watch events. A grep is handy to filter out events you don’t care about, or catch it all in a file and examine it later.

Update: There is another tool I have found that seems to work well and integrates window control and keyboard control. Check out xdotool.

Better Screen Shots for KDE4

By defualt Kubuntu with KDE4 (at least) sets up Print Screen to work with ksnapshot. This program grabs the screen (or a window with the -c option). The program is minimal and lets you save a file, copy it to the clipboard, or open it with a program.

However, you can use apt to install kgrab. This program is functionally the same as ksnapshot but it has an actual menu as well as a way to directly print screen shots.

However, both the KDE “input actions” and Compiz were trying to handle the print screen key. Changing ksnapshot to kgrab didn’t do anything! So the solution was simple:

cd /usr/lib/kde4/bin
sudo mv ksnapshot ksnapshot.orig
sudo ln -s kgrab ksnapshot

That does it.

SXKey Under Wine

Since I often program Parallax/Ubicom/Scenix SX chips, I needed a good way to program the chips under Kubuntu/Ubuntu. The installation of the software under Wine worked fine. However, the program didn’t work right away.

Of course, I had already set up ~/.wine/dosdevices to have a link for com1 (ln -s /dev/ttyS0 ~/.wine/dosdevices/com1). You need to make sure you have permissions on that device also. Rather than open the port to the world, I noted the port is in the “dialout” group, so you can simply add yourself to that group to get read/write access to the port. For example:

alw@enterprise:~$ ls -l /dev/ttyS0

crw-rw—- 1 root dialout 4, 64 2008-08-13 06:45 /dev/ttyS0
alw@enterprise:~$ sudo usermod -a -G dialout alw

Naturally if you aren’t using your real COM1, you’d need to change /dev/ttyS0 to the right designator (although you can still call it COM1 for Wine!).

The com port autodetection was the culprit.  The trick was to open ~/.wine/user.reg and add this line:



I’m not sure if it mattered, but since the entries are alphabetical, I put it in the “right” place. After that, it all worked fine!