You are not logged in.

#1 2012-05-28 21:03:02

Sphaerophoria
Member
Registered: 2011-07-14
Posts: 41

Awesome WM functions do not run in order

This has been bugging me for a while now. It seems that Awesome waits for every line in the function to run before actually doing anything. For instance...

awful.util.spawn(app)
os.execute('sleep 10')

the application isn't spawned until the 10 seconds is over

Can anyone explain to me why awesome does things this way or if there's a way to circumvent it?

Thanks!
Sphaerophoria

Edit: Changed the example to make more sense

Last edited by Sphaerophoria (2012-05-28 21:07:45)

Offline

#2 2012-05-28 21:11:31

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,557
Website

Re: Awesome WM functions do not run in order

I'm not very familiar with awesome, but I've ran into similar issues in other situations under X.  The solution is some sort of flush function.  LibX11 has XFlush() which is likely what is needed, but I'm not sure what the name is in the lua API.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#3 2012-05-28 21:20:33

Sphaerophoria
Member
Registered: 2011-07-14
Posts: 41

Re: Awesome WM functions do not run in order

After some quick googling looks like I use io.stdout:flush()

Thanks for the suggestion. I'll muck around with it a bit and see if i can make it work smile

Offline

#4 2012-05-28 21:25:06

Sphaerophoria
Member
Registered: 2011-07-14
Posts: 41

Re: Awesome WM functions do not run in order

Would you mind giving a quick example of how you fixed a similar issue?

Offline

#5 2012-05-28 21:35:40

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,557
Website

Re: Awesome WM functions do not run in order

You don't want to flush the stdout, although there is no harm in it.  "Flush" is kind of a general term referring to pushing all recent commands or data from whatever memory buffer they may be in to their final target.  This might be needed in any buffered system.

In most situations standard streams (eg stdout) are buffered.  Flushing them will make sure the contents of the screen (for example) are updated.  But this issue (IF I AM CORRECT, I may not be) is from buffering between the window manager and X11.  You need to flush that communication line.

I've used in it C programs.  I learned about it while writing a tool to send commands to X to change the root window name.

Edit: I suspect you'll have to check the functions in the Awful library to see what's available.  My google-fu is weak right now "Awful library" is not returning anything remotely useful.

Last edited by Trilby (2012-05-28 21:51:22)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#6 2012-05-28 21:36:57

Sphaerophoria
Member
Registered: 2011-07-14
Posts: 41

Re: Awesome WM functions do not run in order

Thanks. I realized that just before you posted. Please excuse my ignorance.

Offline

#7 2012-05-28 21:56:26

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,557
Website

Re: Awesome WM functions do not run in order

I found the docs but I don't see anything promising.

Depending on the end goal, a potential work-around would be to do some variations of

awful.util.spawn_with_shell("SomeProgram &; sleep 10")

"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#8 2012-05-28 21:56:36

Sphaerophoria
Member
Registered: 2011-07-14
Posts: 41

Re: Awesome WM functions do not run in order

Read through something like this?

http://awesome.naquadah.org/doc/api/index.html

Offline

#9 2012-05-28 21:57:33

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,557
Website

Re: Awesome WM functions do not run in order

Beat you by 10 seconds.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#10 2012-05-28 22:01:57

Sphaerophoria
Member
Registered: 2011-07-14
Posts: 41

Re: Awesome WM functions do not run in order

Thanks. Unfortunately that was just an example. What I actually wanted to do was start an application and wait for the window to spawn before doing anything else. I could potentially just use the sleep command as a temporoary work around though.

Offline

Board footer

Powered by FluxBB