Add volume to systray

This commit is contained in:
Simonas Narbutas
2019-01-18 13:16:39 +01:00
parent 85703a03c1
commit 3138ff48e3

View File

@@ -118,7 +118,10 @@ menubar.utils.terminal = terminal -- Set the terminal for applications that requ
-- Keyboard map indicator and switcher -- Keyboard map indicator and switcher
mykeyboardlayout = awful.widget.keyboardlayout() mykeyboardlayout = awful.widget.keyboardlayout()
-- Volume
volumewidget = wibox.widget.textbox(awful.spawn.easy_async("pamixer --sink 0 --get-volume",function(stdout, stderr, reason, exit_code)
volumewidget:set_text(" 🔈:"..stdout)
end))
-- Battery -- Battery
batterywidget = wibox.widget.textbox() batterywidget = wibox.widget.textbox()
-- {{{ Wibar -- {{{ Wibar
@@ -163,6 +166,7 @@ mykeyboardlayout:connect_signal("button::release",
end) end)
-- }}} -- }}}
-- Create a wibox for each screen and add it -- Create a wibox for each screen and add it
local taglist_buttons = gears.table.join( local taglist_buttons = gears.table.join(
awful.button({ }, 1, function(t) t:view_only() end), awful.button({ }, 1, function(t) t:view_only() end),
@@ -262,6 +266,7 @@ awful.screen.connect_for_each_screen(function(s)
mykeyboardlayout, mykeyboardlayout,
wibox.widget.systray(), wibox.widget.systray(),
mytextclock, mytextclock,
volumewidget,
batterywidget, batterywidget,
s.mylayoutbox, s.mylayoutbox,
}, },
@@ -375,6 +380,14 @@ globalkeys = gears.table.join(
awful.util.spawn("pamixer --sink 0 -t", false) awful.util.spawn("pamixer --sink 0 -t", false)
awful.spawn.easy_async("pamixer --sink 0 --get-mute", function(stdout, stderr, reason, exit_code) awful.spawn.easy_async("pamixer --sink 0 --get-mute", function(stdout, stderr, reason, exit_code)
naughty.notify {title = "mute", text = stdout, timeout = 0.5} naughty.notify {title = "mute", text = stdout, timeout = 0.5}
if string.match(stdout, "true" ) then
volumewidget:set_text(" 🔇 ")
else
awful.spawn.easy_async("pamixer --sink 0 --get-volume", function(stdout, stderr, reason, exit_code)
volumewidget:set_text(" 🔈:"..stdout)
naughty.notify {title = "Inc", text = stdout, timeout = 0.5}
end)
end
end) end)
end), end),
awful.key({ }, "XF86AudioMicMute", awful.key({ }, "XF86AudioMicMute",
@@ -387,12 +400,15 @@ globalkeys = gears.table.join(
awful.key({ }, "XF86AudioLowerVolume", awful.key({ }, "XF86AudioLowerVolume",
function () function ()
awful.spawn.easy_async("pamixer --sink 0 -d 5 --get-volume", function(stdout, stderr, reason, exit_code) awful.spawn.easy_async("pamixer --sink 0 -d 5 --get-volume", function(stdout, stderr, reason, exit_code)
volumewidget:set_text(" 🔈:"..stdout)
naughty.notify {title = "Inc", text = stdout, timeout = 0.5} naughty.notify {title = "Inc", text = stdout, timeout = 0.5}
end) end)
end), end),
awful.key({ }, "XF86AudioRaiseVolume", awful.key({ }, "XF86AudioRaiseVolume",
function () function ()
awful.spawn.easy_async("pamixer --sink 0 -i 5 --get-volume", function(stdout, stderr, reason, exit_code) awful.spawn.easy_async("pamixer --sink 0 -i 5 --get-volume", function(stdout, stderr, reason, exit_code)
volumewidget:set_text(" 🔈:"..stdout)
naughty.notify {title = "Dec", text = stdout, timeout = 0.5} naughty.notify {title = "Dec", text = stdout, timeout = 0.5}
end) end)
end), end),