summaryrefslogtreecommitdiff
path: root/community/esekeyd/esekeyd.rc
blob: 67dd42265cac8111b2c10c31c3ac4fcb4edbe733 (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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/sh
#
# Start/stop/restart the key daemon.
. /etc/rc.conf
. /etc/rc.d/functions

keystune(){
  for keycode in "${KEYCODES[@]}"; do
    key=`echo $keycode | cut -d:  -f1`
    code=`echo $keycode | cut -d: -f2`
		setkeycodes $key $code
  done
}

# source application-specific settings
CONFIG=
KEYCODES=
DEVICE=
[ -f /etc/conf.d/esekeyd ] && . /etc/conf.d/esekeyd

PID=`pidof -o %PPID /usr/sbin/esekeyd`
case "$1" in
  start)
    stat_busy "Starting esekeyd"
		[ "$KEYCODES" ] && keystune
    [ -z "$PID" ] && /usr/sbin/esekeyd $CONFIG $DEVICE &>/dev/null
    if [ $? -gt 0 ]; then
      stat_fail
    else
      add_daemon esekeyd
      stat_done
    fi
    ;;
  stop)
    stat_busy "Stopping esekeyd"
    [ ! -z "$PID" ]  && kill $PID &> /dev/null
    if [ $? -gt 0 ]; then
      stat_fail
    else
      rm_daemon esekeyd
      stat_done
    fi
    ;;
  restart)
    $0 stop
    $0 start
    ;;
  *)
    echo "usage: $0 {start|stop|restart}"  
esac
exit 0