Migrate modalbind to external repo
This commit is contained in:
parent
38bb081350
commit
ba1c036adf
6
.gitmodules
vendored
6
.gitmodules
vendored
|
@ -1,6 +1,6 @@
|
||||||
[submodule "vicious"]
|
[submodule "vicious"]
|
||||||
path = vicious
|
path = vicious
|
||||||
url = https://github.com/Mic92/vicious
|
url = https://github.com/Mic92/vicious
|
||||||
[submodule "rodentbane"]
|
[submodule "modalbind"]
|
||||||
path = rodentbane
|
path = modalbind
|
||||||
url = git://git.glacicle.com/awesome/rodentbane.git
|
url = https://github.com/crater2150/awesome-modalbind.git
|
||||||
|
|
1
modalbind
Submodule
1
modalbind
Submodule
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit fc14b4e164d2fb25739aae0f054c955320d2ef5b
|
|
@ -20,54 +20,47 @@ local function mpdserver(host)
|
||||||
end
|
end
|
||||||
|
|
||||||
local mpdhosts = {
|
local mpdhosts = {
|
||||||
n = { func = mpdserver("nas"), desc = "NAS" },
|
{"n", mpdserver("nas"), "NAS" },
|
||||||
b = { func = mpdserver("berryhorst"), desc = "Berry" },
|
{"b", mpdserver("berryhorst"), "Berry" },
|
||||||
l = { func = mpdserver("127.0.0.1"), desc = "Local" }
|
{"l", mpdserver("127.0.0.1"), "Local" }
|
||||||
}
|
}
|
||||||
|
|
||||||
local mpdmap = {
|
local mpdmap = {
|
||||||
m = { func = mpd.ctrl.toggle, desc = "Toggle" },
|
{"m", mpd.ctrl.toggle, "Toggle" },
|
||||||
n = { func = mpd.ctrl.next, desc = "Next" },
|
{"n", mpd.ctrl.next, "Next" },
|
||||||
N = { func = mpd.ctrl.prev, desc = "Prev" },
|
{"N", mpd.ctrl.prev, "Prev" },
|
||||||
s = { func = binder.spawn("mpd"), desc = "start MPD" },
|
{"s", binder.spawn("mpd"), "start MPD" },
|
||||||
S = { func = binder.spawn("mpd --kill"), desc = "kill MPD" },
|
{"S", binder.spawn("mpd --kill"), "kill MPD" },
|
||||||
g = { func = binder.spawn(conf.cmd.mpd_client), desc = "Gmpc" },
|
{"g", binder.spawn(conf.cmd.mpd_client), "Gmpc" },
|
||||||
}
|
}
|
||||||
|
|
||||||
local mpdpromts = {
|
local mpdpromts = {
|
||||||
a = { func = mpd.prompt.artist, desc = "artist" },
|
{"a", mpd.prompt.artist, "artist" },
|
||||||
b = { func = mpd.prompt.album, desc = "album" },
|
{"b", mpd.prompt.album, "album" },
|
||||||
t = { func = mpd.prompt.title, desc = "title" },
|
{"t", mpd.prompt.title, "title" },
|
||||||
r = { func = mpd.prompt.toggle_replace_on_search, desc = "toggle replacing" },
|
{"r", mpd.prompt.toggle_replace_on_search, "toggle replacing" },
|
||||||
h = { func = mb.grabf(mpdhosts, "Select MPD host"), desc = "Change host" }
|
{"h", mb.grabf(mpdhosts, "Select MPD host"), "Change host" }
|
||||||
}
|
}
|
||||||
|
|
||||||
local progmap = {
|
local progmap = {
|
||||||
f = { func = binder.spawn(conf.cmd.browser), desc = "Browser" },
|
{"f", binder.spawn(conf.cmd.browser), "Browser" },
|
||||||
i = { func = binder.spawn(conf.cmd.im_client), desc = "IM Client" },
|
{"i", binder.spawn(conf.cmd.im_client), "IM Client" },
|
||||||
I = { func = binder.spawn(conf.cmd.irc_client), desc = "IRC" },
|
{"I", binder.spawn(conf.cmd.irc_client), "IRC" },
|
||||||
t = { func = binder.spawn("telegram-desktop"), desc = "Telegram" },
|
{"t", binder.spawn("telegram-desktop"), "Telegram" },
|
||||||
m = { func = binder.spawn(conf.cmd.mail_client), desc = "Mail" },
|
{"m", binder.spawn(conf.cmd.mail_client), "Mail" },
|
||||||
s = { func = binder.spawn("steam"), desc = "Steam" }
|
{"s", binder.spawn("steam"), "Steam" }
|
||||||
}
|
}
|
||||||
|
|
||||||
local docmap = {
|
local docmap = {
|
||||||
u = { func = binder.spawn("docopen ~/doc/uni pdf"), desc = "Uni-Dokumente" },
|
{"u", binder.spawn("docopen ~/doc/uni pdf"), "Uni-Dokumente" },
|
||||||
b = { func = binder.spawn("docopen ~/books pdf epub mobi txt lit html htm"), desc = "Bücher" },
|
{"b", binder.spawn("docopen ~/books pdf epub mobi txt lit html htm"), "Bücher" },
|
||||||
t = { func = binder.spawn("dmtexdoc"), desc = "Texdoc" },
|
{"t", binder.spawn("dmtexdoc"), "Texdoc" },
|
||||||
j = { func = binder.spawn("dmjavadoc"), desc = "Javadoc" }
|
{"j", binder.spawn("dmjavadoc"), "Javadoc" }
|
||||||
}
|
|
||||||
|
|
||||||
local reloadmap = {
|
|
||||||
r = { func = awesome.restart, desc = "Awesome, full restart" },
|
|
||||||
b = { func = function()
|
|
||||||
binder.add_bindings(require("mybindings"))
|
|
||||||
end, desc = "Bindings" },
|
|
||||||
}
|
}
|
||||||
|
|
||||||
--local calendarmap = {
|
--local calendarmap = {
|
||||||
-- o = { func = function() calendar:next() end, desc = "Next" },
|
-- o = { function() calendar:next() end, "Next" },
|
||||||
-- i = { func = function() calendar:prev() end, desc = "Prev" },
|
-- i = { function() calendar:prev() end, "Prev" },
|
||||||
-- onClose = function() calendar:hide() end
|
-- onClose = function() calendar:hide() end
|
||||||
--}
|
--}
|
||||||
|
|
||||||
|
@ -82,8 +75,6 @@ local myglobalkeys = awful.util.table.join(
|
||||||
awful.key({ modkey, "Shift" }, "m", mb.grabf(mpdpromts, "MPD - Search for")),
|
awful.key({ modkey, "Shift" }, "m", mb.grabf(mpdpromts, "MPD - Search for")),
|
||||||
awful.key({ modkey }, "c", mb.grabf(progmap, "Commands")),
|
awful.key({ modkey }, "c", mb.grabf(progmap, "Commands")),
|
||||||
awful.key({ modkey }, "d", mb.grabf(docmap, "Documents")),
|
awful.key({ modkey }, "d", mb.grabf(docmap, "Documents")),
|
||||||
|
|
||||||
awful.key({ modkey, "Control" }, "r", mb.grabf(reloadmap, "Reload")),
|
|
||||||
--}}}
|
--}}}
|
||||||
|
|
||||||
-- {{{ scratch drop
|
-- {{{ scratch drop
|
||||||
|
|
1
rc.lua
1
rc.lua
|
@ -56,6 +56,7 @@ end
|
||||||
-- {{{ Key bindings
|
-- {{{ Key bindings
|
||||||
|
|
||||||
binder = require("separable.binder")
|
binder = require("separable.binder")
|
||||||
|
binder.modal.set_location("bottom","left")
|
||||||
binder.modal.set_x_offset(18)
|
binder.modal.set_x_offset(18)
|
||||||
|
|
||||||
binder.add_default_bindings()
|
binder.add_default_bindings()
|
||||||
|
|
|
@ -3,7 +3,7 @@ local awful = require("awful")
|
||||||
local beautiful = beautiful
|
local beautiful = beautiful
|
||||||
|
|
||||||
local modkey = conf.modkey or "Mod4"
|
local modkey = conf.modkey or "Mod4"
|
||||||
local mb = require("separable.modalbind")
|
local mb = require("modalbind")
|
||||||
|
|
||||||
local globalkeys = {}
|
local globalkeys = {}
|
||||||
|
|
||||||
|
@ -33,22 +33,22 @@ conf.cmd.run = conf.cmd.run or spawnf("dmenu_run")
|
||||||
|
|
||||||
local function use_layout(layout) return function() awful.layout.set(layout) end end
|
local function use_layout(layout) return function() awful.layout.set(layout) end end
|
||||||
layoutmap = {
|
layoutmap = {
|
||||||
f = { func = use_layout(awful.layout.suit.fair), desc ="Fair" },
|
{"f", use_layout(awful.layout.suit.fair), "Fair" },
|
||||||
h = { func = use_layout(awful.layout.suit.fair.horizontal), desc ="Fair Horizontal" },
|
{"h", use_layout(awful.layout.suit.fair.horizontal), "Fair Horizontal" },
|
||||||
t = { func = use_layout(awful.layout.suit.tile), desc ="Tile" },
|
{"t", use_layout(awful.layout.suit.tile), "Tile" },
|
||||||
b = { func = use_layout(awful.layout.suit.tile.bottom), desc ="Tile Bottom" },
|
{"b", use_layout(awful.layout.suit.tile.bottom), "Tile Bottom" },
|
||||||
m = { func = use_layout(awful.layout.suit.max), desc ="Maximized" },
|
{"m", use_layout(awful.layout.suit.max), "Maximized" },
|
||||||
F = { func = use_layout(awful.layout.suit.max.fullscreen), desc ="Fullscreen" },
|
{"F", use_layout(awful.layout.suit.max.fullscreen), "Fullscreen" },
|
||||||
Space = { func = use_layout(awful.layout.suit.floating), desc ="Float" }
|
{"space", use_layout(awful.layout.suit.floating), "Float" }
|
||||||
}
|
}
|
||||||
|
|
||||||
layoutsettings = {
|
layoutsettings = {
|
||||||
l = { func = function () awful.tag.incmwfact( 0.05) end, desc = "Master bigger" },
|
{"h", function () awful.tag.incmwfact(-0.05) end, "Master smaller" },
|
||||||
h = { func = function () awful.tag.incmwfact(-0.05) end, desc = "Master smaller" },
|
{"l", function () awful.tag.incmwfact( 0.05) end, "Master bigger" },
|
||||||
H = { func = function () awful.tag.incnmaster( 1) end, desc = "More masters" },
|
{"H", function () awful.tag.incnmaster( 1) end, "More masters" },
|
||||||
L = { func = function () awful.tag.incnmaster(-1) end, desc = "Less masters" },
|
{"L", function () awful.tag.incnmaster(-1) end, "Less masters" },
|
||||||
c = { func = function () awful.tag.incncol( 1) end, desc = "More columns" },
|
{"c", function () awful.tag.incncol( 1) end, "More columns" },
|
||||||
C = { func = function () awful.tag.incncol(-1) end, desc = "Less columns" },
|
{"C", function () awful.tag.incncol(-1) end, "Less columns" },
|
||||||
}
|
}
|
||||||
|
|
||||||
local function screen_focus_wrapdir(dir)
|
local function screen_focus_wrapdir(dir)
|
||||||
|
@ -95,7 +95,7 @@ function screen_in_wrapdir(dir, _screen)
|
||||||
end
|
end
|
||||||
|
|
||||||
local default_bindings = awful.util.table.join(
|
local default_bindings = awful.util.table.join(
|
||||||
--awful.key({ modkey, "Control" }, "r", awesome.restart),
|
awful.key({ modkey, "Control" }, "r", awesome.restart),
|
||||||
awful.key({ modkey, "Shift" }, "q", awesome.quit),
|
awful.key({ modkey, "Shift" }, "q", awesome.quit),
|
||||||
awful.key({ modkey, }, "Return", spawnf(conf.cmd.terminal)),
|
awful.key({ modkey, }, "Return", spawnf(conf.cmd.terminal)),
|
||||||
|
|
||||||
|
|
|
@ -1,257 +0,0 @@
|
||||||
local modalbind = {}
|
|
||||||
local wibox = require("wibox")
|
|
||||||
local awful = require("awful")
|
|
||||||
local beautiful = require("beautiful")
|
|
||||||
local inited = false
|
|
||||||
local modewidget = {}
|
|
||||||
local modewibox = { screen = nil }
|
|
||||||
local nesting = 0
|
|
||||||
|
|
||||||
--local functions
|
|
||||||
|
|
||||||
local defaults = {}
|
|
||||||
|
|
||||||
defaults.opacity = 1.0
|
|
||||||
defaults.height = 22
|
|
||||||
defaults.border_width = 1
|
|
||||||
defaults.x_offset = 0
|
|
||||||
defaults.y_offset = 0
|
|
||||||
defaults.show_options = true
|
|
||||||
|
|
||||||
-- Clone the defaults for the used settings
|
|
||||||
local settings = {}
|
|
||||||
for key, value in pairs(defaults) do
|
|
||||||
settings[key] = value
|
|
||||||
end
|
|
||||||
|
|
||||||
local aliases = {}
|
|
||||||
aliases[" "] = "Space"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
local function getXOffset(s, position)
|
|
||||||
local offset = 0
|
|
||||||
if type(position) == "table" then
|
|
||||||
offset = position.x + s.geometry.x
|
|
||||||
elseif position == "topleft" or position == "bottomleft" then
|
|
||||||
offset = s.geometry.x
|
|
||||||
elseif position == "topright" or position == "bottomright" then
|
|
||||||
offset = s.geometry.x + s.geometry.width - modewibox[s].width
|
|
||||||
end
|
|
||||||
return offset + settings.x_offset
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
local function getYOffset(s,position)
|
|
||||||
local offset = 0
|
|
||||||
if type(position) == "table" then
|
|
||||||
offset = position.y + s.geometry.y
|
|
||||||
elseif position == "topleft" or position == "topright" then
|
|
||||||
offset = s.geometry.y
|
|
||||||
elseif position == "bottomleft" or position == "bottomright" then
|
|
||||||
offset = s.geometry.y + s.geometry.height - modewibox[s].height
|
|
||||||
end
|
|
||||||
return offset + settings.y_offset
|
|
||||||
end
|
|
||||||
|
|
||||||
local function set_default(s, position)
|
|
||||||
local minwidth, minheight = modewidget[s]:fit({dpi=96}, s.geometry.width,
|
|
||||||
s.geometry.height)
|
|
||||||
modewibox[s].width = minwidth + 1;
|
|
||||||
modewibox[s].height = math.max(settings.height, minheight)
|
|
||||||
|
|
||||||
-- modewibox[s].width = 250
|
|
||||||
-- modewibox[s].height = 550
|
|
||||||
|
|
||||||
local pos = position or "bottomleft"
|
|
||||||
modewibox[s].x = getXOffset(s, pos)
|
|
||||||
modewibox[s].y = getYOffset(s, pos)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function update_settings()
|
|
||||||
for s, value in pairs(modewibox) do
|
|
||||||
value.border_width = settings.border_width
|
|
||||||
set_default(s)
|
|
||||||
value.opacity = settings.opacity
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
local function ensure_init()
|
|
||||||
awful.screen.connect_for_each_screen(function(s)
|
|
||||||
modewidget[s] = wibox.widget.textbox()
|
|
||||||
modewidget[s]:set_align("left")
|
|
||||||
if beautiful.fontface then
|
|
||||||
modewidget[s]:set_font(beautiful.fontface .. " " .. (beautiful.fontsize + 4))
|
|
||||||
end
|
|
||||||
|
|
||||||
modewibox[s] = wibox({
|
|
||||||
fg = beautiful.fg_normal,
|
|
||||||
bg = beautiful.bg_normal,
|
|
||||||
border_width = settings.border_width,
|
|
||||||
border_color = beautiful.bg_focus,
|
|
||||||
screen = s
|
|
||||||
})
|
|
||||||
|
|
||||||
local modelayout = {}
|
|
||||||
modelayout[s] = wibox.layout.fixed.horizontal()
|
|
||||||
modelayout[s]:add(modewidget[s])
|
|
||||||
modewibox[s]:set_widget(modelayout[s]);
|
|
||||||
set_default(s)
|
|
||||||
modewibox[s].visible = false
|
|
||||||
modewibox[s].ontop = true
|
|
||||||
|
|
||||||
-- Widgets for prompt wibox
|
|
||||||
modewibox[s].widgets = {
|
|
||||||
modewidget[s],
|
|
||||||
layout = wibox.layout.fixed.horizontal
|
|
||||||
}
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function show_box(s, map, name)
|
|
||||||
modewibox.screen = s
|
|
||||||
local label = "<b>" .. name .. "</b>"
|
|
||||||
if settings.show_options then
|
|
||||||
for key, mapping in pairs(map) do
|
|
||||||
if key ~= "onClose" then
|
|
||||||
label = label .. "\n<b>" .. key .. "</b>"
|
|
||||||
if type(mapping) == "table" then
|
|
||||||
label = label .. "\t" .. (mapping.desc or "???")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
modewidget[s]:set_markup(label)
|
|
||||||
modewibox[s].visible = true
|
|
||||||
set_default(s)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function hide_box()
|
|
||||||
local s = modewibox.screen
|
|
||||||
if s ~= nil then modewibox[s].visible = false end
|
|
||||||
end
|
|
||||||
|
|
||||||
function grab(keymap, name, stay_in_mode)
|
|
||||||
if name then
|
|
||||||
show_box(mouse.screen, keymap, name)
|
|
||||||
nesting = nesting + 1
|
|
||||||
end
|
|
||||||
|
|
||||||
keygrabber.run(function(mod, key, event)
|
|
||||||
if key == "Escape" then
|
|
||||||
if keymap["onClose"] then
|
|
||||||
keymap["onClose"]()
|
|
||||||
end
|
|
||||||
keygrabber.stop()
|
|
||||||
nesting = 0
|
|
||||||
hide_box();
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
if event == "release" then return true end
|
|
||||||
|
|
||||||
if aliases[key] then
|
|
||||||
key = aliases[key]
|
|
||||||
end
|
|
||||||
|
|
||||||
if keymap[key] then
|
|
||||||
keygrabber.stop()
|
|
||||||
if type(keymap[key]) == "table" then
|
|
||||||
keymap[key].func()
|
|
||||||
else
|
|
||||||
keymap[key]()
|
|
||||||
end
|
|
||||||
if stay_in_mode then
|
|
||||||
grab(keymap, name, true)
|
|
||||||
else
|
|
||||||
nesting = nesting - 1
|
|
||||||
if nesting < 1 then hide_box() end
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
else
|
|
||||||
print("Unmapped key: \"" .. key .. "\"")
|
|
||||||
end
|
|
||||||
|
|
||||||
return true
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
modalbind.grab = grab
|
|
||||||
|
|
||||||
function grabf(keymap, name, stay_in_mode)
|
|
||||||
return function() grab(keymap, name, stay_in_mode) end
|
|
||||||
end
|
|
||||||
modalbind.grabf = grabf
|
|
||||||
|
|
||||||
function modebox() return modewibox[mouse.screen] end
|
|
||||||
modalbind.modebox = modebox
|
|
||||||
|
|
||||||
--- Change the opacity of the modebox.
|
|
||||||
-- @param amount opacity between 0.0 and 1.0, or nil to use default
|
|
||||||
function set_opacity(amount)
|
|
||||||
settings.opacity = amount or defaults.opacity
|
|
||||||
update_settings()
|
|
||||||
end
|
|
||||||
modalbind.set_opacity = set_opacity
|
|
||||||
|
|
||||||
--- Change height of the modebox.
|
|
||||||
-- @param amount height in pixels, or nil to use default
|
|
||||||
function set_height(amount)
|
|
||||||
settings.height = amount or defaults.height
|
|
||||||
update_settings()
|
|
||||||
end
|
|
||||||
modalbind.set_height = set_height
|
|
||||||
|
|
||||||
--- Change border width of the modebox.
|
|
||||||
-- @param amount width in pixels, or nil to use default
|
|
||||||
function set_border_width(amount)
|
|
||||||
settings.border_width = amount or defaults.border_width
|
|
||||||
update_settings()
|
|
||||||
end
|
|
||||||
modalbind.set_border_width = set_border_width
|
|
||||||
|
|
||||||
--- Change horizontal offset of the modebox.
|
|
||||||
-- set location for the box with set_corner(). The box is shifted to the right
|
|
||||||
-- if it is in one of the left corners or to the left otherwise
|
|
||||||
-- @param amount horizontal shift in pixels, or nil to use default
|
|
||||||
function set_x_offset (amount)
|
|
||||||
settings.x_offset = amount or defaults.x_offset
|
|
||||||
update_settings()
|
|
||||||
end
|
|
||||||
modalbind.set_x_offset = set_x_offset
|
|
||||||
|
|
||||||
--- Change vertical offset of the modebox.
|
|
||||||
-- set location for the box with set_corner(). The box is shifted downwards if it
|
|
||||||
-- is in one of the upper corners or upwards otherwise.
|
|
||||||
-- @param amount vertical shift in pixels, or nil to use default
|
|
||||||
function set_y_offset(amount)
|
|
||||||
settings.y_offset = amount or defaults.y_offset
|
|
||||||
update_settings()
|
|
||||||
end
|
|
||||||
modalbind.set_y_offset = set_y_offset
|
|
||||||
|
|
||||||
--- Set the corner, where the modebox will be displayed
|
|
||||||
-- If a parameter is not a valid orientation (see below), the function returns
|
|
||||||
-- without doing anything
|
|
||||||
-- @param vertical either top or bottom
|
|
||||||
-- @param horizontal either left or right
|
|
||||||
function set_corner(vertical, horizontal)
|
|
||||||
if (vertical ~= "top" and vertical ~= "bottom") then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
if (horizontal ~= "left" and horizontal ~= "right") then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
settings.corner_v = vertical or defaults.corner_v
|
|
||||||
settings.corner_h = horizontal or defaults.corner_h
|
|
||||||
end
|
|
||||||
modalbind.set_corner = set_corner
|
|
||||||
|
|
||||||
function set_show_options(bool)
|
|
||||||
settings.show_options = bool
|
|
||||||
end
|
|
||||||
modalbind.set_show_options = set_show_options
|
|
||||||
|
|
||||||
ensure_init()
|
|
||||||
return modalbind
|
|
Loading…
Reference in a new issue