display, i3

This commit is contained in:
2020-02-15 15:04:47 +01:00
parent 560841459c
commit 93edf69d60
16 changed files with 298 additions and 41 deletions

48
bin/autoconfgure_display.sh Executable file
View File

@ -0,0 +1,48 @@
#!/bin/bash
set -o pipefail
export DISPLAY=:0
XRANDR="/usr/bin/xrandr"
AWK="/usr/bin/awk"
GREP="/usr/bin/grep"
PRIMARY_DISPLAY="eDP1"
function displayChange {
STATUS=${2}
DIS=${1}
POS=${3}
notify-send "Display $DIS $STATUS"
echo "Display $DIS $STATUS" >> /home/paramah/.display.log
if [ $STATUS = "connected" ]; then
$XRANDR --output $DIS --auto
$XRANDR --output $DIS $POS $PRIMARY_DISPLAY
fi
if [ $STATUS = "disconnected" ]; then
$XRANDR --output $DIS --off
fi
}
function myDisplays {
for D in = $($XRANDR |$GREP -w "${1}" |$GREP -v $PRIMARY_DISPLAY |$AWK '{print $1}')
do
if [ $D = "DP2" ]; then
displayChange "DP2" "${1}" "--left-of"
fi
if [ $D = "HDMI1" ]; then
displayChange "HDMI1" "${1}" "--right-of"
fi
done
}
myDisplays "disconnected"
myDisplays "connected"