sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

dmenu-desktoponly-20240811-475d809.diff (2786B)


      1 From fada397413584331798a1a9b8703a10110450889 Mon Sep 17 00:00:00 2001
      2 From: Robert Bilski <robert@rbilski.com>
      3 Date: Sun, 4 Aug 2024 22:07:35 +0200
      4 Subject: [PATCH] Handle .desktop files
      5 
      6 Retrieve files from applications/ and open them using gtk-launch
      7 ---
      8  Makefile           |  8 ++++++--
      9  dmenu_path_desktop | 18 ++++++++++++++++++
     10  dmenu_run_desktop  |  2 ++
     11  3 files changed, 26 insertions(+), 2 deletions(-)
     12  create mode 100755 dmenu_path_desktop
     13  create mode 100755 dmenu_run_desktop
     14 
     15 diff --git a/Makefile b/Makefile
     16 index 458c524..f157bb1 100644
     17 --- a/Makefile
     18 +++ b/Makefile
     19 @@ -28,7 +28,7 @@ clean:
     20  dist: clean
     21  	mkdir -p dmenu-$(VERSION)
     22  	cp LICENSE Makefile README arg.h config.def.h config.mk dmenu.1\
     23 -		drw.h util.h dmenu_path dmenu_run stest.1 $(SRC)\
     24 +		drw.h util.h dmenu_path dmenu_path_desktop dmenu_run dmenu_run_desktop stest.1 $(SRC)\
     25  		dmenu-$(VERSION)
     26  	tar -cf dmenu-$(VERSION).tar dmenu-$(VERSION)
     27  	gzip dmenu-$(VERSION).tar
     28 @@ -36,10 +36,12 @@ dist: clean
     29  
     30  install: all
     31  	mkdir -p $(DESTDIR)$(PREFIX)/bin
     32 -	cp -f dmenu dmenu_path dmenu_run stest $(DESTDIR)$(PREFIX)/bin
     33 +	cp -f dmenu dmenu_path dmenu_path_desktop dmenu_run dmenu_run_desktop stest $(DESTDIR)$(PREFIX)/bin
     34  	chmod 755 $(DESTDIR)$(PREFIX)/bin/dmenu
     35  	chmod 755 $(DESTDIR)$(PREFIX)/bin/dmenu_path
     36 +	chmod 755 $(DESTDIR)$(PREFIX)/bin/dmenu_path_desktop
     37  	chmod 755 $(DESTDIR)$(PREFIX)/bin/dmenu_run
     38 +	chmod 755 $(DESTDIR)$(PREFIX)/bin/dmenu_run_desktop
     39  	chmod 755 $(DESTDIR)$(PREFIX)/bin/stest
     40  	mkdir -p $(DESTDIR)$(MANPREFIX)/man1
     41  	sed "s/VERSION/$(VERSION)/g" < dmenu.1 > $(DESTDIR)$(MANPREFIX)/man1/dmenu.1
     42 @@ -50,7 +52,9 @@ install: all
     43  uninstall:
     44  	rm -f $(DESTDIR)$(PREFIX)/bin/dmenu\
     45  		$(DESTDIR)$(PREFIX)/bin/dmenu_path\
     46 +		$(DESTDIR)$(PREFIX)/bin/dmenu_path_desktop\
     47  		$(DESTDIR)$(PREFIX)/bin/dmenu_run\
     48 +		$(DESTDIR)$(PREFIX)/bin/dmenu_run_desktop\
     49  		$(DESTDIR)$(PREFIX)/bin/stest\
     50  		$(DESTDIR)$(MANPREFIX)/man1/dmenu.1\
     51  		$(DESTDIR)$(MANPREFIX)/man1/stest.1
     52 diff --git a/dmenu_path_desktop b/dmenu_path_desktop
     53 new file mode 100755
     54 index 0000000..5ff74b3
     55 --- /dev/null
     56 +++ b/dmenu_path_desktop
     57 @@ -0,0 +1,18 @@
     58 +#!/bin/sh
     59 +
     60 +cachedir="${XDG_CACHE_HOME:-"$HOME/.cache"}"
     61 +cache="$cachedir/dmenu_run_desktop"
     62 +
     63 +[ ! -e "$cachedir" ] && mkdir -p "$cachedir"
     64 +
     65 +dirs=""
     66 +IFS=:
     67 +for dir in "${XDG_DATA_DIRS:-"/usr/local/share:/usr/share"}"; do
     68 +	dirs="${dirs}:${dir}/applications"
     69 +done;
     70 +
     71 +if stest -dqr -n "$cache" $PATH; then
     72 +	stest -fl $dirs | grep -v 'mimeinfo.cache' | sed 's/\.[^./]*$//' | sort -u | tee "$cache"
     73 +else
     74 +	cat "$cache"
     75 +fi
     76 diff --git a/dmenu_run_desktop b/dmenu_run_desktop
     77 new file mode 100755
     78 index 0000000..a90aceb
     79 --- /dev/null
     80 +++ b/dmenu_run_desktop
     81 @@ -0,0 +1,2 @@
     82 +#!/bin/sh
     83 +dmenu_path_desktop | dmenu "$@" | xargs gtk-launch &
     84 -- 
     85 2.46.0
     86