3 if [ $(whoami) = "root" ] || [ $(whoami) = "manjaro" ]; then
4 echo "user check successful"
6 echo "please run this as root"
10 command -v xrandr &>/dev/null ||
11 (echo "please install xrandr" && exit 1)
15 mkdir -p /opt/instantos/monitor &>/dev/null
16 cd /opt/instantos/monitor
18 xrandr | grep '[^s]connected' | grep -o '[0-9]*x[0-9]*+[0-9]*' | grep -o '[0-9]*$' >positions.txt
19 AMOUNT=$(cat positions.txt | wc -l)
21 # get monitor with highest resolution
22 xrandr | grep '[^s]connected' | grep -Eo '[0-9]{1,}x[0-9]{1,}\+[0-9]{1,}\+[0-9]{1,}' |
23 grep -o '[0-9]*x[0-9]*' >resolutions.txt
25 if [ $(cat resolutions.txt | sort -u | wc -l) = "1" ]; then
26 echo "resolutions identical"
27 cp resolutions.txt max.txt
31 let PIXELS1="$(head -1 resolutions.txt | grep -o '^[0-9]*') * $(cat resolutions.txt | head -1 | grep -o '[0-9]*$')"
32 let PIXELS2="$(tail -1 resolutions.txt | grep -o '^[0-9]*') * $(cat resolutions.txt | head -1 | grep -o '[0-9]*$')"
34 if [ "$PIXELS1" -gt "$PIXELS2" ]; then
35 head -1 resolutions.txt >max.txt
37 tail -1 resolutions.txt >max.txt
40 if [ "$AMOUNT" = "1" ]; then
41 echo "only one monitor found, further setup not needed"
44 if [ "$AMOUNT" -gt 2 ]; then
45 echo "only 2 monitors are supported"
48 echo "$AMOUNT monitors found"
51 xrandr | grep '[^s]connected' | grep -o '^[^ ]*' >names.txt
52 MONITOR1=$(head -1 positions.txt)
53 MONITOR2=$(tail -1 positions.txt)
55 if [ "$MONITOR1" -gt "$MONITOR2" ]; then
56 echo "Monitor 1 is ${MONITOR1}px on the right"
57 echo "$MONITOR1" >right.txt
59 echo "Monitor 2 is ${MONITOR2}px on the right"
60 echo "$MONITOR1" >right.txt