From 19fe110da5632622d877c74be0c999790d852f07 Mon Sep 17 00:00:00 2001 From: paperbenni Date: Mon, 9 Mar 2020 20:25:50 +0100 Subject: [PATCH] make instantmonitor use iconf --- monitor.sh | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/monitor.sh b/monitor.sh index dc18501..b51f7a6 100755 --- a/monitor.sh +++ b/monitor.sh @@ -7,32 +7,32 @@ cd mkdir -p ~/instantos/monitor &>/dev/null cd ~/instantos/monitor -xrandr | grep '[^s]connected' | grep -o '[0-9]*x[0-9]*+[0-9]*' | grep -o '[0-9]*$' >positions.txt -AMOUNT=$(wc -l resolutions.txt - sed -i 's/ /\n/g' resolutions.txt - CHANGERES="True" - echo "Resolution change detected" +if OLDRES="$(iconf resolutions)"; then + # see if resolution has changed + if ! [ "$RESOLUTIONS" = "$OLDRES" ]; then + iconf resolutions "$RESOLUTIONS" + CHANGERES="True" + echo "Resolution change detected" + fi fi -if [ $(sort -u resolutions.txt | wc -l) = "1" ]; then +if [ $(echo "$RESOLUTIONS" | sort -u | wc -l) = "1" ]; then echo "resolutions identical" - head -1 resolutions.txt >max.txt + iconf max $(head -1 <<<"$RESOLUTIONS") else - let PIXELS1="$(head -1 resolutions.txt | grep -o '^[0-9]*') * $(head -1 resolutions.txt | grep -o '[0-9]*$')" - let PIXELS2="$(tail -1 resolutions.txt | grep -o '^[0-9]*') * $(head -1 resolutions.txt | grep -o '[0-9]*$')" + let PIXELS1="$(head -1 <<<$RESOLUTIONS | grep -o '^[0-9]*') * $(head -1 <<<$RESOLUTIONS | grep -o '[0-9]*$')" + let PIXELS2="$(tail -1 <<<$RESOLUTIONS | grep -o '^[0-9]*') * $(tail -1 <<<$RESOLUTIONS | grep -o '[0-9]*$')" if [ "$PIXELS1" -gt "$PIXELS2" ]; then - head -1 resolutions.txt >max.txt + iconf max "$(head -1 <<<$RESOLUTIONS)" else - tail -1 resolutions.txt >max.txt + iconf max "$(tail -1 <<<$RESOLUTIONS)" fi fi @@ -60,15 +60,16 @@ else echo "$AMOUNT monitors found" fi -xrandr | grep '[^s]connected' | grep -o '^[^ ]*' >names.txt -MONITOR1=$(head -1 positions.txt) -MONITOR2=$(tail -1 positions.txt) +iconf names "(xrandr | grep '[^s]connected' | grep -o '^[^ ]*')" + +MONITOR1=$(head -1 <<<"$POSTITIONS") +MONITOR2=$(tail -1 <<<"$POSITIONS") if [ "$MONITOR1" -gt "$MONITOR2" ]; then echo "Monitor 1 is ${MONITOR1}px on the right" - echo "$MONITOR1" >right.txt + iconf -i right "$MONITOR2" else echo "Monitor 2 is ${MONITOR2}px on the right" - echo "$MONITOR1" >right.txt + iconf -i right "$MONITOR2" fi changetrigger -- 2.11.0