6

Is there a way in which I can bind a keypress to a custom script (say a bash script) in feh? From the manual I have found out through ~/.config/feh/keys I can reconfigure keys, but as far as I know the commands should be predefined feh commands. Is there a way around this?

Particularly, what I want to do is capture the filename, when I press a particular key, and then run more operations on this file (or just copy the filename somewhere, if need be). Any options to get this done?

user
  • 915
  • 7
  • 27
  • 38

1 Answers1

8

Use the

--actionN [flag]action 

option. Where N can be 1 to 9. If flag is ; then feh does not load next image after action is done. Optionally -A or --action for 0 key which is also bound to Enter.

Example 1:

feh --action1 "echo %n" *.png

When you press 1 action will be executed, in this case simply echoing the file name. The action will be executed by /bin/sh. Check out FORMAT SPECIFIERS for other image information.

Example 2:

feh --action1 ";~/some_script $PWD/%F" *.png

When 1 is pressed the script ~/some_script are called with argument of file name and path. As action is preceded by ;, feh will not load next image on completion of command.


Optionally you can also unbind the number keys and bind the actions action_0 ... action_1 to other keys.

Runium
  • 28,133
  • 5
  • 50
  • 71