Compositor inhibiting

This commit is contained in:
Yessiest 2023-03-21 22:12:35 +04:00
parent ac15d2ce70
commit 02a3db7ebd
6 changed files with 99 additions and 7 deletions

View File

@ -46,7 +46,24 @@ XF86AudioPlay = ":mpc.play"
XF86AudioPrev = ":mpc.prev"
XF86AudioNext = ":mpc.next"
# Custom keys
Print = "flameshot gui"
Shift+Print = "flameshot launcher"
# Power manager module
[powerman]
# Bad battery condition warning threshold
battery_quality_min = 33
# Low battery warning threshold
battery_capacity_min = 15
# Process to execute on low battery
on_low_battery = ""
# Process to execute on fully charged battery
on_charged_battery = ""
# Process to execute on critical battery condition
on_critical_condition = ""
# Simple compositor inhibiting
[compositor]
# Command to use to spawn compositor
exec = "picom"

50
modules/compositor.lua Normal file
View File

@ -0,0 +1,50 @@
-- This file is part of Reno desktop.
--
-- Reno desktop is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
--
-- Reno desktop is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License along with Reno desktop. If not, see <https://www.gnu.org/licenses/>.
-- Compositor manager with inhibitor
local awful = require("awful")
-- Configuration variables
local cfg = config.compositor or {}
local compositor_enabled = false
local inhibitors = {}
local compositor_pid = nil
local function count(t)
local c = 0
for _,_ in pairs(t) do
c = c + 1
end
return c
end
if cfg.exec then
compositor_pid = awful.spawn(cfg.exec)
compositor_enabled = true
client.connect_signal("manage",function(c)
if c.inhibit_compositor then
inhibitors[c] = true
if compositor_enabled then
awful.spawn("kill "..tostring(compositor_pid))
compositor_enabled = false
end
end
end)
client.connect_signal("unmanage",function(c)
if c.inhibit_compositor then
inhibitors[c] = nil
if count(inhibitors) == 0 then
if compositor_enabled == false then
compositor_pid = awful.spawn(cfg.exec)
compositor_enabled = true
end
end
end
end)
awesome.connect_signal("exit",function()
if compositor_enabled and compositor_pid then
awful.spawn("kill "..tostring(compositor_pid))
end
end)
end

View File

@ -6,6 +6,7 @@
--
-- You should have received a copy of the GNU General Public License along with Reno desktop. If not, see <https://www.gnu.org/licenses/>.
-- Powerman X - second generation of the power management daemon
local awful = require("awful")
local sysctl = require("syscontrol")
local naughty = require("naughty")
local gears = require("gears")
@ -15,6 +16,9 @@ local state_tracking = {}
local cfg = config.powerman or {}
local quality_min = cfg.battery_quality_min or 33
local capacity_min = cfg.battery_capacity_min or 15
local on_low_battery = cfg.on_low_battery or ""
local on_charged_battery = cfg.on_charged_battery
local on_critical_condition = cfg.on_critical_condition
-- Main loop
gears.timer({
timeout = 2,
@ -24,15 +28,18 @@ gears.timer({
local data,_ = sysctl.power_supply.read_attribs(v)
state_tracking[v] = state_tracking[v] or {}
if data.type == "Battery" then
if (tonumber(data.quality) < quality_min) and
if (tonumber(data.quality) < quality_min) and
(not state_tracking[v].quality_notification) then
naughty.notify({
title = "Critical battery condition",
text = "Battery "..data.name.." has reached critically low condition, seek a suitable replacement"
})
state_tracking[v].quality_notification = true
if on_critical_condition then
awful.spawn(on_critical_condition)
end
end
if (tonumber(data.capacity) <= capacity_min) and
if (tonumber(data.capacity) <= capacity_min) and
(not data.charging) and
(not state_tracking[v].capacity_notification) then
naughty.notify({
@ -40,17 +47,23 @@ gears.timer({
text = "Battery "..data.name.." capacity is at "..tostring(data.capacity).."%"
})
state_tracking[v].capacity_notification = true
if on_low_battery then
awful.spawn(on_low_battery)
end
end
if (tonumber(data.capacity) > capacity_min) then
state_tracking[v].capacity_notification = false
end
if (data.capacity == "100") and
if (data.capacity == "100") and
(data.charging) and
(not state_tracking[v].charged_notification) then
naughty.notify({
title = "Battery is completely charged",
text = "Disconnect the charger from the power grid to avoid passive electricity usage."
})
if on_charged_battery then
awful.spawn(on_charged_battery)
end
end
if (not data.charging) then
state_tracking[v].charged_notification = false

11
modules/rules_stub.lua Normal file
View File

@ -0,0 +1,11 @@
local awful = require("awful")
local gears = require("gears")
awful.rules.rules = gears.table.join(awful.rules.rules, {
{ rule_any = { class = {
"steam_app_548430",
"steam_app_%d*",
"love"
}},
properties = {inhibit_compositor = true},
},
})

View File

@ -14,13 +14,13 @@ awful.screen.connect_for_each_screen(function(s)
tag:delete()
end
-- Add 9 default tags
awful.tag({"1", "2", "3", "4", "5", "6", "7", "8", "9"}, s,
awful.tag({"1", "2", "3", "4", "5", "6", "7", "8", "9"}, s,
awful.layout.suit.floating)
end)
-- keybindings for tags
local keys = root.keys()
keys = gears.table.join(keys,
awful.key({global.modkey}, "Left",
awful.key({global.modkey}, "Left",
awful.tag.viewprev,
{description = "view next tag", group = "tag"}),
awful.key({global.modkey}, "Right",

3
rc.lua
View File

@ -17,8 +17,9 @@ package.cpath = package.cpath
require("modules.collect_garbage")
require("modules.global")
require("modules.powermanX")
require("modules.errorlog")
require("modules.base")
require("modules.rules_stub")
require("modules.compositor")
require("modules.binds")
require("modules.xdg_data")
require("modules.autostart")