Plebware Control Centre Banner

Workspace Switcher

workspace-switch.sh

This shell script takes a PlebMachine mode name as a command-line argument, maps that mode to a workspace number, and asks the desktop window manager to switch to the corresponding virtual desktop.

Key Functionality

Mode-to-Workspace Mapping

The script maps the 12 PlebMachine modes to workspace values 1 through 12:

Workspace Command

The script passes the selected workspace value directly to the available desktop-switching utility:

The current code does not subtract 1 from the mapped workspace value. The previous documentation incorrectly described a WS - 1 conversion. That statement has been removed so that this article now describes the code that is actually preserved below.

The exact workspace numbering expected by wmctrl and xdotool should be confirmed during runtime testing on the PlebMachine target desktop. This documentation review does not claim that the current 1โ€“12 mapping has been runtime-verified.

Error Handling

The script exits with status 1 when:

Dependencies

Required Utilities

At least one of wmctrl or xdotool must be available for the script to perform a workspace switch.

System Environment

The script is intended for an X11 desktop environment with a window manager that provides multiple virtual desktops. PlebMachine currently targets XFCE/Xfwm4 on its Debian-based test systems.

Runtime Verification

This article preserves the code and documents its current behaviour. It does not mark the script as runtime verified.

Before this script is classified as WORKING, test the installed copy on the current PlebMachine target system and confirm that all 12 mode mappings land on the intended workspaces.


#!/bin/bash
# workspace-switch.sh - Switch to the specified workspace

MODE="$1"
case "$MODE" in
    everyday)   WS=1 ;;
    author)     WS=2 ;;
    study)      WS=3 ;;
    research)   WS=4 ;;
    graphics)   WS=5 ;;
    music)      WS=6 ;;
    video)      WS=7 ;;
    broadcast)  WS=8 ;;
    ai_helpers) WS=9 ;;
    developer)  WS=10 ;;
    accounting) WS=11 ;;
    leisure)    WS=12 ;;
    *) echo "Unknown mode: $MODE"; exit 1 ;;
esac

# Switch to workspace using wmctrl or xdotool
if command -v wmctrl >/dev/null 2>&1; then
    wmctrl -s "$WS"
elif command -v xdotool >/dev/null 2>&1; then
    xdotool set_desktop "$WS"
else
    echo "No workspace switcher found"
    exit 1
fi

Review โ€” 2026-09-20

Review subject: Workspace Switcher

Review date: 2026-09-20
Review scope: Documentation accuracy, code preservation, duplicate cleanup, runtime-verification status, and PlebVox exclusion.

โ†ฉ Return to the article I came from

Previous: PlebMachine Working Code Library โ€” Explainer and Recovery Guide.

Next: Plebeian Device Operator

No earlier PlebWare article yet

You haven't viewed any other PlebWare articles in this tab yet. If you arrived from Google or opened this article directly, there may be no earlier PlebWare article to return to.

You can keep exploring from here: