Skip to content

feat: add play_pause left click command#682

Merged
Samillion merged 1 commit intoSamillion:mainfrom
Keith94:playpause_command
Apr 19, 2026
Merged

feat: add play_pause left click command#682
Samillion merged 1 commit intoSamillion:mainfrom
Keith94:playpause_command

Conversation

@Keith94
Copy link
Copy Markdown
Contributor

@Keith94 Keith94 commented Apr 18, 2026

Makes left click customizable during regular playback to match upstream mpv.

This PR would allow adding extra things on user's side; for example a script message to show a pause indicator:

play_pause_mbtn_left_command=script-message toggle-pause-indicator; cycle pause

For more context, in my setup I try to avoid showing an indicator when seeking or frame stepping etc so I rely on this script message to show it in specific ways.

@Samillion
Copy link
Copy Markdown
Owner

Samillion commented Apr 18, 2026

I'm concerned about one scenario conflict.

  1. Click (press down) play_pause_mbtn_left_command=cycle pause
  2. Unhold click (press up) mp.command(user_opts.play_pause_mbtn_left_command)
  3. Possible double cycle?

Since _down is being defined, is step 2. still needed?

    ne.eventresponder["mbtn_left_up"] = function ()
        if state.eof_reached then
            mp.commandv("seek", 0, "absolute-percent")
            mp.commandv("set", "pause", "no")
-       else
-           mp.command(user_opts.play_pause_mbtn_left_command)
        end
    end

@Keith94
Copy link
Copy Markdown
Contributor Author

Keith94 commented Apr 19, 2026

If I remove those lines (else and mp.command) it doesn't work properly. I don't see any conflict here unless I'm wrong.

@Samillion
Copy link
Copy Markdown
Owner

But it does override, no? (conflict)

Let me show how to test what I mean, I'm bad at wording things.

In modernz.conf:

play_pause_mbtn_left_command=show-text "test"

Revert back the mp.commandv() but keep bind_buttons() where it is:

    bind_buttons("play_pause") -- dead code. always overridden by event below it
    ne.eventresponder["mbtn_left_up"] = function ()
        if state.eof_reached then
            mp.commandv("seek", 0, "absolute-percent")
            mp.commandv("set", "pause", "no")
        else
            mp.commandv("cycle", "pause")
        end
    end

See what I mean?

@Samillion
Copy link
Copy Markdown
Owner

Hmmm. It works though. It's not actually deadcode.

It'll handle other clicks, and it's overridden where needed

bind_buttons("play_pause") -- mbtn_right and shift+mbtn_left (mid) and mbtn_left_up is overridden below
ne.eventresponder["mbtn_left_up"] = function ()
    if state.eof_reached then
        mp.commandv("seek", 0, "absolute-percent")
        mp.commandv("set", "pause", "no")
    else
        mp.command(user_opts.play_pause_mbtn_left_command) -- ensures no conflict
    end
end

@Samillion
Copy link
Copy Markdown
Owner

Thank you very much.

Merging.

@Samillion Samillion merged commit 67cb95e into Samillion:main Apr 19, 2026
@Keith94 Keith94 deleted the playpause_command branch April 19, 2026 02:39
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.

2 participants