dotfiles

My personal shell configs and stuff
git clone git://git.alex.balgavy.eu/dotfiles.git
Log | Files | Refs | Submodules | README | LICENSE

dmenu-displays (1108B)


      1 #!/bin/sh
      2 substring() {
      3   needle="$1"
      4   haystack="$2"
      5   [ "${haystack#*"$needle"}" != "$haystack" ]
      6 }
      7 current="$(xrandr | grep '^[^[:blank:]]')"
      8 case "$(printf 'Single display\nMirror\nAuto' | dmenu -i -l 5 -p "Display config:")" in
      9   'Single display')
     10     cmd="xrandr --output eDP-1 --off"
     11     substring "HDMI-1 connected" "$current" && cmd="$cmd --output HDMI-1 --primary --mode 1920x1080 --pos 0x0 --rotate normal"
     12     substring " DP-1 connected" "$current" && cmd="$cmd --output DP-1 --primary --mode 1920x1080 --pos 0x0 --rotate normal"
     13     substring " DP-2 connected" "$current" && cmd="$cmd --output DP-2 --off"
     14     $cmd
     15     ;;
     16   'Mirror')
     17     cmd="xrandr --output eDP-1 --mode 1920x1080 --pos 0x0 --rotate normal"
     18     substring "HDMI-1 connected" "$current" && cmd="$cmd --output HDMI-1 --primary --mode 1920x1080 --pos 0x0 --rotate normal"
     19     substring " DP-1 connected" "$current" && cmd="$cmd --output DP-1 --primary --mode 1920x1080 --pos 0x0 --rotate normal"
     20     substring " DP-2 connected" "$current" && cmd="$cmd --output DP-2 --off"
     21     $cmd
     22     ;;
     23   'Auto')
     24     xrandr --auto;;
     25   *);;
     26 esac