1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
#!/bin/sh
. "${PM_FUNCTIONS}"
DISABLE_HAL_POLLING="${DISABLE_HAL_POLLING:-true}"
help() {
cat <<"EOF"
---
$0: Keep HAL from polling optical media for disk insertion
Keep HAL from polling optical media while on battery. This saves a few
tenths of a watt.
This hook has 1 parameter:
DISABLE_HAL_POLLING = true or false.
If true, this hook will turn off the poll HAL does every 2 seconds to see
if media has been inserted into an optical drive.
If false, this hook does nothing.
EOF
}
stop_polling() {
[ "$DISABLE_HAL_POLLING" = "true" ] || exit $NA
command_exists hal-disable-polling || exit $NA
local disks="$(for c in /dev/cd/*; do readlink -f "$c"; done |sort |uniq)"
[ "$disks" ] || exit $NA
savestate hal_polling_disks "$disks"
for c in $disks; do
printf "Disabling HAL polling of %s..." "$c"
hal-disable-polling --device "$c" >/dev/null 2>&1 \
&& echo Done. || echo Failed.
done
}
restart_polling() {
state_exists hal_polling_disks || exit $NA
for disk in $(restorestate hal_polling_disks); do
printf "Reenabling HAL polling of %s..." "$disk"
hal-disable-polling --enable-polling --device "$disk" && echo Done || \
echo Failed.
done
}
case $1 in
true) stop_polling;;
false) restart_polling;;
help) help;;
*) exit $NA;;
esac
|