summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorsmac892023-05-19 12:13:43 -0600
committersmac892023-05-19 12:13:43 -0600
commit593f0225af421a342e426e116a23186bf9b26918 (patch)
tree18594984424035abe8912228521a32aafcefc0d7
downloadaur-593f0225af421a342e426e116a23186bf9b26918.tar.gz
initial release v1
-rw-r--r--.SRCINFO12
-rw-r--r--PKGBUILD15
-rwxr-xr-xfbrokendesktop.py45
3 files changed, 72 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 000000000000..3fabff8c04a9
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,12 @@
+pkgbase = find-broken-desktop
+ pkgdesc = Find .desktop files with invalid executables
+ pkgver = 1.0
+ pkgrel = 1
+ arch = any
+ license = MIT
+ depends = python
+ depends = python-pyxdg
+ source = fbrokendesktop.py
+ sha256sums = 0e47961fec8f6751c695d31952a652cdc29fdbc7e7aef68c708bd40404668cc2
+
+pkgname = find-broken-desktop
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 000000000000..77d5f2a7286b
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,15 @@
+# Maintainer: FirstAirBender <noblechuk5[at]web[dot]de>
+pkgname=find-broken-desktop
+pkgver=1.0
+pkgrel=1
+pkgdesc="Find .desktop files with invalid executables"
+arch=("any")
+license=('MIT')
+depends=('python' 'python-pyxdg')
+source=("fbrokendesktop.py")
+sha256sums=('0e47961fec8f6751c695d31952a652cdc29fdbc7e7aef68c708bd40404668cc2')
+
+package() {
+ chmod +x fbrokendesktop.py
+ install -D fbrokendesktop.py "$pkgdir/usr/bin/findbrokendesktop"
+}
diff --git a/fbrokendesktop.py b/fbrokendesktop.py
new file mode 100755
index 000000000000..7854adf05726
--- /dev/null
+++ b/fbrokendesktop.py
@@ -0,0 +1,45 @@
+#!/usr/bin/python3
+
+import glob
+import re
+import shlex
+import shutil
+
+from os import path
+
+from xdg import BaseDirectory
+from xdg.DesktopEntry import DesktopEntry
+
+# allow matching empty envs with .*
+env_re = re.compile(r'\w+=.*')
+
+def find_missing_desktop_files(desktop_dir: str):
+ for df in glob.iglob('*.desktop', root_dir=desktop_dir):
+ de = DesktopEntry(path.join(desktop_dir, df))
+ if exc := (de.getTryExec() or de.getExec()):
+ cmd = shlex.split(exc)
+ if cmd[0] == 'exec':
+ cmd = cmd[1:]
+ if cmd[0] == 'env':
+ cmd = cmd[1:]
+
+ for tok in cmd:
+ # ignore all attempts to set environment variables
+ if not env_re.match(tok):
+ if not shutil.which(tok):
+ yield shlex.quote(de.getFileName())
+ break
+
+def find_desktop_directories():
+ """
+ https://wiki.archlinux.org/title/desktop_entries#Modify_desktop_files
+ https://wiki.archlinux.org/title/XDG_Autostart#Directories
+ """
+ yield from BaseDirectory.load_data_paths('applications')
+ yield from BaseDirectory.load_config_paths('autostart')
+
+# TODO add option to respect NotShowIn and NoDisplay options
+if __name__ == '__main__':
+ for d in find_desktop_directories():
+ for df in find_missing_desktop_files(d):
+ print (df)