Comments (6)
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.
from whichspace.
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
from whichspace.
I think it's safe to close this.
from whichspace.
@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.
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.
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.
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.
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
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.
Fantastic, Iām glad I could help! š
from whichspace.
Related Issues (20)
- Which Space counts FullScreen apps as Spaces HOT 2
- Multiple Icons in Top Bar HOT 3
- Add a LICENSE
- Feature suggestion: space title HOT 1
- Named spaces HOT 1
- Unaligned on macOS Big Sur HOT 5
- Number off by one if Dashboard was enabled before Catalina HOT 3
- Allow setting icons instead of numbers HOT 1
- [feature request] display space ID for every active monitor HOT 16
- [feature request] command line app HOT 9
- Show workspace number correct if multiple screens are used HOT 1
- [feature request] Add support for Apple Silicon HOT 3
- [feature request] Check which spaces are used HOT 1
- Can't install on M1 Mac, OS Monterey 12.1 HOT 4
- Center the number in the menu bar icon HOT 1
- Call a script whenever the space changes
- Misaligned Icon on Sonoma 14.0 HOT 5
- Wrong space number
- Just doesn't appear in my menu bar? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
š Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ā¤ļø Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from whichspace.