#!/bin/bash
#
# Switch Display input on screen change (DELL 24" monitor specific)
# by John Ryland
# Copyright 2018
#
# This can be made to be run by lightdm before login - see the install script
echo "Switcher started" > /tmp/switcher.log
echo "Synergy started" > /tmp/synergy.log
# Needs to be run with sudo so that it can control the monitor
# (this happens if allow it to be run by lightdm, see the install script)
# Run synergy client where output goes to console so can monitor for screen changes
LAST_LINE=
synergyc -f -d INFO 192.168.1.112 2>&1 | while read LINE
do
if echo $LINE | grep -q "leaving screen"
then
if [ "$LAST_LINE" != "$LINE" ]
then
# Send a DDC command to the monitor (This is specific for the specific DELL monitor)
# ddccontrol -r 0x60 -w 18 dev:/dev/i2c-4 2&>1 > /dev/null
echo "Switching --$LINE--" >> /tmp/switcher.log
LAST_LINE=$LINE
fi
fi
echo $LINE >> /tmp/synergy.log
done