1 |
commit: 1603b35ea5891df11790292d16bc4104f53058a8 |
2 |
Author: Dave Kennedy <dave-kennedy <AT> outlook <DOT> com> |
3 |
AuthorDate: Thu Apr 27 02:55:49 2017 +0000 |
4 |
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> |
5 |
CommitDate: Sat Aug 5 07:30:04 2017 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1603b35e |
7 |
|
8 |
sys-power/acpilight: add init script |
9 |
|
10 |
Adding acpilight init script to the default runlevel will enable saving |
11 |
and restoring the backlight state on shutdown and startup |
12 |
|
13 |
Closes: https://github.com/gentoo/gentoo/pull/4521 |
14 |
|
15 |
sys-power/acpilight/acpilight-1.0-r1.ebuild | 46 +++++++++++++++++++++++++++++ |
16 |
sys-power/acpilight/files/acpilight.confd | 13 ++++++++ |
17 |
sys-power/acpilight/files/acpilight.initd | 41 +++++++++++++++++++++++++ |
18 |
3 files changed, 100 insertions(+) |
19 |
|
20 |
diff --git a/sys-power/acpilight/acpilight-1.0-r1.ebuild b/sys-power/acpilight/acpilight-1.0-r1.ebuild |
21 |
new file mode 100644 |
22 |
index 00000000000..8d128ac7d5f |
23 |
--- /dev/null |
24 |
+++ b/sys-power/acpilight/acpilight-1.0-r1.ebuild |
25 |
@@ -0,0 +1,46 @@ |
26 |
+# Copyright 1999-2017 Gentoo Foundation |
27 |
+# Distributed under the terms of the GNU General Public License v2 |
28 |
+ |
29 |
+EAPI=6 |
30 |
+ |
31 |
+PYTHON_COMPAT=( python2_7 python3_4 python3_5 ) |
32 |
+ |
33 |
+inherit python-r1 udev |
34 |
+ |
35 |
+DESCRIPTION="Replacement for xbacklight that uses the ACPI interface to set brightness" |
36 |
+HOMEPAGE="https://github.com/wavexx/acpilight/" |
37 |
+SRC_URI="https://github.com/wavexx/acpilight/archive/v${PV}.tar.gz -> ${P}.tar.gz" |
38 |
+LICENSE="GPL-3+" |
39 |
+SLOT="0" |
40 |
+KEYWORDS="~amd64 ~x86" |
41 |
+IUSE="" |
42 |
+ |
43 |
+RDEPEND="virtual/udev |
44 |
+ ${PYTHON_DEPS} |
45 |
+ !x11-apps/xbacklight" |
46 |
+REQUIRED_USE="${PYTHON_REQUIRED_USE}" |
47 |
+DOCS=( README.rst ) |
48 |
+ |
49 |
+src_install() { |
50 |
+ python_foreach_impl python_doscript xbacklight |
51 |
+ udev_dorules "${S}"/90-backlight.rules |
52 |
+ doman xbacklight.1 |
53 |
+ einstalldocs |
54 |
+ newinitd "${FILESDIR}"/acpilight.initd acpilight |
55 |
+ newconfd "${FILESDIR}"/acpilight.confd acpilight |
56 |
+} |
57 |
+ |
58 |
+pkg_postinst() { |
59 |
+ udev_reload |
60 |
+ einfo |
61 |
+ elog "To use the xbacklight binary as a regular user, you must be a part of the video group" |
62 |
+ einfo |
63 |
+ elog "If this utility does not find any backlights to manipulate," |
64 |
+ elog "verify you have kernel support on the device and display driver enabled." |
65 |
+ einfo |
66 |
+ elog "To take advantage of the init script, and automate the process of" |
67 |
+ elog "saving and restoring the brightness level you should add acpilight" |
68 |
+ elog "to the boot runlevel. You can do this as root like so:" |
69 |
+ elog "# rc-update add acpilight boot" |
70 |
+ einfo |
71 |
+} |
72 |
|
73 |
diff --git a/sys-power/acpilight/files/acpilight.confd b/sys-power/acpilight/files/acpilight.confd |
74 |
new file mode 100644 |
75 |
index 00000000000..ecb74eb7209 |
76 |
--- /dev/null |
77 |
+++ b/sys-power/acpilight/files/acpilight.confd |
78 |
@@ -0,0 +1,13 @@ |
79 |
+# RESTORE_ON_START: |
80 |
+# Restore brightness level when acpilight starts |
81 |
+# no - Do not restore state |
82 |
+# yes - Restore state |
83 |
+ |
84 |
+RESTORE_ON_START="yes" |
85 |
+ |
86 |
+# SAVE_ON_STOP: |
87 |
+# Save brightness level when acpilight stops |
88 |
+# no - Do not save state |
89 |
+# yes - Save state |
90 |
+ |
91 |
+SAVE_ON_STOP="yes" |
92 |
|
93 |
diff --git a/sys-power/acpilight/files/acpilight.initd b/sys-power/acpilight/files/acpilight.initd |
94 |
new file mode 100644 |
95 |
index 00000000000..0de6029867e |
96 |
--- /dev/null |
97 |
+++ b/sys-power/acpilight/files/acpilight.initd |
98 |
@@ -0,0 +1,41 @@ |
99 |
+#!/sbin/openrc-run |
100 |
+# Copyright 1999-2017 Gentoo Foundation |
101 |
+# Distributed under the terms of the GNU General Public License v2 |
102 |
+ |
103 |
+state_dir=/var/lib/acpilight |
104 |
+ |
105 |
+extra_commands="save restore" |
106 |
+ |
107 |
+depend() { |
108 |
+ need localmount |
109 |
+ after bootmisc modules isapnp coldplug hotplug |
110 |
+} |
111 |
+ |
112 |
+restore() { |
113 |
+ ebegin "Restoring brightness level" |
114 |
+ if [ ! -r "${state_dir}/state" ] ; then |
115 |
+ ewarn "No brightness level in ${state_dir}/state" |
116 |
+ eend 0 |
117 |
+ return 0 |
118 |
+ fi |
119 |
+ xbacklight "$(cat "${state_dir}/state")" |
120 |
+ eend $? |
121 |
+} |
122 |
+ |
123 |
+save() { |
124 |
+ ebegin "Saving brightness level" |
125 |
+ mkdir -p "${state_dir}" && xbacklight -get > "${state_dir}/state" |
126 |
+ eend $? |
127 |
+} |
128 |
+ |
129 |
+start() { |
130 |
+ if [ "${RESTORE_ON_START}" = "yes" ]; then |
131 |
+ restore |
132 |
+ fi |
133 |
+} |
134 |
+ |
135 |
+stop() { |
136 |
+ if [ "${SAVE_ON_STOP}" = "yes" ]; then |
137 |
+ save |
138 |
+ fi |
139 |
+} |