From ce4702e48a941c217b28730284ab25dbcf3eea0c Mon Sep 17 00:00:00 2001 From: "Joerg T. (Mic92)" Date: Tue, 4 May 2010 09:19:56 +0200 Subject: [PATCH] [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. --- widgets/volume.lua | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/widgets/volume.lua b/widgets/volume.lua index 8f34609..6a43e38 100644 --- a/widgets/volume.lua +++ b/widgets/volume.lua @@ -14,6 +14,7 @@ local string = { match = string.match } -- Volume: provides volume levels and state of requested ALSA mixers module("vicious.widgets.volume") +local startup = true -- {{{ Volume widget type local function worker(format, warg) @@ -24,13 +25,19 @@ local function worker(format, warg) ["off"] = "♩" -- "M" } - -- Get mixer control contents - local f = io.popen("amixer get " .. warg) - local mixer = f:read("*all") - f:close() + local volu, mute + if not startup then + -- Get mixer control contents + 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 if volu == nil then return {0, mixer_state["off"]}