X-Git-Url: https://git.madduck.net/etc/awesome.git/blobdiff_plain/8d3868d7ce528cfc075e246c8935bae2724e0868..2ddb55bc44dd0ea06e8caa40798d27f907169c07:/widget/pulseaudio.lua?ds=inline diff --git a/widget/pulseaudio.lua b/widget/pulseaudio.lua index 44694d1..ed37cb5 100644 --- a/widget/pulseaudio.lua +++ b/widget/pulseaudio.lua @@ -6,26 +6,26 @@ --]] -local helpers = require("lain.helpers") -local shell = require("awful.util").shell -local wibox = require("wibox") -local string = { gmatch = string.gmatch, - match = string.match, - format = string.format } -local setmetatable = setmetatable +local helpers = require("lain.helpers") +local shell = require("awful.util").shell +local wibox = require("wibox") +local string = { gmatch = string.gmatch, + match = string.match, + format = string.format } -- PulseAudio volume -- lain.widget.pulseaudio -local function worker(args) - local pulseaudio = { widget = wibox.widget.textbox() } +local function factory(args) + local pulseaudio = { widget = wibox.widget.textbox() } local args = args or {} - local devicetype = args.devicetype or "sink" local timeout = args.timeout or 5 local settings = args.settings or function() end local scallback = args.scallback - - pulseaudio.cmd = args.cmd or "pacmd list-" .. devicetype .. "s | sed -n -e '0,/*/d' -e '/base volume/d' -e '/volume:/p' -e '/muted:/p' -e '/device\\.string/p'" + + pulseaudio.device = "N/A" + pulseaudio.devicetype = args.devicetype or "sink" + pulseaudio.cmd = args.cmd or "pacmd list-" .. pulseaudio.devicetype .. "s | sed -n -e '0,/*/d' -e '/base volume/d' -e '/volume:/p' -e '/muted:/p' -e '/device\\.string/p'" function pulseaudio.update() if scallback then pulseaudio.cmd = scallback() end @@ -38,6 +38,8 @@ local function worker(args) muted = string.match(s, "muted: (%S+)") or "N/A" } + pulseaudio.device = volume_now.index + local ch = 1 volume_now.channel = {} for v in string.gmatch(s, ":.-(%d+)%%") do @@ -59,4 +61,4 @@ local function worker(args) return pulseaudio end -return setmetatable({}, { __call = function(_, ...) return worker(...) end }) +return factory