Added volume widget
parent
840f084db8
commit
8b3a1ac5a0
|
@ -1,7 +1,6 @@
|
||||||
return {
|
return {
|
||||||
keys = gears.table.join(
|
keys = gears.table.join(
|
||||||
require("binds.system.backlight"),
|
require("binds.system.backlight"),
|
||||||
require("binds.system.volume"),
|
|
||||||
require("binds.system.system"),
|
require("binds.system.system"),
|
||||||
|
|
||||||
require("binds.window.client"),
|
require("binds.window.client"),
|
||||||
|
|
|
@ -6,7 +6,7 @@ local desktop = {
|
||||||
textclock = require("desktop.widgets.textclock"),
|
textclock = require("desktop.widgets.textclock"),
|
||||||
layoutbox = require("desktop.widgets.layoutbox"),
|
layoutbox = require("desktop.widgets.layoutbox"),
|
||||||
keymap = modules.ibus.widgets.ibus,
|
keymap = modules.ibus.widgets.ibus,
|
||||||
volume = require("desktop.widgets.volume"),
|
volume = modules.volume.widgets.volume,
|
||||||
tagindicator = require("desktop.widgets.tagindicator"),
|
tagindicator = require("desktop.widgets.tagindicator"),
|
||||||
launcher = require("desktop.widgets.launcher"),
|
launcher = require("desktop.widgets.launcher"),
|
||||||
shortcut = require("desktop.widgets.shortcut"),
|
shortcut = require("desktop.widgets.shortcut"),
|
||||||
|
|
|
@ -46,7 +46,4 @@ widget.widget:connect_signal("button::press",
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
|
||||||
wrapper.volume.commands:get(widget.update)
|
|
||||||
|
|
||||||
return widget.widget
|
return widget.widget
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
local volume = require("modules.volume.util")
|
||||||
|
local widget = require("modules.volume.widget")
|
||||||
|
|
||||||
|
return {
|
||||||
|
widgets = {
|
||||||
|
volume = require("modules.volume.widget").widget
|
||||||
|
},
|
||||||
|
keybinds = require("modules.volume.keybinds"),
|
||||||
|
|
||||||
|
init = function ()
|
||||||
|
-- Make sure volume is unmuted
|
||||||
|
volume.commands:unmute()
|
||||||
|
-- Update volume widget at start
|
||||||
|
volume.commands:get(widget.update)
|
||||||
|
end
|
||||||
|
}
|
|
@ -1,7 +1,9 @@
|
||||||
|
local volume = req_rel(..., "util")
|
||||||
|
|
||||||
return gears.table.join(
|
return gears.table.join(
|
||||||
awful.key( {}, "XF86AudioRaiseVolume",
|
awful.key( {}, "XF86AudioRaiseVolume",
|
||||||
function ()
|
function ()
|
||||||
wrapper.volume.up()
|
volume.volume_up()
|
||||||
end,
|
end,
|
||||||
{
|
{
|
||||||
description = "Volume up",
|
description = "Volume up",
|
||||||
|
@ -11,7 +13,7 @@ return gears.table.join(
|
||||||
|
|
||||||
awful.key( {}, "XF86AudioLowerVolume",
|
awful.key( {}, "XF86AudioLowerVolume",
|
||||||
function ()
|
function ()
|
||||||
wrapper.volume.down()
|
volume.volume_down()
|
||||||
end,
|
end,
|
||||||
{
|
{
|
||||||
description = "Volume down",
|
description = "Volume down",
|
||||||
|
@ -21,7 +23,7 @@ return gears.table.join(
|
||||||
|
|
||||||
awful.key( {}, "XF86AudioMute",
|
awful.key( {}, "XF86AudioMute",
|
||||||
function ()
|
function ()
|
||||||
wrapper.volume.togglemute()
|
volume.toggle_mute()
|
||||||
end,
|
end,
|
||||||
{
|
{
|
||||||
description = "Mute",
|
description = "Mute",
|
|
@ -34,22 +34,23 @@ function volume.commands:get(callback)
|
||||||
|
|
||||||
awful.spawn.easy_async("pamixer --get-mute --get-volume" .. volume.pamixer_options,
|
awful.spawn.easy_async("pamixer --get-mute --get-volume" .. volume.pamixer_options,
|
||||||
function(stdout, stderr, exitreason, exitcode)
|
function(stdout, stderr, exitreason, exitcode)
|
||||||
muted = string.match(stdout, "(%w%w%w%w%w?) ") -- "true" or "false"
|
muted = string.match(stdout, "(%w%w%w%w%w?) ") -- "true" or "false"
|
||||||
muted = (muted == "true")
|
muted = (muted == "true")
|
||||||
|
|
||||||
value = string.match(stdout, "(%d?%d?%d)") -- (\d?\d?\d)\%)
|
value = string.match(stdout, "(%d?%d?%d)") -- (\d?\d?\d)\%)
|
||||||
|
|
||||||
if (value == nil) then
|
if (value == nil) then
|
||||||
value = false
|
value = false
|
||||||
else
|
else
|
||||||
value = tonumber(string.format("% 3d", value))
|
value = tonumber(string.format("% 3d", value))
|
||||||
|
end
|
||||||
|
|
||||||
|
callback({
|
||||||
|
mute = muted,
|
||||||
|
value = value
|
||||||
|
})
|
||||||
end
|
end
|
||||||
|
)
|
||||||
callback({
|
|
||||||
mute = muted,
|
|
||||||
value = value
|
|
||||||
})
|
|
||||||
end)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function volume.commands:watch(timeout, callback, widget)
|
function volume.commands:watch(timeout, callback, widget)
|
||||||
|
@ -74,7 +75,7 @@ volume.exec_hooks = function()
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
volume.up = function()
|
volume.volume_up = function()
|
||||||
if volume.muted then
|
if volume.muted then
|
||||||
volume.unmute()
|
volume.unmute()
|
||||||
end
|
end
|
||||||
|
@ -85,7 +86,7 @@ volume.up = function()
|
||||||
volume.exec_hooks()
|
volume.exec_hooks()
|
||||||
end
|
end
|
||||||
|
|
||||||
volume.down = function()
|
volume.volume_down = function()
|
||||||
if volume.muted then
|
if volume.muted then
|
||||||
volume.unmute()
|
volume.unmute()
|
||||||
end
|
end
|
||||||
|
@ -130,7 +131,7 @@ volume.unmute = function()
|
||||||
volume.exec_hooks()
|
volume.exec_hooks()
|
||||||
end
|
end
|
||||||
|
|
||||||
volume.togglemute = function()
|
volume.toggle_mute = function()
|
||||||
volume.commands:get(function(status)
|
volume.commands:get(function(status)
|
||||||
if status.mute then
|
if status.mute then
|
||||||
volume.unmute()
|
volume.unmute()
|
||||||
|
@ -140,7 +141,5 @@ volume.togglemute = function()
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Make sure volume is unmuted at startup
|
|
||||||
volume.commands:unmute()
|
|
||||||
|
|
||||||
return volume
|
return volume
|
|
@ -1,3 +1,4 @@
|
||||||
|
local volume = req_rel(..., "util")
|
||||||
local widget = {}
|
local widget = {}
|
||||||
|
|
||||||
|
|
||||||
|
@ -68,7 +69,6 @@ widget.widget = wibox.widget {
|
||||||
|
|
||||||
widget.widget:connect_signal("mouse::enter", function(result)
|
widget.widget:connect_signal("mouse::enter", function(result)
|
||||||
widget.widget.bg = beautiful.color.bar.hover_bg
|
widget.widget.bg = beautiful.color.bar.hover_bg
|
||||||
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
widget.widget:connect_signal("mouse::leave", function(result)
|
widget.widget:connect_signal("mouse::leave", function(result)
|
||||||
|
@ -80,15 +80,15 @@ widget.widget:connect_signal("button::press",
|
||||||
|
|
||||||
-- Right-click
|
-- Right-click
|
||||||
if (button == 3) then
|
if (button == 3) then
|
||||||
wrapper.volume.togglemute()
|
volume.toggle_mute()
|
||||||
|
|
||||||
-- Scroll up
|
-- Scroll up
|
||||||
elseif (button == 4) then
|
elseif (button == 4) then
|
||||||
wrapper.volume.up()
|
volume.volume_up()
|
||||||
|
|
||||||
-- Scroll down
|
-- Scroll down
|
||||||
elseif (button == 5) then
|
elseif (button == 5) then
|
||||||
wrapper.volume.down()
|
volume.volume_down()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
@ -124,19 +124,13 @@ widget.update = function(status)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
volume.add_hook(widget.update)
|
||||||
-- Add various hooks
|
volume.commands:watch(
|
||||||
|
|
||||||
wrapper.volume.add_hook(widget.update)
|
|
||||||
wrapper.volume.commands:watch(
|
|
||||||
5,
|
5,
|
||||||
function()
|
function()
|
||||||
wrapper.volume.commands:get(widget.update)
|
volume.commands:get(widget.update)
|
||||||
end,
|
end,
|
||||||
widget.widget
|
widget.widget
|
||||||
)
|
)
|
||||||
|
|
||||||
-- Update volume widget at start
|
return widget
|
||||||
wrapper.volume.commands:get(widget.update)
|
|
||||||
|
|
||||||
return widget.widget
|
|
3
rc.lua
3
rc.lua
|
@ -47,7 +47,8 @@ local buttons = binds.buttons
|
||||||
modules = {}
|
modules = {}
|
||||||
for k, v in ipairs({
|
for k, v in ipairs({
|
||||||
"mpc",
|
"mpc",
|
||||||
"ibus"
|
"ibus",
|
||||||
|
"volume"
|
||||||
}) do
|
}) do
|
||||||
modules[v] = require("modules." .. v)
|
modules[v] = require("modules." .. v)
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
return {
|
return {
|
||||||
backlight = require("wrapper.backlight"),
|
backlight = require("wrapper.backlight"),
|
||||||
volume = require("wrapper.volume"),
|
|
||||||
sound = require("wrapper.sound"),
|
sound = require("wrapper.sound"),
|
||||||
mdadm = require("wrapper.mdadm")
|
mdadm = require("wrapper.mdadm")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue