Last active
September 1, 2022 02:58
-
-
Save rfht/475a53fb7552bb0de719d403677385a4 to your computer and use it in GitHub Desktop.
check OpenBSD lid status and reconfigure display/WM accordingly, using autorandr and fvwm2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# make sure the appropriate autorandr configurations exist | |
for a_status in docked docked_open; do | |
autorandr | egrep -q "^$a_status( .*)?$" || \ | |
{ echo "Error: no autorandr for $a_status"; exit 1; } | |
done | |
lid_status=$(sysctl -n hw.sensors.acpibtn0.indicator0 | cut -f1 -d' ') | |
if [ $lid_status = "On" ]; then # "On" = lid open | |
autorandr -l docked_open 2>&1 | grep -q '^Config already loaded$' && exit | |
elif [ $lid_status = "Off" ]; then # "Off" = lid closed | |
autorandr -l docked 2>&1 | grep -q '^Config already loaded$' && exit | |
else | |
echo "ERROR: invalid lid status"; exit 1 | |
fi | |
# Restart fvwm2 (needs Module FvwmCommandS in fvwm2) | |
/usr/local/bin/FvwmCommand Restart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment