summaryrefslogtreecommitdiff
path: root/pkgs/astal/src/widget/bar/audio.lua
blob: c1934f976af2cc16908fe4a6db98aae9d83cabdd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
local astal = require("astal")
local Widget = require("astal.gtk3.widget")
local Wp = astal.require("AstalWp")
local bind = astal.bind

return function()
	local speaker = Wp.get_default().audio.default_speaker

	return Widget.Box({
		class_name = "audio",
		Widget.Icon({
			icon = bind(speaker, "volume-icon"),
		}),
		Widget.Label({
			label = bind(speaker, "volume"):as(function(p)
				return tostring(math.floor(p * 100)) .. '%'
			end)
		}),
	})
end