Bug#918966: new(?) backlight brightness script
On Sat, 12 Jan 2019, Dmitry Bogatov wrote: > Sure. Your contribution would be welcome. I pushed it to a branch “tg-brightness” in the sysvinit packaging on Salsa. I decided to rework the init script, so it can even work on multiple backlight brightness knobs, and added the Intel one from my Thinkpad, keeping the ACPI one compatible. (Also, quite some shell scripting cleanup. As developer of a shell, I know what I’m doing there ☺) bye, //mirabilos -- tarent solutions GmbH Rochusstraße 2-4, D-53123 Bonn • http://www.tarent.de/ Tel: +49 228 54881-393 • Fax: +49 228 54881-235 HRB 5168 (AG Bonn) • USt-ID (VAT): DE122264941 Geschäftsführer: Dr. Stefan Barth, Kai Ebenrett, Boris Esser, Alexander Steeg
Bug#918966: new(?) backlight brightness script
[2019-01-17 21:13] Thorsten Glaser > On Sat, 12 Jan 2019, Dmitry Bogatov wrote: > > > Sure. Your contribution would be welcome. > > I pushed it to a branch “tg-brightness” in the sysvinit > packaging on Salsa. Next time, wip/ namespace is preferred. It makes it clear, that force-push are to be expected. > I decided to rework the init script, so it can even work > on multiple backlight brightness knobs, and added the > Intel one from my Thinkpad, keeping the ACPI one compatible. Thank you. But I have some considerations: * If no knob is found, all actions are silent. I believe some log_success_msg "brighntess not found" would be nice. * You merge 'start' and 'restart' action. Restart, by definition, is stop->start. * You did not declare MSG `local'. Why? * `local' is not mandated by POSIX. Does all posix-like shells in Debian support it? * In most cases, initscripts use '[ "${VERBOSE}" != no ]' snippet. Could you please convert to this style? * I believe, that "x$foo" is unnecessary. "$foo" expands to "" if $foo is empty.
Bug#918966: new(?) backlight brightness script
On Sun, 13 Jan 2019, Josh Triplett wrote: > This isn't a purely "desktop" feature. In the past, some systems have > booted up with the backlight *off*, making the screen all but invisible, In the current, too: #890326 bye, //mirabilos -- tarent solutions GmbH Rochusstraße 2-4, D-53123 Bonn • http://www.tarent.de/ Tel: +49 228 54881-393 • Fax: +49 228 54881-235 HRB 5168 (AG Bonn) • USt-ID (VAT): DE122264941 Geschäftsführer: Dr. Stefan Barth, Kai Ebenrett, Boris Esser, Alexander Steeg
Bug#918966: new(?) backlight brightness script
On Fri, 11 Jan 2019 07:41:27 +0200 Aleksi Suhonen wrote: > After upgrading and rebooting a virtual machine that has only a virtual > serial console, I get this message: > > /etc/init.d/brightness: 36: /etc/init.d/brightness: cannot create > /sys/class/backlight/acpi_video0/brightness: Directory nonexistent > > It's not critical, but I'm wondering if desktop features could be > separated from this package. Or if there was a debconf knob to turn them > all on and off easily? This isn't a purely "desktop" feature. In the past, some systems have booted up with the backlight *off*, making the screen all but invisible, and this script helps avoid that.
Bug#918966: new(?) backlight brightness script
[2019-01-11 07:41] Aleksi Suhonen > part text/plain 828 > Package: initscripts > Severity: wishlist > Version: 2.93-3 > > After upgrading and rebooting a virtual machine that has only a virtual > serial console, I get this message: > > /etc/init.d/brightness: 36: /etc/init.d/brightness: cannot create > /sys/class/backlight/acpi_video0/brightness: Directory nonexistent > It's not critical, but I'm wondering if desktop features could be > separated from this package. Or if there was a debconf knob to turn them > all on and off easily? I understand your concern about desktop feature, but since it quite simple shell script, I believe, there is no better place for it. If you have idea, where `brightness' script suits better to, you are welcome! > Also, the error message could be avoided with some more checking: > > if [ -d /sys/class/backlight/acpi_video0 ]; then > readonly SYS_CONTROL=/sys/class/backlight/acpi_video0/brightness > readonly SYS_MAXIMUM=/sys/class/backlight/acpi_video0/max_brightness > else > readonly SYS_CONTROL=/dev/null > readonly SYS_MAXIMUM=/dev/null > fi I like this approach the best. Here is pending patch. Feedback is welcome, in wording in particular. From 97e33ff24c857bf20f6d73a2d75c2d200acd0693 Mon Sep 17 00:00:00 2001 From: Dmitry Bogatov Date: Fri, 11 Jan 2019 13:31:21 + Subject: [PATCH] Check in `brightness' initscript for backlight presence Check for presence of backlight-related virtual files in `brightness' initscript before trying to set values in them, since they can be missing on systems with only a serial console. (Closes: #918966) --- debian/changelog | 2 ++ debian/src/initscripts/etc/init.d/brightness | 9 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index a8336299..db5b0443 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,6 +3,8 @@ sysvinit (2.93-4) UNRELEASED; urgency=medium * Drop unneeded `40_multiarch_libcrypt.patch': upstream Makefile correctly supplies -lcrypt flag by itself. * Make debian/upstream/signing-key.asc minimal + * Check for presence of backlight-related virtual files in `brightness' +initscript (Closes: #918966) -- Dmitry Bogatov Thu, 10 Jan 2019 19:45:28 + diff --git a/debian/src/initscripts/etc/init.d/brightness b/debian/src/initscripts/etc/init.d/brightness index 3e22bff8..93c1cb8a 100755 --- a/debian/src/initscripts/etc/init.d/brightness +++ b/debian/src/initscripts/etc/init.d/brightness @@ -9,13 +9,18 @@ # Description: This script saves the brightness level between restarts. #It is called from the boot, halt and reboot scripts. ### END INIT INFO +. /lib/init/vars.sh +. /lib/lsb/init-functions + readonly SAVEDFILE=/var/lib/initscripts/brightness readonly DEFAULT_LEVEL=4 readonly SYS_CONTROL=/sys/class/backlight/acpi_video0/brightness readonly SYS_MAXIMUM=/sys/class/backlight/acpi_video0/max_brightness -. /lib/init/vars.sh -. /lib/lsb/init-functions +if ! test -f "${SYS_CONTROL}" ; then + log_success_msg "Brightness control not supported: no backlight" + exit 0 +fi do_status () { MSG="Current brightness level is $(cat ${SYS_CONTROL})"
Bug#918966: new(?) backlight brightness script
[2019-01-11 08:40] Thorsten Glaser > On Fri, 11 Jan 2019, Aleksi Suhonen wrote: > > > if [ -d /sys/class/backlight/acpi_video0 ]; then > > readonly SYS_CONTROL=/sys/class/backlight/acpi_video0/brightness > > readonly SYS_MAXIMUM=/sys/class/backlight/acpi_video0/max_brightness > > else > > readonly SYS_CONTROL=/dev/null > > readonly SYS_MAXIMUM=/dev/null > > fi > > My Thinkpad has yet different paths, but I don't have them > at hand right now. Will have to dig them out from /etc/rc.local > when I have it again (it's at work and I'm not). Sure. Your contribution would be welcome.
Bug#918966: new(?) backlight brightness script
On Fri, 11 Jan 2019, Aleksi Suhonen wrote: > if [ -d /sys/class/backlight/acpi_video0 ]; then > readonly SYS_CONTROL=/sys/class/backlight/acpi_video0/brightness > readonly SYS_MAXIMUM=/sys/class/backlight/acpi_video0/max_brightness > else > readonly SYS_CONTROL=/dev/null > readonly SYS_MAXIMUM=/dev/null > fi My Thinkpad has yet different paths, but I don't have them at hand right now. Will have to dig them out from /etc/rc.local when I have it again (it's at work and I'm not). bye, //mirabilos -- tarent solutions GmbH Rochusstraße 2-4, D-53123 Bonn • http://www.tarent.de/ Tel: +49 228 54881-393 • Fax: +49 228 54881-235 HRB 5168 (AG Bonn) • USt-ID (VAT): DE122264941 Geschäftsführer: Dr. Stefan Barth, Kai Ebenrett, Boris Esser, Alexander Steeg
Bug#918966: new(?) backlight brightness script
Package: initscripts Severity: wishlist Version: 2.93-3 After upgrading and rebooting a virtual machine that has only a virtual serial console, I get this message: /etc/init.d/brightness: 36: /etc/init.d/brightness: cannot create /sys/class/backlight/acpi_video0/brightness: Directory nonexistent It's not critical, but I'm wondering if desktop features could be separated from this package. Or if there was a debconf knob to turn them all on and off easily? Also, the error message could be avoided with some more checking: if [ -d /sys/class/backlight/acpi_video0 ]; then readonly SYS_CONTROL=/sys/class/backlight/acpi_video0/brightness readonly SYS_MAXIMUM=/sys/class/backlight/acpi_video0/max_brightness else readonly SYS_CONTROL=/dev/null readonly SYS_MAXIMUM=/dev/null fi Best Regards, -- Aleksi Suhonen