qubes.StartApp 731 B

12345678910111213141516171819202122232425
  1. #!/bin/sh
  2. if [ -z "$1" ]; then
  3. echo "This service requires an argument" >&2
  4. exit 1
  5. fi
  6. app_basename="$1.desktop"
  7. # Based on XDG Base Directory Specification, Version 0.7
  8. [ -n "$XDG_DATA_HOME" ] || XDG_DATA_HOME="$HOME/.local/share"
  9. [ -n "$XDG_DATA_DIRS" ] || XDG_DATA_DIRS="/usr/local/share:/usr/share"
  10. for dir in $(echo "$XDG_DATA_HOME:$XDG_DATA_DIRS" | tr : ' '); do
  11. if ! [ -d "$dir/applications" ]; then
  12. continue
  13. fi
  14. for subdir in $(find "$dir/applications" -type d | sort); do
  15. if [ -f "$subdir/$app_basename" ]; then
  16. exec qubes-desktop-run "$subdir/$app_basename"
  17. fi
  18. done
  19. done
  20. echo "applications/$app_basename not found in $XDG_DATA_HOME:$XDG_DATA_DIRS" >&2
  21. exit 1