diff options
| author | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2025-01-26 07:23:50 +0900 |
|---|---|---|
| committer | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2025-01-26 07:23:50 +0900 |
| commit | d64154004a4915a2cf45a962e506e954ef1bdfe7 (patch) | |
| tree | ce2bebf8335758214945c6125522d1c737427ab3 /ar/.local/bin/setmonitor | |
| parent | aa032cee1714a550507692a4ddba9560ee04c90e (diff) | |
modified x11/xprofile, modified bin/setmonitor
Diffstat (limited to 'ar/.local/bin/setmonitor')
| -rwxr-xr-x | ar/.local/bin/setmonitor | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/ar/.local/bin/setmonitor b/ar/.local/bin/setmonitor index 9fe36c9..18c054a 100755 --- a/ar/.local/bin/setmonitor +++ b/ar/.local/bin/setmonitor @@ -1,17 +1,9 @@ #!/bin/sh # Parse connected displays -default="--mode 1920x1080 --rotate normal --scale 1.0x1.0" -default_dpi=96 -displays=$(xrandr -q | grep -w "connected") -x=$(echo "$displays" | grep "mm" | sed -E "s/.* ([0-9]+)mm x ([0-9]+)mm.*/\1/") -y=$(echo "$displays" | grep "mm" | sed -E "s/.* ([0-9]+)mm x ([0-9]+)mm.*/\2/") -calx=$(((1920 + (x / 10) - 1) / (x / 10))) # Ceiling for x -caly=$(((1080 + (y / 10) - 1) / (y / 10))) # Ceiling for y -dpi=$(if [ "$calx" -gt "$caly" ]; then echo "$calx"; else echo "$caly"; fi) -dpi=$(if [ "$dpi" -lt "$default_dpi" ]; then echo "$default_dpi"; else echo "$dpi"; fi) +default="--mode 1920x1080 --rotate normal --scale 1.0x1.0 --dpi 96" -for connected in $(echo "$displays" | cut -d ' ' -f 1); do +for connected in $(xrandr -q | grep -w "connected" | cut -d ' ' -f 1); do case $connected in eDP*) edp="$connected" ;; HDMI*) hdmi="$connected" ;; @@ -23,20 +15,20 @@ done # If the lid is closed, turn off the laptop's screen if grep -q "disabled" /sys/class/drm/card0-eDP-1/enabled || 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 --dpi "$dpi" + xrandr --output "$edp" --off --output "$hdmi" --primary $default elif [ -z "$hdmi" ] && [ -n "$dp" ] && [ -n "$edp" ]; then - xrandr --output "$edp" --off --output "$dp" --primary $default --dpi "$dpi" + xrandr --output "$edp" --off --output "$dp" --primary $default else - xrandr --output "$edp" --off --output "$display" --primary $default --dpi "$dpi" + 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 --dpi "$dpi" --output "$hdmi" --primary --pos 0x0 $default --dpi "$dpi" + 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 --dpi "$dpi" --output "$dp" --primary --pos 0x0 $default --dpi "$dpi" + 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 --dpi "$dpi" + xrandr --output "$edp" --primary $default else xrandr --output "$display" --primary --auto fi |
