Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
wiki:using_acpid_to_control_your_pc_buttons [2013/03/01 11:01] – Update tinypoodle | wiki:using_acpid_to_control_your_pc_buttons [2022/09/21 17:10] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | =====Using acpid to control your PC buttons===== | ||
+ | 1. Mount acpid.tcz | ||
+ | 2. Create files ''/ | ||
+ | |||
+ | 3. In ''/ | ||
+ | < | ||
+ | action=/ | ||
+ | </ | ||
+ | This code catches all events generated by acpid and passes them to gen.sh. | ||
+ | |||
+ | 4. In '' | ||
+ | < | ||
+ | case $1 in | ||
+ | button/ | ||
+ | | ||
+ | button/ | ||
+ | echo -n " | ||
+ | " | ||
+ | echo -n " | ||
+ | " | ||
+ | | ||
+ | # *) | ||
+ | # popup $1;; | ||
+ | esac</ | ||
+ | The 4 keys are computer specific and only given as examples. | ||
+ | |||
+ | 5. To discover your PC's key codes, uncomment the last 2 lines of code just before the esac statement. These lines will take each generated event code and popup a message with the key code. Write enough characters into the gen.sh script file from each key code to uniquely identify each key (don't take all as the last parts may change with each button press). The * wild card will accept the rest of the key code. If there are spaces in the key code, enclose it with double quote marks as shown. | ||
+ | |||
+ | 6. Assign actions for each key event as shown by the examples in the file. | ||
+ | |||
+ | 7. Backup the file / | ||
+ | |||
+ | 8. In / | ||
+ | < | ||
+ | This line starts acpid and loads the event file. The advantage of having the actions file gen.sh in / | ||
+ | |||
+ | 9. Reboot the pc to activate acpid. | ||
+ | |||
+ | Once you have everything you want, simply comment out the 2 lines of code before esac again. | ||
+ | |||
+ | For more sleep command options, see the suspend-utils.tcz extension and also the thread about it in tce 2.x news. | ||
+ | |||
+ | The above method is just one way to control buttons with acpid; there are many other ways of doing it; this way is convenient due to the ability to edit the actions file without having to re-initialise acpid each time. | ||
+ | |||
+ | Here is a full actions file that is used on a EeePC 1000HE: | ||
+ | < | ||
+ | case $1 in | ||
+ | button/ | ||
+ | exitcheck.sh shutdown;; | ||
+ | button/ | ||
+ | echo -n " | ||
+ | " | ||
+ | echo -n " | ||
+ | " | ||
+ | | ||
+ | " | ||
+ | xrandr --output VGA --auto --output LVDS --off;; | ||
+ | " | ||
+ | xrandr --output VGA --off --output LVDS --auto;; | ||
+ | " | ||
+ | xrandr --output VGA --auto --output LVDS --auto;; | ||
+ | " | ||
+ | " | ||
+ | if [[ -z `amixer cget numid=1 | grep " | ||
+ | then | ||
+ | amixer cset numid=1 on | ||
+ | else | ||
+ | amixer cset numid=1 off | ||
+ | fi | ||
+ | aplay / | ||
+ | " | ||
+ | | VOL=`amixer cget numid=2 | grep ": values=" | ||
+ | [[ $VOL -gt 3 ]] && amixer cset numid=2 `expr $VOL - 4`;; | ||
+ | " | ||
+ | | VOL=`amixer cget numid=2 | grep ": values=" | ||
+ | [[ $VOL -lt 61 ]] && amixer cset numid=2 `expr $VOL + 4`;; | ||
+ | " | ||
+ | xset dpms force off;; | ||
+ | " | ||
+ | / | ||
+ | *) | ||
+ | popup $1 & | ||
+ | sleep 1 | ||
+ | kill `pidof popup` &;; | ||
+ | esac | ||
+ | </ |