Samuel Prevost
Samuel Prevost

Reputation: 1124

How to pause VLC from the command line

I use i3wm as my window manager and I want to add a binding to play/pause, next, prev and stop VLC. However, unlike MPV, VLC doesn't have built-in CLI control when the VLC process is already running externally.

Upvotes: 5

Views: 3710

Answers (3)

chinmay_manas
chinmay_manas

Reputation: 116

I'm using playerctl for controlling any playback settings

# Media player controls
bindsym XF86AudioPlay exec playerctl play-pause
#bindsym XF86AudioPause exec playerctl pause
bindsym XF86AudioNext exec playerctl next
bindsym XF86AudioPrev exec playerctl previous

But, if two applications are using audio at the same time, which one will respond to playerctl, is unknown.

Upvotes: 2

Samuel Prevost
Samuel Prevost

Reputation: 1124

I found this lovely Reddit comment answering than need for play/pause, and through trial and error I found how to also stop/prev and next:

bindsym XF86AudioNext exec dbus-send --type=method_call \
        --dest=org.mpris.MediaPlayer2.vlc \
        /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next

bindsym XF86AudioPrev exec dbus-send --type=method_call \
        --dest=org.mpris.MediaPlayer2.vlc \
        /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous

bindsym XF86AudioPlay exec dbus-send --type=method_call \
        --dest=org.mpris.MediaPlayer2.vlc \
        /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause

bindsym XF86AudioStop exec dbus-send --type=method_call \
        --dest=org.mpris.MediaPlayer2.vlc \
        /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Stop

EDIT: Using playerctl like Antoine mentionned makes this more straightforward:

bindsym XF86AudioNext exec playerctl next

bindsym XF86AudioPrev exec playerctl previous

bindsym XF86AudioPlay exec playerctl play

bindsym XF86AudioStop exec playerctl pause

Upvotes: 7

Antoine
Antoine

Reputation: 176

Would installing playerctl work, alternatively?

Upvotes: 5

Related Questions