feat: add ping-pong desktop cycling action (macOS only)#195
Open
winniesi wants to merge 1 commit into
Open
Conversation
Adds a new 'Cycle Desktops' action that ping-pong cycles through desktops: 1→2→3→4→3→2→1→2→3... The action appears in the Navigation category and can be assigned to any button (mode shift, middle click, side buttons, etc.). Desktop detection uses CGSGetActiveSpace to get the current space id64, then parses com.apple.spaces to find which display owns that space. Only id64 values inside the Spaces array block are counted (excluding 'Current Space' and 'Collapsed Space' entries) to avoid incorrect desktop counts on multi-monitor setups. The engine tracks direction state (left/right) in config.json and reverses at boundaries. Skips when only 1 desktop exists. Changes: - core/key_simulator.py: Add cycle_desktops action (macOS only) - core/engine.py: Add _get_macos_desktop_info() and _cycle_desktops() - ui/locale_manager.py: Add zh_CN/zh_TW translations
6d52e61 to
79f3313
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new Cycle Desktops action that ping-pong cycles through desktops on macOS:
1→2→3→4→3→2→1→2→3…This is useful when you want to quickly switch back and forth between desktops without reaching the edge and stopping.The action appears in the Navigation category and can be assigned to any button (mode shift, middle click, side buttons, etc.).
How it works
Desktop detection
Uses two macOS APIs to detect the current state:
CGSGetActiveSpace(private CoreGraphics API) — returns theid64of the space on the display where the cursor is located.com.apple.spaces(user defaults) — contains the per-monitor space configuration, including the ordered list of space IDs for each display.The implementation parses the
Spaces = (...)array block for each monitor section using parenthesis-depth matching, and finds the display whose space list contains the currentid64. This correctly handles multi-monitor setups where each display has its own set of desktops.Ping-pong logic
The engine tracks the current direction (
rightorleft) inconfig.jsonundersettings.desktop_direction:Platform support
cycle_desktopsactionCGSGetActiveSpace+com.apple.spacesThe macOS
space_right/space_leftactions already use_post_symbolic_hotkeywhich triggers the system "Move left/right a space" shortcuts. Thecycle_desktopsaction delegates to these existing actions.Changes
core/key_simulator.py: Addcycle_desktopsaction definition in the macOSACTIONSdictionary (Navigation category). Not added to Windows/Linux.core/engine.py: Add_get_macos_desktop_info()static method for desktop detection, and rewrite_cycle_desktops()with ping-pong logic.ui/locale_manager.py: Add Chinese translations (zh_CN: 循环切换桌面, zh_TW: 循環切換桌面).Testing
1→2→3→…→N→(N-1)→…→1→2→…Device info