Spawning Xdialogs from devd...

Gary Newcombe gary at pattersonsoftware.com
Tue Apr 29 06:09:06 UTC 2008


G'day.

This is an X61 laptop, and I'm trying to use the Fn keys to call scripts to do various jobs, while informing users or getting input using Xdialog popups.

Here's an example case. Rebooting the pc if pressing Fn+F4.

[/etc/devd.conf]
...
notify 10 {
        match "system"          "ACPI";
        match "subsystem"       "IBM";
        action "/root/bin/acpi_oem_exec.sh $notify ibm";
};

[/root/bin/acpi_oem_exec.sh]
...
#!/bin/sh
NOTIFY=`echo $1`
case ${NOTIFY} in
        0x04)
                /home/rep/bin/script.sh &
                MESSAGE="do script"
                ;;
	*)
                MESSAGE="nothing found"
                ;;
esac
...


[/etc/sysctl.conf]
...
dev.acpi_ibm.0.events=1


[/home/rep/bin/reboot.sh]
...
#!/bin/sh
if [ ! -f /tmp/reboot ] ; then
  touch /tmp/reboot
  title="Reboot computer"
  msg="Laptop is rebooting immediately..."
  Xdialog --title "$title" --beep --ok-label "OK" --infobox "$msg" 5 40 2000  > /dev/null 2>&1
  wavplay /home/rep/sounds/shutdown.wav > /dev/null 2>&1
  shutdown -r now
fi
exit 0

>From a fresh boot and startx, pressing Fn+F4 from the window manager (Window Maker) calls the script and executes, but no Xdialog or sound. If I startx and run devd in the foreground with:

sh /etc/rc.d/devd stop && devd -dD\

all is fine, Xdialogs displayed and sound too. Likewise, if I restart devd from an xterm (sh /etc/rc.d/devd restart), all is fine:

However, if I restart devd from an ssh term or another console, only sound, no Xdialogs.

I'm curious to know what is actually going on here. I wouldn't have thought the context from which devd is restarted would make any difference, but clearly it does. Any clues?

Also, does anyone have any ideas how I can call Xdialog to get the windows displayed?

Many thanks,
Gary

---








More information about the freebsd-questions mailing list