Skip to content

Instantly share code, notes, and snippets.

@PedroHLC
Last active December 11, 2023 15:17
Show Gist options
  • Save PedroHLC/dd053e2618cda0155947b5a73eef9911 to your computer and use it in GitHub Desktop.
Save PedroHLC/dd053e2618cda0155947b5a73eef9911 to your computer and use it in GitHub Desktop.
Uses bash+awk+find+XDG_DATA_DIRS to launch an application by searching the first x-desktop that starts with the argument (you can use wildcards, remember to escape them)
#!/usr/bin/env bash
set -euo pipefail
LAUNCH_SEARCHING="$1"
exec $(awk '/^Exec=/{sub(/^Exec=/, ""); print $1}' $(echo -n "$XDG_DATA_DIRS" |\
xargs -d ':' -ri \
find -H '{}/applications/' -iname "${LAUNCH_SEARCHING}*.desktop" 2>/dev/null |\
head -n 1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment