Estou tentando alterar algumas configurações com a ajuda do udev quando conecto e descubro o dispositivo de controle de acesso, mas não consigo executá-lo. Estou executando o Ubuntu 15.04 e é isso que eu tenho:
sudo systemctl status udev
● systemd-udevd.service - udev Kernel Device Manager
Loaded: loaded (/lib/systemd/system/systemd-udevd.service; static; vendor preset: enabled)
Active: active (running) since lör 2015-05-02 20:28:42 CEST; 2h 3min ago
Docs: man:systemd-udevd.service(8)
man:udev(7)
Main PID: 293 (systemd-udevd)
CGroup: /system.slice/systemd-udevd.service
└─293 /lib/systemd/systemd-udevd
agni% ls -l /etc/udev/rules.d/50*
-rw-r--r-- 1 root root 122 maj 2 20:25 /etc/udev/rules.d/50-kappa.rules
Isto é o que a regra contém. Eu tentei algumas coisas diferentes, mas isso é o que está nele atualmente, e pelo que entendi, deve funcionar
cat /etc/udev/rules.d/50-kappa.rules
ACTION=="change", SUBSYSTEM=="power_supply", RUN+="/usr/local/bin/power-change.sh true"
e o script que deve ser executado
ls -l /usr/local/bin/power-change.sh
-rwxr-xr-x 1 root root 255 maj 2 17:24 /usr/local/bin/power-change.sh
cat /usr/local/bin/power-change.sh
set_ac() {
echo -e "$(date)\nAC CONNECTED" > /home/kempe/test2.txt
}
set_bat() {
echo -e "$(date)\nAC DISCONNECTED" > /home/kempe/test2.txt
}
case in
true) set_ac ;;
false) set_bat ;;
*) exit 1 ;;
esac
exit 0
E isso é o que eu fiz para tentar fazê-lo funcionar sem sorte
sudo udevadm control --reload #no effect
sudo udevadm trigger # no effect
sudo reboot # no effect :)
udevadm monitor --property
monitor will print the received events for:
UDEV - the event which udev sends out after rule processing
KERNEL - the kernel uevent
KERNEL[816.963544] change /devices/LNXSYSTM:00/LNXSYBUS:00/ACPI0003:00/power_supply/ADP1 (power_supply)
ACTION=change
DEVPATH=/devices/LNXSYSTM:00/LNXSYBUS:00/ACPI0003:00/power_supply/ADP1
POWER_SUPPLY_NAME=ADP1
POWER_SUPPLY_ONLINE=0
SEQNUM=2847
SUBSYSTEM=power_supply
UDEV [816.966150] change /devices/LNXSYSTM:00/LNXSYBUS:00/ACPI0003:00/power_supply/ADP1 (power_supply)
ACTION=change
DEVPATH=/devices/LNXSYSTM:00/LNXSYBUS:00/ACPI0003:00/power_supply/ADP1
POWER_SUPPLY_NAME=ADP1
POWER_SUPPLY_ONLINE=0
SEQNUM=2847
SUBSYSTEM=power_supply
USEC_INITIALIZED=6963257
KERNEL[817.171654] change /devices/virtual/backlight/mba6x_backlight (backlight)
ACTION=change
DEVPATH=/devices/virtual/backlight/mba6x_backlight
SEQNUM=2848
SOURCE=sysfs
SUBSYSTEM=backlight
UDEV [817.174385] change /devices/virtual/backlight/mba6x_backlight (backlight)
ACTION=change
DEVPATH=/devices/virtual/backlight/mba6x_backlight
SEQNUM=2848
SOURCE=sysfs
SUBSYSTEM=backlight
SYSTEMD_WANTS=systemd-backlight@backlight:mba6x_backlight.service
TAGS=:systemd:
USEC_INITIALIZED=8174
Se eu executar o script diretamente do terminal, ele funcionará bem, então não há problema
/usr/local/bin/power-change.sh true
agni% cat /home/kempe/test2.txt
-e lör 2 maj 2015 23:06:52 CEST
AC CONNECTED
Alguma sugestão?