User:Garoth/Spawning Windows Where Launched

NOTE: this is just an idea page. This code hasn't been implemented. Maybe someone wants to do everyone a favour.

A problem that users have frequently wanted fixed is windows not spawning where you launched them. For the longest time, this was considered to be very difficult to do right, but recently we talked our way into a way this might be possible.

11:25 < Garoth> 1) make a custom prompt that, when spawing a program, addes a rule (see awful.rules) that matches against the pid of the program it just spawned. This                  rule would move the window that has appeared that has that pid (c.pid) back to                   where you were when you launched the program.  11:25 < Garoth> 2) Need to implement some way to remove rules from awful.rules when they've                   been used 11:26 < Garoth> Alternatively, it might be easier to not use awful.rules due to #2 and implement the matching/moving manually in your manage signal callback 11:27 < Garoth> Oh, also -- you need some sort of timeout. Not all programs that you might spawn will have windows -- and then you'd have bad rules cluttering up your matching system (awful.rules or whatever) 11:27 < Garoth> Just thinking out loud here, but for #2, it might be easiest to tell awesome to generate a timer callback for like a minute 11:27 < Garoth> if the program hasn't spawned within a minute... just forget about it

One additional thing that would get bonus points: it could be the case that the program spawns a subprocess with a separate pid to use to run the GUI. That seems unlikely, but an edge case. A thing that could be do-able is to scan through the process list and see if the pid that's spawning is a child of one of the pids in the database. I think this won't come up much. To someone possibly implementing this idea: I wouldn't worry about this edge case too much.

As discussed on IRC:
 * It would be almost trival to make awesome.spawn return the pid of the application that was started.
 * No idea what exactly it does, but the spawn stuff (libstartup-notify, used for the mouse cursor change currently) might help with this.