qubes.StartApp 797 B

1234567891011121314151617181920212223242526
  1. #!/bin/sh
  2. if [ -z "$1" ]; then
  3. echo "This service requires an argument" >&2
  4. exit 1
  5. fi
  6. # make sure it has .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. for subdir in $(find "$dir/applications" -type d | sort); do
  16. if [ -f "$subdir/$app_basename" ]; then
  17. exec qubes-desktop-run "$subdir/$app_basename"
  18. fi
  19. done
  20. done
  21. echo "applications/$app_basename not found in $XDG_DATA_HOME:$XDG_DATA_DIRS" >&2
  22. exit 1