add awesomeWM config + utility scripts that were in there
This commit is contained in:
parent
a419b86997
commit
986ea52711
27 changed files with 947 additions and 9 deletions
30
awesome/modules/autostart.lua
Normal file
30
awesome/modules/autostart.lua
Normal file
|
@ -0,0 +1,30 @@
|
|||
local awful = require("awful")
|
||||
require("modules/smart_reload")
|
||||
require("modules/laptop_detector")
|
||||
|
||||
if is_reloading() then
|
||||
finish_reload()
|
||||
return
|
||||
end
|
||||
|
||||
awful.spawn(CONFIG_DIR .. "utils/xcape_conf.sh") -- xcape config
|
||||
awful.spawn("picom -b") -- compositor
|
||||
awful.spawn("/usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1") -- authentication popup for obs virtual camera etc
|
||||
awful.spawn("redshift")
|
||||
awful.spawn("sxhkd")
|
||||
|
||||
if not is_laptop then
|
||||
awful.spawn("numlockx on") -- numlock
|
||||
awful.spawn(CONFIG_DIR .. "utils/xrandr_conf.sh") -- xrandr config
|
||||
|
||||
awful.spawn("discord", { screen = 3 })
|
||||
awful.spawn("vscodium")
|
||||
awful.spawn("spotify", { tag = "2", screen = 3, urgent = false })
|
||||
awful.spawn("firefox")
|
||||
|
||||
awful.spawn(terminal .. " -e fish -c \"sleep 2 && gomuks\"", { tag = "3", screen = 3, urgent = false, focus = false })
|
||||
awful.spawn(terminal .. " -e fish -c \"sleep 5 && ncpamixer\"",
|
||||
{ tag = "4", screen = 3, urgent = false, focus = false })
|
||||
awful.spawn(terminal .. " -e btop", { tag = "5", screen = 3, urgent = false, focus = false })
|
||||
awful.spawn(terminal .. " -e fish -c \"sleep 5 && snoud\"", { tag = "6", screen = 3, urgent = false, focus = false })
|
||||
end
|
74
awesome/modules/battery.lua
Normal file
74
awesome/modules/battery.lua
Normal file
|
@ -0,0 +1,74 @@
|
|||
local awful = require("awful")
|
||||
local wibox = require("wibox")
|
||||
--local beautiful = require("beautiful")
|
||||
local gears = require("gears")
|
||||
|
||||
require("modules/laptop_detector")
|
||||
|
||||
if not is_laptop then
|
||||
battery_widget = wibox.widget.textbox()
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
local tohex = function(value)
|
||||
local h = string.format("%x", value)
|
||||
if h:len() == 1 then
|
||||
h = "0" .. h
|
||||
end
|
||||
return h
|
||||
end
|
||||
|
||||
-- battery percentage
|
||||
local battery_text = awful.widget.watch("cat /sys/class/power_supply/BAT0/capacity", 30, function(widget, stdout)
|
||||
for line in stdout:gmatch("[^\r\n]+") do
|
||||
widget.text = line .. "%"
|
||||
break
|
||||
end
|
||||
|
||||
widget.align = "center"
|
||||
end)
|
||||
|
||||
local battery_charging = awful.widget.watch("cat /sys/class/power_supply/AC/online", 5, function(widget, stdout)
|
||||
for line in stdout:gmatch("[^\r\n]+") do
|
||||
if line == "1" then
|
||||
widget.text = " +"
|
||||
else
|
||||
widget.text = " -"
|
||||
end
|
||||
break
|
||||
end
|
||||
end)
|
||||
|
||||
local battery_bar = awful.widget.watch("cat /sys/class/power_supply/BAT0/capacity", 30, function(widget, stdout)
|
||||
local charge = 0
|
||||
for line in stdout:gmatch("[^\r\n]+") do
|
||||
charge = tonumber(line)
|
||||
break
|
||||
end
|
||||
widget.value = charge
|
||||
local red = 0
|
||||
local green = 102
|
||||
if charge <= 50 then
|
||||
red = (50 - charge) * 5
|
||||
green = charge * 2
|
||||
end
|
||||
local color = "#" .. tohex(red) .. tohex(green) .. "00"
|
||||
widget.color = color
|
||||
widget.max_value = 100
|
||||
widget.forced_width = 64
|
||||
widget.border_color = color --"#008866"
|
||||
widget.background_color = "#000000"
|
||||
widget.border_width = 1
|
||||
widget.shape = function(cr, width, height) gears.shape.octogon(cr, width, height, 2) end
|
||||
widget.margins = { top = 1, bottom = 1, left = 5, right = 5 }
|
||||
end,
|
||||
wibox.widget.progressbar())
|
||||
|
||||
|
||||
battery_widget = {
|
||||
battery_bar,
|
||||
battery_text,
|
||||
battery_charging,
|
||||
layout = wibox.layout.stack
|
||||
}
|
39
awesome/modules/brightness.lua
Normal file
39
awesome/modules/brightness.lua
Normal file
|
@ -0,0 +1,39 @@
|
|||
local awful = require("awful")
|
||||
local wibox = require("wibox")
|
||||
--local beautiful = require("beautiful")
|
||||
|
||||
require("modules/laptop_detector")
|
||||
|
||||
if not is_laptop then
|
||||
brightness = {}
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
local piechart_widget, piechart_timer = awful.widget.watch("simple-brightness get", 1,
|
||||
function(widget, stdout)
|
||||
local val = tonumber(stdout)
|
||||
widget.data_list = {
|
||||
{ "brightness", val },
|
||||
{ "fill", 255 - val }
|
||||
}
|
||||
widget.display_labels = false
|
||||
widget.forced_height = 24
|
||||
widget.forced_width = 24
|
||||
--widget.border_color = "#ffff00"
|
||||
widget.border_width = 0
|
||||
widget.colors = { "#ffbb00", "#444444" }
|
||||
end,
|
||||
wibox.widget.piechart()
|
||||
)
|
||||
|
||||
local inc_f = function(amt)
|
||||
awful.spawn("simple-brightness inc " .. tostring(amt))
|
||||
-- TODO: force update, decrease watch frequency
|
||||
--piechart_timer
|
||||
end
|
||||
|
||||
brightness = {
|
||||
piechart = piechart_widget,
|
||||
inc = inc_f
|
||||
}
|
12
awesome/modules/laptop_detector.lua
Normal file
12
awesome/modules/laptop_detector.lua
Normal file
|
@ -0,0 +1,12 @@
|
|||
local function file_exists(name)
|
||||
local f = io.open(name, "r")
|
||||
if f ~= nil then
|
||||
io.close(f)
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
is_laptop = file_exists("/sys/class/power_supply/BAT0/capacity")
|
||||
--is_laptop = true
|
29
awesome/modules/navigation_keys.lua
Normal file
29
awesome/modules/navigation_keys.lua
Normal file
|
@ -0,0 +1,29 @@
|
|||
local awful = require("awful")
|
||||
local gears = require("gears")
|
||||
|
||||
navigation_keys = gears.table.join(
|
||||
-- Layout manipulation
|
||||
awful.key({ modkey, "Shift" }, "j", function() awful.client.swap.byidx(1) end,
|
||||
{ description = "swap with next client by index", group = "client" }),
|
||||
|
||||
awful.key({ modkey, "Shift" }, "k", function() awful.client.swap.byidx(-1) end,
|
||||
{ description = "swap with previous client by index", group = "client" }),
|
||||
|
||||
awful.key({ modkey, "Control" }, "j", function() awful.screen.focus_relative(1) end,
|
||||
{ description = "focus the next screen", group = "screen" }),
|
||||
|
||||
awful.key({ modkey, "Control" }, "k", 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" })
|
||||
)
|
34
awesome/modules/smart_reload.lua
Normal file
34
awesome/modules/smart_reload.lua
Normal file
|
@ -0,0 +1,34 @@
|
|||
local awful = require("awful")
|
||||
|
||||
CONFIG_DIR = awful.util.get_configuration_dir()
|
||||
HOME_DIR = CONFIG_DIR .. "../../"
|
||||
|
||||
local function file_exists(name)
|
||||
local f = io.open(name, "r")
|
||||
if f ~= nil then
|
||||
io.close(f)
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
local INDICATOR_FILE = "/tmp/awesome_is_restarting"
|
||||
|
||||
function test()
|
||||
local focused_client = awful.client.focus.history.get()
|
||||
focused_client:raise()
|
||||
end
|
||||
|
||||
function smart_reload()
|
||||
awful.spawn("touch " .. INDICATOR_FILE)
|
||||
awesome.restart()
|
||||
end
|
||||
|
||||
function is_reloading()
|
||||
return file_exists(INDICATOR_FILE)
|
||||
end
|
||||
|
||||
function finish_reload()
|
||||
awful.spawn("rm " .. INDICATOR_FILE)
|
||||
end
|
64
awesome/modules/special_keys.lua
Normal file
64
awesome/modules/special_keys.lua
Normal file
|
@ -0,0 +1,64 @@
|
|||
local awful = require("awful")
|
||||
local gears = require("gears")
|
||||
|
||||
require("modules/laptop_detector")
|
||||
|
||||
special_keys = gears.table.join(
|
||||
awful.key({ "Ctrl" }, "Print", function()
|
||||
awful.util.spawn(SCRIPTS_DIR .. "screenshot_selection.sh")
|
||||
end,
|
||||
{ description = "screenshot selection", group = "screenshot" }),
|
||||
|
||||
awful.key({ modkey, "Shift" }, "s", function()
|
||||
awful.util.spawn(SCRIPTS_DIR .. "screenshot_selection.sh")
|
||||
end,
|
||||
{ description = "screenshot selection", group = "screenshot" }),
|
||||
|
||||
awful.key({}, "Print", function()
|
||||
awful.util.spawn(SCRIPTS_DIR .. "screenshot_full.sh")
|
||||
end,
|
||||
{ description = "full screenshot", group = "screenshot" }),
|
||||
|
||||
awful.key({ "Shift" }, "Print", function()
|
||||
awful.util.spawn(SCRIPTS_DIR .. "record_mp4.sh")
|
||||
end,
|
||||
{ description = "record selection", group = "screenshot" }),
|
||||
|
||||
awful.key({ modkey }, "Print", function()
|
||||
awful.util.spawn(SCRIPTS_DIR .. "screenshot_active.sh")
|
||||
end,
|
||||
{ description = "screenshot active window", group = "screenshot" }),
|
||||
|
||||
|
||||
awful.key({ modkey }, "r", function()
|
||||
awful.util.spawn("rofi -show")
|
||||
end,
|
||||
{ description = "Rofi", group = "launcher" }),
|
||||
|
||||
|
||||
-- Media Keys
|
||||
awful.key({}, "XF86AudioPlay", function()
|
||||
awful.util.spawn("playerctl play-pause", false)
|
||||
end),
|
||||
awful.key({}, "XF86AudioNext", function()
|
||||
awful.util.spawn("playerctl next", false)
|
||||
end),
|
||||
awful.key({}, "XF86AudioPrev", function()
|
||||
awful.util.spawn("playerctl previous", false)
|
||||
end)
|
||||
)
|
||||
|
||||
if is_laptop then
|
||||
special_keys = gears.table.join(
|
||||
special_keys,
|
||||
awful.key({}, "XF86MonBrightnessUp", function()
|
||||
awful.spawn("/usr/bin/simple-brightness -inc 32")
|
||||
end,
|
||||
{ description = "Increase brightness", group = "laptop" }),
|
||||
|
||||
awful.key({}, "XF86MonBrightnessDown", function()
|
||||
awful.spawn("/usr/bin/simple-brightness -dec 32")
|
||||
end,
|
||||
{ description = "Lower brightness", group = "laptop" })
|
||||
)
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue