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": [
// Globals defined by awesome
"root",
"awesome",
"client",
"screen",
"mouse",
"double_click_timer",
"vim",
"lspSymbol"
// Globals defined in rc.lua
// 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,
-- to make switching icon sets easy.
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 {
volume_up = conf_dir .. "assets/sounds/volumeup-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(
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",
function ()
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",
function ()
awful.spawn(conf.app_1)
@ -37,6 +65,7 @@ return gears.table.join(
group = "Launcher"
}
),
awful.key( {"Mod4", "Shift", "Control"}, "4",
function ()
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",
function ()
awful.spawn(terminal)
awful.spawn(conf.terminal)
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"}, "\\",
function ()
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 {
keys = gears.table.join(
require("binds.system.system"),
require("binds.system"),
require("binds.window.client"),
require("binds.window.layout"),
require("binds.window.tags"),
require("binds.client"),
require("binds.layout"),
require("binds.tags"),
require("binds.desktop.awesome"),
require("binds.desktop.launcher"),
require("binds.desktop.screenshot")
require("binds.awesome")
),
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(
awful.key( {"Mod4"}, "p",
function ()
awful.prompt.run {
prompt = "<b>Really shutdown? (y/n/r) </b>",
textbox = awful.screen.focused().mypromptbox.widget,
exe_callback = bin.system.shutdown
exe_callback = shutdown
}
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",
function ()

View File

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

View File

@ -1,7 +1,7 @@
local backlight = {}
-- 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 .. " "
backlight.hooks = {}

View File

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