summaryrefslogtreecommitdiff
path: root/debian/.local/bin/setmonitor
diff options
context:
space:
mode:
authorTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2025-12-24 13:54:03 +0900
committerTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2025-12-24 13:54:03 +0900
commit28e8bdf7f8286bd431b7f3b709e79f3827b31469 (patch)
tree85b44eff6da4d8443198fb6e04dfb6ee55244588 /debian/.local/bin/setmonitor
parent8470ff001befcfd0f626dea69a9e76d43aee0511 (diff)
updates
Diffstat (limited to 'debian/.local/bin/setmonitor')
-rwxr-xr-xdebian/.local/bin/setmonitor35
1 files changed, 35 insertions, 0 deletions
diff --git a/debian/.local/bin/setmonitor b/debian/.local/bin/setmonitor
new file mode 100755
index 0000000..8ed4589
--- /dev/null
+++ b/debian/.local/bin/setmonitor
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+# Parse connected displays
+default="--mode 1920x1080 --rotate normal --scale 1.0x1.0 --dpi 96"
+
+for connected in $(xrandr -q | grep -w "connected" | cut -d ' ' -f 1); do
+ case $connected in
+ eDP*) edp="$connected" ;;
+ HDMI*) hdmi="$connected" ;;
+ DP*) dp="$connected" ;;
+ *) display="$connected" ;;
+ esac
+done
+
+# If the lid is closed, turn off the laptop's screen
+if grep -q "closed" /proc/acpi/button/lid/LID/state; then
+ if [ -n "$hdmi" ] && [ -z "$dp" ] && [ -n "$edp" ]; then
+ xrandr --output "$edp" --off --output "$hdmi" --primary $default
+ elif [ -z "$hdmi" ] && [ -n "$dp" ] && [ -n "$edp" ]; then
+ xrandr --output "$edp" --off --output "$dp" --primary $default
+ else
+ xrandr --output "$edp" --off --output "$display" --auto --primary $default
+ fi
+else
+ # Apply display settings when lid is open
+ if [ -n "$hdmi" ] && [ -z "$dp" ] && [ -n "$edp" ]; then
+ xrandr --output "$edp" --pos 1920x0 $default --output "$hdmi" --primary --pos 0x0 $default
+ elif [ -z "$hdmi" ] && [ -n "$dp" ] && [ -n "$edp" ]; then
+ xrandr --output "$edp" --pos 1920x0 $default --output "$dp" --primary --pos 0x0 $default
+ elif [ -z "$hdmi" ] && [ -z "$dp" ] && [ -n "$edp" ]; then
+ xrandr --output "$edp" --primary $default
+ else
+ xrandr --output "$display" --primary --auto
+ fi
+fi