View previous topic :: View next topic |
Author |
Message |
jacques_h n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
![](images/avatars/13971903114288a4480b70e.gif)
Joined: 16 May 2005 Posts: 71
|
Posted: Sat Nov 05, 2005 4:31 pm Post subject: [aspi] Configuration des hotkeys |
|
|
bonjour,
après moult doc j'ai réussi à configurer mes acpi hotkey sur mon asus v6v mais un problème se pose : en effet dans le fichier .sh dans /etc/acpi
par ex.
Code: |
set $*
group=${1/\/*/}
action=${1/*\//}
case "$group" in
button)
case "$action" in
power) /sbin/init 0
;;
*) logger "ACPI action - $action - is not defined"
;;
esac ;;
hotkey)
case "$3" in
00000030) logger "SOUND UP !!" ;;
00000031) logger "SOUND DOWN !!" ;;
00000032) logger "MUTE !!" ;;
0000006d) logger "HIBERNATE !!" ;;
00000080) logger "SLEEP !!" ;;
0000005d) logger "Toogle Wifi !!" ;;
0000006b) logger "Toogle PAD" ;;
0000005c) logger "Explorer" ;;
00000051) logger "Firefox" ;;
*) logger "Indefini : $3"
;;
esac ;;
*) logger "ACPI hotkey action($action) group($group) is not defined" ;;
esac
;
|
.... toutes les actions s'execute en root. pour la configuration du son c pas grave mais pour le lancement de firefox ??? ben c plus génant, plus de bookmark, config réseau, ...
existe t il un moyen de savoir quel user appuyer sur le bouton ?
sinon j'ai tester un truc du genre su - user -c command_a_exec mais ca ne fonctionne pas pour firefox par exemple.
une idée. merci d'avance. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
widan Veteran
![Veteran Veteran](/images/ranks/rank_rect_5_vet.gif)
![](images/avatars/142533236243680bda6f27b.jpg)
Joined: 07 Jun 2005 Posts: 1512 Location: Paris, France
|
Posted: Sat Nov 05, 2005 6:09 pm Post subject: |
|
|
Il faut deux éléments pour faire marcher ce genre de chose: le script ACPI lui-même (qui tourne en root) et un autre programme tournant dans le contexte de l'utilisateur (qui aura accès à X, et qui aura les bonnes configs.
Avec ce script par exemple:
Code: | #!/bin/bash
FIFO="/var/acpi-event-waiter"
function die()
{
echo "$0: $@" 1>&2
exit 1
}
# Check FIFO exists and is really a FIFO
[[ -e "${FIFO}" ]] || die "${FIFO} does not exist"
[[ -p "${FIFO}" ]] || die "${FIFO} is not a named pipe"
echo "$0: Starting event waiter" 1>&2
# Wait for events (in the background)
(
while true; do
command=$(cat "${FIFO}" 2> /dev/null)
# Check that it succeeded, to avoid infinite looping in case the
# FIFO gets removed after a "cat" completed, but before a new one
# is run (if it gets deleted while cat is running, cat will never
# exit, but that's not a problem)
[[ $? -eq 0 ]] || die "There is something wrong (FIFO removed ?)"
case "$command" in
die)
echo "$0: Exiting gracefully on die command" 1>&2
exit 0
;;
run-firefox)
firefox &
;;
run-xcalc)
xcalc &
;;
*)
echo "$0: Unknown command '$command'" 1>&2
;;
esac
done
) & |
Pour utiliser ça, il faut d'abord créer le pipe nommé:
Code: | # mknod /var/acpi-event-fifo p |
Lancer le script (en tant qu'utilisateur, et depuis un xterm ou le .xinitrc/.Xsession - en tout cas, il a besoin d'être dans un contexte où on peut lancer Firefox ou autres).
Pour essayer, en root (ou depuis le script ACPI):
Code: | echo "run-xcalc" > /var/acpi-event-fifo |
|
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|