Advertisement
lluks420

init-monitors.sh

Apr 27th, 2021
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.22 KB | None | 0 0
  1. # find out the active monitor (tv or desk-monitors) and set corresponding sink
  2. if [[ $(xrandr --listactivemonitors | awk '!/Monitors/ {print $4}' | grep DP-2) == "DP-2" ]]; then
  3.     MAIN_MONITOR=DP-2
  4.     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
  5.     pactl set-default-sink $(pacmd list-sinks | grep -e 'name:' -e 'index:' | grep "Creative" | awk '{print $2}'| awk '{print substr($0, 2, length($0) - 2)}')
  6. else
  7.     MAIN_MONITOR=HDMI-0
  8.     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
  9.     pactl set-default-sink $(pacmd list-sinks | grep -e 'name:' -e 'index:' | grep "hdmi" | awk '{print $2}'| awk '{print substr($0, 2, length($0) - 2)}')
  10. fi
  11.  
  12. GREEN='\033[0;36m'
  13. NC='\033[0m' # No Color
  14. echo -e "Connected monitors:" ${GREEN}$(xrandr --listmonitors | awk '!/Monitors/ {print $4}')
  15. echo -e "${NC}Primary monitor:" ${GREEN}$MAIN_MONITOR
  16. echo -e "${NC}Default sink:" ${GREEN}$default_sink
  17.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement