[wiki] [sites] [dwm][PATCH] Add doublepressquit patch to dwm || Sebastian Karlsen

From: <git_AT_suckless.org>
Date: Tue, 01 Mar 2022 15:00:44 +0100

commit 3096575b6b8fc8c4d08e0fa8afde95e40a1b4101
Author: Sebastian Karlsen <sebastian_AT_karlsen.fr>
Date: Tue Mar 1 14:59:08 2022 +0100

    [dwm][PATCH] Add doublepressquit patch to dwm

diff --git a/dwm.suckless.org/patches/doublepressquit/dwm-doublepressquit-6.3.diff b/dwm.suckless.org/patches/doublepressquit/dwm-doublepressquit-6.3.diff
new file mode 100644
index 00000000..0a44adee
--- /dev/null
+++ b/dwm.suckless.org/patches/doublepressquit/dwm-doublepressquit-6.3.diff
_AT_@ -0,0 +1,57 @@
+From 1ff5d32e691fa8fb001d0619b72da11ef8232009 Mon Sep 17 00:00:00 2001
+From: Sebastian Karlsen <suckless_AT_karlsen.fr>
+Date: Tue, 1 Mar 2022 14:49:03 +0100
+Subject: [PATCH] Only quit dwm if binding is pressed twice quickly
+
+---
+ config.def.h | 3 +++
+ dwm.c | 19 ++++++++++++++++++-
+ 2 files changed, 21 insertions(+), 1 deletion(-)
+
+diff --git a/config.def.h b/config.def.h
+index a2ac963..8123671 100644
+--- a/config.def.h
++++ b/config.def.h
+_AT_@ -21,6 +21,9 @@ static const char *colors[][3] = {
+ /* tagging */
+ static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
+
++/* Lockfile */
++static char lockfile[] = "/tmp/dwm.lock";
++
+ static const Rule rules[] = {
+ /* xprop(1):
+ * WM_CLASS(STRING) = instance, class
+diff --git a/dwm.c b/dwm.c
+index a96f33c..d55f186 100644
+--- a/dwm.c
++++ b/dwm.c
+_AT_@ -1252,7 +1252,24 @@ propertynotify(XEvent *e)
+ void
+ quit(const Arg *arg)
+ {
+- running = 0;
++ FILE *fd = NULL;
++ struct stat filestat;
++
++ if ((fd = fopen(lockfile, "r")) && stat(lockfile, &filestat) == 0) {
++ fclose(fd);
++
++ if (filestat.st_ctime <= time(NULL)-2)
++ remove(lockfile);
++ }
++
++ if ((fd = fopen(lockfile, "r")) != NULL) {
++ fclose(fd);
++ remove(lockfile);
++ running = 0;
++ } else {
++ if ((fd = fopen(lockfile, "a")) != NULL)
++ fclose(fd);
++ }
+ }
+
+ Monitor *
+--
+2.35.1
+
diff --git a/dwm.suckless.org/patches/doublepressquit/index.md b/dwm.suckless.org/patches/doublepressquit/index.md
new file mode 100644
index 00000000..0f8c6ebf
--- /dev/null
+++ b/dwm.suckless.org/patches/doublepressquit/index.md
_AT_@ -0,0 +1,16 @@
+doublepressquit
+===============
+
+Description
+-----------
+On the default keybinding of Mod-Shift-Q, it is possible to press it by
+accident, closing all your work. This patch makes it so dwm will only exit if
+the keybinding is pressed twice quickly (<= 2 seconds).
+
+Download
+--------
+* [dwm-doublepressquit-6.3.diff](dwm-doublepressquit-6.3.diff)
+
+Author
+------
+* Sebastian Karlsen - <suckless_AT_karlsen.fr>
Received on Tue Mar 01 2022 - 15:00:44 CET

This archive was generated by hypermail 2.3.0 : Tue Mar 01 2022 - 15:00:58 CET