Merge pull request #362 from augustogunsch/cmus_functions

Cmus functions
This commit is contained in:
streetturtle 2022-07-16 20:48:05 -04:00 committed by GitHub
commit 7467480c58
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 6 deletions

View file

@ -31,10 +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 = "play/pause cmus", group = "custom"}),
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

@ -96,14 +96,43 @@ local function worker(user_args)
end
end
function cmus_widget:play_pause()
spawn("cmus-remote -u")
function cmus_widget:update()
spawn.easy_async("cmus-remote -Q",
function(stdout, _, _, code)
update_widget(cmus_widget.widget, stdout, _, _, code)
end)
end
function cmus_widget:play_pause()
spawn("cmus-remote -u")
cmus_widget.update()
end
function cmus_widget:pause()
spawn("cmus-remote -U")
cmus_widget.update()
end
function cmus_widget:play()
spawn("cmus-remote -p")
cmus_widget.update()
end
function cmus_widget:next_track()
spawn("cmus-remote -n")
cmus_widget.update()
end
function cmus_widget:prev_track()
spawn("cmus-remote -r")
cmus_widget.update()
end
function cmus_widget:stop()
spawn("cmus-remote -s")
cmus_widget.update()
end
cmus_widget.widget:buttons(
awful.util.table.join(
awful.button({}, 1, function() cmus_widget:play_pause() end)