Knowledge Base

Preserving for the future: Shell scripts, AoC, and more

New package for Devuan: stackrpms-acer-chromebook

I picked up a really old Acer Chromebook, and wanted to make sure my customizations are repeatable. Also, I needed to prove I can control the power button.

So, go download package stackrpms-acer-chromebook now! And of course, the source code is right nearby.

The fluxbox templates react to the keystroke for the power button. Also, I mapped the brightness and volume keys to CTRL+SHIFT, so I can still use the regular F6-F10 functionality.

To disable the default listening behavior of the power button and lid switch, I learned about elogind-inhibit, and I wrote a small program to use it. Just call this from the provided fluxbox/startup file (in /etc/stackrpms-acer-chromebook).

files/2024/listings/disable-powerbutton-daemon (Source)

 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
#!/bin/sh
# File: /usr/bin/disable-powerbutton-daemon
# Location: stackrpms-acer-chromebook package
# Author: bgstack15
# SPDX-License-Identifier: GPL-3.0
# Startdate: 2024-04-29-2 20:22
# Title: Power Button Suppressor Daemon
# Project: disable-powerbutton
# Purpose: Runs elogind-inhibit so we can use the power button to run logout-manager
# History:
# Usage:
#   In ~/.fluxbox/startup:   disable-powerbutton-daemon &
#   Which enables this behavior to work:
#      In ~/.fluxbox/keys:   124 :Exec logout-manager-gtk
# Reference:
#    Enlightenment desktop, man elogind-inhibit
# Related:
#    /usr/libexec/stackrpms-acer-chromebook/disable-powerbutton-loop
#    /etc/stackrpms-acer-chromebook/fluxbox.keys
#    /etc/stackrpms-acer-chromebook/fluxbox.startup
#    /etc/default/disable-powerbutton
# Improve:
# Dependencies:
#    dep-devuan: logout-manager, elogind
# Documentation:
#    To run this manually:
#    elogind-inhibit --what shutdown:handle-suspend-key:handle-hibernate-key:handle-lid-switch:idle:sleep --who "stackrpms5" --why "i hate the power button" --mode=block '/bin/forever.sh'
DAEMON_NAME="disable-powerbutton"
test -f "/etc/default/${DAEMON_NAME}" && . "/etc/default/${DAEMON_NAME}"
test -f "/etc/sysconfig/${DAEMON_NAME}" && . "/etc/sysconfig/${DAEMON_NAME}"
test -z "${DP_WHAT}" && DP_WHAT="shutdown:sleep:idle:handle-power-key:handle-suspend-key:handle-hibernate-key:handle-lid-switch"
test -z "${DP_COMMAND}" && DP_COMMAND="/usr/libexec/stackrpms-acer-chromebook/disable-powerbutton-loop"
export DP_SAFETY_FILE
elogind-inhibit --what "${DP_WHAT}"--who "disable-powerbutton-daemon" --why "Let power button call logout-manager" --mode=block "${DP_COMMAND}"

That can use /etc/default/disable-powerbutton or not, because the included defaults are good enough.

It runs an infinite loop script:

files/2024/listings/disable-powerbutton-loop (Source)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/sh
# File: /usr/libexec/stackrpms-acer-chromebook/disable-powerbutton-loop
# Location: stackrpms-acer-chromebook package
# Author: bgstack15
# Startdate: 2024-04-29-2 19:56
# Title: Sleep forever
# Project: disable-powerbutton
# Purpose: Sleep forever until a safety file exists
# History:
# Usage:
#    called by disable-powerbutton-daemon
# Reference:
# Related:
#    /usr/bin/disable-powerbutton-daemon
# Improve:
#    Probably should be a very small inotify loop
# Dependencies:
# Documentation:
test -z "${DP_SAFETY_FILE}" && DP_SAFETY_FILE=/tmp/stop-disable-powerbutton
while test ! -f "${DP_SAFETY_FILE}" ;
do
   sleep 900
done

Comments