mpd_prompt with modular bindings added
This commit is contained in:
		
							parent
							
								
									44668f7af9
								
							
						
					
					
						commit
						3f3552f4e2
					
				
					 3 changed files with 83 additions and 6 deletions
				
			
		
							
								
								
									
										10
									
								
								bindings.lua
									
										
									
									
									
								
							
							
						
						
									
										10
									
								
								bindings.lua
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -6,6 +6,7 @@ awful.button({ }, 5, awful.tag.viewprev)
 | 
			
		|||
))
 | 
			
		||||
-- }}}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
-- {{{ Key bindings
 | 
			
		||||
globalkeys = awful.util.table.join(
 | 
			
		||||
--{{{ Focus and Tags
 | 
			
		||||
| 
						 | 
				
			
			@ -88,16 +89,13 @@ globalkeys = awful.util.table.join(
 | 
			
		|||
    awful.key({ }, "XF86AudioLowerVolume",  function () awful.util.spawn("amixer set Master 2%-")end ),
 | 
			
		||||
    awful.key({ }, "XF86AudioRaiseVolume",  function () awful.util.spawn("amixer set Master 2%+")end ),
 | 
			
		||||
    awful.key({ }, "XF86AudioMute",         function () awful.util.spawn("amixer set Master toggle") end),
 | 
			
		||||
    awful.key({ modkey , "Shift" },   "m",  function () awful.util.spawn("mpdmenu -a") end),
 | 
			
		||||
    awful.key({ modkey , "Control" }, "m",  function () awful.util.spawn("mpdmenu -t") end),
 | 
			
		||||
    awful.key({ modkey },             "m",  function () awful.util.spawn("mpc toggle") end),
 | 
			
		||||
    awful.key({ modkey },             "n",  function () awful.util.spawn("mpc next") end),
 | 
			
		||||
    awful.key({ modkey , "Shift"},    "n",  function () awful.util.spawn("mpc prev") end),
 | 
			
		||||
    awful.key({ modkey },             ">",  function () awful.util.spawn("mpc next") end),
 | 
			
		||||
    awful.key({ modkey },             "<",  function () awful.util.spawn("mpc prev") end),
 | 
			
		||||
    awful.key({ modkey , "Shift" },   "m",  mpd_prompt.grabber),
 | 
			
		||||
    awful.key({ },        "XF86AudioPlay",  function () awful.util.spawn("mpc toggle") end),
 | 
			
		||||
    awful.key({ },        "XF86AudioNext",  function () awful.util.spawn("mpc next") end),
 | 
			
		||||
    awful.key({ },        "XF86AudioPrev",  function () awful.util.spawn("mpc prev") end),
 | 
			
		||||
    awful.key({ },        "XF86AudioStop",  function () awful.util.spawn("mpdmenu -a") end),
 | 
			
		||||
    awful.key({ modkey , "Control" }, "n",  function () awful.util.spawn("mpdmenu -j") end),
 | 
			
		||||
    awful.key({ modkey }, "`",  function () teardrop("urxvtc -e ncmpcpp","bottom","center", 0.99, 0.4)end ),
 | 
			
		||||
 | 
			
		||||
    --}}}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										78
									
								
								mpd_prompt.lua
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										78
									
								
								mpd_prompt.lua
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,78 @@
 | 
			
		|||
local awful     = awful
 | 
			
		||||
local obvious   = obvious
 | 
			
		||||
local naughty   = naughty
 | 
			
		||||
local keygrabber = keygrabber
 | 
			
		||||
local io = io
 | 
			
		||||
local pairs = pairs
 | 
			
		||||
 | 
			
		||||
local M = {}
 | 
			
		||||
 | 
			
		||||
local type = ""
 | 
			
		||||
local clear_before = true
 | 
			
		||||
 | 
			
		||||
local keymap = {}
 | 
			
		||||
 | 
			
		||||
local show,
 | 
			
		||||
	mpc_play_search
 | 
			
		||||
 | 
			
		||||
M.grabber = function()
 | 
			
		||||
	keygrabber.run(function(mod, key, event)
 | 
			
		||||
		if event == "release" then return true end
 | 
			
		||||
		keygrabber.stop()
 | 
			
		||||
		if keymap[key] then keymap[key]() end
 | 
			
		||||
		return true
 | 
			
		||||
	end)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
M.artist = function()
 | 
			
		||||
	type = "artist"
 | 
			
		||||
	show()
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
M.album = function()
 | 
			
		||||
	type = "album"
 | 
			
		||||
	show()
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
M.title = function()
 | 
			
		||||
	type = "title"
 | 
			
		||||
	show()
 | 
			
		||||
end
 | 
			
		||||
M.title = title
 | 
			
		||||
 | 
			
		||||
M.replace_on_search = function(bool)
 | 
			
		||||
	clear_before = bool
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
M.toggle_replace_on_search = function()
 | 
			
		||||
	clear_before = not clear_before
 | 
			
		||||
	if not (naughty == nil) then
 | 
			
		||||
		naughty.notify({
 | 
			
		||||
			text="MPD prompts now " ..(
 | 
			
		||||
			clear_before and "replace" or "add to"
 | 
			
		||||
			).. " the playlist"
 | 
			
		||||
		})
 | 
			
		||||
	end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function show()
 | 
			
		||||
	obvious.popup_run_prompt.set_prompt_string("Play ".. type .. ":")
 | 
			
		||||
	obvious.popup_run_prompt.set_run_function(mpc_play_search)
 | 
			
		||||
	obvious.popup_run_prompt.run_prompt()
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function mpc_play_search(s)
 | 
			
		||||
	if clear_before then awful.util.spawn("mpc clear") end
 | 
			
		||||
	awful.util.spawn_with_shell("mpc search ".. type .." '" .. s .. "' | mpc add")
 | 
			
		||||
	awful.util.spawn("mpc play");
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
keymap = {
 | 
			
		||||
    a = M.artist,
 | 
			
		||||
    A = M.album,
 | 
			
		||||
    t = M.title,
 | 
			
		||||
    r = M.toggle_replace_on_search
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
return M
 | 
			
		||||
							
								
								
									
										1
									
								
								rc.lua
									
										
									
									
									
								
							
							
						
						
									
										1
									
								
								rc.lua
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -10,6 +10,7 @@ require("obvious.popup_run_prompt")
 | 
			
		|||
require("vicious")
 | 
			
		||||
require("rodentbane.rodentbane")
 | 
			
		||||
require("aweswt")
 | 
			
		||||
mpd_prompt = require("mpd_prompt")
 | 
			
		||||
 | 
			
		||||
MY_PATH  = os.getenv("HOME") .. "/.config/awesome/"
 | 
			
		||||
WALLPATH = MY_PATH .. "walls/"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue