mirror of
https://github.com/elenapan/dotfiles.git
synced 2026-05-10 08:36:12 +08:00
Only emit microphone info of the currently active source
This commit is contained in:
parent
2e143eff4f
commit
ce387838d0
1 changed files with 9 additions and 8 deletions
|
|
@ -3,18 +3,19 @@
|
|||
-- muted (boolean)
|
||||
local awful = require("awful")
|
||||
|
||||
local muted_old = -1
|
||||
local function emit_microphone_info()
|
||||
-- Use tail to grab the last line of the output (which refers to the microphone)
|
||||
awful.spawn.easy_async_with_shell("pacmd list-sources | grep muted | tail -1 | awk '{print $2}'",
|
||||
function(stdout)
|
||||
-- Remove trailing whitespace
|
||||
muted = stdout:gsub('^%s*(.-)%s*$', '%1')
|
||||
awesome.emit_signal("evil::microphone", muted == "yes")
|
||||
-- See evil/volume.lua for the reason why we print the +7 and +11 lines after '* index'
|
||||
awful.spawn.easy_async_with_shell("pacmd list-sources | awk '/\\* index: /{nr[NR+7];nr[NR+11]}; NR in nr'", function(stdout)
|
||||
local muted = stdout:match('muted:(%s+)[yes]')
|
||||
local muted_int = muted and 1 or 0
|
||||
if not (muted_int == muted_old) then
|
||||
awesome.emit_signal("evil::microphone", muted)
|
||||
muted_old = muted_int
|
||||
end
|
||||
)
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
-- Run once to initialize widgets
|
||||
emit_microphone_info()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue