qubes.StartApp 731 B

123456789101112131415161718192021222324
  1. #!/bin/sh
  2. if [ -z "$1" ]; then
  3. echo "This service require an argument" >&2
  4. exit 1
  5. fi
  6. # make sure it have .desktop suffix, and only one of it
  7. app_basename="${1%.desktop}.desktop"
  8. # Based on XDG Base Directory Specification, Version 0.7
  9. [ -n "$XDG_DATA_HOME" ] || XDG_DATA_HOME="$HOME/.local/share"
  10. [ -n "$XDG_DATA_DIRS" ] || XDG_DATA_DIRS="/usr/local/share:/usr/share"
  11. for dir in $(echo "$XDG_DATA_HOME:$XDG_DATA_DIRS" | tr : ' '); do
  12. if ! [ -d "$dir/applications" ]; then
  13. continue
  14. fi
  15. if [ -f "$dir/applications/$app_basename" ]; then
  16. exec qubes-desktop-run "$dir/applications/$app_basename"
  17. fi
  18. done
  19. echo "applications/$app_basename not found in $XDG_DATA_HOME:$XDG_DATA_DIRS" >&2
  20. exit 1