I'd like to change my webcam's exposure-time & gain... using something like v4l2-ctl -d /dev/video2 -c gain=15.

As far I searched, the keybindings for mpv is located/configured at ~/.config/mpv/input.conf. However, I couldn't find anywhere on internet "How to execute external shell scripts from mpv's keybindings". Is this possible?

  • Why is mpv relevant? Didn't you say all you want is to assign a command to a keyboard shortcut?
    – terdon
    Commented May 5, 2021 at 15:06
  • I intend this to use on different distros with different DEs. If I get it configure on mpv, then I don't have to configure it on each desktop environment (I suppose each one is different than the other). Instead, I just copy one mpv config file.
    – Garid Z.
    Commented May 5, 2021 at 16:56
  • 1
    But how is mpv relevant here? You are showing us a command called v4l2-ctl. What does this have to do with mpv? Are you maybe looking for something like xkeybinds? Have a look at my answer here: Shortcut keys that are independent to keyboard layout. Does that do what you need? You can still copy the ~/.xbindkeysrc file anywhere you want.
    – terdon
    Commented May 5, 2021 at 17:05

1 Answer 1


Use the run command. Add for example this line to ~/.config/mpv/input.conf if you want to copy the current playback position to your Wayland clipboard when you press y:

y run "/bin/sh" "-c" "printf %s ${=time-pos} | wl-copy"

See also § Command interface in the manual.

However, I agree with terdon that you don't need mpv in this case.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .