On Sat, Oct 2, 2010 at 01:41, David Unric <[email protected]> wrote:
> Hello,
>
> it starts to drive me a bit mad because I cann't understand what's going
> wrong with the following code:
>
> prg_out = io.popen('/usr/bin/xkb-switch'):read('*a')
>
> When run in a separate script or from Lua interpreter it works as expected,
> ie. it stores program output in prg_out variable. But run from rc.lua it
> hangs forever. Function io.popen() successfully returns file handle but any
> attempt to call read() or close() at this handle results in script stall :(
> The same behavior when trying to catch output of other programs like xrandr,
> xmodmap.
>

It works for me, for xrandr.I have a widget for controlling the
back-light of my laptop.

Where do you call xrandr in your rc.lua ? Maybe you're calling it too
early during the starting process, and all the X features are not
initialized ?
I do remember I had a problem with xrandr --prop, as I delayed the
first query by 10 seconds, but I cannot remember the issue I
encountered.

You can try something like

function testXRandr()
   local fd = io.popen("xrandr --prop")
   local stdout = fd:read("*all")
   fd:close()
-- do something with stdout
end

mytimer = timer({ timeout = 10 })
mytimer:add_signal("timeout", testXRandr)
mytimer:start()

Hope that's help

-- 
Cyprien Nicolas
PhD Student in Computer Science
INRIA Sophia Antipolis Méditerranée
University of Nice - Sophia Antipolis

--
To unsubscribe, send mail to [email protected].

Reply via email to