Skip to content

Instantly share code, notes, and snippets.

@frangio
Last active March 24, 2016 23:43
Show Gist options
  • Save frangio/f98e9a6c0060ca1b2e65 to your computer and use it in GitHub Desktop.
Save frangio/f98e9a6c0060ca1b2e65 to your computer and use it in GitHub Desktop.
Enhanced `dmenu_run`.
#!/bin/sh
set -o errexit
is_graphical() {
desktop=/usr/share/applications/"$1".desktop
[ -f "$desktop" ] && ! grep -Fq Terminal=true "$desktop" \
|| ldd "$(which "$1")" | grep -Fq libX11
}
run() {
echo "$@"
if is_graphical "$1"; then
exec "$@"
else
exec "${TERMINAL:-urxvtc}" -e "$@"
fi
}
run $(dmenu_path | dmenu "$@")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment