Giter Site home page Giter Site logo

Comments (6)

jsauerconsult avatar jsauerconsult commented on August 19, 2024 1

That works perfectly. I've seen that AppleScript technique before; I should have thought of that myself.

Thanks for taking the time to help me out. I plan to share this with the Keyboard Maestro community, thus I suspect you'll be seeing more WhichSpace downloads. Here's the macro that I will call at the beginning of many others.

Set SpaceNo

from whichspace.

gechr avatar gechr commented on August 19, 2024

Thank you for the kind words! šŸ˜

Assuming I correctly understand your intention, if all you want to do is switch between spaces using keybinds, I don't think you need to use a tool like Keyboard Maestro, macOS has native support for it under System Preferences ā†’ Keyboard ā†’ Shortcuts ā†’ Mission Control

image

from whichspace.

StevenJPx2 avatar StevenJPx2 commented on August 19, 2024

I think it's safe to close this.

from whichspace.

jsauerconsult avatar jsauerconsult commented on August 19, 2024

@gechr, thanks so much for the quick reply!

Sorry I should have described my scenario more clearly. Yes, I use the keyboard shortcuts that you point out. However, because I have configured more than 10 spaces, I can sometimes forget which app (or combination of apps) I have assigned to a given space. Thankfully, Keyboard Maestro provides a simple way to display palettes.

Spaces Palette

So here's the way I generally work: a) press a keyboard shortcut to display the above pallet, then b) press a single key to move to the desired space. For example, suppose I'm working with Safari (5) and I want to move to move to BBEdit (9) but I've forgotten that it's in space 9. I just press Ctrl+Opt+P, take a quick glance at the palette, then press 9. Note that I've assigned BBedit to Desktop 9.

BBEdit - Space 9

What I'd like to do is have another macro to return to the previously displayed space. If I had access to a space number, the macro behind the palette could save that value to a Keyboard Maestro global variable before switching to the new space. Then the new Toggle Space macro could read that value and switch back to the original space. For reference, here's a simplified version of the macro behind the BBEdit palette item.

BBedit

Note that the macro uses keystrokes to switch spaces. This is done because according to the Keyboard Maestro developer, Peter N Lewis, Apple does not provide a way to do it with a Public API.

Note for the sake of discussion here, I've simplified my typical scenarios. I have more complex macros that automatically switch to new spaces. Again, with these macros it would be very helpful to read and save the space number before moving to other spaces so that the original space could be restored after a series of macro actions.

Again, thanks for sharing WhichSpace!

from whichspace.

gechr avatar gechr commented on August 19, 2024

Aha, thanks for the detailed explanation, I understand now.

The good news is, I don't think I need to change anything in WhichSpace for you to be able to get the space number from the menubar icon directly, although I can't guarantee this will continue to work for future releases of WhichSpace, or even macOS!

Based on this StackOverflow answer, I came up with the following, which returns the number displayed in WhichSpace's menubar icon:

WhichSpace icon

image

AppleScript

$ osascript -e 'tell application "System Events" to tell process "WhichSpace" to title of menu bar items of menu bar 1'
3

Let me know if this works for you!

from whichspace.

gechr avatar gechr commented on August 19, 2024

Fantastic, Iā€™m glad I could help! šŸ˜„

from whichspace.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    šŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. šŸ“ŠšŸ“ˆšŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ā¤ļø Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.