Update to Awesome 4.0
Configuration works mostly identical to previous state. Some exceptions: - Minor changes in tag names (removed unicode symbols), as they are now referenced by name in the rules. - Calendar module is not yet ported and not loaded. - Scratch terminal on F12 key currently moves to bottom of the screen after first opening. Probably will be reimplemented using the new extended awful.spawn API. - awsetbg util writes different wallpaperrc (preexisting wallpaperrc is ignored, as the filename now includes .lua)
This commit is contained in:
parent
457f474a2c
commit
a43b908350
10 changed files with 549 additions and 633 deletions
|
@ -1,8 +1,10 @@
|
|||
local modalbind = {}
|
||||
local wibox = require("wibox")
|
||||
local awful = require("awful")
|
||||
local beautiful = require("beautiful")
|
||||
local inited = false
|
||||
local modewidget = {}
|
||||
local modewibox = { screen = -1 }
|
||||
local modewibox = { screen = nil }
|
||||
local nesting = 0
|
||||
|
||||
--local functions
|
||||
|
@ -22,17 +24,168 @@ 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 ipairs(modewibox) do
|
||||
for s, value in pairs(modewibox) do
|
||||
value.border_width = settings.border_width
|
||||
set_default(s)
|
||||
value.opacity = settings.opacity
|
||||
end
|
||||
end
|
||||
|
||||
local aliases = {}
|
||||
aliases[" "] = "Space"
|
||||
|
||||
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
|
||||
|
@ -100,155 +253,5 @@ function set_show_options(bool)
|
|||
end
|
||||
modalbind.set_show_options = set_show_options
|
||||
|
||||
|
||||
local function getXOffset(s, position)
|
||||
local offset = 0
|
||||
if type(position) == "table" then
|
||||
offset = position.x + screen[s].geometry.x
|
||||
elseif position == "topleft" or position == "bottomleft" then
|
||||
offset = screen[s].geometry.x
|
||||
elseif position == "topright" or position == "bottomright" then
|
||||
offset = screen[s].geometry.x + screen[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 + screen[s].geometry.y
|
||||
elseif position == "topleft" or position == "topright" then
|
||||
offset = screen[s].geometry.y
|
||||
elseif position == "bottomleft" or position == "bottomright" then
|
||||
offset = screen[s].geometry.y + screen[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(screen[s].geometry.width,
|
||||
screen[s].geometry.height)
|
||||
modewibox[s].width = minwidth + 1;
|
||||
modewibox[s].height = math.max(settings.height, minheight)
|
||||
|
||||
local pos = position or "bottomleft"
|
||||
modewibox[s].x = getXOffset(s, pos)
|
||||
modewibox[s].y = getYOffset(s, pos)
|
||||
end
|
||||
|
||||
local function ensure_init()
|
||||
if inited then
|
||||
return
|
||||
end
|
||||
inited = true
|
||||
for s = 1, screen.count() do
|
||||
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)
|
||||
ensure_init()
|
||||
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 ~= -1 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
|
||||
|
||||
ensure_init()
|
||||
return modalbind
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue