init.lua 533 B

1234567891011121314151617181920
  1. local wibox = require("wibox")
  2. local awful = require("awful")
  3. light_widget = wibox.widget.textbox()
  4. light_widget:set_align("center")
  5. function update_light(widget)
  6. local cmd = "brightnessctl i | awk '{if ($1 == \"Current\"){print substr($4, 2, length($4) - 2)}}'"
  7. local fd = io.popen(cmd)
  8. local status = fd:read("*l")
  9. fd:close()
  10. widget:set_markup("L: "..status)
  11. end
  12. update_light(light_widget)
  13. mytimer = timer({ timeout = 1 })
  14. mytimer:connect_signal("timeout", function () update_light(light_widget) end)
  15. mytimer:start()