Automatically toggle sleep on screen close when active monitor changed

This commit is contained in:
Jake Bauer 2024-08-05 17:37:11 +02:00
parent 4d6f939554
commit cd723f98cb
1 changed files with 2 additions and 0 deletions

View File

@ -11,12 +11,14 @@ while true; do
if [ "$(xrandr --nograb --current | grep '^DP-1 connected')" ]; then
echo "Display Switcher: switching to external display"
active_display="external"
doas sysctl machdep.lidaction=0
xrandr --output DP-1 --auto --dpi 224 --output eDP-1 --off
fi
else
if [ "$(xrandr --nograb --current | grep '^DP-1 disconnected')" ]; then
echo "Display Switcher: switching to internal display"
active_display="internal"
doas sysctl machdep.lidaction=1
xrandr --output eDP-1 --auto --dpi 176 --output DP-1 --off
fi
fi