Open willbelr opened 3 years ago
Duplicate events, that must be very annoying. Don't think this is a problem with xplugd, but I could be wrong of course. I guess the only way to work around this would be to make your script idempotent, i.e., make it check your desired state first before trying to apply it.
I hoped that there would be a better solution, but I could get it to behave correctly by using a lock file. Also I wanted to thank you for sharing this software, I found it much friendlier than udev for switching displays.
#!/bin/sh
event_handler() {
monitor=DP2-1
case "$1,$2,$3" in
display,$monitor,connected)
connected;;
display,$monitor,disconnected)
disconnected;;
esac
}
connected() {
xrandr --output eDP1 --off
xrandr --output DP2-1 --primary --mode 3440x1440 --pos 0x0 --rotate normal --dpi 102x102
}
disconnected() {
xrandr --output DP2-1 --off
xrandr --output eDP1 --primary --mode 1366x768 --pos 0x0 --rotate normal --dpi 96x96
}
LOCK=/tmp/xplugd-lock-$2
if test -f "$LOCK"; then
echo "! xplugrc: Execution prevented by lock file '$LOCK'"
else
touch "$LOCK"
event_handler $1 $2 $3
rm "$LOCK"
fi
The following script (.xplugrc) execute twice on connection or disconnection of DP2-1;
The event also appear twice. What could I do as a workaround?
System infos;