Actions
Free users get 1 action with full capability. Pro users get unlimited actions.
Actions let WorkTop run a command for you whenever you switch desktops.
Open Notepad when you switch to "Personal", spin up a dev server when
you switch to "Work", silence notifications when you switch to "Focus".
Anything you can run from a shell, WorkTop can trigger automatically.
Creating an action
- Open the Manager window (double-click the tray icon, or launch WorkTop from the Start menu).
- Click Actions in the sidebar.
- Click New action.
- Give the action a name.
-
Pick When. The event that fires the action:
- Switching to... - runs every time you switch TO a specific desktop.
- Switching away from... - runs every time you switch AWAY FROM a specific desktop.
- Any desktop switch - runs on every switch, regardless of source or destination.
- If the event needs a desktop, pick one from the Desktop dropdown.
- Type your Command. See Command examples for inspiration.
- Optionally set a Working directory (plain path, no quotes; spaces are fine), adjust the Delay (how long after the switch to wait) or Timeout (how long the command may run before WorkTop kills it).
- Click Test command to run the command once and verify it works. See Testing an action.
- Click Create.
The action is active immediately. Try switching desktops to see it fire. You can disable, edit, or delete it from the Actions list at any time.
Testing an action
The Test command button in the action form runs your command once so you can verify it works before saving. The result shows below the button: exit code, duration, and any output the command produced.
Testing actually runs the command. It is not a dry run or simulation. If your command opens a window, that window opens. If it deletes files, those files are deleted. Test on benign commands first.
Variables are filled in with realistic values based on the action's event:
-
For Switching to "X":
{from_name}/{from_id}are the currently active desktop;{to_name}/{to_id}are the configured target desktop X. - For Switching away from "X": the reverse.
- For Any desktop switch: both sides resolve to the currently active desktop. If your command branches on variables, you can temporarily change the event to a specific Switching-to value to test each branch.
Variables in commands
WorkTop substitutes the following placeholders in your command string before running it. They let one action behave differently depending on which desktop you're switching between.
{from_name}: the name of the desktop you're leaving.{to_name}: the name of the desktop you're switching to.{from_id}: the GUID of the desktop you're leaving.{to_id}: the GUID of the desktop you're switching to.
Example: echo Switched from {from_name} to {to_name} >> %TEMP%\worktop.log
(with shell enabled) appends a line to a log file every time you switch.
Variables combine especially well with Any desktop switch: one action can do different things per desktop by branching on the variable inside your command. See Scripting with variables.
More
- Command examples: opening apps, running PowerShell, working with files.
- Scripting with variables: how to make one Action behave differently per desktop.
- Rainmeter layouts per desktop: guide for automatically loading a different Rainmeter layout on each desktop.
Good to know
- Actions execute your command verbatim with your user's permissions. WorkTop does not validate or sandbox the command. Treat the Command field with the same caution you'd apply to running something in a terminal.
- Actions fire in the background. WorkTop does not wait for them to finish before completing the desktop switch.
- If a command exceeds its timeout, WorkTop kills the process. The default timeout is 30 seconds.
- Actions only fire while WorkTop is running. They do not run while the app is closed.