summaryrefslogtreecommitdiffstats
path: root/system/triggerhappy/rc.triggerhappy
blob: 5dd6f3ed50f790c8bea0a212a8323a04120bd095 (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
#!/bin/sh

# rc.triggerhappy, sysv-style init script for triggerhappy.
# part of the slackbuilds.org triggerhappy build.

# The daemon has to be started as root, but will drop privileges
# and run as this user after initialization:
THD_USER=nobody

THD_SOCKET=/var/run/thd.socket
THD_ARGS="--daemon --user $THD_USER --socket $THD_SOCKET --triggers /etc/triggerhappy/triggers.d/ /dev/input/event*"

case "$1" in
  ""|"start") if [ -e $THD_SOCKET ]; then
                echo "$0: $THD_SOCKET already exists (daemon running or stale socket?)"
                exit 1;
              fi
              echo "Starting triggerhappy daemon (thd)"
              /usr/sbin/thd $THD_ARGS ;;
  stop)       echo "Stopping triggerhappy daemon (thd)"
              /usr/sbin/th-cmd --socket $THD_SOCKET --quit
              /bin/rm -f $THD_SOCKET ;;
  restart)    $0 stop ; /bin/sleep 1; exec $0 start ;;
  *)          echo "Usage: $0 [stop|start|restart]"
              exit 1 ;;
esac

exit 0