Add mpd host selection menu
This commit is contained in:
parent
890bdf1866
commit
a96cfbb8a1
15
bindings.lua
15
bindings.lua
|
@ -35,20 +35,31 @@ bindings.spawnf = spawnf
|
||||||
|
|
||||||
conf.cmd.run = conf.cmd.run or spawnf("dmenu_run")
|
conf.cmd.run = conf.cmd.run or spawnf("dmenu_run")
|
||||||
|
|
||||||
|
local function mpdserver(host)
|
||||||
|
return function() mpd.set_server(host, "6600") end
|
||||||
|
end
|
||||||
|
|
||||||
|
mpdhosts = {
|
||||||
|
n = { func = mpdserver("nas.fritz.box"), desc = "NAS" },
|
||||||
|
b = { func = mpdserver("berryhorst.fritz.box"), desc = "Berry" },
|
||||||
|
l = { func = mpdserver("127.0.0.1"), desc = "Local" }
|
||||||
|
}
|
||||||
|
|
||||||
mpdmap = {
|
mpdmap = {
|
||||||
m = { func = mpd.ctrl.toggle, desc = "Toggle" },
|
m = { func = mpd.ctrl.toggle, desc = "Toggle" },
|
||||||
n = { func = mpd.ctrl.next, desc = "Next" },
|
n = { func = mpd.ctrl.next, desc = "Next" },
|
||||||
N = { func = mpd.ctrl.prev, desc = "Prev" },
|
N = { func = mpd.ctrl.prev, desc = "Prev" },
|
||||||
s = { func = spawnf("mpd"), desc = "start MPD" },
|
s = { func = spawnf("mpd"), desc = "start MPD" },
|
||||||
S = { func = spawnf("mpd --kill"), desc = "kill MPD" },
|
S = { func = spawnf("mpd --kill"), desc = "kill MPD" },
|
||||||
g = { func = spawnf(conf.cmd.mpd_client), desc = "Gmpc" }
|
g = { func = spawnf(conf.cmd.mpd_client), desc = "Gmpc" },
|
||||||
}
|
}
|
||||||
|
|
||||||
mpdpromts = {
|
mpdpromts = {
|
||||||
a = { func = mpd.prompt.artist, desc = "artist" },
|
a = { func = mpd.prompt.artist, desc = "artist" },
|
||||||
b = { func = mpd.prompt.album, desc = "album" },
|
b = { func = mpd.prompt.album, desc = "album" },
|
||||||
t = { func = mpd.prompt.title, desc = "title" },
|
t = { func = mpd.prompt.title, desc = "title" },
|
||||||
r = { func = mpd.prompt.toggle_replace_on_search, desc = "toggle replacing" }
|
r = { func = mpd.prompt.toggle_replace_on_search, desc = "toggle replacing" },
|
||||||
|
h = { func = mb.grabf(mpdhosts, "Select MPD host"), desc = "Change host" }
|
||||||
}
|
}
|
||||||
|
|
||||||
progmap = {
|
progmap = {
|
||||||
|
|
55
mpd.lua
55
mpd.lua
|
@ -12,15 +12,43 @@ local defaults = {}
|
||||||
local settings = {}
|
local settings = {}
|
||||||
|
|
||||||
defaults.replace_on_search = true
|
defaults.replace_on_search = true
|
||||||
|
defaults.host = "127.0.0.1"
|
||||||
|
defaults.port = "6600"
|
||||||
|
|
||||||
for key, value in pairs(defaults) do
|
for key, value in pairs(defaults) do
|
||||||
settings[key] = value
|
settings[key] = value
|
||||||
end
|
end
|
||||||
|
|
||||||
mpc = function(command)
|
for key, value in pairs(conf.mpd) do
|
||||||
awful.util.spawn("mpc " .. command)
|
settings[key] = value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- {{{ local helpers
|
||||||
|
local function mpc(command)
|
||||||
|
log.spawn("mpc -h " .. settings.host .. " -p " .. settings.port .. " " .. command)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function dmenu(opts)
|
||||||
|
log.spawn("dmpc -h " .. settings.host .. " -p " .. settings.port .. " " ..
|
||||||
|
(clear_before and "-r" or "-R") .. " " .. opts)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function notify(stext)
|
||||||
|
if not (naughty == nil) then
|
||||||
|
naughty.notify({
|
||||||
|
text= stext
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
--}}}
|
||||||
|
|
||||||
|
M.set_server = function(host, port)
|
||||||
|
settings.host = host
|
||||||
|
settings.port = port
|
||||||
|
notify("Using mpd server " .. settings.host .. ":" .. settings.port)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
-- {{{ mpd.ctrl submodule
|
-- {{{ mpd.ctrl submodule
|
||||||
|
|
||||||
M.ctrl = {}
|
M.ctrl = {}
|
||||||
|
@ -49,10 +77,6 @@ end
|
||||||
|
|
||||||
-- {{{ mpd.prompt submodule
|
-- {{{ mpd.prompt submodule
|
||||||
|
|
||||||
local clear_before = conf.mpd_prompt_clear_before == nil and
|
|
||||||
true or
|
|
||||||
conf.mpd_prompt_clear_before
|
|
||||||
|
|
||||||
M.prompt = {}
|
M.prompt = {}
|
||||||
|
|
||||||
M.prompt.artist = function()
|
M.prompt.artist = function()
|
||||||
|
@ -69,32 +93,19 @@ M.prompt.title = function()
|
||||||
end
|
end
|
||||||
M.prompt.title = title
|
M.prompt.title = title
|
||||||
|
|
||||||
function dmenu(opts)
|
|
||||||
awful.util.spawn("dmpc " .. (clear_before and "-r" or "-R") .. " " .. opts)
|
|
||||||
end
|
|
||||||
|
|
||||||
M.prompt.replace_on_search = function(bool)
|
M.prompt.replace_on_search = function(bool)
|
||||||
clear_before = bool
|
settings.replace_on_search = bool
|
||||||
end
|
end
|
||||||
|
|
||||||
M.prompt.toggle_replace_on_search = function()
|
M.prompt.toggle_replace_on_search = function()
|
||||||
clear_before = not clear_before
|
settings.replace_on_search = not settings.replace_on_search
|
||||||
notify("MPD prompts now " ..(
|
notify("MPD prompts now " ..(
|
||||||
clear_before and "replace" or "add to"
|
settings.replace_on_search and "replace" or "add to"
|
||||||
).. " the playlist")
|
).. " the playlist")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
-- {{{ notify wrapper
|
|
||||||
notify = function(stext)
|
|
||||||
if not (naughty == nil) then
|
|
||||||
naughty.notify({
|
|
||||||
text= stext
|
|
||||||
})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
--}}}
|
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue