Thunar hashing in the context menu

Since the last update gtkhash and the addon for thunar are dropped from the repos and moved to aur. There are gui alternatives, but they are huge and bloated. So, for those users who do not use AUR and do not like to type filenames in the command line, here is a script for a Thunar custom action that appears in the context menu:

xfce4-terminal --hold -e "/home/teo/.local/bin/hasher.sh %f"

Note that you cannot use this on multiple files or directories.

And the script itself (adapt the filepath above)

#!/bin/bash
echo -n "sha256: "; rhash --sha256 $1 
echo -n "md5: "; rhash -M $1

Note that you need to install rhash of course. With man rhash you can see what hashes are supported and add something if needed, i just added the 2 that i use the most - sha256 and md5

Another option, using the build in sha256 command without external script or package will be

xfce4-terminal --hold -e "sha256sum %F"

For example, if you have a .sig file containing the checksum, you can add the following custom action

xfce4-terminal --hold -e "sha256sum -c %F"

with the condition to show on *sig files. So that you rightclick the .sig file and it tells you if the check passes.

Nice. 8)

Scripting capabilities is why I still use Nemo over Dolphin as my file manager. Nemo has the following environment variables you can interrogate using whatever language you want:

'NEMO_SCRIPT_SELECTED_FILE_PATHS': ''
'NEMO_SCRIPT_SELECTED_URIS': ''
'NEMO_SCRIPT_CURRENT_URI': ''
'NEMO_SCRIPT_WINDOW_GEOMETRY': ''
'NEMO_SCRIPT_NEXT_PANE_SELECTED_FILE_PATHS': ''
'NEMO_SCRIPT_NEXT_PANE_SELECTED_URIS': ''
'NEMO_SCRIPT_NEXT_PANE_CURRENT_URI': ''

For example, in Python:

import sys

for FILE in sys.environ['NEMO_SCRIPT_SELECTED_FILE_PATHS']:
    do_something_with(FILE)