I’m trying to write a bash script that executes a command when an external monitor is connected/disconnected. This is what I’ve got so far (based on the answer here) but it’s not working, can anyone tell me what I’m doing wrong?
#!/bin/bash
while true
do
sleep 5
xrandr=$(xrandr)
con_monitors=$(echo $xrandr | grep -c " connected ")
if [[ $con_monitors -gt 1 ]]; then
gsettings reset org.gnome.desktop.interface text-scaling-factor
else
gsettings set org.gnome.desktop.interface text-scaling-factor 1.2
fi
done