From 39a481eb565f388b5de4c6865cc3ead9d52da429 Mon Sep 17 00:00:00 2001 From: Ali Hatami Tajik Date: Fri, 7 Apr 2023 17:08:59 +0330 Subject: [PATCH] Add drm rules for monitor change event --- src/rules/90-drm.rules | 1 + src/scripts/setupmonitor.sh | 12 ++++++++++++ 2 files changed, 13 insertions(+) create mode 100644 src/rules/90-drm.rules create mode 100755 src/scripts/setupmonitor.sh diff --git a/src/rules/90-drm.rules b/src/rules/90-drm.rules new file mode 100644 index 0000000..cbd4186 --- /dev/null +++ b/src/rules/90-drm.rules @@ -0,0 +1 @@ +SUBSYSTEM=="drm", ENV{MONITOR_LOCK}="/tmp/monitorlock", ENV{SONOLOG}="/tmp/sonolog.log", RUN+="/usr/local/bin/setupmonitor.sh" \ No newline at end of file diff --git a/src/scripts/setupmonitor.sh b/src/scripts/setupmonitor.sh new file mode 100755 index 0000000..40552d7 --- /dev/null +++ b/src/scripts/setupmonitor.sh @@ -0,0 +1,12 @@ +#!/bin/bash +# This script will run when drm change event detected. +# This sctipt should be placed in /usr/local/bin +# SONOLOG file must be set beforehand in the udev rule +# MONITOR_LOCK should be set +( + flock -n 100 || exit 1 + sleep 1 # wait until all changes take place + xrandr --auto + python3 /usr/bin/local/python/setupmonitor.py + echo $(data) - INFO - Setup Monitor Done >> $SONOLOG +) 100> $MONITOR_LOCK \ No newline at end of file