Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- output_xrandr="$(xrandr)"
- active_list=($(xrandr --listactivemonitors | grep '+' | awk {'print $4'}))
- disconnected=($(echo "$output_xrandr"| grep 'disconnected' | awk {'print $1'}))
- if [[ -n "$disconnected" ]]; then
- for ((i=0; i < ${#disconnected[@]}; i++)); do
- echo "disconnected: ${disconnected[$i]}"
- done
- fi
- connected="$(echo "$output_xrandr"| grep ' connected')"
- primary="$(echo "$connected"| grep 'primary' | awk {'print $1'})"
- echo "primary: $primary"
- connected_list=($(echo "$connected"| awk {'print $1'}))
- inactive_list=""
- status=""
- count_inactive=0
- for ((i=0; i < ${#connected_list[@]}; i++)); do
- for ((k=0; k < ${#active_list[@]}; k++)); do
- if [[ ${active_list[$k]} != ${connected_list[$i]} ]]; then
- status="inactive"
- else
- status="active"
- break
- fi
- done
- if [[ $status == "inactive" ]]; then
- inactive_list[$count_inactive]=${connected_list[$i]}
- ((count_inactive=count_inactive+1))
- fi
- done
- echo "active: $active_list"
- echo "inactive: $inactive_list"
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement