Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

input.conf: bind Ctrl+v to play the path in the clipboard #15576

Merged
merged 1 commit into from
Dec 28, 2024

Conversation

guidocella
Copy link
Contributor

No description provided.

@sfan5
Copy link
Member

sfan5 commented Dec 26, 2024

personally I use the following script:

mp.add_key_binding("ctrl+v", "paste", function()
        local s = from_clipboard()
        s = s:match("^%s*(.-)%s*$")
        if s == "" then return end

        if mp.get_property_native("idle-active") then
                mp.commandv("loadfile", s)
        else
                mp.commandv("loadfile", s, "append")
                mp.osd_message("Appended " .. s)
        end
end)

I think this behavior would be useful

Copy link

github-actions bot commented Dec 26, 2024

Download the artifacts for this pull request:

Windows
macOS

@guidocella
Copy link
Contributor Author

Isn't that just loadfile ... append-play? For trimming, if you copy a file from a file explorer or copy a url from the context menu or address bar it's not gonna have leading or trailing spaces so I don't think it's worth adding a script just for that.

@sfan5
Copy link
Member

sfan5 commented Dec 26, 2024

Isn't that just loadfile ... append-play?

I guess. Except the visual feedback.

@guidocella
Copy link
Contributor Author

guidocella commented Dec 26, 2024

Changed to append-play. If you use --osd-playing-msg=${media-title} you do already get a visual feedback, and if you show-text ${clipboard/text} in the binding it is shown for an instant and quickly replaced by --osd-playing-msg which looks bad.

Edit: actually even in this case we should show a message because the path can be a URL that loads slowly.

@guidocella
Copy link
Contributor Author

Nevermind, with append-play we need to show something when appending to the playlist without playing immediately, so added show-text "Appended ${clipboard/text}".

@guidocella guidocella force-pushed the paste branch 2 times, most recently from 98d8a23 to fdc045d Compare December 26, 2024 15:34
@mrfragger
Copy link

Nevermind, with append-play we need to show something when appending to the playlist without playing immediately, so added show-text "Appended ${clipboard/text}".

copy-paste-url.lua works by just pasting a URL and intermediately playing it if there is nothing playing. If something is playing it appends it to the playlist.

uosc doesn't do that instead it has various functions...I wanted to keep the same behavior as copy-paste-url.lua so I have a shortcut after updating uosc each time to change behavior to just add pasted URL immediately.

# run /bin/bash -c "cd ~/.config/mpv/scripts/uosc; cat main.lua | sed \"s/playlist-count') > 1/playlist-count') > 0/g\" > mainnew.lua; rm main.lua; mv mainnew.lua main.lua"; show-text "sets playlist-count > 0 rather than > 1 so it'll play video right away rather than just adding to playlist - quits mpv"; quit #! [Utilities] > [Advanced] > After updating uosc fix playlist-count 0 not 1, quits mpv

@guidocella
Copy link
Contributor Author

You can just bind loadfile in input.conf with either append-play or no flags to get the respective behavior. There is no need to modify scripts now that we have the clipboard property.

etc/input.conf Outdated
@@ -171,6 +171,7 @@
#l ab-loop # set/clear A-B loop points
#L cycle-values loop-file "inf" "no" # toggle infinite looping
#ctrl+c quit 4
#Ctrl+v loadfile ${clipboard/text} append-play; show-text 'Appended ${clipboard/text}' # append the copied path
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Appended seems quite ambiguous. Appended where? To what?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So maybe even shorter +> ${clipboard/text}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change to + ${clipboard/text}, if the > was not a typo I don't understand what it represents.

DOCS/man/mpv.rst Outdated
@@ -242,6 +242,11 @@ F8
F9
Show the list of audio and subtitle streams.

Ctrl+v
Append the file or URL in the clipboard to the playlist. If nothing is
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

two spaces

@@ -171,6 +171,7 @@
#l ab-loop # set/clear A-B loop points
#L cycle-values loop-file "inf" "no" # toggle infinite looping
#ctrl+c quit 4
#Ctrl+v loadfile ${clipboard/text} append-play; show-text '+ ${clipboard/text}' # append the copied path
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

works, not sure the shortcut is the best, but works.

@kasper93 kasper93 merged commit a0f8d27 into mpv-player:master Dec 28, 2024
24 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants