Update and add bling task_preview, tag_preview and window_switcher Add catppuccin-macchiato Use my weather key Update keybindings Update autorun Fix sliders
51 lines
1.3 KiB
Lua
51 lines
1.3 KiB
Lua
-- ## Brightness ##
|
|
-- ~~~~~~~~~~~~~~~~
|
|
|
|
-- requirements
|
|
-- ~~~~~~~~~~~~
|
|
local awful = require("awful")
|
|
-- Provides:
|
|
-- signal::brightness
|
|
-- percentage (integer)
|
|
|
|
|
|
local brightness_subscribe_script = [[
|
|
bash -c "
|
|
while (inotifywait -e modify /sys/class/backlight/?**/brightness -qq) do echo; done
|
|
"]]
|
|
|
|
local brightness_script = [[
|
|
sh -c "
|
|
brightnessctl g
|
|
"]]
|
|
|
|
local brightness_max = [[
|
|
sh -c "
|
|
brightnessctl m
|
|
"]]
|
|
|
|
local emit_brightness_info = function()
|
|
awful.spawn.with_line_callback(brightness_script, {
|
|
stdout = function(value)
|
|
awful.spawn.with_line_callback(brightness_max, {
|
|
stdout = function(max)
|
|
local percentage = tonumber(value)/tonumber(max) * 100
|
|
percentage = tonumber(percentage) or 0
|
|
awesome.emit_signal("signal::brightness", percentage)
|
|
end})
|
|
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)
|