On 03/19/2013 04:39 PM, Pierre M wrote:
PS: Thanks a lot Renan for pointing at wmctrl, it is such a useful
tool when you work with several desktops :-)

No problem! I also found your solution very cool. I'm not very familiar with Perl, but there is a race condition with using the timer to get the new window: say you command to open a new window in desktop 4 and it takes a while to open. You also command another window to open on desktop 7, and it very quickly shows up.

In the bash script, I tie each invocation with the process pid, so that no mismatch can happen. But from what I can understand of perl, it seems like it could happen that this version opens two new windows in the places meant for the other?

OTOH the perl version has a timeout which is very convenient for not blocking the shell :) Perhaps if you tied each invocation with the pid of the process you would get the only positive differential from the bash version :)

Cheers,
Renato.
On 19 March 2013 19:33, Pierre M <[email protected]> wrote:
Ok, I did it. I named it "oiw.sh" because that's how I roll; just place it
somewhere in your system and rename as desired.
Hi Renan, cheers =)

Funny that, i did the same thing today and just finished. It's in the attached.
I called it oid.pl, as wmctrl calls workspaces "desktops", and as i'm
a Perl monger:
"Open In Desktop"

There's no "sleep" in it: i check the number of opened windows, and
wait until there are more (there's a timeout if no window is opened).
Then, i identify them and move them to the requested desktop.

Instructions for use are at the beginning of the file.
Basically it looks like this (and you can also define a timeout duration):

perl oid.pl 3 iceweasel www.linux.org

As indicated in the file, you should create an alias in your .bashrc file:
alias oid='perl oild.pl'

I hope others enjoy it too :-)

PS: i tried to keep the code as clean as possible. But i also kept it
dependence-free (you just need Perl), so i couldn't use CPAN modules
like Method::Signatures that make the code so much more readable, or
others like List::Util that make it so much more simple (and thus
readable/maintainable).


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

Reply via email to