3

I want a simple semi-safe command that encrypts a file using gpg symmetric encryption and then remove the original file. In the terminal this command works fine:

 gpg --passphrase-file /home/xxx/.gnupg/sympass --symmetric <file> && rm <file>

where <file> is the file to be encrypted (and deleted). This works fine in the terminal, but when I try to do a custom action in Thunar in this way

xfce4-terminal -e gpg --passphrase-file /home/xxx/.gnupg/sympass --symmetric %f && rm %f

and try to use this action in Thunar, nothing happens. Why, and is there some way to debug thunar custom actions?

muru
  • 207,228

1 Answers1

6

There are two issues here. One is that the && is not recognized and you need a full shell and the other is that in order for it to run, you need a tty which thunar doesn't have when launched from the GUI menu. So, first write a script with these contents:

#!/bin/bash
gpg --passphrase-file /home/beos/.gnupg/sympass --symmetric "$1"  && rm "$1"

Make the script executable (chmod a+x /path/to/script.sh) and then set the action to:

xfce4-terminal -x /path/to/script.sh %f

That should cause it to run in a terminal and in a normal bash session so it should work as expected.

terdon
  • 104,119