Compare commits

..

3 Commits

Author SHA1 Message Date
Yessiest f8f500d306 Testing new uevent-based attribute reading 2022-09-04 21:03:37 +04:00
Yessiest e8dfae3013 Minor bugfix 2022-09-04 16:05:41 +04:00
Yessiest 663fbd1f8c Various QoL improvements 2022-09-04 14:49:18 +04:00
6 changed files with 87 additions and 80 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
/desktop.conf
/wallpaper.txt
/links
/libs/pam

View File

@ -1,10 +1,10 @@
# Global variables
[global]
terminal = "$HOME/.local/bin/st"
browser = "prime-run librewolf"
modkey = "Mod4"
theme = "reno98"
shell = "zsh"
terminal = "$HOME/.local/bin/st"
browser = "prime-run librewolf"
modkey = "Mod4"
theme = "reno98"
shell = "zsh"
# Keybindings
# Format: <modifier>(+<modifier>+...)+<key> = "<command or :internal.function>"
@ -28,4 +28,5 @@ modkey+n = ":client.minimize"
modkey+m = ":client.maximize"
# Custom keys
modkey+v = "notify-send test"
Print = "flameshot gui"
Shift+Print = "flameshot launcher"

View File

@ -19,7 +19,7 @@ local function position_popup(popup,widget,style)
-- Figure out the geometry of the base widget
local widget_geo
for k,v in pairs(mouse.current_widgets or {}) do
if widget == v then
if (widget == v) and mouse.current_widget_geometries then
widget_geo = mouse.current_widget_geometries[k]
end
end

View File

@ -38,6 +38,7 @@ syscontrol.backlight.read_attribs = function(dev_name)
writable = false
}
fhandler:close()
bhandler:close()
local wfhandler = io.open("/sys/class/backlight/"..dev_name.."/brightness","w")
if wfhandler then
wfhandler:close()
@ -83,36 +84,39 @@ end
syscontrol.power_supply.read_attribs = function(dev_name)
local fhandler,err = io.open("/sys/class/power_supply/"..dev_name.."/type","r")
if fhandler then
local dtype = fhandler:read("*a"):match("%S*")
fhandler:close()
local full_path = "/sys/class/power_supply/"..dev_name
local uevent_f = io.open("/sys/class/power_supply/"..dev_name.."/uevent","r")
if not uevent_f then
return nil, "Unable to open uevent file"
end
local uevent_data = {}
local device = {
type = dtype,
full_path = full_path,
type = fhandler:read("*a"),
full_path = "/sys/class/power_supply/"..dev_name,
name = dev_name
}
if dtype == "Mains" then
local online_f = io.open(full_path.."/online","r")
device.online = (online_f:read("*a"):match("%S*") == "1")
online_f:close()
elseif dtype == "Battery" then
local capacity_f = io.open(full_path.."/capacity","r")
local model_f = io.open(full_path.."/model_name","r")
local energy_full_design_f = io.open(full_path.."/energy_full_design","r")
local energy_full_f = io.open(full_path.."/energy_full","r")
local charging_f = io.open(full_path.."/status","r")
device.model = model_f:read("*a"):match("[^\n]*")
device.energy_full_design = tonumber(energy_full_design_f:read("*a"))
device.energy_full = tonumber(energy_full_f:read("*a"))
fhandler:close()
uevent:read("*a"):gsub("[^\n]+",function(line)
local key,value = line:match("^([^=]+)=([^=]*)")
if value:match("^%d+$") then
value = tonumber(value)
end
uevent_data[key] = value
end)
uevent:close()
if device.type == "Battery" then
device.model = uevent_data.POWER_SUPPLY_MODEL_NAME or "N/A"
device.energy_full_design = uevent_data.POWER_SUPPLY_ENERGY_FULL_DESIGN
device.energy_full = uevent_data.POWER_SUPPLY_ENERGY_FULL
if not device.energy_full_design then
device.energy_full_design = uevent_data.POWER_SUPPLY_CHARGE_FULL_DESIGN or -1
device.energy_full = uevent_data.POWER_SUPPLY_CHARGE_FULL or -1
end
device.quality = (device.energy_full/device.energy_full_design)*100
device.capacity = tonumber(capacity_f:read("*a"))
device.charging = (charging_f:read("*a"):match("%S*") == "Charging")
capacity_f:close()
model_f:close()
energy_full_design_f:close()
energy_full_f:close()
end
return device
device.capacity = uevent_data.POWER_SUPPLY_CAPACITY or 0
device.charging = (uevent_data.POWER_SUPPLY_STATUS == "Charging")
elseif device.type == "Mains" then
device.online = (uevent_data.POWER_SUPPLY_ONLINE == 1)
end
else
return nil, err
end

View File

@ -46,6 +46,51 @@ for k,v in pairs(json.decode(config) or {}) do
end
end -- }}}
do --{{{ Screen
local wibar_config = {}
local style = awmtk2.create_style("wibar",awmtk2.default,{})
for k,v in pairs({"wibar_top","wibar_bottom","wibar_left","wibar_right"}) do
style[v] = awmtk2.create_delta(v, {},
(beautiful.widgets and beautiful.widgets.wibar) or {},
style.wibar)
wibar_config[v] = read_file(root_path.."/themes/"..global.theme.."/config/"..v..".json")
end
local templates = awmtk2.create_template_lib("wibar",awmtk2.templates,{})
local t = awmtk2.build_templates(templates,style)
awful.screen.connect_for_each_screen(function(s)
for k,v in pairs({"wibar_top","wibar_bottom","wibar_left","wibar_right"}) do
local contents = { widget = wibox.container.background }
if wibar_config[v] then
contents = builder(wibar_config[v],{
client = c,
style = style[v],
buttons = buttons,
screen = s
})
s[v] = awful.wibar({
-- There really isn't a better way to do this. I wish there was.
position = v:gsub("wibar_",""),
screen = s,
visible = true,
stretch = style[v].stretch,
ontop = style[v].ontop,
width = style[v].width,
height = style[v].height,
border_width = style[v].border_width,
border_color = style[v].border_color,
opacity = style[v].opacity or 1,
shape = style[v].shape,
bg = style[v].bg,
bgimage = style[v].bgimage,
fg = style[v].fg,
input_passthrough = style[v].input_passthrough
})
s[v]:setup(t.wibar(contents))
end
end
end)
end -- }}}
do -- {{{ Titlebars
local titlebar_config = {}
@ -98,52 +143,8 @@ client.connect_signal("request::titlebars",function(c)
fg_focus = style[v].fg_focus,
font = style[v].font
}):setup(t.titlebar(contents))
awful.rules.rules[1].properties.placement(c)
end
end)
end --}}}
do --{{{ Screen
local wibar_config = {}
local style = awmtk2.create_style("wibar",awmtk2.default,{})
for k,v in pairs({"wibar_top","wibar_bottom","wibar_left","wibar_right"}) do
style[v] = awmtk2.create_delta(v, {},
(beautiful.widgets and beautiful.widgets.wibar) or {},
style.wibar)
wibar_config[v] = read_file(root_path.."/themes/"..global.theme.."/config/"..v..".json")
end
local templates = awmtk2.create_template_lib("wibar",awmtk2.templates,{})
local t = awmtk2.build_templates(templates,style)
awful.screen.connect_for_each_screen(function(s)
for k,v in pairs({"wibar_top","wibar_bottom","wibar_left","wibar_right"}) do
local contents = { widget = wibox.container.background }
if wibar_config[v] then
contents = builder(wibar_config[v],{
client = c,
style = style[v],
buttons = buttons,
screen = s
})
s[v] = awful.wibar({
-- There really isn't a better way to do this. I wish there was.
position = v:gsub("wibar_",""),
screen = s,
visible = true,
stretch = style[v].stretch,
ontop = style[v].ontop,
width = style[v].width,
height = style[v].height,
border_width = style[v].border_width,
border_color = style[v].border_color,
opacity = style[v].opacity or 1,
shape = style[v].shape,
bg = style[v].bg,
bgimage = style[v].bgimage,
fg = style[v].fg,
input_passthrough = style[v].input_passthrough
})
s[v]:setup(t.wibar(contents))
end
end
end)
end -- }}}

View File

@ -328,8 +328,8 @@ theme["action-poweroff-symbolic"] = themes_path.."reno98/icons/action-poweroff-s
theme["action-lock-screen-symbolic"] = themes_path.."reno98/icons/action-lock-screen-symbolic.png"
theme["action-suspend-symbolic"] = themes_path.."reno98/icons/action-suspend-symbolic.png"
-- Notification popups settings
theme.notification_width = 200
theme.notification_height = 40
theme.notification_width = 240
theme.notification_height = 60
-- Default icon for clients
-- This one has to be baked as a surface to avoid memory leaks