2012-03-15 23:52:06 +00:00
|
|
|
local M = {}
|
2013-04-13 15:17:09 +00:00
|
|
|
local conf = conf
|
2013-05-01 22:25:52 +00:00
|
|
|
local awful = awful
|
|
|
|
local log = log
|
2012-03-15 23:52:06 +00:00
|
|
|
|
|
|
|
-- local functions
|
2013-05-01 22:25:52 +00:00
|
|
|
local dmenu, mpc_play_search, notify, mpc
|
2012-03-15 23:52:06 +00:00
|
|
|
|
|
|
|
local defaults = {}
|
|
|
|
local settings = {}
|
|
|
|
|
|
|
|
defaults.replace_on_search = true
|
|
|
|
|
|
|
|
for key, value in pairs(defaults) do
|
|
|
|
settings[key] = value
|
|
|
|
end
|
|
|
|
|
2013-05-01 22:25:52 +00:00
|
|
|
mpc = function(command)
|
|
|
|
awful.util.spawn("mpc " .. command)
|
2012-03-15 23:52:06 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
-- {{{ mpd.ctrl submodule
|
|
|
|
|
|
|
|
M.ctrl = {}
|
|
|
|
|
|
|
|
M.ctrl.toggle = function ()
|
2013-05-01 22:25:52 +00:00
|
|
|
mpc("toggle")
|
2012-03-15 23:52:06 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
M.ctrl.play = function ()
|
2013-05-01 22:25:52 +00:00
|
|
|
mpc("play")
|
2012-03-15 23:52:06 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
M.ctrl.pause = function ()
|
2013-05-01 22:25:52 +00:00
|
|
|
mpc("pause")
|
2012-03-15 23:52:06 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
M.ctrl.next = function ()
|
2013-05-01 22:25:52 +00:00
|
|
|
mpc("next")
|
2012-03-15 23:52:06 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
M.ctrl.prev = function ()
|
2013-05-01 22:25:52 +00:00
|
|
|
mpc("prev")
|
2012-03-15 23:52:06 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
-- }}}
|
|
|
|
|
|
|
|
-- {{{ mpd.prompt submodule
|
|
|
|
|
2013-04-13 15:17:09 +00:00
|
|
|
local clear_before = conf.mpd_prompt_clear_before == nil and
|
2012-03-15 23:52:06 +00:00
|
|
|
true or
|
2013-04-13 15:17:09 +00:00
|
|
|
conf.mpd_prompt_clear_before
|
2012-03-15 23:52:06 +00:00
|
|
|
|
|
|
|
M.prompt = {}
|
|
|
|
|
|
|
|
M.prompt.artist = function()
|
2013-05-01 22:25:52 +00:00
|
|
|
dmenu("-a")
|
2012-03-15 23:52:06 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
M.prompt.album = function()
|
2013-05-01 22:25:52 +00:00
|
|
|
dmenu("-a -b")
|
2012-03-15 23:52:06 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
M.prompt.title = function()
|
2013-05-01 22:25:52 +00:00
|
|
|
dmenu("-a -b -t")
|
2012-03-15 23:52:06 +00:00
|
|
|
end
|
|
|
|
M.prompt.title = title
|
|
|
|
|
2013-05-01 22:25:52 +00:00
|
|
|
function dmenu(opts)
|
|
|
|
awful.util.spawn("dmpc " .. (clear_before and "-r" or "-R") .. " " .. opts)
|
|
|
|
end
|
|
|
|
|
2012-03-15 23:52:06 +00:00
|
|
|
M.prompt.replace_on_search = function(bool)
|
|
|
|
clear_before = bool
|
|
|
|
end
|
|
|
|
|
|
|
|
M.prompt.toggle_replace_on_search = function()
|
|
|
|
clear_before = not clear_before
|
|
|
|
notify("MPD prompts now " ..(
|
|
|
|
clear_before and "replace" or "add to"
|
|
|
|
).. " the playlist")
|
|
|
|
end
|
|
|
|
|
|
|
|
function mpc_play_search(s)
|
2013-05-01 22:25:52 +00:00
|
|
|
notify("Found " .. (s) .. " matches");
|
2012-03-15 23:52:06 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
-- }}}
|
|
|
|
|
|
|
|
-- {{{ notify wrapper
|
|
|
|
notify = function(stext)
|
|
|
|
if not (naughty == nil) then
|
|
|
|
naughty.notify({
|
|
|
|
text= stext
|
|
|
|
})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
--}}}
|
|
|
|
|
|
|
|
return M
|
|
|
|
|
|
|
|
-- vim: set fenc=utf-8 tw=80 foldmethod=marker :
|