summaryrefslogtreecommitdiff
path: root/sysutils/asusoled/files/asusoled.in
blob: 690bd5743bdeb8ea8ae974de06f03dccfd41cbe3 (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
52
#!/bin/sh

# PROVIDE: asusoled
# REQUIRE: DAEMON
# KEYWORD: nojail shutdown
#
# Add the following lines to /etc/rc.conf to enable the ASUS OLED display:
#
# asusoled_enable="YES"
#

asusoled_enable=${asusoled_enable-"NO"}
asusoled_flags=${asusoled_flags-"-f %%PREFIX%%/share/asusoled/asus.png"}
asusoled_command=${asusoled_command-""}

. /etc/rc.subr

name=asusoled
rcvar=asusoled_enable

start_cmd=asusoled_start
stop_cmd=asusoled_stop

asusoled_bin="%%PREFIX%%/sbin/asusoled"
asusoled_pidfile="/var/run/${name}.pid"

asusoled_start() {
    if checkyesno asusoled_enable
    then
	echo "Starting asusoled."
	${asusoled_bin} -e || exit 1
	if test ! -z "${asusoled_command}"
	then
	    ${asusoled_bin} ${asusoled_flags} -c "${asusoled_command}"
	else
	    ${asusoled_bin} ${asusoled_flags}
	fi
    fi
}

asusoled_stop() {
    if checkyesno asusoled_enable
    then
	echo "Stopping asusoled."
	test -f ${asusoled_pidfile} &&
	    ${asusoled_bin} -k -p ${asusoled_pidfile}
	${asusoled_bin} -d
    fi
}

load_rc_config ${name}
run_rc_command "$1"