在终端中工作的相同命令不适用于 Thunar 自定义操作

Ben*_*son 3 xubuntu command-line gnupg thunar-custom-actions 15.10

我想要一个简单的半安全命令,它使用 gpg 对称加密对文件进行加密,然后删除原始文件。在终端中,此命令工作正常:

 gpg --passphrase-file /home/xxx/.gnupg/sympass --symmetric <file> && rm <file>
Run Code Online (Sandbox Code Playgroud)

<file>要加密(和删除)的文件在哪里。这在终端中工作正常,但是当我尝试以这种方式在 Thunar 中执行自定义操作时

xfce4-terminal -e gpg --passphrase-file /home/xxx/.gnupg/sympass --symmetric %f && rm %f
Run Code Online (Sandbox Code Playgroud)

并尝试在 Thunar 中使用此操作,没有任何反应。为什么,有什么方法可以调试 thunar 自定义操作?

ter*_*don 6

这里有两个问题。一个是&&无法识别,你需要一个完整的外壳,另一个是为了运行它,你需要一个 tty,当从 GUI 菜单启动时,thunar 没有。因此,首先编写一个包含以下内容的脚本:

#!/bin/bash
gpg --passphrase-file /home/beos/.gnupg/sympass --symmetric "$1"  && rm "$1"
Run Code Online (Sandbox Code Playgroud)

使脚本可执行 ( chmod a+x /path/to/script.sh),然后将操作设置为:

xfce4-terminal -x /path/to/script.sh %f
Run Code Online (Sandbox Code Playgroud)

这应该会导致它在终端和正常的 bash 会话中运行,因此它应该按预期工作。