From fada397413584331798a1a9b8703a10110450889 Mon Sep 17 00:00:00 2001 From: Robert Bilski Date: Sun, 4 Aug 2024 22:07:35 +0200 Subject: [PATCH] Handle .desktop files Retrieve files from applications/ and open them using gtk-launch --- Makefile | 8 ++++++-- dmenu_path_desktop | 18 ++++++++++++++++++ dmenu_run_desktop | 2 ++ 3 files changed, 26 insertions(+), 2 deletions(-) create mode 100755 dmenu_path_desktop create mode 100755 dmenu_run_desktop diff --git a/Makefile b/Makefile index 458c524..f157bb1 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,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 @@ -36,10 +36,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 @@ -50,7 +52,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..5ff74b3 --- /dev/null +++ b/dmenu_path_desktop @@ -0,0 +1,18 @@ +#!/bin/sh + +cachedir="${XDG_CACHE_HOME:-"$HOME/.cache"}" +cache="$cachedir/dmenu_run_desktop" + +[ ! -e "$cachedir" ] && mkdir -p "$cachedir" + +dirs="" +IFS=: +for dir in "${XDG_DATA_DIRS:-"/usr/local/share:/usr/share"}"; do + dirs="${dirs}:${dir}/applications" +done; + +if stest -dqr -n "$cache" $PATH; then + stest -fl $dirs | grep -v 'mimeinfo.cache' | sed 's/\.[^./]*$//' | sort -u | tee "$cache" +else + cat "$cache" +fi diff --git a/dmenu_run_desktop b/dmenu_run_desktop new file mode 100755 index 0000000..a90aceb --- /dev/null +++ b/dmenu_run_desktop @@ -0,0 +1,2 @@ +#!/bin/sh +dmenu_path_desktop | dmenu "$@" | xargs gtk-launch & -- 2.46.0