Spaces 'Application Assignments' and Applescript

Let’s face it – Spaces, Leopard’s new virtual desktop implementation, isn’t as polished as many of us would like it to be. It has more than it’s share of undocumented features, bugs, and annoyances.

One of my personal gripes with spaces it’s lack of keyboard shortcuts for managing what Spaces calls “Application Assignments”. I’d like to be able to quickly assign an application to all Spaces with a quick keypress. Also – I often find myself hunting through my Spaces for 3 or 4 Safari windows I’ve left in various places – it’d be nice if there was an easy way to collect all windows of a given app on the current Space.

So, this morning, I sat down and started hacking at some Applescripts to do just that. After wading through the bizarre way that Application Assignments are stored, I ended up with 4 Applescripts:

  • Assign to All Spaces – assigns the frontmost window to all spaces.
  • Assign to Space X – opens an input dialog asking you which space to assign the frontmost window to.
  • Collect on Current Space – brings all windows from the frontmost appliation to the current space.
  • Remove Assignments – remove any appliaction assignments the frontmost window may have.

Here’s a zip file of all 4:

Spaces Applescripts

These scripts are designed to be invoked via a keyboard shortcut via Quicksilver or FastScripts.

If you have any corrects / additions / suggestions as to how to improve these scripts, drop ‘em in the comments!

Comments

Leave a response

  1. Jim had this to say Tue, 27 Nov 2007 17:35:50 GMT

    Great work!

    Any chance the assign to all spaces script could be implemented on a per window basis? I’m trying to use it for Adium, to have my buddy list be available on all spaces. But I don’t necessarily always want the chat windows available.

  2. Jesse Newland had this to say Tue, 27 Nov 2007 17:44:11 GMT

    @Jim – Spaces works per-application, not per-windows. Sorry.

  3. Jono had this to say Tue, 27 Nov 2007 18:40:56 GMT

    Very handy!

    Thanks a lot for this.

  4. crazyj had this to say Tue, 27 Nov 2007 23:00:36 GMT

    @Jim – I had my Adium working that way by accident. Because it wasn’t what I wanted it was really annoying. Now I somehow have both in All Spaces, which is what I wanted, but I don’t know how I accomplished it or how you could reverse it to get what you are looking for, but I believe it CAN be done.

  5. Adam Salter had this to say Wed, 28 Nov 2007 03:53:34 GMT

    @Jim – It can be done because the Finder does it. The Finder desktop is on all spaces, but all other windows can be assigned to a particular space. The problem is that I suspect it’s not a publicly available method. I.e. only the FInder can do this… Which is pretty silly since there are other reasons an application might want to do this – as your suggestion shows.

  6. God of Biscuits had this to say Wed, 28 Nov 2007 04:15:21 GMT

    I wonder if there’s a way to spread a given app’s windows according to task?

    LIke I want to have Safari opened in every space, but I want separate windows in separate places.

    In other words, I want Safari to live in every space, but with different Safari windows in each space.

  7. Eric Litman had this to say Wed, 28 Nov 2007 14:01:53 GMT

    Collect on Current Space FTW.

  8. Timothy Moenk had this to say Fri, 30 Nov 2007 05:35:21 GMT

    Awesome! Just got my first mac a few weeks ago and I’ve been grumbling about how Spaces is missing some pretty key management features.

    Hooray! :D

  9. brett had this to say Fri, 30 Nov 2007 07:39:40 GMT

    That is fantastic. I’ve been lost without the keyboard shortcuts for assigning apps to different desktops that Virtue had. Thanks so much for taking the time to put these together.

  10. randy had this to say Fri, 30 Nov 2007 13:44:22 GMT

    As an old unix hack, I like to set up different sizes of terminals – with specific layouts, in different window manager desktops. For example: s1: coding – 3 terms side by side, each 102×80 s2: logs – 2 wide terms to watch nginx & rails dev.log stuff scroll by, nginx 315×29, rails 315×48 etc…

    Perhaps I can drag terminals to different spaces, and carefully align ‘em one-by-one, but I’d rather just launch the ‘code’ window group in s1, and ‘log’ window group in s2. Particularly because my actual ‘standard’ window groups are a bit more complex than I sketched above. I’ve done this on unix desktops since sun’s openwindows in the early 90s…

  11. Jono had this to say Tue, 04 Dec 2007 09:30:16 GMT

    I have the odd problem with some windows sticking to spaces & I’m not sure the Remove Assignments.scpt is always working correctly for me.

    Is there somewhere I can trash the settings I’ve applied with the scripts?

  12. Galoncitron had this to say Wed, 05 Dec 2007 15:23:55 GMT

    Absolutely terrific! I was just starting to look for this function, and here it was! Well done and thank’s for sharing!

  13. Patrick had this to say Sat, 22 Dec 2007 23:10:24 GMT

    Hi Jesse,

    I’m so glad you made those scripts but unfortunately the “Assign to Space” script won’t work for me.

    I made a screenshot of the error message when invoking the script via FastScripts:

    http://myskitch.com/halbtuerke/fastscripts_error_notice-20071223-000947.png

    I hope you can help me.

    Thanks in advance

  14. Xav had this to say Tue, 25 Dec 2007 18:34:23 GMT

    Hi, I’m still looking for a script that just moves a window to a specific space.

    Your “Assign to Space” is almost there, but I don’t want the app window to be tied to the selected space…

    For example, if I have 3 Safari windows in a space and run your “Assign to space” script, all of the windows will be moved, while I want only the frontmost window to.

    Is anything like that doable?

  15. AngryAnt had this to say Mon, 07 Jan 2008 14:21:14 GMT

    Xav: Thats built in. Just click and hold the title bar of the window you want moved and then press the key combo for the space you want it in. Fx: ctrl + 2.

  16. KB had this to say Thu, 10 Jan 2008 22:48:56 GMT

    Wonderful script! Great work man!

    Any plans to create a script to backup all assigned application assignments to a file?

    Helpful for transferring preferences to other accounts, etc.

  17. spazek had this to say Sun, 13 Jan 2008 01:07:37 GMT

    Very useful!

    Thank you for this!

  18. Richard Pitcairn had this to say Tue, 15 Jan 2008 06:23:42 GMT

    I just tried these scripts out. Get this error message on using “Collect” script.

    Error number: -1728 Message: Can’t get text 2 thru 0 of ”|:no-bundle:1498248036|:65544”.

    I can’t figure out what this means but hope it can be fixed.

    Thanks, Richard

  19. rssnewsdigest had this to say Thu, 03 Apr 2008 11:53:13 GMT

    Try rssnewsdigest.com, a new comprehensive news aggregator. With rssnewsdigest, you don ’t really have to go anywhere else. http://rssnewsdigest.com

  20. handy had this to say Fri, 25 Apr 2008 14:29:54 GMT

    thanks thats very useful.

Your Comments