From 07ab3a77b44944a1ac234fbd717391f36370416e Mon Sep 17 00:00:00 2001 From: Brian Picciano Date: Tue, 17 Oct 2017 18:12:57 -0600 Subject: initial public commit --- awesome/pulseaudio.lua | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 awesome/pulseaudio.lua (limited to 'awesome/pulseaudio.lua') diff --git a/awesome/pulseaudio.lua b/awesome/pulseaudio.lua new file mode 100644 index 0000000..765fd12 --- /dev/null +++ b/awesome/pulseaudio.lua @@ -0,0 +1,40 @@ +local io = io +local math = math +local tonumber = tonumber +local tostring = tostring +local string = string +local naughty = require("naughty") + +function volumeInfo() + volmin = 0 + volmax = 65536 + local f = io.popen("pacmd dump |grep set-sink-volume|grep analog-stereo") + local g = io.popen("pacmd dump |grep set-sink-mute|grep analog-stereo") + local v = f:read() + local mute = g:read() + if mute ~= nil and string.find(mute, "no") then + volume = math.floor(tonumber(string.sub(v, string.find(v, 'x')-1)) * 100 / volmax) + else + volume = "off" + end + f:close() + g:close() + return "vol:"..volume.." " +end + +function muteAll() + local outh = io.popen("pactl list short sources | awk '{print $1}'") + while true do + local i = outh:read() + if i == nil then break end + io.popen("pactl set-source-mute " .. i .. " 1"):close() + end + outh:close() +end + +function unmuted() + local outh = io.popen("pactl list sources | grep 'Mute: no'") + local any = outh:read() + outh:close() + return any ~= nil +end -- cgit v1.2.3