summaryrefslogtreecommitdiff
path: root/repo/laptop-mode-tools/laptop-mode.initd
blob: eef819913cc682958fa27042b72dbdd07a2e5de5 (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
#!/sbin/openrc-run
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

extra_started_commands="reload"

depend() {
	need localmount
	use acpid hald
	after bootmisc
}

checkconfig() {
	if [ ! -f /proc/sys/vm/laptop_mode ] ; then
		eerror "Kernel does not support laptop_mode"
		return 1
	fi
}

start() {
	checkconfig || return 1

	ebegin "Starting laptop_mode"
	# bug #342049 fix
	# check if dir exists and creates if it doesn't
	checkpath -q -d -m 755 /var/run/laptop-mode-tools
	touch /var/run/laptop-mode-tools/enabled
	/usr/sbin/laptop_mode auto >/dev/null
	eend $?
}

stop() {
	ebegin "Stopping laptop_mode"
	rm -f /var/run/laptop-mode-tools/enabled
	/usr/sbin/laptop_mode stop >/dev/null
	eend $?
}

reload() {
	if ! service_started "${SVCNAME}" ; then
		eerror "${SVCNAME} has not yet been started"
		return 1
	fi

	ebegin "Reloading laptop_mode"
	/usr/sbin/laptop_mode stop >/dev/null
	rm -f /var/run/laptop-mode-tools/*
	/usr/sbin/laptop_mode auto force >/dev/null
	eend $?
}

# vim: set ts=4 :