[wiki] [sites] Added a new patch for DWM and DMENU: desktoponly || Maxim Mihaylin

From: <git_AT_suckless.org>
Date: Sun, 06 Aug 2023 09:25:56 +0200

commit 754a18736c8639c9e77f91e2a3471b03301e0733
Author: Maxim Mihaylin <slimbox.sdb_AT_gmail.com>
Date: Sun Aug 6 13:25:01 2023 +0600

    Added a new patch for DWM and DMENU: desktoponly

diff --git a/dwm.suckless.org/patches/desktoponly/dwm-desktoponly-20230806-e81f17d.diff b/dwm.suckless.org/patches/desktoponly/dwm-desktoponly-20230806-e81f17d.diff
new file mode 100644
index 00000000..b1a6c1e6
--- /dev/null
+++ b/dwm.suckless.org/patches/desktoponly/dwm-desktoponly-20230806-e81f17d.diff
_AT_@ -0,0 +1,40 @@
+From 72ec0ec3c504ba348db9f6e8218d2a5d3cc6812a Mon Sep 17 00:00:00 2001
+From: Maxim Mihaylin <slimbox.sdb_AT_gmail.com>
+Date: Sun, 6 Aug 2023 12:12:15 +0600
+Subject: [PATCH] Patch for dmenu-desktoponly
+
+---
+ config.def.h | 2 ++
+ dwm.c | 3 +++
+ 2 files changed, 5 insertions(+)
+
+diff --git a/config.def.h b/config.def.h
+index 9efa774..1062702 100644
+--- a/config.def.h
++++ b/config.def.h
+_AT_@ -55,6 +55,8 @@ static const Layout layouts[] = {
+ /* helper for spawning shell commands in the pre dwm-5.0 fashion */
+ #define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
+
++static const int dmenudesktop = 1; /* 1 means dmenu will use only desktop files from [/usr/share/applications/] */
++
+ /* commands */
+ static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
+ static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
+diff --git a/dwm.c b/dwm.c
+index f1d86b2..949badd 100644
+--- a/dwm.c
++++ b/dwm.c
+_AT_@ -1650,6 +1650,9 @@ spawn(const Arg *arg)
+ struct sigaction sa;
+
+ if (arg->v == dmenucmd)
++ if (dmenudesktop)
++ dmenucmd[0] = "dmenu_run_desktop";
++
+ dmenumon[0] = '0' + selmon->num;
+ if (fork() == 0) {
+ if (dpy)
+--
+2.40.1
+
diff --git a/dwm.suckless.org/patches/desktoponly/index.md b/dwm.suckless.org/patches/desktoponly/index.md
new file mode 100644
index 00000000..9eb96a89
--- /dev/null
+++ b/dwm.suckless.org/patches/desktoponly/index.md
_AT_@ -0,0 +1,16 @@
+desktoponly
+===========
+
+Description
+-----------
+This patch allows dmenu to use only desktop files from `/usr/share/applications`.
+
+**Important**: It is necessary to use with a patch [desktoponly](https://dmenu.suckless.org/patches/desktoponly/) for dmenu.
+
+Download
+--------
+* [dwm-desktoponly-20230806-e81f17d.diff](dwm-desktoponly-20230806-e81f17d.diff) (1.3K) (2023-08-06)
+
+Author
+------
+* Maxim Mihaylin - <slimbox.sdb_AT_gmail.com>
diff --git a/tools.suckless.org/dmenu/patches/desktoponly/dmenu-desktoponly-20230805-7ab0cb5.diff b/tools.suckless.org/dmenu/patches/desktoponly/dmenu-desktoponly-20230805-7ab0cb5.diff
new file mode 100644
index 00000000..6316523b
--- /dev/null
+++ b/tools.suckless.org/dmenu/patches/desktoponly/dmenu-desktoponly-20230805-7ab0cb5.diff
_AT_@ -0,0 +1,75 @@
+From b15cc4ff72165dc24e6d08f4e5ec3a936b079195 Mon Sep 17 00:00:00 2001
+From: Maxim Mihaylin <slimbox.sdb_AT_gmail.com>
+Date: Sat, 5 Aug 2023 23:26:15 +0600
+Subject: [PATCH] Changes dmenu behavior to show only desktop files. It is
+ recommended to use the patch of the same name for dwm.
+
+---
+ Makefile | 8 ++++++--
+ dmenu_path_desktop | 7 +++++++
+ dmenu_run_desktop | 2 ++
+ 3 files changed, 15 insertions(+), 2 deletions(-)
+ create mode 100755 dmenu_path_desktop
+ create mode 100755 dmenu_run_desktop
+
+diff --git a/Makefile b/Makefile
+index a03a95c..752edc9 100644
+--- a/Makefile
++++ b/Makefile
+_AT_@ -34,7 +34,7 @@ clean:
+ dist: clean
+ mkdir -p dmenu-$(VERSION)
+ cp LICENSE Makefile README arg.h config.def.h config.mk dmenu.1\
+- drw.h util.h dmenu_path dmenu_run stest.1 $(SRC)\
++ drw.h util.h dmenu_path dmenu_path_desktop dmenu_run dmenu_run_desktop stest.1 $(SRC)\
+ dmenu-$(VERSION)
+ tar -cf dmenu-$(VERSION).tar dmenu-$(VERSION)
+ gzip dmenu-$(VERSION).tar
+_AT_@ -42,10 +42,12 @@ dist: clean
+
+ install: all
+ mkdir -p $(DESTDIR)$(PREFIX)/bin
+- cp -f dmenu dmenu_path dmenu_run stest $(DESTDIR)$(PREFIX)/bin
++ cp -f dmenu dmenu_path dmenu_path_desktop dmenu_run dmenu_run_desktop stest $(DESTDIR)$(PREFIX)/bin
+ chmod 755 $(DESTDIR)$(PREFIX)/bin/dmenu
+ chmod 755 $(DESTDIR)$(PREFIX)/bin/dmenu_path
++ chmod 755 $(DESTDIR)$(PREFIX)/bin/dmenu_path_desktop
+ chmod 755 $(DESTDIR)$(PREFIX)/bin/dmenu_run
++ chmod 755 $(DESTDIR)$(PREFIX)/bin/dmenu_run_desktop
+ chmod 755 $(DESTDIR)$(PREFIX)/bin/stest
+ mkdir -p $(DESTDIR)$(MANPREFIX)/man1
+ sed "s/VERSION/$(VERSION)/g" < dmenu.1 > $(DESTDIR)$(MANPREFIX)/man1/dmenu.1
+_AT_@ -56,7 +58,9 @@ install: all
+ uninstall:
+ rm -f $(DESTDIR)$(PREFIX)/bin/dmenu\
+ $(DESTDIR)$(PREFIX)/bin/dmenu_path\
++ $(DESTDIR)$(PREFIX)/bin/dmenu_path_desktop\
+ $(DESTDIR)$(PREFIX)/bin/dmenu_run\
++ $(DESTDIR)$(PREFIX)/bin/dmenu_run_desktop\
+ $(DESTDIR)$(PREFIX)/bin/stest\
+ $(DESTDIR)$(MANPREFIX)/man1/dmenu.1\
+ $(DESTDIR)$(MANPREFIX)/man1/stest.1
+diff --git a/dmenu_path_desktop b/dmenu_path_desktop
+new file mode 100755
+index 0000000..e6b1144
+--- /dev/null
++++ b/dmenu_path_desktop
+_AT_@ -0,0 +1,7 @@
++#!/bin/bash
++entries=$(ls /usr/share/applications/)
++for entry in $entries; do
++ if [[ $entry == *.desktop ]]; then
++ echo "${entry%.*}"
++ fi
++done;
+diff --git a/dmenu_run_desktop b/dmenu_run_desktop
+new file mode 100755
+index 0000000..410b4b1
+--- /dev/null
++++ b/dmenu_run_desktop
+_AT_@ -0,0 +1,2 @@
++#!/bin/sh
++dmenu_path_desktop | dmenu "$_AT_" | ${SHELL:-"/bin/sh"} &
+--
+2.40.1
+
diff --git a/tools.suckless.org/dmenu/patches/desktoponly/index.md b/tools.suckless.org/dmenu/patches/desktoponly/index.md
new file mode 100644
index 00000000..d6c32acd
--- /dev/null
+++ b/tools.suckless.org/dmenu/patches/desktoponly/index.md
_AT_@ -0,0 +1,19 @@
+desktoponly
+===========
+
+Description
+-----------
+This patch allows dmenu to use only desktop files from `/usr/share/applications`.
+
+Usage
+-----
+It is recommended to use with a patch [desktoponly](https://dwm.suckless.org/patches/desktoponly/) for dwm. Otherwise just run `dmenu_run_desktop` for desktop files or `dmenu_run` as usual for default behavior.
+
+Download
+--------
+* [dwm-desktoponly-20230805-7ab0cb5.diff](dwm-desktoponly-20230805-7ab0cb5.diff) (2.5K) (2023-08-05)
+
+Author
+------
+* Maxim Mihaylin - <slimbox.sdb_AT_gmail.com>
+
Received on Sun Aug 06 2023 - 09:25:56 CEST

This archive was generated by hypermail 2.3.0 : Sun Aug 06 2023 - 09:37:05 CEST