Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- DISPLAY=":0" && export DISPLAY
- [ -f "$HOME/res.info" ] && rm -f $HOME/res.info
- [ "$1" == "--rotate" ] && {
- case "$2" in
- "nn" ) rotate1="normal"; rotate2="normal" ;;
- "nr" ) rotate1="normal"; rotate2="right" ;;
- "nl" ) rotate1="normal"; rotate2="left" ;;
- "rn" ) rotate1="right" ; rotate2="normal" ;;
- "ln" ) rotate1="left" ; rotate2="normal" ;;
- "ll" ) rotate1="left" ; rotate2="left" ;;
- "rr" ) rotate1="right" ; rotate2="right" ;;
- "rl" ) rotate1="right" ; rotate2="left" ;;
- "lr" ) rotate1="left" ; rotate2="right" ;;
- * ) rotate1="normal"; rotate2="normal" ;;
- esac
- }
- [ ! "$1" ] && { rotate1="normal"; rotate2="normal"; }
- [ "$1" == "-h" ] && {
- echo -e "use: script --rotate (n|r|l)(n|r|l)\nn-normal,l-left,r-right\nexemple: \"script --rotate ll\" for both left scr rotate"
- exit
- }
- mon_data=`xrandr -q | sed -e "/disconnected/d" -e "/Screen/d"`
- outputs=`echo "$mon_data" | grep -o -E '.{3,7} connected' | grep -o -E '^.{3,7} '`
- output1=`echo "$outputs" | sed '2d'`
- output2=`echo "$outputs" | sed '1d'`
- [[ ! "$output1" || ! "$output2" ]] && { echo "err 2"; exit; }
- modes1=$(echo "$mon_data" | sed -e "/$output1/,/$output2/d" | grep -o -E "[0-9]{3,4}x[0-9]{3,4}")
- modes2=$(echo "$mon_data" | sed -n "/$output2/,\$p" | grep -o -E "[0-9]{3,4}x[0-9]{3,4}")
- [[ ! "$modes1" || ! "$modes2" ]] && { echo "err 2-1"; exit; }
- xrandr --output $output1 --right-of $output2
- count="0"
- exit_status="1"
- while [ "$exit_status" != "0" ]; do
- count=$(($count + 1))
- xrandr --output $output1 --mode `echo "$modes1" | sed "$count!d"` --rotate $rotate1 > /dev/null 2>&1
- exit_status="$?"
- [ "$count" == "10" ] && { echo "err 3"; exit; }
- done
- echo "${output1}> `echo "$modes2" | sed "$count!d"`"
- count="0"
- exit_status="1"
- while [ "$exit_status" != "0" ]; do
- count=$(($count + 1))
- xrandr --output $output2 --mode `echo "$modes2" | sed "$count!d"` --rotate $rotate2 > /dev/null 2>&1
- exit_status="$?"
- [ "$count" == "10" ] && { echo "err 4"; exit; }
- done
- echo "${output2}> `echo "$modes2" | sed "$count!d"`"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement