-
Notifications
You must be signed in to change notification settings - Fork 2
Copy subtitles with mpv
Eduardo edited this page Sep 3, 2020
·
5 revisions
Sometimes it might be convenient to copy and paste the subtitles appearing on screen. mpv
is a very powerful and light media player that supports interaction with subtitle text via its variable sub-text
.
The file ~/.config/mpv/input.conf
stores the player's keybindings, so we can add the following line to copy subtitles to the primary selection (middle click to paste) with Ctrl+s
.
Ctrl+s run "/bin/sh" "-c" "echo \"${sub-text}\" | tr -d '\n' | xclip -selection primary && notify-send \"Copied text to primary seletction\""
Or use the following to copy with Ctrl+Shift+S
to clipboard and and paste with Ctrl + v
.
Ctrl+Shift+S run "/bin/sh" "-c" "echo \"${sub-text}\" | tr -d '\n' | xclip -selection clipboard && notify-send \"Copied text to clipboard\""
Quick explanation:
-
xclip
is copying, but you may change it to your preferred clipboard manager, likexsel
. -
tr -d '\n'
is used to remove the line break character, merging multiple lines in one. -
notify-send
makes a notification pop-up if there is a notification daemon running and we managed to copy successfuly
Now, combined with record
and printscreen
, it's possible to extract audio, picture and text very quickly.