summaryrefslogtreecommitdiff
path: root/etc/powerd/scripts/hotkey_button
blob: d835bd23c06362f7d9eed217c25cf49587e3c41b (plain)
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
#!/bin/sh -
#
#	$NetBSD: hotkey_button,v 1.2 2008/01/17 00:37:46 christos 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
		/usr/bin/su -- "$XUSER" -c "/etc/powerd/actions/${1}"
	fi
	exit 0
	;;
released)
	;;
*)
	logger -p warning "${0}: unsupported event ${2} on device ${1}" >&1
	exit 1
esac