Advertisement
lluks420

switch-screens.sh

Apr 27th, 2021 (edited)
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.56 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. ## Created By lluks
  4. ## switch to the wanted monitors and set the according audio using rofi and dmenu
  5.  
  6. function init () {
  7.     sh /home/lluks/.config/polybar/launch.sh 2> /dev/null
  8.     echo -e "Displays set to: \e[32m"$1"\e[39m"
  9.     echo -e "\e[0mSelected sink is: \e[32m"$2"\e[39m"
  10.     pactl set-default-sink $2
  11.     # restore background
  12.     nitrogen --restore
  13. }
  14.  
  15. MENU="$(rofi -sep "|" -dmenu -i -p 'System' -width 9 -hide-scrollbar -line-padding 4 -padding 20 -lines 4 <<< " Mirror| TV Only| Desk Only| All Monitors")"
  16.     case "$MENU" in
  17.         *'Mirror')
  18.             xrandr --output DP-0 --off --output DP-1 --off --output HDMI-0 --mode 1920x1080 --pos 1080x170 --rotate normal --output DP-2 --primary --mode 2560x1440 --pos 1080x170 --rotate normal --output DP-3 --off --output DP-4 --off --output DP-5 --mode 1920x1080 --pos 0x0 --rotate left
  19.             default_sink=$(pacmd list-sinks | grep -e 'name:' -e 'index:' | grep "hdmi" | awk '{print $2}'| awk '{print substr($0, 2, length($0) - 2)}')
  20.             sleep 1
  21.             init "${MENU:2}" $default_sink;;
  22.         *'TV Only')
  23.             xrandr --output DP-0 --off --output DP-1 --off --output HDMI-0 --primary --mode 1920x1080 --pos 0x268 --rotate normal --output DP-2 --off --output DP-3 --off --output DP-4 --off --output DP-5 --off
  24.             sleep 1
  25.             default_sink=$(pacmd list-sinks | grep -e 'name:' -e 'index:' | grep "hdmi" | awk '{print $2}'| awk '{print substr($0, 2, length($0) - 2)}')
  26.             init "${MENU:2}" $default_sink;;
  27.                 *'Desk Only')
  28.             xrandr --output DP-0 --off --output DP-1 --off --output HDMI-0 --off --output DP-2 --primary --mode 2560x1440 --pos 1080x240 --rotate normal --output DP-3 --off --output DP-4 --off --output DP-5 --mode 1920x1080 --pos 0x0 --rotate left
  29.             default_sink=$(pacmd list-sinks | grep -e 'name:' -e 'index:' | grep "Creative" | awk '{print $2}'| awk '{print substr($0, 2, length($0) - 2)}')
  30.             if [ -z "$default_sink" ]
  31.             then
  32.                 sleep 1
  33.                 default_sink=$(pacmd list-sinks | grep -e 'name:' -e 'index:' | grep "hdmi" | awk '{print $2}'| awk '{print substr($0, 2, length($0) - 2)}')
  34.             fi
  35.             init "${MENU:2}" $default_sink;;
  36.         *'All Monitors')
  37.             xrandr --output DP-0 --off --output DP-1 --off --output HDMI-0 --mode 1920x1080 --pos 0x298 --rotate normal --output DP-2 --primary --mode 2560x1440 --pos 3000x170 --rotate normal --output DP-3 --off --output DP-4 --off --output DP-5 --mode 1920x1080 --pos 1920x0 --rotate left
  38.             sleep 1
  39.             default_sink=$(pacmd list-sinks | grep -e 'name:' -e 'index:' | grep "hdmi" | awk '{print $2}'| awk '{print substr($0, 2, length($0) - 2)}')
  40.             init "${MENU:2}" $default_sink;;
  41.     esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement