dotfiles/awesome/volume.lua

30 lines
838 B
Lua
Raw Normal View History

2016-08-22 12:58:25 +01:00
local wibox = require("wibox")
local awful = require("awful")
volume_widget = wibox.widget.textbox()
volume_widget:set_align("right")
function update_volume()
2017-10-19 17:04:37 +01:00
awful.spawn.easy_async('amixer sget Master', function(stdout, stderr)
local status = stdout
2016-08-22 12:58:25 +01:00
local widget = volume_widget
-- local volume = tonumber(string.match(status, "(%d?%d?%d)%%")) / 100
local volume = string.match(status, "(%d?%d?%d)%%")
volume = string.format("% 3d", volume)
status = string.match(status, "%[(o[^%]]*)%]")
if string.find(status, "on", 1, true) then
-- For the volume numbers
volume = volume .. "%"
else
-- For the mute button
volume = volume .. "M"
end
widget:set_markup("V :" .. volume)
2017-10-19 17:04:37 +01:00
end)
2016-08-22 12:58:25 +01:00
end
update_volume()