awesomewm/mpd.lua

104 lines
1.5 KiB
Lua
Raw Normal View History

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
-- local functions
2013-05-01 22:25:52 +00:00
local dmenu, mpc_play_search, notify, mpc
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)
end
-- {{{ mpd.ctrl submodule
M.ctrl = {}
M.ctrl.toggle = function ()
2013-05-01 22:25:52 +00:00
mpc("toggle")
end
M.ctrl.play = function ()
2013-05-01 22:25:52 +00:00
mpc("play")
end
M.ctrl.pause = function ()
2013-05-01 22:25:52 +00:00
mpc("pause")
end
M.ctrl.next = function ()
2013-05-01 22:25:52 +00:00
mpc("next")
end
M.ctrl.prev = function ()
2013-05-01 22:25:52 +00:00
mpc("prev")
end
-- }}}
-- {{{ mpd.prompt submodule
2013-04-13 15:17:09 +00:00
local clear_before = conf.mpd_prompt_clear_before == nil and
true or
2013-04-13 15:17:09 +00:00
conf.mpd_prompt_clear_before
M.prompt = {}
M.prompt.artist = function()
2013-05-01 22:25:52 +00:00
dmenu("-a")
end
M.prompt.album = function()
2013-05-01 22:25:52 +00:00
dmenu("-a -b")
end
M.prompt.title = function()
2013-05-01 22:25:52 +00:00
dmenu("-a -b -t")
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
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");
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 :