2020-11-01 20:03:06 +01:00
|
|
|
local wibox = require("wibox")
|
|
|
|
local beautiful = require('beautiful')
|
|
|
|
|
[volume] BREAKING CHANGE - new widget instead of old ones
Having three widgets for volume led to a problem of code duplication -
same logic was duplicated three times. However when an issue was
discovered and fixed, it was fixed in only one of three widgets.
So I decided to create a volume widget from scratch, adding new
features, such as selecting input/output, better responsiveness,
easily customizable widget ui (bar, text, icon, icon and text, arc).
Should close #199, #198, #185, #182, #47, #122, #183.
2021-03-20 01:49:00 +01:00
|
|
|
local ICON_DIR = os.getenv("HOME") .. '/.config/awesome/awesome-wm-widgets/volume-widget/icons/'
|
2020-11-09 21:54:33 +01:00
|
|
|
|
2020-11-01 20:03:06 +01:00
|
|
|
local widget = {}
|
|
|
|
|
2020-12-15 04:33:56 +01:00
|
|
|
function widget.get_widget(widgets_args)
|
|
|
|
local args = widgets_args or {}
|
|
|
|
|
|
|
|
local thickness = args.thickness or 2
|
|
|
|
local main_color = args.main_color or beautiful.fg_color
|
|
|
|
local bg_color = args.bg_color or '#ffffff11'
|
|
|
|
local mute_color = args.mute_color or beautiful.fg_urgent
|
|
|
|
local size = args.size or 18
|
2020-11-01 20:03:06 +01:00
|
|
|
|
|
|
|
return wibox.widget {
|
|
|
|
{
|
|
|
|
id = "icon",
|
2020-11-09 21:54:33 +01:00
|
|
|
image = ICON_DIR .. 'audio-volume-high-symbolic.svg',
|
2020-11-01 20:03:06 +01:00
|
|
|
resize = true,
|
|
|
|
widget = wibox.widget.imagebox,
|
|
|
|
},
|
|
|
|
max_value = 100,
|
2020-12-15 04:33:56 +01:00
|
|
|
thickness = thickness,
|
2020-11-01 20:03:06 +01:00
|
|
|
start_angle = 4.71238898, -- 2pi*3/4
|
2020-12-15 04:33:56 +01:00
|
|
|
forced_height = size,
|
|
|
|
forced_width = size,
|
|
|
|
bg = bg_color,
|
2020-11-01 20:03:06 +01:00
|
|
|
paddings = 2,
|
|
|
|
widget = wibox.container.arcchart,
|
|
|
|
set_volume_level = function(self, new_value)
|
|
|
|
self.value = new_value
|
|
|
|
end,
|
|
|
|
mute = function(self)
|
2020-12-15 04:33:56 +01:00
|
|
|
self.colors = { mute_color }
|
2020-11-01 20:03:06 +01:00
|
|
|
end,
|
|
|
|
unmute = function(self)
|
2020-12-15 04:33:56 +01:00
|
|
|
self.colors = { main_color }
|
2020-11-09 16:53:07 +01:00
|
|
|
end
|
2020-11-01 20:03:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
return widget
|