qvm-actions.sh 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/bin/bash
  2. # Allow us to handle filenames with spaces using newline separator from Thunar
  3. IFS='
  4. '
  5. # Check if at least two arguments are provided: actions + file(s)
  6. if [ "$#" -le 1 ]; then
  7. echo "Not enough arguments provided. Aborting..."
  8. fi
  9. # File(s)
  10. files=${*:2}
  11. # copy and move handle a list of files where other actions don't
  12. case $1 in
  13. copy)
  14. #shellcheck disable=SC2016
  15. qvm-copy-to-vm '$default' "$files" | zenity --notification --text="Copying files..." --timeout 3
  16. ;;
  17. move)
  18. #shellcheck disable=SC2016
  19. qvm-move-to-vm '$default' "$files" | zenity --notification --text="Moving files..." --timeout 3
  20. ;;
  21. img)
  22. for file in $files
  23. do
  24. /usr/lib/qubes/qvm-convert-img.gnome "$file"
  25. done
  26. ;;
  27. pdf)
  28. for file in $files
  29. do
  30. /usr/lib/qubes/qvm-convert-pdf.gnome "$file"
  31. done
  32. ;;
  33. openvm)
  34. for file in $files
  35. do
  36. #shellcheck disable=SC2016
  37. qvm-open-in-vm '$default' "$file" | zenity --notification --text "Opening $file in VM..." --timeout 3 &
  38. done
  39. ;;
  40. opendvm)
  41. for file in $files
  42. do
  43. qvm-open-in-dvm "$files" | zenity --notification --text "Opening $file in DisposableVM..." --timeout 3 &
  44. done
  45. ;;
  46. *)
  47. echo "Unknown action. Aborting..."
  48. exit 1
  49. ;;
  50. esac