Added tooltip to volume widget

master
Mark 2022-04-23 21:18:23 -07:00
parent c37ea71746
commit 4755b90666
Signed by: Mark
GPG Key ID: AD62BB059C2AAEE4
1 changed files with 14 additions and 2 deletions

View File

@ -54,6 +54,7 @@ function P:_update_widget()
end
self.widget.arc.value = self.volume / 100;
v.widget.tooltip.text = "Volume " .. self.volume .. "%"
--self.widget.bar.value = self.volume;
@ -78,7 +79,7 @@ end
-- Simple actions
---
function P:volume_up()
if (not self.ready) then
if (not self.ready) or (self.volume >= 100) then
return
end
@ -89,11 +90,14 @@ function P:volume_up()
awful.spawn("pamixer --increase 5" .. self:_full_args(), false)
wrapper.sound.play("volume_up")
self.volume = self.volume + 5
if self.volume > 100 then
self.volume = 100
end
self:_update_widget()
end
function P:volume_down()
if (not self.ready) then
if (not self.ready) or (self.volume <= 0) then
return
end
@ -104,6 +108,9 @@ function P:volume_down()
awful.spawn("pamixer --decrease 5" .. self:_full_args(), false)
wrapper.sound.play("volume_down")
self.volume = self.volume - 5
if self.volume < 0 then
self.volume = 0
end
self:_update_widget()
end
@ -184,6 +191,11 @@ function P:new(args)
end
)
v.widget.tooltip = awful.tooltip {
objects = { v.widget.widget },
text = "System volume"
}
setmetatable(v, self)
self.__index = self