[experiments-volume] add icon widget
This commit is contained in:
parent
3cf9ce8ffe
commit
a5ab50defb
|
@ -99,7 +99,6 @@ function utils.extract_sinks_and_sources(pacmd_output)
|
||||||
ports[key] = t[2]
|
ports[key] = t[2]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
print(json.encode(sources))
|
|
||||||
|
|
||||||
return sinks, sources
|
return sinks, sources
|
||||||
end
|
end
|
||||||
|
|
|
@ -14,8 +14,6 @@ local gears = require("gears")
|
||||||
local beautiful = require("beautiful")
|
local beautiful = require("beautiful")
|
||||||
local watch = require("awful.widget.watch")
|
local watch = require("awful.widget.watch")
|
||||||
local utils = require("awesome-wm-widgets.experiments.volume.utils")
|
local utils = require("awesome-wm-widgets.experiments.volume.utils")
|
||||||
local arc_widget = require("awesome-wm-widgets.experiments.volume.arc-widget")
|
|
||||||
local icon_and_text_widget = require("awesome-wm-widgets.experiments.volume.icon-and-text-widget")
|
|
||||||
|
|
||||||
|
|
||||||
local LIST_DEVICES_CMD = [[sh -c "pacmd list-sinks; pacmd list-sources"]]
|
local LIST_DEVICES_CMD = [[sh -c "pacmd list-sinks; pacmd list-sources"]]
|
||||||
|
@ -25,6 +23,12 @@ local DEC_VOLUME_CMD = 'amixer -q -D pulse sset Master 5%-'
|
||||||
local TOG_VOLUME_CMD = 'amixer -q -D pulse sset Master toggle'
|
local TOG_VOLUME_CMD = 'amixer -q -D pulse sset Master toggle'
|
||||||
|
|
||||||
|
|
||||||
|
local widget_types = {
|
||||||
|
icon_and_text = require("awesome-wm-widgets.experiments.volume.widgets.icon-and-text-widget"),
|
||||||
|
icon = require("awesome-wm-widgets.experiments.volume.widgets.icon-widget"),
|
||||||
|
arc = require("awesome-wm-widgets.experiments.volume.widgets.arc-widget")
|
||||||
|
}
|
||||||
|
|
||||||
local volume_widget = wibox.widget{}
|
local volume_widget = wibox.widget{}
|
||||||
|
|
||||||
local rows = { layout = wibox.layout.fixed.vertical }
|
local rows = { layout = wibox.layout.fixed.vertical }
|
||||||
|
@ -156,8 +160,15 @@ end
|
||||||
|
|
||||||
local function worker(args)
|
local function worker(args)
|
||||||
|
|
||||||
volume_widget = arc_widget.get_widget()
|
local args = args or {}
|
||||||
-- volume_widget = icon_and_text_widget.get_widget()
|
|
||||||
|
local widget_type = args.widget_type
|
||||||
|
|
||||||
|
if widget_types[widget_type] == nil then
|
||||||
|
volume_widget = widget_types['icon_and_text'].get_widget()
|
||||||
|
else
|
||||||
|
volume_widget = widget_types[widget_type].get_widget()
|
||||||
|
end
|
||||||
|
|
||||||
volume_widget:buttons(
|
volume_widget:buttons(
|
||||||
awful.util.table.join(
|
awful.util.table.join(
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
local wibox = require("wibox")
|
local wibox = require("wibox")
|
||||||
local beautiful = require('beautiful')
|
local beautiful = require('beautiful')
|
||||||
|
|
||||||
|
local ICON_DIR = os.getenv("HOME") .. '/.config/awesome/awesome-wm-widgets/experiments/volume/icons/'
|
||||||
|
|
||||||
local widget = {}
|
local widget = {}
|
||||||
|
|
||||||
function widget.get_widget()
|
function widget.get_widget()
|
||||||
|
@ -8,7 +10,7 @@ function widget.get_widget()
|
||||||
return wibox.widget {
|
return wibox.widget {
|
||||||
{
|
{
|
||||||
id = "icon",
|
id = "icon",
|
||||||
image = '/usr/share/icons/Arc/status/symbolic/audio-volume-muted-symbolic.svg',
|
image = ICON_DIR .. 'audio-volume-high-symbolic.svg',
|
||||||
resize = true,
|
resize = true,
|
||||||
widget = wibox.widget.imagebox,
|
widget = wibox.widget.imagebox,
|
||||||
},
|
},
|
|
@ -10,7 +10,6 @@ function widget.get_widget()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
id = "icon",
|
id = "icon",
|
||||||
image = '/usr/share/icons/Arc/status/symbolic/audio-volume-muted-symbolic.svg',
|
|
||||||
resize = false,
|
resize = false,
|
||||||
widget = wibox.widget.imagebox,
|
widget = wibox.widget.imagebox,
|
||||||
},
|
},
|
|
@ -0,0 +1,35 @@
|
||||||
|
local wibox = require("wibox")
|
||||||
|
|
||||||
|
local widget = {}
|
||||||
|
|
||||||
|
local WIDGET_DIR = os.getenv("HOME") .. '/.config/awesome/awesome-wm-widgets/experiments/volume/icons/'
|
||||||
|
|
||||||
|
function widget.get_widget()
|
||||||
|
|
||||||
|
return wibox.widget {
|
||||||
|
{
|
||||||
|
id = "icon",
|
||||||
|
resize = false,
|
||||||
|
widget = wibox.widget.imagebox,
|
||||||
|
},
|
||||||
|
valign = 'center',
|
||||||
|
layout = wibox.container.place,
|
||||||
|
set_volume_level = function(self, new_value)
|
||||||
|
local new_value_num = tonumber(new_value)
|
||||||
|
local volume_icon_name = ''
|
||||||
|
if (new_value_num >= 0 and new_value_num < 33) then
|
||||||
|
volume_icon_name="audio-volume-low-symbolic"
|
||||||
|
elseif (new_value_num < 66) then
|
||||||
|
volume_icon_name="audio-volume-medium-symbolic"
|
||||||
|
else
|
||||||
|
volume_icon_name="audio-volume-high-symbolic"
|
||||||
|
end
|
||||||
|
self:get_children_by_id('icon')[1]:set_image(WIDGET_DIR .. volume_icon_name .. '.svg')
|
||||||
|
end,
|
||||||
|
mute = function(self) self:get_children_by_id('icon')[1]:set_image(WIDGET_DIR .. 'audio-volume-muted-symbolic.svg') end,
|
||||||
|
unmute = function() end,
|
||||||
|
}
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
return widget
|
Loading…
Reference in New Issue