Add stop function

This commit is contained in:
Augusto Gunsch 2022-07-10 21:04:15 +02:00
parent 12cfe038f8
commit d9c689d733
2 changed files with 15 additions and 9 deletions

View File

@ -31,11 +31,12 @@ s.mytasklist, -- Middle widget
To improve responsiveness of the widget when playback is changed by a shortcut use corresponding methods of the widget:
```lua
awful.key({ modkey, "Shift" }, "p", function () cmus_widget:play_pause() end, {description = "toggle track", group = "cmus"}),
awful.key({ }, "XF86AudioPlay", function () cmus_widget:play() end, {description = "play track", group = "cmus"}),
awful.key({ }, "XF86AudioPause", function () cmus_widget:play() end, {description = "pause track", group = "cmus"}),
awful.key({ }, "XF86AudioNext", function () cmus_widget:next_track() end, {description = "next track", group = "cmus"}),
awful.key({ }, "XF86AudioPrev", function () cmus_widget:prev_track() end, {description = "previous track", group = "cmus"}),
awful.key({ modkey, "Shift" }, "p", function () cmus_widget:play_pause() end, {description = "toggle track", group = "cmus"}),
awful.key({ }, "XF86AudioPlay", function () cmus_widget:play() end, {description = "play track", group = "cmus"}),
awful.key({ }, "XF86AudioPause", function () cmus_widget:play() end, {description = "pause track", group = "cmus"}),
awful.key({ }, "XF86AudioNext", function () cmus_widget:next_track() end, {description = "next track", group = "cmus"}),
awful.key({ }, "XF86AudioPrev", function () cmus_widget:prev_track() end, {description = "previous track", group = "cmus"}),
awful.key({ }, "XF86AudioStop", function () cmus_widget:stop() end, {description = "stop cmus", group = "cmus"}),
```
## Customization

View File

@ -109,22 +109,27 @@ local function worker(user_args)
end
function cmus_widget:pause()
spawn("cmus-remote -u")
spawn("cmus-remote -U")
cmus_widget.update()
end
function cmus_widget:play()
spawn("cmus-remote -u")
spawn("cmus-remote -p")
cmus_widget.update()
end
function cmus_widget:next_track()
spawn("cmus-remote -u")
spawn("cmus-remote -n")
cmus_widget.update()
end
function cmus_widget:prev_track()
spawn("cmus-remote -u")
spawn("cmus-remote -p")
cmus_widget.update()
end
function cmus_widget:stop()
spawn("cmus-remote -s")
cmus_widget.update()
end