configure-monitors (1081B) - raw
1 #!/bin/sh 2 3 xr="${XDG_CONFIG_HOME:-$HOME/.config}/Xresources" 4 5 if [ -n "$(xrandr --query | grep "DP2 connected")" ]; then 6 xrandr --output eDP1 --off --output DP2 --auto 7 if grep --quiet "Xft.dpi: 192" "$xr"; then 8 sed -i "s/^Xft.dpi: 192/! Xft.dpi: 192/g" "$xr" 9 else 10 echo "! Xft.dpi: 192" >> "$xr" 11 fi 12 elif [ -n "$(xrandr --query | grep "HDMI2 connected")" ]; then 13 xrandr --output eDP1 --off --output HDMI2 --auto 14 if grep --quiet "Xft.dpi: 192" "$xr"; then 15 sed -i "s/^Xft.dpi: 192/! Xft.dpi: 192/g" "$xr" 16 else 17 echo "! Xft.dpi: 192" >> "$xr" 18 fi 19 # elif [ -n "$(xrandr --query | grep "HDMI2 connected")" ]; then 20 # xrandr --output eDP1 --off --output HDMI2 --mode 3840x2160 21 # if grep --quiet "Xft.dpi: 192" "$xr"; then 22 # sed -i "s/^! Xft.dpi: 192/Xft.dpi: 192/g" "$xr" 23 # else 24 # echo "Xft.dpi: 192" >> "$xr" 25 # fi 26 else 27 xrandr --output eDP1 --auto --output DP2 --off 28 if grep --quiet "Xft.dpi: 192" "$xr"; then 29 sed -i "s/^! Xft.dpi: 192/Xft.dpi: 192/g" "$xr" 30 else 31 echo "Xft.dpi: 192" >> "$xr" 32 fi 33 fi 34 xrdb $HOME/.config/Xresources