Add example hotkey_button script

This commit is contained in:
jmcneill 2007-12-22 19:04:10 +00:00
parent 941ceb8768
commit 1247e31569
4 changed files with 36 additions and 4 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: mi,v 1.196 2007/11/12 15:02:58 jmmv Exp $
# $NetBSD: mi,v 1.197 2007/12/22 19:04:10 jmcneill Exp $
#
# Note: end-user configuration files that are moved to another location
# should not be marked "obsolete"; they should just be removed from
@ -135,6 +135,7 @@
./etc/postfix/postfix-script etc-postfix-etc postfix
./etc/postinstall etc-obsolete obsolete
./etc/powerd/scripts/acadapter etc-sysutil-etc
./etc/powerd/scripts/hotkey_button etc-sysutil-etc
./etc/powerd/scripts/lid_switch etc-sysutil-etc
./etc/powerd/scripts/power_button etc-sysutil-etc
./etc/powerd/scripts/reset_button etc-sysutil-etc

View File

@ -1,4 +1,4 @@
# $NetBSD: special,v 1.115 2007/07/14 21:20:33 ad Exp $
# $NetBSD: special,v 1.116 2007/12/22 19:04:10 jmcneill Exp $
# @(#)special 8.2 (Berkeley) 1/23/94
#
# This file may be overwritten on upgrades.
@ -149,6 +149,7 @@
./etc/powerd type=dir mode=0755 optional
./etc/powerd/scripts type=dir mode=0755 optional
./etc/powerd/scripts/acadapter type=file mode=0555 optional
./etc/powerd/scripts/hotkey_button type=file mode=0555 optional
./etc/powerd/scripts/lid_switch type=file mode=0555 optional
./etc/powerd/scripts/power_button type=file mode=0555 optional
./etc/powerd/scripts/reset_button type=file mode=0555 optional

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.7 2007/07/02 15:26:18 xtraeme Exp $
# $NetBSD: Makefile,v 1.8 2007/12/22 19:04:11 jmcneill Exp $
.include <bsd.own.mk>
@ -6,7 +6,8 @@
# src/etc/mtree/special
# src/distrib/sets/lists/etc/mi
CONFIGFILES= acadapter lid_switch power_button reset_button sleep_button
CONFIGFILES= acadapter hotkey_button lid_switch power_button
CONFIGFILES+= reset_button sleep_button
CONFIGFILES+= sensor_battery sensor_drive sensor_fan sensor_indicator
CONFIGFILES+= sensor_power sensor_resistance sensor_temperature
CONFIGFILES+= sensor_voltage

View File

@ -0,0 +1,29 @@
#!/bin/sh -
#
# $NetBSD: hotkey_button,v 1.1 2007/12/22 19:04:11 jmcneill Exp $
#
# Generic script for hotkey events.
#
# Arguments passed by powerd(8):
#
# hotkey event
PATH=/usr/pkg/bin:$PATH; export PATH
# XXXJDM need a better way to determine this
XUSER="$(ls -l /dev/console | awk '{ print $3; }')"
DISPLAY=:0.0; export DISPLAY
case "${2}" in
pressed)
if [ -f "/etc/powerd/actions/${1}" ]; then
sudo -u "$XUSER" -i "/etc/powerd/actions/${1}"
fi
exit 0
;;
released)
;;
*)
logger -p warning "${0}: unsupported event ${2} on device ${1}" >&1
exit 1
esac