WIP: Somewm migration

This commit is contained in:
Alexander Gehrke 2026-08-12 18:09:07 +02:00
parent f5caff6684
commit ce56320097
17 changed files with 342 additions and 238 deletions

37
mpd.lua
View file

@ -13,11 +13,11 @@ defaults.host = "127.0.0.1"
defaults.port = "6600"
for key, value in pairs(defaults) do
settings[key] = value
settings[key] = value
end
for key, value in pairs(conf.mpd) do
settings[key] = value
settings[key] = value
end
-- {{{ local helpers
@ -26,14 +26,22 @@ local function mpc(command)
end
local function dmenu(opts)
log.spawn("dmpc -h " .. settings.host .. " -p " .. settings.port .. " " ..
(settings.replace_on_search and "-r" or "-R") .. " " .. opts)
log.spawn(
"dmpc -h "
.. settings.host
.. " -p "
.. settings.port
.. " "
.. (settings.replace_on_search and "-r" or "-R")
.. " "
.. opts
)
end
local function notify(stext)
if not (naughty == nil) then
naughty.notify({
text= stext
naughty.notification({
text = stext,
})
end
end
@ -45,28 +53,27 @@ M.set_server = function(host, port)
notify("Using mpd server " .. settings.host .. ":" .. settings.port)
end
-- {{{ mpd.ctrl submodule
M.ctrl = {}
M.ctrl.toggle = function ()
M.ctrl.toggle = function()
mpc("toggle")
end
M.ctrl.play = function ()
M.ctrl.play = function()
mpc("play")
end
M.ctrl.pause = function ()
M.ctrl.pause = function()
mpc("pause")
end
M.ctrl.next = function ()
M.ctrl.next = function()
mpc("next")
end
M.ctrl.prev = function ()
M.ctrl.prev = function()
mpc("prev")
end
@ -88,7 +95,6 @@ M.prompt.album = function()
dmenu("-A -b")
end
M.prompt.title = function()
dmenu("-A -b -t")
end
@ -103,14 +109,11 @@ end
M.prompt.toggle_replace_on_search = function()
settings.replace_on_search = not settings.replace_on_search
notify("MPD prompts now " ..(
settings.replace_on_search and "replace" or "add to"
).. " the playlist")
notify("MPD prompts now " .. (settings.replace_on_search and "replace" or "add to") .. " the playlist")
end
-- }}}
return M
-- vim: set fenc=utf-8 tw=80 foldmethod=marker :