Custom responses to HAL events

Paul Worrall lists at basilisk.ukfsn.org
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 
containing:

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

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

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

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

Thanks again
-- 
Paul
___________________________________________________
This message is from the kde mailing list.
Account management:  https://mail.kde.org/mailman/listinfo/kde.
Archives: http://lists.kde.org/.
More info: http://www.kde.org/faq.html.




More information about the kde mailing list