summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorB. Stack <bgstack15@gmail.com>2024-04-30 17:07:32 -0400
committerB. Stack <bgstack15@gmail.com>2024-04-30 17:07:32 -0400
commitda13d05a83432f2c0c453d19e6b602b9e6bad610 (patch)
tree83e435c8b92dc03e5573d7167d3ecacc702bbc0c /src
parentdeb should be ready now (diff)
downloadstackrpms-acer-chromebook-da13d05a83432f2c0c453d19e6b602b9e6bad610.tar.gz
stackrpms-acer-chromebook-da13d05a83432f2c0c453d19e6b602b9e6bad610.tar.bz2
stackrpms-acer-chromebook-da13d05a83432f2c0c453d19e6b602b9e6bad610.zip
add disable-powerbutton daemon and tools
Diffstat (limited to 'src')
-rw-r--r--src/Makefile4
-rw-r--r--src/etc/stackrpms-acer-chromebook/fluxbox.keys2
-rw-r--r--src/etc/stackrpms-acer-chromebook/fluxbox.startup25
-rw-r--r--src/etc/sysconfig/disable-powerbutton8
-rwxr-xr-xsrc/usr/bin/disable-powerbutton-daemon34
-rwxr-xr-xsrc/usr/libexec/stackrpms-acer-chromebook/disable-powerbutton-loop23
6 files changed, 82 insertions, 14 deletions
diff --git a/src/Makefile b/src/Makefile
index ef6a8fc..065349e 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -6,6 +6,7 @@
# Purpose: To use traditional Unix make utility
# History:
# 2022-11-04 forked from bgscripts Makefile
+# 2024-04-30 improved sysconfig discovery
# Usage:
# Reference:
# bgscripts Makefile
@@ -84,12 +85,13 @@ deplist_opts:
@${grepbin} -h -o -riIE '\<(dep|rec|sug)-[^\ :]+:' ${SRCDIR} | ${sedbin} -r -e 's/(dep|rec|sug)-//;' -e 's/:$$//;' | ${sortbin} | ${uniqbin} 1>&2
install_files:
+ @# install_files updated the sysconfig test -f
@ls usr/share/man/man*/*gz 1>/dev/null 2>&1 && echo "Including man pages." || :
@${echobin} Installing files to ${DESTDIR}
for td in $$( ${findbin} ${SRCDIR} -type d ! -name '.*.swp' ! -name 'Makefile' -printf '%P\n' | ${sedbin} -r -e "s:etc/sysconfig:${DEFAULTDIR}:" -e "s:${DESTDIR}/?::" ) ; do ${installbin} -m0755 -d ${DESTDIR}/$${td} ; done
for tf in $$( ${findbin} ${SRCDIR} ! -type d ! -name '.*.swp' ! -name 'Makefile' ! \( -path '*/man/*' -name '*.txt' \) ! -path '*/sysconfig/*' -printf '%P\n' ) ; do MODE=0644 ; echo "$${tf}" | grep -qE "(bin|libexec|deprecated)/" && MODE=0755 ; ${installbin} -m$${MODE} ${SRCDIR}/$${tf} ${DESTDIR}/$${tf} ; done
@# sysconfig/default dir
- test -f "$( echo ${SRCDIR}/etc/sysconfig/* 2>/dev/null | head -n1 )" && { ${installbin} -m0644 -t ${DEFAULTDIR} ${SRCDIR}/etc/sysconfig/* ; } || :
+ ${findbin} ${SRCDIR}/etc/sysconfig/* -maxdepth 0 -quit 1>/dev/null 2>&1 && { ${installbin} -m0644 -t ${DEFAULTDIR} ${SRCDIR}/etc/sysconfig/* ; } || :
MAN_TXT:=$(wildcard usr/share/man/man*/*.txt)
MAN_GZ:= $(subst .txt,.gz,$(MAN_TXT))
diff --git a/src/etc/stackrpms-acer-chromebook/fluxbox.keys b/src/etc/stackrpms-acer-chromebook/fluxbox.keys
index 96865cd..06aa158 100644
--- a/src/etc/stackrpms-acer-chromebook/fluxbox.keys
+++ b/src/etc/stackrpms-acer-chromebook/fluxbox.keys
@@ -201,5 +201,5 @@ Mod4 Mod1 80 :MacroCmd {ResizeTo 34% 33%} {MoveTo 33% 00% Up}
Mod4 Mod1 81 :MacroCmd {ResizeTo 33% 33%} {MoveTo 67% 00% Up}
# Acer Chromebook C720 keys, React to power key
-# The ability to use this depends on elogind-inhibit!
+# The ability to use this depends on disable-powerbutton-daemon (elogind-inhibit)
124 :Exec logout-manager-gtk
diff --git a/src/etc/stackrpms-acer-chromebook/fluxbox.startup b/src/etc/stackrpms-acer-chromebook/fluxbox.startup
index ef8cd5a..2b1d644 100644
--- a/src/etc/stackrpms-acer-chromebook/fluxbox.startup
+++ b/src/etc/stackrpms-acer-chromebook/fluxbox.startup
@@ -1,35 +1,36 @@
#!/bin/sh
-# File: /etc/stackrpms-acer-chromebook/fluxbox.startup
-# Location: stackrpms-acer-chromebook package
+# File: /etc/stackrpms-thinkpad-p50s/fluxbox.startup
+# Location: stackrpms-thinkpad-p50s package
# Author: bgstack15
# Startdate: 2019-12-26
# SPDX-License-Identifier: GPL-3.0
# Title: Common fluxbox startup file for Thinkpad P50s platform
-# Package: stackrpms-acer-chromebook
+# Package: stackrpms-thinkpad-p50s
# Purpose: standardize fluxbox config across systems
# History:
# 2019-12-26 started on ltb-018 from fluxbox startup example
# 2022-11-03 adapted for this package
# 2023-12-12 revised to be consistent across bgconf and stackrpms-thinkpad-p50s
-# 2024-04-30 adapted for acer chromebook package
+# 2024-04-30 update disable-powerbutton-daemon, copyq, centralized xmodmap
# Usage:
# symlink your ~/.fluxbox/startup to this file with:
-# ln -sf /etc/stackrpms-acer-chromebook/fluxbox.startup ~/.fluxbox/startup
+# ln -sf /etc/stackrpms-thinkpad-p50s/fluxbox.startup ~/.fluxbox/startup
# Reference:
# ltb-018:~/.fluxbox/startup
# Improve:
# Documentation:
-# last modified: 2022-11-03-5 14:28
+# last modified: 2024-04-30-3 17:06
# Change your keymap:
-test -f /etc/stackrpms-acer-chromebook/Xmodmap && xmodmap /etc/stackrpms-acer-chromebook/Xmodmap
-test -f .Xmodmap && xmodmap ".Xmodmap"
+find /etc/stackrpms-*/Xmodmap .Xmodmap -maxdepth 0 -exec xmodmap {} \; 2>&1 | grep -vE '\*\/Xmodmap.: No such' || :
echo "${PATH}" | grep -q "${HOME}/bin" 1>/dev/null 2>&1 && export PATH="${HOME}/bin:${PATH}"
+# If present, suppress power button immediate shutdown, e.g., on a Chromebook
+disable-powerbutton-daemon &
+
# for vlc on hidpi screens
-export QT_AUTO_SCREEN_SCALE_FACTOR=0
-export QT_SCREEN_SCALE_FACTORS=1
+export QT_AUTO_SCREEN_SCALE_FACTOR=0 QT_SCREEN_SCALE_FACTORS=1
# Applications you want to run with fluxbox.
which fbautostart > /dev/null
@@ -41,8 +42,8 @@ fi
spacefm --desktop &
start-pulseaudio-x11 &
-volumeicon &
-copyq &
+volumeicon &
+( sleep 8 ; copyq ; ) &
xscreensaver -nosplash &
# This might be redundant if /usr/share/services/com.example.Notifications.service but will not hurt.
/usr/lib/notification-daemon/notification-daemon &
diff --git a/src/etc/sysconfig/disable-powerbutton b/src/etc/sysconfig/disable-powerbutton
new file mode 100644
index 0000000..34c1fc3
--- /dev/null
+++ b/src/etc/sysconfig/disable-powerbutton
@@ -0,0 +1,8 @@
+# Config file for disable-powerbutton-daemon
+# Running that program is designed to suppress the default behavior of the power button which is to shut down immediately.
+# DP_WHAT Which elogind-inhibit behaviors to control.
+DP_WHAT="shutdown:sleep:idle:handle-power-key:handle-suspend-key:handle-hibernate-key:handle-lid-switch"
+# DP_COMMAND which program to run, and when this program ends, the inhibition ends.
+DP_COMMAND="/usr/libexec/stackrpms-acer-chromebook/disable-powerbutton-loop"
+# When this file exists at the end of a sleep loop, the loop ends and therefore the inhibition ends.
+DP_SAFETY_FILE=/tmp/stop-disable-powerbutton
diff --git a/src/usr/bin/disable-powerbutton-daemon b/src/usr/bin/disable-powerbutton-daemon
new file mode 100755
index 0000000..cde67c7
--- /dev/null
+++ b/src/usr/bin/disable-powerbutton-daemon
@@ -0,0 +1,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}"
diff --git a/src/usr/libexec/stackrpms-acer-chromebook/disable-powerbutton-loop b/src/usr/libexec/stackrpms-acer-chromebook/disable-powerbutton-loop
new file mode 100755
index 0000000..9bdc4cb
--- /dev/null
+++ b/src/usr/libexec/stackrpms-acer-chromebook/disable-powerbutton-loop
@@ -0,0 +1,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
bgstack15