Thunar & GPG: context menu

Step-by-Step descriptions of how to do things.
Post Reply
User avatar
^rooker
Site Admin
Posts: 1481
Joined: Fri Aug 29, 2003 8:39 pm

Thunar & GPG: context menu

Post by ^rooker »

I wanted GPG-integration in my Thunar context menu, but somehow I thought that KGPG was a bit overkill in an XFCE environment ;)

Using Thunar's built-in "custom actions" editor, I've written a small script and then added custom actions for Thunar.

1) The bash-script
This small wrapper script is necessary, because the filename manipulation (e.g. remove '.gpg' file suffix when decrypting) was not possible by the shell thunar's custom actions are executed in.

Code: Select all

#!/bin/bash
FILE_IN="$2"
DIR="$3"

case "$1" in
    encrypt)
        echo "not implemented, yet."
    ;;

    decrypt)
        FILE_OUT="$DIR/$(basename $FILE_IN .gpg)"
        echo "Decrypting '$FILE_IN' to '$FILE_OUT'..."
        cmd="gpg --output '$FILE_OUT' --decrypt '$FILE_IN'"
        eval $cmd
    ;;

    *)
        echo ""
        echo "SYNTAX: $0 (encrypt|decrypt) <filename> <dirname>"
        echo ""
        echo "<filename>: Use %n"
        echo "<dirname>: Use %d"
        echo ""
        sleep 5
    ;;
esac
Not beautiful, but effective :)

2) Decrypt:
Add the following custom action in Thunar:

Code: Select all

xterm -iconic -e /usr/bin/thunar-gpg decrypt %n %d
For encryption, I want to figure out a nice way of selecting the "recipient" from the GUI...
Jumping out of an airplane is not a basic instinct. Neither is breathing underwater. But put the two together and you're traveling through space!
User avatar
^rooker
Site Admin
Posts: 1481
Joined: Fri Aug 29, 2003 8:39 pm

Re: Thunar & GPG: context menu

Post by ^rooker »

NOTE: there might be troubles with files if they have whitespace characters (e.g. space) in their filename.
Jumping out of an airplane is not a basic instinct. Neither is breathing underwater. But put the two together and you're traveling through space!
Post Reply