Misc cleanup

master
Mark 2022-07-16 17:41:00 -07:00
parent 7d1a0b6155
commit ea62dabfc1
Signed by: Mark
GPG Key ID: AD62BB059C2AAEE4
21 changed files with 143 additions and 175 deletions

21
.vscode/settings.json vendored
View File

@ -1,12 +1,27 @@
{ {
"Lua.diagnostics.globals": [ "Lua.diagnostics.globals": [
// Globals defined by awesome
"root", "root",
"awesome", "awesome",
"client", "client",
"screen", "screen",
"mouse", "mouse",
"double_click_timer",
"vim", // Globals defined in rc.lua
"lspSymbol" // Awesome modules
"gears",
"awful",
"naughty",
"beautiful",
"menubar",
"wibox",
// Misc
"conf_dir",
"req_rel",
"debug_message",
"conf",
"core",
"modules"
] ]
} }

View File

@ -1,6 +1,3 @@
local gears = require("gears")
local conf_dir = gears.filesystem.get_configuration_dir()
-- Some subdir variables, -- Some subdir variables,
-- to make switching icon sets easy. -- to make switching icon sets easy.
local brightnessdir = conf_dir .. "assets/icons/brightness/clockwise/" local brightnessdir = conf_dir .. "assets/icons/brightness/clockwise/"

View File

@ -1,6 +1,3 @@
local gears = require("gears")
local conf_dir = gears.filesystem.get_configuration_dir()
return { return {
volume_up = conf_dir .. "assets/sounds/volumeup-click.mp3", volume_up = conf_dir .. "assets/sounds/volumeup-click.mp3",
volume_down = conf_dir .. "assets/sounds/volumedown-click.mp3" volume_down = conf_dir .. "assets/sounds/volumedown-click.mp3"

View File

@ -1,36 +0,0 @@
dir = configuration_dir .. "bin/"
local script_dir = dir .. "scripts/"
return {
system = {
shutdown = function(confirm_prompt)
if (string.lower(confirm_prompt) == "y") or (string.lower(confirm_prompt) == "yes") then
awful.spawn("shutdown now", false)
elseif (string.lower(confirm_prompt) == "r") or (string.lower(confirm_prompt) == "reset") then
awful.spawn("shutdown -r now", false)
end
end,
lock = function()
awful.spawn(script_dir .. "lock " .. beautiful.icons.lockicon, false)
end
},
rofi = {
launcher = function()
awful.spawn("rofi -show drun -theme \"" .. dir .. "/rofi/launcher.rasi\"")
end
},
capture = function(source, target)
awful.spawn(script_dir .. "capture " .. source .. " " .. target, false)
end,
flameshot = {
gui = function()
--awful.spawn("flameshot gui -p \"" .. conf.screenshot_dir .. "\"", false)
awful.spawn("flameshot gui", false)
end
}
}

View File

@ -1,4 +1,22 @@
local hotkeys = require("awful.hotkeys_popup")
return gears.table.join( return gears.table.join(
awful.key( {"Mod4"}, "s",
hotkeys.show_help,
{
description = "Show help",
group = "Desktop"
}
),
awful.key( {"Mod4", "Control", "Shift"}, "r",
awesome.restart,
{
description = "Restart awesome",
group = "Desktop"
}
),
awful.key( {"Mod4"}, "r", awful.key( {"Mod4"}, "r",
function () function ()
awful.screen.focused().mypromptbox:run() awful.screen.focused().mypromptbox:run()
@ -9,6 +27,16 @@ return gears.table.join(
} }
), ),
awful.key( {"Mod4"}, "x",
function ()
awful.screen.focused().mypromptbox:run()
end,
{
description = "Run prompt",
group = "Launcher"
}
),
awful.key( {"Mod4", "Shift", "Control"}, "1", awful.key( {"Mod4", "Shift", "Control"}, "1",
function () function ()
awful.spawn(conf.app_1) awful.spawn(conf.app_1)
@ -37,6 +65,7 @@ return gears.table.join(
group = "Launcher" group = "Launcher"
} }
), ),
awful.key( {"Mod4", "Shift", "Control"}, "4", awful.key( {"Mod4", "Shift", "Control"}, "4",
function () function ()
awful.spawn(conf.app_4) awful.spawn(conf.app_4)
@ -47,19 +76,9 @@ return gears.table.join(
} }
), ),
awful.key( {"Mod4"}, "x",
function ()
awful.screen.focused().mypromptbox:run()
end,
{
description = "Run prompt",
group = "Launcher"
}
),
awful.key( {"Mod4"}, "Return", awful.key( {"Mod4"}, "Return",
function () function ()
awful.spawn(terminal) awful.spawn(conf.terminal)
end, end,
{ {
@ -68,28 +87,6 @@ return gears.table.join(
} }
), ),
awful.key( {"Mod4"}, "]",
function ()
awful.spawn(terminal .. " ranger /home/mark")
end,
{
description = "Launch ranger in kitty",
group = "Launcher"
}
),
awful.key( {"Mod4", "Control"}, "Return",
function ()
awful.spawn("kitty --class \"kitty-noblur\" --override background_opacity=0.5 --override hide_window_decorations=yes")
end,
{
description = "Open a floating kitty terminal",
group = "Launcher"
}
),
awful.key( {"Mod4"}, "\\", awful.key( {"Mod4"}, "\\",
function () function ()
awful.spawn(conf.browser) awful.spawn(conf.browser)

View File

@ -1,19 +0,0 @@
local hotkeys = require("awful.hotkeys_popup")
return gears.table.join(
awful.key( {"Mod4"}, "s",
hotkeys.show_help,
{
description = "Show help",
group = "Desktop"
}
),
awful.key( {"Mod4", "Control", "Shift"}, "r",
awesome.restart,
{
description = "Restart awesome",
group = "Desktop"
}
)
)

View File

@ -1,23 +0,0 @@
return gears.table.join(
awful.key( {"Control"}, "Print",
function ()
bin.capture("region", "ocr")
end,
{
description = "OCR a region to the clipboard",
group = "Desktop"
}
),
awful.key( {}, "Print",
function ()
bin.flameshot.gui()
end,
{
description = "Take a screenshot",
group = "Desktop"
}
)
)

View File

@ -1,14 +1,12 @@
return { return {
keys = gears.table.join( keys = gears.table.join(
require("binds.system.system"), require("binds.system"),
require("binds.window.client"), require("binds.client"),
require("binds.window.layout"), require("binds.layout"),
require("binds.window.tags"), require("binds.tags"),
require("binds.desktop.awesome"), require("binds.awesome")
require("binds.desktop.launcher"),
require("binds.desktop.screenshot")
), ),
buttons = {} buttons = {}

View File

@ -1,10 +1,19 @@
local function shutdown(confirm_prompt)
if (string.lower(confirm_prompt) == "y") or (string.lower(confirm_prompt) == "yes") then
awful.spawn("shutdown now", false)
elseif (string.lower(confirm_prompt) == "r") or (string.lower(confirm_prompt) == "reset") then
awful.spawn("shutdown -r now", false)
end
end
return gears.table.join( return gears.table.join(
awful.key( {"Mod4"}, "p", awful.key( {"Mod4"}, "p",
function () function ()
awful.prompt.run { awful.prompt.run {
prompt = "<b>Really shutdown? (y/n/r) </b>", prompt = "<b>Really shutdown? (y/n/r) </b>",
textbox = awful.screen.focused().mypromptbox.widget, textbox = awful.screen.focused().mypromptbox.widget,
exe_callback = bin.system.shutdown exe_callback = shutdown
} }
end, end,
{ {
@ -13,16 +22,7 @@ return gears.table.join(
} }
), ),
awful.key( {"Mod4"}, "a",
function ()
bin.system.lock()
end,
{
description = "Lock screen",
group = "System"
}
),
awful.key( {"Mod4", "Control"}, "x", awful.key( {"Mod4", "Control"}, "x",
function () function ()

View File

@ -1,7 +1,4 @@
local LayoutManager = { local LayoutManager = {}
layouts = nil, -- Table of groups
-- current state is kept in each tag, as tag.layout.
}
-- screen.layouts, awful.layouts, and tag.layouts are all ignored. -- screen.layouts, awful.layouts, and tag.layouts are all ignored.
-- This module replaces the standard layout functions. -- This module replaces the standard layout functions.
@ -10,9 +7,9 @@ local LayoutManager = {
-- Get group from layout -- Get group from layout
-- We assume that this layout is in LayoutManager.layouts -- We assume that this layout is in conf.layouts
function LayoutManager:get_group(layout) function LayoutManager:get_group(layout)
for k, v in pairs(self.layouts) do for k, v in pairs(conf.layouts) do
for l, m in pairs(v) do for l, m in pairs(v) do
if (layout == m) then if (layout == m) then
return k return k
@ -22,7 +19,7 @@ function LayoutManager:get_group(layout)
end end
function LayoutManager:get_alt(layout) function LayoutManager:get_alt(layout)
for k, v in pairs(self.layouts) do for k, v in pairs(conf.layouts) do
for l, m in pairs(v) do for l, m in pairs(v) do
if (layout == m) then if (layout == m) then
return l return l
@ -34,7 +31,7 @@ end
function LayoutManager:default_layout() function LayoutManager:default_layout()
return self.layouts[1][1] return conf.layouts[1][1]
end end
-- Change layout group -- Change layout group
@ -47,9 +44,9 @@ function LayoutManager:group(step)
local group = self:get_group(layout) - 1 local group = self:get_group(layout) - 1
group = ((group + step) % #self.layouts) + 1 group = ((group + step) % #conf.layouts) + 1
awful.layout.set(self.layouts[group][1], tag) awful.layout.set(conf.layouts[group][1], tag)
end end
-- Change layout alternate -- Change layout alternate
@ -63,9 +60,9 @@ function LayoutManager:alt(step)
local group = self:get_group(layout) local group = self:get_group(layout)
alt = ((alt + step) % #self.layouts[group]) + 1 alt = ((alt + step) % #conf.layouts[group]) + 1
awful.layout.set(self.layouts[group][alt], tag) awful.layout.set(conf.layouts[group][alt], tag)
end end
function LayoutManager:next() function LayoutManager:next()

View File

@ -1,7 +1,7 @@
local backlight = {} local backlight = {}
-- The space at the end is important! -- The space at the end is important!
local script = configuration_dir .. "modules/backlight/backlight.fish" local script = conf_dir .. "modules/backlight/backlight.fish"
script = script .. " " script = script .. " "
backlight.hooks = {} backlight.hooks = {}

View File

@ -1,6 +1,6 @@
local battery = {} local battery = {}
local script = configuration_dir .. "modules/battery/battery.fish" local script = conf_dir .. "modules/battery/battery.fish"
battery.watch = function(timeout, callback, widget) battery.watch = function(timeout, callback, widget)
awful.widget.watch(script, timeout, callback, widget) awful.widget.watch(script, timeout, callback, widget)

17
modules/i3lock/init.lua Normal file
View File

@ -0,0 +1,17 @@
local script = conf_dir .. "modules/i3lock/lock.fish"
script = script .. " "
return {
keybinds = gears.table.join(
awful.key( {"Mod4"}, "a",
function ()
awful.spawn(script .. beautiful.icons.lockicon, false)
end,
{
description = "Lock screen",
group = "System"
}
)
)
}

View File

@ -1,6 +1,6 @@
local launcher = {} local launcher = {}
local conf = configuration_dir .. "modules/launcher/launcher.rasi" local conf = conf_dir .. "modules/launcher/launcher.rasi"
launcher.launcher = function() launcher.launcher = function()
awful.spawn("rofi -show drun -theme \"" .. conf .. "\"") awful.spawn("rofi -show drun -theme \"" .. conf .. "\"")

View File

@ -0,0 +1,39 @@
local script = conf_dir .. "modules/screenshot/screenshot.fish"
script = script .. " "
local function capture(source, target)
awful.spawn(script .. "capture " .. source .. " " .. target, false)
end
local function flameshot()
--awful.spawn("flameshot gui -p \"" .. conf.screenshot_dir .. "\"", false)
awful.spawn("flameshot gui", false)
end
return {
keybinds = gears.table.join(
awful.key( {"Control"}, "Print",
function ()
capture("region", "ocr")
end,
{
description = "OCR a region to the clipboard",
group = "Desktop"
}
),
awful.key( {}, "Print",
function ()
flameshot()
end,
{
description = "Take a screenshot",
group = "Desktop"
}
)
)
}

35
rc.lua
View File

@ -1,15 +1,15 @@
-- AwesomeWM core -- AwesomeWM modules
gears = require("gears") gears = require("gears")
awful = require("awful") awful = require("awful")
naughty = require("naughty") naughty = require("naughty")
beautiful = require("beautiful") beautiful = require("beautiful")
menubar = require("menubar") menubar = require("menubar")
wibox = require("wibox") wibox = require("wibox")
configuration_dir = gears.filesystem.get_configuration_dir()
require("awful.autofocus") require("awful.autofocus")
conf_dir = gears.filesystem.get_configuration_dir()
-- A "relative require" hack. Does the same thing as `require,` -- A "relative require" hack. Does the same thing as `require`,
-- But takes a relative path. -- But takes a relative path.
-- Called with req_rel(..., "module") -- Called with req_rel(..., "module")
function req_rel(ddd, modname) function req_rel(ddd, modname)
@ -22,22 +22,12 @@ debug_message = function(msg)
naughty.notify({title = "Debug message:", text = tostring(msg)}) naughty.notify({title = "Debug message:", text = tostring(msg)})
end end
-- These must be loaded in order. -- Order matters.
-- Make sure you've created conf.lua!
conf = require("conf") conf = require("conf")
layoutmanager = require("core.layouts.layoutmanager")
layoutmanager.layouts = conf.layouts
bin = require("bin")
beautiful.init(require("theme")) beautiful.init(require("theme"))
core = require("core") core = require("core")
-- Load key bindings -- Load key bindings
local binds = require("binds") local binds = require("binds")
local keys = binds.keys local keys = binds.keys
@ -50,7 +40,9 @@ for k, v in ipairs({
"ibus", "ibus",
"volume", "volume",
"launcher", "launcher",
"simple_widgets" "simple_widgets",
"screenshot",
"i3lock"
}) do }) do
modules[v] = require("modules." .. v) modules[v] = require("modules." .. v)
@ -71,7 +63,7 @@ for _, mod in ipairs(modules) do
end end
-- Finalize keys -- Finalize keybinds
root.keys(keys) root.keys(keys)
root.buttons(buttons) root.buttons(buttons)
@ -90,14 +82,11 @@ end
core.start() core.start()
-- Check for errors -- Check for errors
dofile(configuration_dir .. "errors.lua") dofile(conf_dir .. "errors.lua")
terminal = conf.terminal
menubar.utils.terminal = terminal
menubar.utils.terminal = conf.terminal
-- Load client methods -- Load client methods
awful.rules.rules = require("clients.rules") awful.rules.rules = require("clients.rules")
dofile(configuration_dir .. "clients/signals.lua") dofile(conf_dir .. "clients/signals.lua")
require("clients.render") require("clients.render")