]> git.donarmstrong.com Git - deb_pkgs/autorandr.git/commitdiff
Improvement of the regex performance for lid monitoring
authorChristophe-Marie Duquesne <chmd@chmd.fr>
Sun, 10 Nov 2019 16:37:29 +0000 (17:37 +0100)
committerChristophe-Marie Duquesne <chmd@chmd.fr>
Sun, 10 Nov 2019 16:37:29 +0000 (17:37 +0100)
This version of the regex avoids reading entire lines from the libinput
output, and concentrates on the event field.

contrib/etc/xdg/autostart/autorandr-lid-listener.desktop
contrib/listen_lid.sh
contrib/systemd/autorandr-lid-listener.service

index 48c7fc80315908de96d749ffabdb29b2e1eecda7..9d16f07f98c6dce6300412ed8887f37860cf6b26 100644 (file)
@@ -2,5 +2,5 @@
 Name=Autorandr Lid Listener
 Comment=Trigger autorandr whenever the lid state changes
 Type=Application
-Exec=bash -c "stdbuf -oL libinput debug-events | grep --line-buffered SWITCH_TOGGLE | while read line; do autorandr --change --default default; done"
+Exec=bash -c "stdbuf -oL libinput debug-events | egrep --line-buffered '^ event[0-9]+\s+SWITCH_TOGGLE\s' | while read line; do autorandr --change --default default; done"
 X-GNOME-Autostart-Phase=Initialization
index 8283d374e3d2563ab1d095c9e6ea82dda98f69d7..7288490d05c94064c22eaec5995ef18ea23c5ddf 100755 (executable)
@@ -3,6 +3,8 @@
 # /!\ You must be part of the input group
 # sudo gpasswd -a $USER input
 
-stdbuf -oL libinput debug-events | grep --line-buffered SWITCH_TOGGLE | while read line; do
+stdbuf -oL libinput debug-events | \
+    egrep --line-buffered '^ event[0-9]+\s+SWITCH_TOGGLE\s' | \
+    while read line; do
     autorandr --change --default default
 done
index 7e4543832987280883d18467d00042e928e0f323..a6776ee887a93201b61996dc55cf109cbcfa3b2f 100644 (file)
@@ -3,7 +3,7 @@ Description=Runs autorandr whenever the lid state changes
 
 [Service]
 Type=simple
-ExecStart=bash -c "stdbuf -oL libinput debug-events | grep --line-buffered SWITCH_TOGGLE | while read line; do autorandr --batch --change --default default; done"
+ExecStart=bash -c "stdbuf -oL libinput debug-events | egrep --line-buffered '^ event[0-9]+\s+SWITCH_TOGGLE\s' | while read line; do autorandr --batch --change --default default; done"
 Restart=always
 RestartSec=30
 SyslogIdentifier=autorandr