Fix a bug in xidle where the program was executed twice

Anthony BOCCI <[email protected]>
Newsgroups gmane.os.openbsd.tech
Message-ID <lbeB-86rrftDH8-mD-_M5j3FdcUWknw1yJOueGIJ76JlH6TgVSDbQfQAbrDGPdJMNxAZlFVvrM-UDx8wiFrdRm7FALxC4aE5iUuUOE1qJcY=@abosec.fr>
Hi,

There is a bug in xidle that causes the program given in the -program
option to be executed twice: once when the timeout has passed, and a
second time when a mouse or keyboard event occurs.
The consequence is that when it's paired with xlock or similar, the
user needs to enter the password twice to unlock the machine.

The bug has been described on the FreeBSD Bugzilla, and I reused
their patch here.

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=275761

Anthony
fix-idle-triggers-program-twice.patch (application/octet-stream, 423 B)
diff --git app/xidle/xidle.c app/xidle/xidle.c
index 623ca784a..62f4222b0 100644
--- app/xidle/xidle.c
+++ app/xidle/xidle.c
@@ -431,7 +431,7 @@ main(int argc, char **argv)
 				 * Was for real or due to terminal
 				 * switching or a locking program?
 				 */
-				if (timeout > 0 && se->forced == False)
+				if (timeout > 0 && se->forced == False && se->state == ScreenSaverOn)
 					action(&x, args);
 			}
 			break;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.