[volume] Add a delay to avoid freezes with pulse

Pulseaudio load some extensions on startup of X11.
Amixer can't request the volume state in this time
and freezes awesome too.
This commit is contained in:
Joerg T. (Mic92) 2010-05-04 09:19:56 +02:00
parent 56300c4efa
commit ce4702e48a
1 changed files with 13 additions and 6 deletions

View File

@ -14,6 +14,7 @@ local string = { match = string.match }
-- Volume: provides volume levels and state of requested ALSA mixers -- Volume: provides volume levels and state of requested ALSA mixers
module("vicious.widgets.volume") module("vicious.widgets.volume")
local startup = true
-- {{{ Volume widget type -- {{{ Volume widget type
local function worker(format, warg) local function worker(format, warg)
@ -24,13 +25,19 @@ local function worker(format, warg)
["off"] = "" -- "M" ["off"] = "" -- "M"
} }
-- Get mixer control contents local volu, mute
local f = io.popen("amixer get " .. warg) if not startup then
local mixer = f:read("*all") -- Get mixer control contents
f:close() local f = io.popen("amixer get " .. warg)
local mixer = f:read("*all")
f:close()
-- Capture mixer control state: [5%] ... ... [on]
volu, mute = string.match(mixer, "([%d]+)%%.*%[([%l]*)")
else
startup = false
end
-- Capture mixer control state: [5%] ... ... [on]
local volu, mute = string.match(mixer, "([%d]+)%%.*%[([%l]*)")
-- Handle mixers without data -- Handle mixers without data
if volu == nil then if volu == nil then
return {0, mixer_state["off"]} return {0, mixer_state["off"]}