Awesome configs for Ben.

This commit is contained in:
Derek Taylor
2023-04-05 14:32:50 -05:00
parent 1966d656c1
commit 6252ad30c1
608 changed files with 9300 additions and 3600 deletions

0
.config/awesome/lain/util/dkjson.lua Executable file → Normal file
View File

11
.config/awesome/lain/util/init.lua Executable file → Normal file
View File

@@ -6,7 +6,7 @@
Utilities section
Licensed under GNU General Public License v2
* (c) 2013, Luca CPZ
* (c) 2013, Luke Bonham
* (c) 2010-2012, Peter Hofmann
--]]
@@ -76,7 +76,7 @@ function util.magnify_client(c, width_f, height_f)
end
end
-- https://github.com/lcpz/lain/issues/195
-- https://github.com/copycat-killer/lain/issues/195
function util.mc(c, width_f, height_f)
c = c or util.magnified_client
if not c then return end
@@ -158,10 +158,9 @@ end
-- }}}
-- On the fly useless gaps change
function util.useless_gaps_resize(thatmuch, s, t)
local scr = s or awful.screen.focused()
local tag = t or scr.selected_tag
tag.gap = tag.gap + tonumber(thatmuch)
function util.useless_gaps_resize(thatmuch)
local scr = awful.screen.focused()
scr.selected_tag.gap = scr.selected_tag.gap + tonumber(thatmuch)
awful.layout.arrange(scr)
end

48
.config/awesome/lain/util/markup.lua Executable file → Normal file
View File

@@ -1,61 +1,61 @@
--[[
Licensed under MIT License
* (c) 2013, Luca CPZ
* (c) 2013, Luke Bonham
* (c) 2009, Uli Schlachter
* (c) 2009, Majic
--]]
local format = string.format
local string = { format = string.format }
local setmetatable = setmetatable
-- Lain markup util submodule
-- lain.util.markup
local markup = { fg = {}, bg = {} }
-- Convenience tags
function markup.bold(text) return format("<b>%s</b>", text) end
function markup.italic(text) return format("<i>%s</i>", text) end
function markup.strike(text) return format("<s>%s</s>", text) end
function markup.underline(text) return format("<u>%s</u>", text) end
function markup.monospace(text) return format("<tt>%s</tt>", text) end
function markup.big(text) return format("<big>%s</big>", text) end
function markup.small(text) return format("<small>%s</small>", text) end
-- Convenience tags.
function markup.bold(text) return '<b>' .. text .. '</b>' end
function markup.italic(text) return '<i>' .. text .. '</i>' end
function markup.strike(text) return '<s>' .. text .. '</s>' end
function markup.underline(text) return '<u>' .. text .. '</u>' end
function markup.monospace(text) return '<tt>' .. text .. '</tt>' end
function markup.big(text) return '<big>' .. text .. '</big>' end
function markup.small(text) return '<small>' .. text .. '</small>' end
-- Set the font
-- Set the font.
function markup.font(font, text)
return format("<span font='%s'>%s</span>", font, text)
return '<span font="' .. font .. '">' .. text ..'</span>'
end
-- Set the foreground
-- Set the foreground.
function markup.fg.color(color, text)
return format("<span foreground='%s'>%s</span>", color, text)
return '<span foreground="' .. color .. '">' .. text .. '</span>'
end
-- Set the background
-- Set the background.
function markup.bg.color(color, text)
return format("<span background='%s'>%s</span>", color, text)
return '<span background="' .. color .. '">' .. text .. '</span>'
end
-- Set foreground and background
-- Set foreground and background.
function markup.color(fg, bg, text)
return format("<span foreground='%s' background='%s'>%s</span>", fg, bg, text)
return string.format('<span foreground="%s" background="%s">%s</span>', fg, bg, text)
end
-- Set font and foreground
-- Set font and foreground.
function markup.fontfg(font, fg, text)
return format("<span font='%s' foreground='%s'>%s</span>", font, fg, text)
return string.format('<span font="%s" foreground="%s">%s</span>', font, fg, text)
end
-- Set font and background
-- Set font and background.
function markup.fontbg(font, bg, text)
return format("<span font='%s' background='%s'>%s</span>", font, bg, text)
return string.format('<span font="%s" background="%s">%s</span>', font, bg, text)
end
-- Set font, foreground and background
-- Set font, foreground and background.
function markup.fontcolor(font, fg, bg, text)
return format("<span font='%s' foreground='%s' background='%s'>%s</span>", font, fg, bg, text)
return string.format('<span font="%s" foreground="%s" background="%s">%s</span>', font, fg, bg, text)
end
-- link markup.{fg,bg}(...) calls to markup.{fg,bg}.color(...)

View File

@@ -1,144 +0,0 @@
--[[
Licensed under GNU General Public License v2
* (c) 2017, Simon Désaulniers <sim.desaulniers@gmail.com>
* (c) 2017, Uli Schlachter
* (c) 2017, Jeferson Siqueira <jefersonlsiq@gmail.com>
--]]
-- Menu iterator with Naughty notifications
-- lain.util.menu_iterator
local naughty = require("naughty")
local util = require("lain.util")
local atable = require("awful.util").table
local assert = assert
local pairs = pairs
local tconcat = table.concat
local unpack = unpack
local state = { cid = nil }
local function naughty_destroy_callback(reason)
local closed = naughty.notificationClosedReason
if reason == closed.expired or reason == closed.dismissedByUser then
local actions = state.index and state.menu[state.index - 1][2]
if actions then
for _,action in pairs(actions) do
-- don't try to call nil callbacks
if action then action() end
end
state.index = nil
end
end
end
-- Iterates over a menu.
-- After the timeout, callbacks associated to the last visited choice are
-- executed. Inputs:
-- * menu: a list of {label, {callbacks}} pairs
-- * timeout: time to wait before confirming the menu selection
-- * icon: icon to display in the notification of the chosen label
local function iterate(menu, timeout, icon)
local timeout = timeout or 4 -- default timeout for each menu entry
local icon = icon or nil -- icon to display on the menu
-- Build the list of choices
if not state.index then
state.menu = menu
state.index = 1
end
-- Select one and display the appropriate notification
local label
local next = state.menu[state.index]
state.index = state.index + 1
if not next then
label = "Cancel"
state.index = nil
else
label, _ = unpack(next)
end
state.cid = naughty.notify({
text = label,
icon = icon,
timeout = timeout,
screen = mouse.screen,
replaces_id = state.cid,
destroy = naughty_destroy_callback
}).id
end
-- Generates a menu compatible with the first argument of `iterate` function and
-- suitable for the following cases:
-- * all possible choices individually (partition of singletons);
-- * all possible subsets of the set of choices (powerset).
--
-- Inputs:
-- * args: an array containing the following members:
-- * choices: Array of choices (string) on which the menu will be
-- generated.
-- * name: Displayed name of the menu (in the form "name: choices").
-- * selected_cb: Callback to execute for each selected choice. Takes
-- the choice as a string argument. Can be `nil` (no action
-- to execute).
-- * rejected_cb: Callback to execute for each rejected choice (possible
-- choices which are not selected). Takes the choice as a
-- string argument. Can be `nil` (no action to execute).
-- * extra_choices: An array of extra { choice_str, callback_fun } pairs to be
-- added to the menu. Each callback_fun can be `nil`.
-- * combination: The combination of choices to generate. Possible values:
-- "powerset" and "single" (default).
-- Output:
-- * m: menu to be iterated over.
local function menu(args)
local choices = assert(args.choices or args[1])
local name = assert(args.name or args[2])
local selected_cb = args.selected_cb
local rejected_cb = args.rejected_cb
local extra_choices = args.extra_choices or {}
local ch_combinations = args.combination == "powerset" and helpers.powerset(choices) or helpers.trivial_partition_set(choices)
for _,c in pairs(extra_choices) do
ch_combinations = atable.join(ch_combinations, {{c[1]}})
end
local m = {} -- the menu
for _,c in pairs(ch_combinations) do
if #c > 0 then
local cbs = {}
-- selected choices
for _,ch in pairs(c) do
if atable.hasitem(choices, ch) then
cbs[#cbs + 1] = selected_cb and function() selected_cb(ch) end or nil
end
end
-- rejected choices
for _,ch in pairs(choices) do
if not atable.hasitem(c, ch) and atable.hasitem(choices, ch) then
cbs[#cbs + 1] = rejected_cb and function() rejected_cb(ch) end or nil
end
end
-- add user extra choices (like the choice "None" for example)
for _,x in pairs(extra_choices) do
if x[1] == c[1] then
cbs[#cbs + 1] = x[2]
end
end
m[#m + 1] = { name .. ": " .. tconcat(c, " + "), cbs }
end
end
return m
end
return { iterate = iterate, menu = menu }

26
.config/awesome/lain/util/quake.lua Executable file → Normal file
View File

@@ -1,17 +1,20 @@
--[[
Licensed under GNU General Public License v2
* (c) 2016, Luca CPZ
* (c) 2016, Luke Bonham
* (c) 2015, unknown
--]]
local awful = require("awful")
local capi = { client = client }
local math = math
local string = string
local math = { floor = math.floor }
local string = { format = string.format }
local pairs = pairs
local screen = screen
local setmetatable = setmetatable
-- Quake-like Dropdown application spawn
@@ -60,7 +63,7 @@ function quake:display()
client.floating = true
client.border_width = self.border
client.size_hints_honor = false
client:geometry(self.geometry[self.screen.index] or self:compute_size())
client:geometry(self.geometry[self.screen] or self:compute_size())
-- Set not sticky and on top
client.sticky = false
@@ -92,12 +95,12 @@ end
function quake:compute_size()
-- skip if we already have a geometry for this screen
if not self.geometry[self.screen.index] then
if not self.geometry[self.screen] then
local geom
if not self.overlap then
geom = screen[self.screen.index].workarea
geom = screen[self.screen].workarea
else
geom = screen[self.screen.index].geometry
geom = screen[self.screen].geometry
end
local width, height = self.width, self.height
if width <= 1 then width = math.floor(geom.width * width) - 2 * self.border end
@@ -109,9 +112,9 @@ function quake:compute_size()
if self.vert == "top" then y = geom.y
elseif self.vert == "bottom" then y = geom.height + geom.y - height
else y = geom.y + (geom.height - height)/2 end
self.geometry[self.screen.index] = { x = x, y = y, width = width, height = height }
self.geometry[self.screen] = { x = x, y = y, width = width, height = height }
end
return self.geometry[self.screen.index]
return self.geometry[self.screen]
end
function quake:new(config)
@@ -155,10 +158,7 @@ function quake:toggle()
if self.followtag then self.screen = awful.screen.focused() end
local current_tag = self.screen.selected_tag
if current_tag and self.last_tag ~= current_tag and self.visible then
local c=self:display()
if c then
c:move_to_tag(current_tag)
end
self:display():move_to_tag(current_tag)
else
self.visible = not self.visible
self:display()

38
.config/awesome/lain/util/separators.lua Executable file → Normal file
View File

@@ -1,13 +1,13 @@
--[[
Licensed under GNU General Public License v2
* (c) 2015, Luca CPZ
* (c) 2015, Luke Bonham
* (c) 2015, plotnikovanton
--]]
local wibox = require("wibox")
local gears = require("gears")
local wibox = require("wibox")
local gears = require("gears")
-- Lain Cairo separators util submodule
-- lain.util.separators
@@ -18,22 +18,14 @@ local separators = { height = 0, width = 9 }
-- Right
function separators.arrow_right(col1, col2)
local widget = wibox.widget.base.make_widget()
widget.col1 = col1
widget.col2 = col2
widget.fit = function(m, w, h)
return separators.width, separators.height
end
widget.update = function(col1, col2)
widget.col1 = col1
widget.col2 = col2
widget:emit_signal("widget::redraw_needed")
end
widget.draw = function(mycross, wibox, cr, width, height)
if widget.col2 ~= "alpha" then
cr:set_source_rgb(gears.color.parse_color(widget.col2))
if col2 ~= "alpha" then
cr:set_source_rgb(gears.color.parse_color(col2))
cr:new_path()
cr:move_to(0, 0)
cr:line_to(width, height/2)
@@ -49,8 +41,8 @@ function separators.arrow_right(col1, col2)
cr:fill()
end
if widget.col1 ~= "alpha" then
cr:set_source_rgb(gears.color.parse_color(widget.col1))
if col1 ~= "alpha" then
cr:set_source_rgb(gears.color.parse_color(col1))
cr:new_path()
cr:move_to(0, 0)
cr:line_to(width, height/2)
@@ -66,22 +58,14 @@ end
-- Left
function separators.arrow_left(col1, col2)
local widget = wibox.widget.base.make_widget()
widget.col1 = col1
widget.col2 = col2
widget.fit = function(m, w, h)
return separators.width, separators.height
end
widget.update = function(col1, col2)
widget.col1 = col1
widget.col2 = col2
widget:emit_signal("widget::redraw_needed")
end
widget.draw = function(mycross, wibox, cr, width, height)
if widget.col1 ~= "alpha" then
cr:set_source_rgb(gears.color.parse_color(widget.col1))
if col1 ~= "alpha" then
cr:set_source_rgb(gears.color.parse_color(col1))
cr:new_path()
cr:move_to(width, 0)
cr:line_to(0, height/2)
@@ -97,14 +81,14 @@ function separators.arrow_left(col1, col2)
cr:fill()
end
if widget.col2 ~= "alpha" then
if col2 ~= "alpha" then
cr:new_path()
cr:move_to(width, 0)
cr:line_to(0, height/2)
cr:line_to(width, height)
cr:close_path()
cr:set_source_rgb(gears.color.parse_color(widget.col2))
cr:set_source_rgb(gears.color.parse_color(col2))
cr:fill()
end
end