One reason why I like Linux and its ecosystem is that software is mostly scriptable. If it does not do what I want it to do, there’s usually a way to extend it. While writing this post, I’m going through my collection of photos to select some that I want to print.

In Windows I would probably do this by going through the pictures in an image viewer on one half of the screen and selecting the files in a file browser on the other half of the screen. The same approach could of course also be used in Linux, but I usually don’t use a file browser (ranger is still on my list of software to learn).

To look at images I use the image viewer sxiv - and sxiv can be scripted! You can put an executable in $HOME/.config/sxiv/exec/key-handler. When you press the external key-handler command (Ctrl+x by default) plus a follow-up key press, sxiv will pass the follow-up key press as first argument to the executable and one or multiple selected file paths to stdin.

To copy files on key press I wrote the following script:

#!/bin/sh

case "$1" in
"C-s")      while read file; do cp "$file" "$HOME/photo-selection/" & done ;;
esac

Now I can go through all pictures in sxiv and press Ctrl+x Ctrl+s to quickly select photos for printing.

Plus, there are probably infinite possibilities of what else can be done: You could delete pictures on key press, set a rating in your image management software (if that one also allows scripting), send them to your printer, upload them to a server and more. Even complex actions can be thought of, for example on key press the image could be resized to the right width for my blog, it could be automatically moved into the assets folder of Jekyll and an image reference could be added to the latest draft. All with (almost) a single key press.

I do not maintain a comments section. If you have any questions or comments regarding my posts, please do not hesitate to send me an e-mail to blog@stefan-koch.name.