Fixed indentation in pulseaudio widget code (3->4 spaces)

This commit is contained in:
Calvin Timmer 2017-02-02 14:55:34 +01:00
parent 3da60ff492
commit 6350d0e040
1 changed files with 30 additions and 29 deletions

View File

@ -15,16 +15,16 @@ local string = { gmatch = string.gmatch,
-- PulseAudio volume -- PulseAudio volume
-- lain.widgets.pulseaudio -- lain.widgets.pulseaudio
local function factory(args) local function factory(args)
local pulseaudio = {} local pulseaudio = {}
local args = args or {}
local devicetype = args.devicetype or "sink" local args = args or {}
local timeout = args.timeout or 5 local devicetype = args.devicetype or "sink"
local settings = args.settings or function() end local timeout = args.timeout or 5
local scallback = args.scallback local settings = args.settings or function() end
local scallback = args.scallback
pulseaudio.cmd = args.cmd or ("pacmd list-" .. devicetype .. "s | sed -n -e '/* index:/,/index:/ !d' -e '/* index:/ p' -e '/base volume:/ d' -e '/volume:/ p' -e '/muted:/ p' -e '/device\\.string/ p'") pulseaudio.cmd = args.cmd or ("pacmd list-" .. devicetype .. "s | sed -n -e '/* index:/,/index:/ !d' -e '/* index:/ p' -e '/base volume:/ d' -e '/volume:/ p' -e '/muted:/ p' -e '/device\\.string/ p'")
-- sed script explanation: -- sed script explanation:
-- '/* index:/,/index:/ !d' removes all lines outside of the range between the line containing '* index:' and the next line containing 'index:'. '* index:' denotes the beginning of the default device section. -- '/* index:/,/index:/ !d' removes all lines outside of the range between the line containing '* index:' and the next line containing 'index:'. '* index:' denotes the beginning of the default device section.
-- '/* index:/ p' prints the line containing '* index:'. -- '/* index:/ p' prints the line containing '* index:'.
@ -33,37 +33,38 @@ local function factory(args)
-- '/muted:/ p' prints the line containing 'muted:'. -- '/muted:/ p' prints the line containing 'muted:'.
-- '/device\\.string/ p' prints the line containing 'device.string:'. -- '/device\\.string/ p' prints the line containing 'device.string:'.
pulseaudio.widget = wibox.widget.textbox() pulseaudio.widget = wibox.widget.textbox()
function pulseaudio.update() function pulseaudio.update()
if scallback then pulseaudio.cmd = scallback() end if scallback then pulseaudio.cmd = scallback() end
helpers.async({ shell, "-c", pulseaudio.cmd }, function(s) helpers.async({ shell, "-c", pulseaudio.cmd }, function(s)
volume_now = { volume_now = {
index = string.match(s, "index: (%S+)") or "N/A", index = string.match(s, "index: (%S+)") or "N/A",
device = string.match(s, "device.string = \"(%S+)\"") or "N/A", device = string.match(s, "device.string = \"(%S+)\"") or "N/A",
sink = device, -- legacy API sink = device, -- legacy API
muted = string.match(s, "muted: (%S+)") or "N/A" muted = string.match(s, "muted: (%S+)") or "N/A"
} }
local ch = 1 local ch = 1
volume_now.channel = {} volume_now.channel = {}
for v in string.gmatch(s, ":.-(%d+)%%") do for v in string.gmatch(s, ":.-(%d+)%%") do
volume_now.channel[ch] = v volume_now.channel[ch] = v
ch = ch + 1 ch = ch + 1
end end
volume_now.left = volume_now.channel[1] or "N/A" volume_now.left = volume_now.channel[1] or "N/A"
volume_now.right = volume_now.channel[2] or "N/A" volume_now.right = volume_now.channel[2] or "N/A"
widget = pulseaudio.widget widget = pulseaudio.widget
settings()
end) settings()
end end)
end
helpers.newtimer("pulseaudio", timeout, pulseaudio.update) helpers.newtimer("pulseaudio", timeout, pulseaudio.update)
return pulseaudio return pulseaudio
end end
return factory return factory