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