File /etc/udev/rules.d/50-lvs-rfkill.rules |
SUBSYSTEM=="rfkill", RUN+="lvs-rfkill.sh"
|
File /etc/udev/rules.d/50-lvs-webcam.rules |
# Change the idProduct and idVendor attributes to your camera's. # Use lsusb to find them. SUBSYSTEM=="video4linux", ATTRS{idProduct}=="0343", ATTRS{idVendor}=="5986", RUN+="lvs-webcam.sh" |
Reload udev rules |
udevadm control --reload-rules
|
File /lib/udev/lvs-rfkill.sh |
#!/bin/sh find_display() { if [ -r "/proc/$1/environ" ] then perl -ne 'if ( /DISPLAY=([^:]+){0,1}(:\d+)(.\d+){0,1}/ ) { print "$1$2$3\n"; }' < /proc/$1/environ fi return 0 } user_loop() { OLD_DISPLAY=$DISPLAY ps -C kwrapper -C kwrapper4 h -o pid,user | while read pid user do grep -q ksmserver /proc/$pid/cmdline &> /dev/null || continue export DISPLAY=$(find_display $pid) su - $user -c "$1" done export DISPLAY=$OLD_DISPLAY unset OLD_DISPLAY sleep 1 } title= msg= case $RFKILL_TYPE in wlan) title="Wireless" case $ACTION in add|change) case $RFKILL_STATE in 0) msg="Wireless disabled" ;; 1) msg="Wireless enabled" ;; 2) msg="Wireless disabled by hardware" ;; esac ;; remove) msg="Wireless disabled" ;; esac ;; bluetooth) title="Bluetooth" case $ACTION in add) msg="Bluetooth enabled" echo 1 > /sys/$DEVPATH/state ;; remove) msg="Bluetooth disabled" ;; esac ;; esac if [ "$msg" != "" ] then user_loop "$(ls /usr/kde/*/bin/kdialog | tail -n 1) \ --title \"$title\" --passivepopup \"$msg\" 3" fi |
File /lib/udev/lvs-webcam.sh |
#!/bin/sh find_display() { if [ -r "/proc/$1/environ" ] then perl -ne 'if ( /DISPLAY=([^:]+){0,1}(:\d+)(.\d+){0,1}/ ) { print "$1$2$3\n"; }' < /proc/$1/environ fi return 0 } user_loop() { OLD_DISPLAY=$DISPLAY ps -C kwrapper -C kwrapper4 h -o pid,user | while read pid user do grep -q ksmserver /proc/$pid/cmdline &> /dev/null || continue export DISPLAY=$(find_display $pid) su - $user -c "$1" done export DISPLAY=$OLD_DISPLAY unset OLD_DISPLAY sleep 1 } title="Webcam" msg="Webcam" case $ACTION in add) msg="$msg enabled" ;; remove) msg="$msg disabled" ;; esac user_loop "$(ls /usr/kde/*/bin/kdialog | tail -n 1) \ --title \"$title\" --passivepopup \"$msg\" 3" |
No comments:
Post a Comment