mirror of
https://github.com/elenapan/dotfiles.git
synced 2026-05-11 17:35:57 +08:00
battery: Only send charger update when status changes
On some laptops, `acpi_listen` sometimes prints charger updates even if there was no change. This commit ensures that no unneeded updates will be sent with the `evil::charger` signal.
This commit is contained in:
parent
3013bd3992
commit
20c7a8b4c1
1 changed files with 5 additions and 1 deletions
|
|
@ -29,6 +29,7 @@ awful.spawn.easy_async_with_shell("sh -c 'out=\"$(find /sys/class/power_supply/B
|
|||
end)
|
||||
end)
|
||||
|
||||
local status_old = -1
|
||||
-- First get charger file path
|
||||
awful.spawn.easy_async_with_shell("sh -c 'out=\"$(find /sys/class/power_supply/*/online)\" && (echo \"$out\" | head -1) || false' ", function (charger_file, _, __, exit_code)
|
||||
-- No charger file found
|
||||
|
|
@ -39,7 +40,10 @@ awful.spawn.easy_async_with_shell("sh -c 'out=\"$(find /sys/class/power_supply/*
|
|||
local emit_charger_info = function()
|
||||
awful.spawn.easy_async_with_shell("cat "..charger_file, function (out)
|
||||
local status = tonumber(out) == 1
|
||||
awesome.emit_signal("evil::charger", status)
|
||||
if not (status == status_old) then
|
||||
awesome.emit_signal("evil::charger", status)
|
||||
status_old = status
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue