summaryrefslogtreecommitdiff
path: root/experiments/volume/widgets/icon-and-text-widget.lua
diff options
context:
space:
mode:
Diffstat (limited to 'experiments/volume/widgets/icon-and-text-widget.lua')
-rw-r--r--experiments/volume/widgets/icon-and-text-widget.lua23
1 files changed, 14 insertions, 9 deletions
diff --git a/experiments/volume/widgets/icon-and-text-widget.lua b/experiments/volume/widgets/icon-and-text-widget.lua
index 5517f11..74044fb 100644
--- a/experiments/volume/widgets/icon-and-text-widget.lua
+++ b/experiments/volume/widgets/icon-and-text-widget.lua
@@ -1,10 +1,15 @@
local wibox = require("wibox")
+local beautiful = require('beautiful')
local widget = {}
-local WIDGET_DIR = os.getenv("HOME") .. '/.config/awesome/awesome-wm-widgets/experiments/volume/icons/'
+local ICON_DIR = os.getenv("HOME") .. '/.config/awesome/awesome-wm-widgets/experiments/volume/icons/'
-function widget.get_widget()
+function widget.get_widget(widgets_args)
+ local args = widgets_args or {}
+
+ local font = args.font or beautiful.font
+ local icon_dir = args.icon_dir or ICON_DIR
return wibox.widget {
{
@@ -18,15 +23,15 @@ function widget.get_widget()
},
{
id = 'txt',
+ font = font,
widget = wibox.widget.textbox
},
layout = wibox.layout.fixed.horizontal,
- is_muted = true,
set_volume_level = function(self, new_value)
self:get_children_by_id('txt')[1]:set_text(new_value)
- local volume_icon_name = ''
+ local volume_icon_name
if self.is_muted then
- volume_icon_name = 'audio-volume-muted-symbolic.svg'
+ volume_icon_name = 'audio-volume-muted-symbolic'
else
local new_value_num = tonumber(new_value)
if (new_value_num >= 0 and new_value_num < 33) then
@@ -37,16 +42,16 @@ function widget.get_widget()
volume_icon_name="audio-volume-high-symbolic"
end
end
- self:get_children_by_id('icon')[1]:set_image(WIDGET_DIR .. volume_icon_name .. '.svg')
+ self:get_children_by_id('icon')[1]:set_image(icon_dir .. volume_icon_name .. '.svg')
end,
mute = function(self)
+ print("called")
self.is_muted = true
- self:get_children_by_id('icon')[1]:set_image(WIDGET_DIR .. 'audio-volume-muted-symbolic.svg')
+ self:get_children_by_id('icon')[1]:set_image(icon_dir .. 'audio-volume-muted-symbolic.svg')
end,
unmute = function(self)
self.is_muted = false
- end,
-
+ end
}
end