This commit is contained in:
Niktia Bykov
2024-01-01 15:42:39 +05:00
commit 982f56d950
60 changed files with 5427 additions and 0 deletions

464
.config/awesome/rc.lua Normal file
View File

@ -0,0 +1,464 @@
-- If LuaRocks is installed, make sure that packages installed through it are
-- found (e.g. lgi). If LuaRocks is not installed, do nothing.
pcall(require, "luarocks.loader")
-- Standard awesome library
local gears = require("gears")
local awful = require("awful")
require("awful.autofocus")
-- Widget and layout library
local wibox = require("wibox")
-- Theme handling library
local beautiful = require("beautiful")
-- Notification library
local naughty = require("naughty")
local hotkeys_popup = require("awful.hotkeys_popup")
-- Enable hotkeys help widget for VIM and other apps
-- when client with a matching name is opened:
require("awful.hotkeys_popup.keys")
-- {{{ Error handling
-- Check if awesome encountered an error during startup and fell back to
-- another config (This code will only ever execute for the fallback config)
if awesome.startup_errors then
naughty.notify({
preset = naughty.config.presets.critical,
title = "Oops, there were errors during startup!",
text = awesome.startup_errors,
})
end
-- Handle runtime errors after startup
do
local in_error = false
awesome.connect_signal("debug::error", function(err)
-- Make sure we don't go into an endless error loop
if in_error then
return
end
in_error = true
naughty.notify({
preset = naughty.config.presets.critical,
title = "Oops, an error happened!",
text = tostring(err),
})
in_error = false
end)
end
-- }}}
-- {{{ Variable definitions
-- Themes define colours, icons, font and wallpapers.
beautiful.init(gears.filesystem.get_themes_dir() .. "default/theme.lua")
-- This is used later as the default terminal and editor to run.
browser = "librewolf"
terminal = "alacritty"
editor = os.getenv("nvim") or "nvim"
editor_cmd = terminal .. " -e " .. editor
modkey = "Mod4"
awful.layout.layouts = {
awful.layout.suit.tile,
}
local taglist_buttons = gears.table.join(
awful.button({}, 1, function(t)
t:view_only()
end),
awful.button({ modkey }, 1, function(t)
if client.focus then
client.focus:move_to_tag(t)
end
end),
awful.button({}, 3, awful.tag.viewtoggle),
awful.button({ modkey }, 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 tasklist_buttons = gears.table.join(
awful.button({}, 1, function(c)
if c == client.focus then
c.minimized = true
else
c:emit_signal("request::activate", "tasklist", { raise = true })
end
end),
awful.button({}, 3, function()
awful.menu.client_list({ theme = { width = 250 } })
end),
awful.button({}, 4, function()
awful.client.focus.byidx(1)
end),
awful.button({}, 5, function()
awful.client.focus.byidx(-1)
end)
)
local function set_wallpaper(s)
-- Wallpaper
if beautiful.wallpaper then
local wallpaper = beautiful.wallpaper
-- If wallpaper is a function, call it with the screen
if type(wallpaper) == "function" then
wallpaper = wallpaper(s)
end
gears.wallpaper.maximized(wallpaper, s, true)
end
end
-- Re-set wallpaper when a screen's geometry changes (e.g. different resolution)
screen.connect_signal("property::geometry", set_wallpaper)
awful.screen.connect_for_each_screen(function(s)
awful.tag({ "1", "2", "3", "4", "5", "6", "7", "8", "9" }, s, awful.layout.layouts[1])
end)
-- {{{ Mouse bindings
root.buttons(gears.table.join(
-- awful.button({}, 3, function()
-- mymainmenu:toggle()
-- end),
awful.button({}, 4, awful.tag.viewnext),
awful.button({}, 5, awful.tag.viewprev)
))
-- }}}
-- {{{ Key bindings
globalkeys = gears.table.join(
awful.key({ modkey }, "s", hotkeys_popup.show_help, { description = "show help", group = "awesome" }),
-- awful.key({ modkey }, "Left", awful.tag.viewprev, { description = "view previous", group = "tag" }),
-- awful.key({ modkey }, "Right", awful.tag.viewnext, { description = "view next", group = "tag" }),
awful.key({ modkey }, "Escape", awful.tag.history.restore, { description = "go back", group = "tag" }),
awful.key({ modkey }, "l", function()
awful.client.focus.byidx(1)
end, { description = "focus next by index", group = "client" }),
awful.key({ modkey }, "h", function()
awful.client.focus.byidx(-1)
end, { description = "focus previous by index", group = "client" }),
awful.key({ modkey }, "w", function()
mymainmenu:show()
end, { description = "show main menu", group = "awesome" }),
-- Layout manipulation
awful.key({ modkey, "Shift" }, "h", function()
awful.client.swap.byidx(1)
end, { description = "swap with next client by index", group = "client" }),
awful.key({ modkey, "Shift" }, "l", function()
awful.client.swap.byidx(-1)
end, { description = "swap with previous client by index", group = "client" }),
awful.key({ modkey }, "k", function()
awful.screen.focus_relative(1)
end, { description = "focus the next screen", group = "screen" }),
awful.key({ modkey }, "j", function()
awful.screen.focus_relative(-1)
end, { description = "focus the previous screen", group = "screen" }),
awful.key({ modkey }, "u", awful.client.urgent.jumpto, { description = "jump to urgent client", group = "client" }),
awful.key({ modkey }, "Tab", function()
awful.client.focus.history.previous()
if client.focus then
client.focus:raise()
end
end, { description = "go back", group = "client" }),
-- Standard program
awful.key({ modkey, "Shift" }, "r", awesome.restart, { description = "reload awesome", group = "awesome" }),
awful.key({ modkey, "Shift" }, "e", awesome.quit, { description = "quit awesome", group = "awesome" }),
awful.key({ modkey }, "y", function()
awful.tag.incmwfact(0.05)
end, { description = "increase master width factor", group = "layout" }),
awful.key({ modkey }, "o", function()
awful.tag.incmwfact(-0.05)
end, { description = "decrease master width factor", group = "layout" }),
-- launch dmenu
awful.key({ modkey }, "d", function()
awful.util.spawn("dmenu_run")
end, { description = "dmenu", group = "launcher" }),
-- launch browser
awful.key({ modkey }, "b", function()
awful.util.spawn(browser)
end, { description = "launch browser", group = "launcher" }),
-- launch terminal
awful.key({ modkey }, "Return", function()
awful.spawn(terminal)
end, { description = "open a terminal", group = "launcher" }),
-- launch ncmpcpp
awful.key({ modkey }, "m", function()
awful.spawn.with_shell(terminal .. " -e ncmpcpp")
end, { description = "open ncmpcpp", group = "launcher" }),
-- music player daemon controls
awful.key({}, "XF86AudioPlay", function()
awful.spawn("playerctl play-pause")
end, { description = "toggle play", group = "launcher" }),
awful.key({}, "XF86AudioPause", function()
awful.spawn.with_shell("playerctl play-pause")
end, { description = "toggle play", group = "launcher" }),
awful.key({}, "XF86AudioNext", function()
awful.spawn.with_shell("playerctl next")
end, { description = "next", group = "launcher" }),
awful.key({}, "XF86AudioPrev", function()
awful.spawn.with_shell("playerctl previous")
end, { description = "previous", group = "launcher" }),
awful.key({ modkey, "Shift" }, "bracketleft", function()
awful.spawn.with_shell("playerctl -p mpd volume 0.05-")
end, { description = "decrease volume", group = "launcher" }),
awful.key({ modkey, "Shift" }, "bracketright", function()
awful.spawn.with_shell("playerctl -p mpd volume 0.05+")
end, { description = "increase volume", group = "launcher" }),
-- media hotkeys
awful.key({}, "XF86AudioRaiseVolume", function()
awful.spawn("pactl set-sink-volume @DEFAULT_SINK@ +10%")
end, { description = "raise volume", group = "launcher" }),
awful.key({}, "XF86AudioLowerVolume", function()
awful.spawn("pactl set-sink-volume @DEFAULT_SINK@ -10%")
end, { description = "lower volume", group = "launcher" }),
awful.key({}, "XF86AudioMute", function()
awful.spawn("pactl set-sink-mute @DEFAULT_SINK@ toggle")
end, { description = "toggle mute", group = "launcher" }),
-- toggle picom
awful.key({ modkey }, "c", function()
awful.spawn.with_shell("~/.config/awesome/scripts/toggle_picom.sh")
end, { description = "toggle picom", group = "launcher" }),
-- make screenshot
awful.key({ modkey }, "Print", function()
awful.spawn.with_shell("flameshot gui")
end, { description = "flameshot", group = "launcher" }),
-- logout
awful.key({ modkey, "Shift" }, "BackSpace", function()
awful.spawn.with_shell("$HOME/.config/awesome/scripts/logout_script.sh")
end, { description = "logout", group = "launcher" })
)
clientkeys = gears.table.join(
awful.key({ modkey }, "f", function(c)
c.fullscreen = not c.fullscreen
c:raise()
end, { description = "toggle fullscreen", group = "client" }),
awful.key({ modkey, "Shift" }, "q", function(c)
c:kill()
end, { description = "close", group = "client" }),
awful.key(
{ modkey, "Shift" },
"space",
awful.client.floating.toggle,
{ description = "toggle floating", group = "client" }
),
awful.key({ modkey }, "space", function(c)
c:swap(awful.client.getmaster())
end, { description = "move to master", group = "client" }),
awful.key({ modkey }, "p", function(c)
c:move_to_screen()
end, { description = "move to screen", group = "client" }),
awful.key({ modkey }, "t", function(c)
c.ontop = not c.ontop
end, { description = "toggle keep on top", group = "client" })
)
-- Bind all key numbers to tags.
-- Be careful: we use keycodes to make it work on any keyboard layout.
-- This should map on the top row of your keyboard, usually 1 to 9.
for i = 1, 9 do
globalkeys = gears.table.join(
globalkeys,
-- View tag only.
awful.key({ modkey }, "#" .. i + 9, function()
local screen = awful.screen.focused()
local tag = screen.tags[i]
if tag then
tag:view_only()
end
end, { description = "view tag #" .. i, group = "tag" }),
-- Toggle tag display.
awful.key({ modkey, "Control" }, "#" .. i + 9, function()
local screen = awful.screen.focused()
local tag = screen.tags[i]
if tag then
awful.tag.viewtoggle(tag)
end
end, { description = "toggle tag #" .. i, group = "tag" }),
-- Move client to tag.
awful.key({ modkey, "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, { description = "move focused client to tag #" .. i, group = "tag" }),
-- Toggle tag on focused client.
awful.key({ modkey, "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, { description = "toggle focused client on tag #" .. i, group = "tag" })
)
end
clientbuttons = gears.table.join(
awful.button({}, 1, function(c)
c:emit_signal("request::activate", "mouse_click", { raise = true })
end),
awful.button({ modkey }, 1, function(c)
c:emit_signal("request::activate", "mouse_click", { raise = true })
awful.mouse.client.move(c)
end),
awful.button({ modkey }, 3, function(c)
c:emit_signal("request::activate", "mouse_click", { raise = true })
awful.mouse.client.resize(c)
end)
)
-- Set keys
root.keys(globalkeys)
-- }}}
-- {{{ Rules
-- Rules to apply to new clients (through the "manage" signal).
awful.rules.rules = {
-- All clients will match this rule.
{
rule = {},
properties = {
border_width = beautiful.border_width,
border_color = beautiful.border_normal,
focus = awful.client.focus.filter,
raise = true,
keys = clientkeys,
buttons = clientbuttons,
screen = awful.screen.preferred,
placement = awful.placement.no_overlap + awful.placement.no_offscreen,
},
},
{
rule = { instance = "polybar" },
properties = { border_width = false, focusable = false, below = true },
},
-- Floating clients.
{
rule_any = {
instance = {
"DTA", -- Firefox addon DownThemAll.
"copyq", -- Includes session name in class.
"pinentry",
},
class = {
"Arandr",
"Blueman-manager",
"Gpick",
"Kruler",
"MessageWin", -- kalarm.
"Sxiv",
"Tor Browser", -- Needs a fixed window size to avoid fingerprinting by screen size.
"Wpa_gui",
"veromix",
"xtightvncviewer",
},
-- Note that the name property shown in xprop might be set slightly after creation of the client
-- and the name shown there might not match defined rules here.
name = {
"Event Tester", -- xev.
},
role = {
"AlarmWindow", -- Thunderbird's calendar.
"ConfigManager", -- Thunderbird's about:config.
"pop-up", -- e.g. Google Chrome's (detached) Developer Tools.
},
},
properties = { floating = true },
},
-- Add titlebars to normal clients and dialogs
{ rule_any = { type = { "normal", "dialog" } }, properties = { titlebars_enabled = false } },
}
-- }}}
-- {{{ Signals
-- Signal function to execute when a new client appears.
client.connect_signal("manage", function(c)
-- Set the windows at the slave,
-- i.e. put it at the end of others instead of setting it master.
-- if not awesome.startup then awful.client.setslave(c) end
if awesome.startup and not c.size_hints.user_position and not c.size_hints.program_position then
-- Prevent clients from being unreachable after screen count changes.
awful.placement.no_offscreen(c)
end
end)
-- Enable sloppy focus, so that focus follows mouse.
client.connect_signal("mouse::enter", function(c)
c:emit_signal("request::activate", "mouse_enter", { raise = false })
end)
client.connect_signal("focus", function(c)
c.border_color = beautiful.border_focus
end)
client.connect_signal("unfocus", function(c)
c.border_color = beautiful.border_normal
end)
-- Gaps
beautiful.useless_gap = 10
client.connect_signal("property::minimized", function(c)
c.minimized = false
end)
-- client.connect_signal("property::maximized", function(c)
-- c.shape = function(cr, w, h)
-- gears.shape.rounded_rect(cr, w, h, 0)
-- end
-- end)
-- rounded borders
client.connect_signal("manage", function(c)
if c.instance ~= "polybar" then
c.shape = function(cr, w, h)
gears.shape.rounded_rect(cr, w, h, 0)
end
end
end)
-- !!! somehow this breaks fullscreen !!!
-- floating on top always
-- client.connect_signal("property::floating", function(c)
-- if c.floating then
-- c.ontop = true
-- else
-- c.ontop = false
-- end
-- end)
-- Autostart
-- awful.spawn.with_shell("picom")
awful.spawn.with_shell("$HOME/.config/polybar/launch_polybar.sh")
awful.spawn.with_shell("~/.fehbg")
awful.spawn.with_shell("xinput set-prop 13 298 0, -1")
awful.spawn.with_shell("amixer -c 0 set Front unmute")
-- awful.spawn.with_shell("mpDris2")
-- awful.spawn.with_shell("dex -ae i3")
naughty.config.defaults.icon_size = 32