elenapan/config/awesome/evil/brightness.lua
elenapan c738169ca5 New theme: ephemeral, anti-aliased corners, app drawer, lock screen,
evil daemon system, dependency list update, README improvements.


Former-commit-id: db310f8e49
Former-commit-id: 4f25f9200c3ac9f9385daca5a68378249ff0329e
Former-commit-id: 69fa3954e5738446a59b409b7e326233e7c3ef55
Former-commit-id: 673176f7857e39f3455f4ccb426eef2789c0e891
2019-08-01 02:17:59 +03:00

38 lines
1.1 KiB
Lua

-- Provides:
-- evil::brightness
-- percentage (integer)
local awful = require("awful")
-- Subscribe to backlight changes
-- Requires inotify-tools
local brightness_subscribe_script = [[
bash -c "
while (inotifywait -e modify /sys/class/backlight/?**/brightness -qq) do echo; done
"]]
local brightness_script = [[
sh -c "
light -G
"]]
local emit_brightness_info = function()
awful.spawn.with_line_callback(brightness_script, {
stdout = function(line)
percentage = math.floor(tonumber(line))
awesome.emit_signal("evil::brightness", percentage)
end
})
end
-- Run once to initialize widgets
emit_brightness_info()
-- Kill old inotifywait process
awful.spawn.easy_async_with_shell("ps x | grep \"inotifywait -e modify /sys/class/backlight\" | grep -v grep | awk '{print $1}' | xargs kill", function ()
-- Update brightness status with each line printed
awful.spawn.with_line_callback(brightness_subscribe_script, {
stdout = function(_)
emit_brightness_info()
end
})
end)