X-Git-Url: https://git.madduck.net/etc/awesome.git/blobdiff_plain/33c0e0c2360a04fcc6f51bccb0ad2a7a9e9c07b3:/widget/pulse.lua..66d9f3db4596e43efa55488569e06365a2125750:/.config/awesome/lain/widget/static/gitweb.js diff --git a/widget/pulse.lua b/widget/pulse.lua deleted file mode 100644 index f63fe55..0000000 --- a/widget/pulse.lua +++ /dev/null @@ -1,57 +0,0 @@ ---[[ - - Licensed under GNU General Public License v2 - * (c) 2016, Luca CPZ - ---]] - -local helpers = require("lain.helpers") -local shell = require("awful.util").shell -local wibox = require("wibox") -local string = string -local type = type - --- PulseAudio volume --- lain.widget.pulse - -local function factory(args) - local pulse = { widget = wibox.widget.textbox(), device = "N/A" } - local args = args or {} - local timeout = args.timeout or 5 - local settings = args.settings or function() end - - pulse.devicetype = args.devicetype or "sink" - pulse.cmd = args.cmd or "pacmd list-" .. pulse.devicetype .. "s | sed -n -e '/*/,$!d' -e '/index/p' -e '/base volume/d' -e '/volume:/p' -e '/muted:/p' -e '/device\\.string/p'" - - function pulse.update() - helpers.async({ shell, "-c", type(pulse.cmd) == "string" and pulse.cmd or pulse.cmd() }, - function(s) - volume_now = { - index = string.match(s, "index: (%S+)") or "N/A", - device = string.match(s, "device.string = \"(%S+)\"") or "N/A", - muted = string.match(s, "muted: (%S+)") or "N/A" - } - - pulse.device = volume_now.index - - local ch = 1 - volume_now.channel = {} - for v in string.gmatch(s, ":.-(%d+)%%") do - volume_now.channel[ch] = v - ch = ch + 1 - end - - volume_now.left = volume_now.channel[1] or "N/A" - volume_now.right = volume_now.channel[2] or "N/A" - - widget = pulse.widget - settings() - end) - end - - helpers.newtimer("pulse", timeout, pulse.update) - - return pulse -end - -return factory