mirror of
https://codeberg.org/frosty/dotfiles.git
synced 2024-09-19 03:37:10 -04:00
add awesome wm
This commit is contained in:
parent
4dc2a37d83
commit
9965cac771
161
awesome/.config/awesome/binds.lua
Normal file
161
awesome/.config/awesome/binds.lua
Normal file
|
@ -0,0 +1,161 @@
|
|||
local gears = require("gears")
|
||||
local awful = require("awful")
|
||||
|
||||
local config = require("config")
|
||||
|
||||
local utils = require("utils")
|
||||
|
||||
local taglist_buttons = gears.table.join(
|
||||
awful.button({ }, 1, function(t)
|
||||
t:view_only() end
|
||||
),
|
||||
awful.button({ "Mod4" }, 1, function(t)
|
||||
if client.focus then
|
||||
client.focus:move_to_tag(t)
|
||||
end
|
||||
end),
|
||||
awful.button({ }, 3,
|
||||
awful.tag.viewtoggle
|
||||
),
|
||||
awful.button({ "Mod4" }, 3, function(t)
|
||||
if client.focus then
|
||||
client.focus:toggle_tag(t)
|
||||
end
|
||||
end),
|
||||
awful.button({ }, 4, function(t)
|
||||
awful.tag.viewnext(t.screen)
|
||||
end),
|
||||
awful.button({ }, 5, function(t)
|
||||
awful.tag.viewprev(t.screen)
|
||||
end)
|
||||
)
|
||||
|
||||
local global_keys = gears.table.join(
|
||||
awful.key({ "Mod4" }, "j", function()
|
||||
awful.client.focus.byidx(1)
|
||||
end),
|
||||
awful.key({ "Mod4" }, "k", function()
|
||||
awful.client.focus.byidx(-1)
|
||||
end),
|
||||
|
||||
awful.key({ "Mod4", "Shift" }, "j", function()
|
||||
awful.client.swap.byidx(1)
|
||||
end),
|
||||
awful.key({ "Mod4", "Shift" }, "k", function()
|
||||
awful.client.swap.byidx(-1)
|
||||
end),
|
||||
|
||||
awful.key({ "Mod4" }, "period", function()
|
||||
awful.screen.focus_relative(1)
|
||||
end),
|
||||
awful.key({ "Mod4" }, "comma", function()
|
||||
awful.screen.focus_relative(-1)
|
||||
end),
|
||||
|
||||
awful.key({ "Mod4" }, "Return", function()
|
||||
awful.spawn(config.terminal)
|
||||
end),
|
||||
awful.key({ "Mod4" }, "p", function()
|
||||
awful.spawn("dmenu_run")
|
||||
end),
|
||||
|
||||
awful.key({ "Mod4", "Control" }, "r",
|
||||
awesome.restart
|
||||
),
|
||||
awful.key({ "Mod4", "Control" }, "q",
|
||||
awesome.quit
|
||||
),
|
||||
|
||||
awful.key({ "Mod4" }, "l", function()
|
||||
awful.tag.incmwfact(0.05)
|
||||
end),
|
||||
awful.key({ "Mod4" }, "h", function()
|
||||
awful.tag.incmwfact(-0.05)
|
||||
end),
|
||||
|
||||
awful.key({ "Mod4" }, "i", function()
|
||||
awful.tag.incnmaster(1, nil, true)
|
||||
end),
|
||||
awful.key({ "Mod4" }, "d", function()
|
||||
awful.tag.incnmaster(-1, nil, true)
|
||||
end),
|
||||
|
||||
awful.key({ "Mod4" }, "t", function()
|
||||
awful.layout.set(awful.layout.suit.tile)
|
||||
end),
|
||||
awful.key({ "Mod4" }, "m", function()
|
||||
awful.layout.set(awful.layout.suit.max)
|
||||
end),
|
||||
awful.key({ "Mod4" }, "f", function()
|
||||
awful.layout.set(awful.layout.suit.floating)
|
||||
end)
|
||||
)
|
||||
|
||||
local client_keys = gears.table.join(
|
||||
awful.key({ "Mod4", "Shift" }, "f", function(c)
|
||||
c.fullscreen = not c.fullscreen
|
||||
c:raise()
|
||||
end),
|
||||
awful.key({ "Mod4", "Shift" }, "c", function(c)
|
||||
c:kill()
|
||||
end),
|
||||
awful.key({ "Mod4", "Shift" }, "space",
|
||||
awful.client.floating.toggle
|
||||
)
|
||||
)
|
||||
|
||||
for i = 1, 9 do
|
||||
global_keys = gears.table.join(global_keys,
|
||||
awful.key({ "Mod4" }, "#" .. i + 9, function()
|
||||
local screen = awful.screen.focused()
|
||||
local tag = screen.tags[i]
|
||||
if tag then
|
||||
tag:view_only()
|
||||
end
|
||||
end),
|
||||
awful.key({ "Mod4", "Control" }, "#" .. i + 9, function()
|
||||
local screen = awful.screen.focused()
|
||||
local tag = screen.tags[i]
|
||||
if tag then
|
||||
awful.tag.viewtoggle(tag)
|
||||
end
|
||||
end),
|
||||
awful.key({ "Mod4", "Shift" }, "#" .. i + 9, function()
|
||||
if client.focus then
|
||||
local tag = client.focus.screen.tags[i]
|
||||
if tag then
|
||||
client.focus:move_to_tag(tag)
|
||||
end
|
||||
end
|
||||
end),
|
||||
awful.key({ "Mod4", "Control", "Shift" }, "#" .. i + 9, function()
|
||||
if client.focus then
|
||||
local tag = client.focus.screen.tags[i]
|
||||
if tag then
|
||||
client.focus:toggle_tag(tag)
|
||||
end
|
||||
end
|
||||
end)
|
||||
)
|
||||
end
|
||||
|
||||
local client_buttons = gears.table.join(
|
||||
awful.button({ }, 1, function(c)
|
||||
c:emit_signal("request::activate", "mouse_click", { raise = true })
|
||||
end),
|
||||
awful.button({ "Mod4" }, 1, function(c)
|
||||
c:emit_signal("request::activate", "mouse_click", { raise = true })
|
||||
awful.mouse.client.move(c)
|
||||
end),
|
||||
awful.button({ "Mod4" }, 3, function(c)
|
||||
c:emit_signal("request::activate", "mouse_click", { raise = true })
|
||||
awful.mouse.client.resize(c, config.resize_corner)
|
||||
end)
|
||||
)
|
||||
|
||||
return {
|
||||
taglist_buttons = taglist_buttons,
|
||||
global_keys = global_keys,
|
||||
client_keys = client_keys,
|
||||
client_buttons = client_buttons,
|
||||
}
|
28
awesome/.config/awesome/config.lua
Normal file
28
awesome/.config/awesome/config.lua
Normal file
|
@ -0,0 +1,28 @@
|
|||
local awful = require("awful")
|
||||
|
||||
local config = {}
|
||||
|
||||
-- Default programs
|
||||
config.terminal = "st"
|
||||
config.file_manager = "thunar"
|
||||
config.browser = "firefox"
|
||||
config.editor = "codium"
|
||||
|
||||
-- Theme name
|
||||
config.theme_name = "default"
|
||||
|
||||
-- Layouts
|
||||
config.layouts = {
|
||||
awful.layout.suit.tile,
|
||||
awful.layout.suit.max,
|
||||
awful.layout.suit.floating,
|
||||
}
|
||||
config.default_layout = 1 -- Index of layout (1-indexed)
|
||||
|
||||
-- Tags
|
||||
config.tags = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }
|
||||
|
||||
-- Resize corner
|
||||
config.resize_corner = "bottom_right"
|
||||
|
||||
return config
|
24
awesome/.config/awesome/errors.lua
Normal file
24
awesome/.config/awesome/errors.lua
Normal file
|
@ -0,0 +1,24 @@
|
|||
local naughty = require("naughty")
|
||||
|
||||
if awesome.startup_errors then
|
||||
naughty.notify({
|
||||
preset = naughty.config.presets.critical,
|
||||
title = "There were errors during startup",
|
||||
text = awesome.startup_errors
|
||||
})
|
||||
end
|
||||
|
||||
do
|
||||
local in_error = false
|
||||
awesome.connect_signal("debug::error", function(err)
|
||||
if in_error then return end
|
||||
in_error = true
|
||||
|
||||
naughty.notify({
|
||||
preset = naughty.config.presets.critical,
|
||||
title = "An error occurred",
|
||||
text = tostring(err)
|
||||
})
|
||||
in_error = false
|
||||
end)
|
||||
end
|
43
awesome/.config/awesome/rc.lua
Normal file
43
awesome/.config/awesome/rc.lua
Normal file
|
@ -0,0 +1,43 @@
|
|||
-- Handle any errors
|
||||
require("errors")
|
||||
|
||||
-- Load LuaRocks if available
|
||||
pcall(require, "luarocks.loader")
|
||||
|
||||
-- Base
|
||||
local awful = require("awful")
|
||||
local wibox = require("wibox")
|
||||
local beautiful = require("beautiful")
|
||||
|
||||
-- Configurations
|
||||
local config = require("config")
|
||||
|
||||
-- Initialize the theme
|
||||
beautiful.init(string.format("%s/themes/%s/theme.lua", awesome.conffile:match("(.*/)"), config.theme_name))
|
||||
|
||||
-- Other definitions
|
||||
local binds = require("binds")
|
||||
local rules = require("rules")
|
||||
local widgets = require("wibar")
|
||||
|
||||
-- Set layouts
|
||||
awful.layout.layouts = config.layouts
|
||||
|
||||
-- Set up the tags and wibox for each screen
|
||||
awful.screen.connect_for_each_screen(function(s)
|
||||
awful.tag(config.tags, s, awful.layout.layouts[config.default_layout])
|
||||
|
||||
wibar_setup(s)
|
||||
end)
|
||||
|
||||
-- Set root key binds
|
||||
root.keys(binds.global_keys)
|
||||
|
||||
-- Apply rules
|
||||
awful.rules.rules = rules
|
||||
|
||||
-- Connect signals
|
||||
require("signals")
|
||||
|
||||
-- Always ensure a window is focused
|
||||
require("awful.autofocus")
|
44
awesome/.config/awesome/rules.lua
Normal file
44
awesome/.config/awesome/rules.lua
Normal file
|
@ -0,0 +1,44 @@
|
|||
local awful = require("awful")
|
||||
local beautiful = require("beautiful")
|
||||
|
||||
local binds = require("binds")
|
||||
|
||||
return {
|
||||
{ -- All clients
|
||||
rule = { },
|
||||
properties = {
|
||||
placement = awful.placement.no_overlap + awful.placement.no_offscreen,
|
||||
focus = awful.client.focus.filter,
|
||||
screen = awful.screen.preferred,
|
||||
border_width = beautiful.border_width,
|
||||
border_color = beautiful.border_normal,
|
||||
raise = true,
|
||||
keys = binds.client_keys,
|
||||
buttons = binds.client_buttons
|
||||
}
|
||||
},
|
||||
|
||||
{ -- Floating clients
|
||||
rule_any = {
|
||||
class = {
|
||||
"Arandr",
|
||||
"mpv",
|
||||
"Nsxiv"
|
||||
}
|
||||
},
|
||||
properties = { floating = true }
|
||||
},
|
||||
|
||||
{ -- Sticky Firefox PiP clients
|
||||
rule = { name = "Picture-in-Picture" },
|
||||
properties = {
|
||||
floating = true,
|
||||
sticky = true
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
rule = { floating = true },
|
||||
properties = { placement = awful.placement.centered }
|
||||
},
|
||||
}
|
49
awesome/.config/awesome/signals.lua
Normal file
49
awesome/.config/awesome/signals.lua
Normal file
|
@ -0,0 +1,49 @@
|
|||
local awful = require("awful")
|
||||
local beautiful = require("beautiful")
|
||||
|
||||
local utils = require("utils")
|
||||
|
||||
-- Set wallpaper
|
||||
screen.connect_signal("property::geometry", function(s)
|
||||
if beautiful.wallpaper then
|
||||
gears.wallpaper.maximized(beautiful.wallpaper, s, true)
|
||||
end
|
||||
end)
|
||||
|
||||
-- Ensure client is on screen
|
||||
client.connect_signal("manage", function(c)
|
||||
if awesome.startup
|
||||
and not c.size_hints.user_position
|
||||
and not c.size_hints.program_position
|
||||
then
|
||||
awful.placement.no_offscreen(c)
|
||||
end
|
||||
end)
|
||||
|
||||
-- Use sloppy focus for clients
|
||||
client.connect_signal("mouse::enter", function(c)
|
||||
c:emit_signal("request::activate", "mouse_enter", { raise = false })
|
||||
end)
|
||||
|
||||
-- Set border color based on focus status
|
||||
client.connect_signal("focus", function(c)
|
||||
if tag_only_has_floating() then
|
||||
awful.client.focus.byidx(1)
|
||||
else
|
||||
t = 0
|
||||
repeat
|
||||
awful.client.focus.byidx(-1)
|
||||
t = t + 1
|
||||
until not client.focus.floating or t > 5
|
||||
end
|
||||
c.border_color = beautiful.border_focus
|
||||
end)
|
||||
client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
|
||||
|
||||
client.connect_signal("unminimize", function(c) c.unminize() end)
|
||||
|
||||
client.connect_signal("manage", function (c)
|
||||
if c.floating then
|
||||
c.ontop = true
|
||||
end
|
||||
end)
|
40
awesome/.config/awesome/themes/default/theme.lua
Normal file
40
awesome/.config/awesome/themes/default/theme.lua
Normal file
|
@ -0,0 +1,40 @@
|
|||
local beautiful = require("beautiful")
|
||||
local theme_assets = require("beautiful.theme_assets")
|
||||
local xresources = require("beautiful.xresources")
|
||||
|
||||
local dpi = xresources.apply_dpi
|
||||
|
||||
local theme = {}
|
||||
|
||||
-- Fonts
|
||||
theme.font = "monospace 8"
|
||||
|
||||
-- Foreground colors
|
||||
theme.fg_normal = "#aaaaaa"
|
||||
theme.fg_focus = "#eeeeee"
|
||||
theme.fg_urgent = "#000000"
|
||||
|
||||
-- Background colors
|
||||
theme.bg_normal = "#222222"
|
||||
theme.bg_focus = "#888888"
|
||||
theme.bg_urgent = "#FFFFFF"
|
||||
|
||||
-- Border width and colors
|
||||
theme.border_width = dpi(1)
|
||||
|
||||
theme.border_normal = "#444444"
|
||||
theme.border_focus = "#aaaaaa"
|
||||
|
||||
-- Gap size
|
||||
theme.useless_gap = dpi(4)
|
||||
|
||||
-- Taglist squares
|
||||
local taglist_square_size = dpi(4)
|
||||
|
||||
theme.taglist_squares_sel = theme_assets.taglist_squares_sel(taglist_square_size, theme.fg_normal)
|
||||
theme.taglist_squares_unsel = theme_assets.taglist_squares_unsel(taglist_square_size, theme.fg_normal)
|
||||
|
||||
-- Wallpaper path
|
||||
theme.wallpaper = string.format("%s/wallpaper", os.getenv("XDG_DATA_HOME"))
|
||||
|
||||
return theme
|
12
awesome/.config/awesome/utils.lua
Normal file
12
awesome/.config/awesome/utils.lua
Normal file
|
@ -0,0 +1,12 @@
|
|||
local awful = require("awful")
|
||||
|
||||
function tag_only_has_floating()
|
||||
local tag = awful.screen.focused().selected_tag
|
||||
local clients = tag:clients()
|
||||
for _, c in ipairs(clients) do
|
||||
if not c.floating then
|
||||
return false
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
30
awesome/.config/awesome/wibar.lua
Normal file
30
awesome/.config/awesome/wibar.lua
Normal file
|
@ -0,0 +1,30 @@
|
|||
local awful = require("awful")
|
||||
local wibox = require("wibox")
|
||||
|
||||
local binds = require("binds")
|
||||
|
||||
function wibar_setup(s)
|
||||
s.taglist = awful.widget.taglist {
|
||||
filter = awful.widget.taglist.filter.all,
|
||||
buttons = binds.taglist_buttons,
|
||||
screen = s,
|
||||
}
|
||||
|
||||
s.wibox = awful.wibar {
|
||||
screen = s,
|
||||
}
|
||||
|
||||
s.wibox:setup {
|
||||
layout = wibox.layout.align.horizontal,
|
||||
{
|
||||
layout = wibox.layout.fixed.horizontal,
|
||||
s.taglist,
|
||||
},
|
||||
nil,
|
||||
{
|
||||
layout = wibox.layout.fixed.horizontal,
|
||||
wibox.widget.systray(),
|
||||
wibox.widget.textclock(),
|
||||
},
|
||||
}
|
||||
end
|
Loading…
Reference in a new issue