我使用 i3wm 作为我的窗口管理器,我想添加一个播放/暂停、下一个、上一个和停止 VLC 的绑定。然而,与 MPV 不同的是,当 VLC 进程已经在外部运行时,VLC 没有内置 CLI 控制。
我发现这个可爱的 Reddit 评论回答了不需要播放/暂停的问题,通过反复试验,我发现了如何停止/上一个和下一个:
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
Run Code Online (Sandbox Code Playgroud)
编辑:playerctl像安东尼提到的那样使用使得这更简单:
bindsym XF86AudioNext exec playerctl next
bindsym XF86AudioPrev exec playerctl previous
bindsym XF86AudioPlay exec playerctl play
bindsym XF86AudioStop exec playerctl pause
Run Code Online (Sandbox Code Playgroud)