Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
Note, that…
-----------
…this project is not developed any longer. It still works, though. I do not use it any more, nor do I use awesome. I am willing to merge bug fixes and improvements that do not alter the appearance or behaviour. Breaking changes in this sense, I will not merge.

You are welcome to fork this and I will add a link to it in the README.
Currently known, feature adding forks:
* [seniorivn/apw](https://github.com/seniorivn/apw)
This is a fork from [Mokasin's APW repo](https://github.com/mokasin/apw). Functionality to mute the default microphone was added.

My experiences show that it's also compatible with Awesome 4.0+.

Awesome Pulseaudio Widget
=========================
Expand Down
35 changes: 34 additions & 1 deletion pulseaudio.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,16 @@ local pulseaudio = {}

local cmd = "pacmd"
local default_sink = ""
local default_source = ""

function pulseaudio:Create()
local o = {}
setmetatable(o, self)
self.__index = self

o.Volume = 0 -- volume of default sink
o.Mute = false -- state of the mute flag of the default sink
o.Mute = true -- state of the mute flag of the default sink
o.MuteMic = true

-- retrieve current state from pulseaudio
pulseaudio.UpdateState(o)
Expand All @@ -56,6 +58,14 @@ function pulseaudio:UpdateState()
return false
end

-- find default source
default_source = string.match(out, "set%-default%-source ([^\n]+)")

if default_source == nil then
default_source = ""
return false
end

-- retrieve volume of default sink
for sink, value in string.gmatch(out, "set%-sink%-volume ([^%s]+) (0x%x+)") do
if sink == default_sink then
Expand All @@ -72,6 +82,17 @@ function pulseaudio:UpdateState()
end

self.Mute = m == "yes"

-- retrieve mute state of default source
local m
for source, value in string.gmatch(out, "set%-source%-mute ([^%s]+) (%a+)") do
if source == default_source then
m = value
end
end

self.MuteMic = m == "yes"

end

-- Run process and wait for it to end
Expand Down Expand Up @@ -112,6 +133,18 @@ function pulseaudio:ToggleMute()
self:UpdateState()
end

-- Toggles the mute flag of the default default_source.
function pulseaudio:ToggleMuteMic()
if self.MuteMic then
run(cmd .. " set-source-mute " .. default_source .. " 0")
else
run(cmd .. " set-source-mute " .. default_source .. " 1")
end

-- …and updates values.
self:UpdateState()
end


return pulseaudio

9 changes: 7 additions & 2 deletions widget.lua
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,13 @@ end


function pulseWidget.ToggleMute()
p:ToggleMute()
_update()
p:ToggleMute()
_update()
end

function pulseWidget.ToggleMuteMic()
p:ToggleMuteMic()
_update()
end

function pulseWidget.Update()
Expand Down