Skip to content

Add workspace management methods#44

Draft
Olbrasoft wants to merge 1 commit intoickyicky:mainfrom
Olbrasoft:feature/workspace-methods
Draft

Add workspace management methods#44
Olbrasoft wants to merge 1 commit intoickyicky:mainfrom
Olbrasoft:feature/workspace-methods

Conversation

@Olbrasoft
Copy link

Summary

This PR adds five new D-Bus methods for workspace management:

  • GetWorkspaces: Returns JSON array of all workspaces with index, active status, and window count
  • GetActiveWorkspace: Returns the index of the active workspace
  • GetWorkspaceCount: Returns the total number of workspaces
  • SwitchWorkspace: Switches to a specific workspace by index
  • GetWorkspaceWindows: Returns windows on a specific workspace

Use Case

These methods enable programmatic workspace control for automation tools and custom desktop management applications. For example:

  • Desktop automation scripts that need to manage windows across workspaces
  • Virtual assistant applications that can switch workspaces or query workspace state
  • Custom desktop panels that show workspace information

Example Usage

# Get all workspaces
gdbus call --session --dest org.gnome.Shell \
  --object-path /org/gnome/Shell/Extensions/Windows \
  --method org.gnome.Shell.Extensions.Windows.GetWorkspaces

# Get active workspace index
gdbus call --session --dest org.gnome.Shell \
  --object-path /org/gnome/Shell/Extensions/Windows \
  --method org.gnome.Shell.Extensions.Windows.GetActiveWorkspace

# Switch to workspace 1
gdbus call --session --dest org.gnome.Shell \
  --object-path /org/gnome/Shell/Extensions/Windows \
  --method org.gnome.Shell.Extensions.Windows.SwitchWorkspace 1

Test Plan

  • Test GetWorkspaces returns correct workspace count and active status
  • Test GetActiveWorkspace returns correct index
  • Test GetWorkspaceCount returns correct count
  • Test SwitchWorkspace changes to correct workspace
  • Test GetWorkspaceWindows returns windows on specified workspace
  • Test error handling for invalid workspace index

Add five new D-Bus methods for workspace management:
- GetWorkspaces: Returns JSON array of all workspaces with index, active status, and window count
- GetActiveWorkspace: Returns the index of the active workspace
- GetWorkspaceCount: Returns the total number of workspaces
- SwitchWorkspace: Switches to a specific workspace by index
- GetWorkspaceWindows: Returns windows on a specific workspace

These methods enable programmatic workspace control for automation tools
and custom desktop management scripts.
@toupeira
Copy link

toupeira commented Jan 3, 2026

Was just looking for a way to do this and found this PR, thanks @Olbrasoft! 🙇

I tested on GNOME 49.2, seems to work great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants