Custom responses to HAL events

Paul Worrall lists at
Wed Nov 15 23:10:06 GMT 2006

On Wednesday 15 November 2006 08:28, Boyan Tabakov wrote:

> I am not sure if you accomplish this by means of KDE, but here is what I'd
> do to make it work:
> You have hal, right? There is a command line tool called hal-device that
> lists all the devices recognized by hal that are connected to the system.
> Type hal-device | less and look through the list when your PDA is
> connected. Find the line that identifies it. You can then right a simple
> daemon that monitors when this device is plugged and make it show/hide your
> desktop icon. It ma look something like this:
> #!/bin/bash
> while true ; do
> if [ `hal-device | grep "identification string goes here" | wc -l` -ge 1 ]
> then
> 	-f ~/Desktop/.My\ Hidden\ Icon &&
> 	mv ~/Desktop/.My\ Hidden\ Icon ~/Desktop/My\ Visible\ Icon
> else
> 	-f ~/Desktop/My\ Visible\ Icon &&
> 	mv ~/Desktop/My\ Visible\ Icon ~/Desktop/.My\ Hidden\ Icon
> fi
> sleep 5 # sleep for 5 seconds before attempting to refresh
> done
> Just make sure the script is started when you launch KDE, buy copying it to
> ~/.kde/Autostart
> There maybe are ways to detect the kernel notification upon the PDA
> connect, but I don't know how to do that...

Thanks Boyan... that got me thinking.  The solution I have come up with is to 
use a udev rule.  When I plug in my PDA, a network interface called usb0 is 
created for it, so I created a file /etc/udev/rules.d/85-PDA.rules 

    KERNEL=="usb0", RUN+="/home/paul/bin/PDA"

and a /home/paul/bin/PDA script containing:

#! /bin/sh
case "$ACTION" in
    cp /home/paul/PDA.desktop /home/paul/Desktop
    rm -f /home/paul/Desktop/PDA.desktop

This needs a bit of polishing, but it seems to do what I wanted.

Thanks again
This message is from the kde mailing list.
Account management:
More info:

More information about the kde mailing list