Advertisement
Guest User

Untitled

a guest
Oct 17th, 2022
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.22 KB | None | 0 0
  1. #!/usr/bin/env bash
  2. #
  3. # dmenu-splitmonitor.sh
  4. #
  5. if [ $# -eq 0 ]; then
  6.     echo "Supply the width of the center monitor as an argument"
  7.     echo "e.g. dmenu-splitmonitor-custom.sh 1400"
  8.     exit
  9. fi
  10.  
  11. widthCenter=$1
  12.  
  13. if [ "$widthCenter" = "Default" ]; then
  14.     widthCenter=1500
  15. fi
  16.  
  17.  
  18. let widthLeft=(3840-$widthCenter)/2
  19. let positionRight=widthCenter+widthLeft
  20. let widthRight=(3840-$widthCenter)/2
  21. if [ "$widthCenter" -eq 1920 ]; then
  22.     let widthRight=0
  23.     let widthLeft=1920
  24.     let positionRight=0
  25. fi
  26.  
  27. echo "$widthLeft @ 0"
  28. echo "$widthCenter @ $widthLeft"
  29. echo "$widthRight @ $positionRight"
  30.  
  31. xrandr | grep -E 'HDMI-1 connected( primary)? 3840x1080' &> /dev/null
  32. if [ $? == 0 ]; then
  33.     echo "Deleting existing"
  34.     xrandr --delmonitor HDMI-1-3
  35.     xrandr --delmonitor HDMI-1-1
  36.     xrandr --delmonitor HDMI-1-2
  37.     if [ "$widthCenter" != "Full" ]; then
  38.         echo "Configuring output"
  39.  
  40.         xrandr --setmonitor HDMI-1-1 $widthLeft/255x1080/286+0+0 none
  41.         xrandr --setmonitor HDMI-1-2 $widthCenter/255x1080/286+$widthLeft+0 none
  42.         if [ $widthRight -gt 0 ]; then
  43.             xrandr --setmonitor HDMI-1-3 $widthRight/255x1080/286+$positionRight+0 none
  44.         fi
  45.  
  46.         xrandr --output HDMI-1 --auto --left-of eDP-1
  47.     fi
  48.     echo "Reloading"
  49.     i3-msg reload
  50.  
  51. fi
  52.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement