init.lua 519 B

1234567891011121314151617181920
  1. local wibox = require("wibox")
  2. local awful = require("awful")
  3. volume_widget = wibox.widget.textbox()
  4. volume_widget:set_align("right")
  5. function update_volume(widget)
  6. local cmd = "LANG=C pactl list sinks | awk '{if ($1 == \"Volume:\") print $5}'"
  7. local fd = io.popen(cmd)
  8. local status = fd:read("*l")
  9. fd:close()
  10. widget:set_markup("V: "..status)
  11. end
  12. update_volume(volume_widget)
  13. mytimer = timer({ timeout = 1 })
  14. mytimer:connect_signal("timeout", function () update_volume(volume_widget) end)
  15. mytimer:start()