# Keeping Context on Linux: My Virtual Desktop Workflow Tool

Like quite a lot of other people after the advent of terminal based coding agents, I started using virtual desktops and now I have a separate virtual desktop for each task I'm working on. This helps to keep everything related to the specific task in a single place: IDE with the relevant project, `claude`, Sentry with the issue I'm debugging, Grafana with debug logs, Slack with conversation about the problem etc.

As much as management of virtual desktops is great in KDE, which I use, it has some problems. I decided to make my desktop-context-switching easier and created [vdesk-tools](https://github.com/r2rstep/vdesk-tools). And just recently I've published the scripts so that maybe also other's work gets smoother, too.

### Problems and how it solves them

#### Internet browser

Normally, when you click a link (e.g. in a terminal or Slack), it gets opened in the last active browser window. This window can be located in a different desktop than the one where you clicked the link, breaking your workflow.

`vdesk-tools` creates a wrapper around your default browser and always opens the link in the current virtual desktop to keep your context intact. Depending on the scenario it either:

*   activates already running browser window in the current virtual desktop and opens the link as a new tab,
    
*   or opens the link in a new window in the current desktop.
    

#### Virtual desktops management

`vdesk tools` allow adding, renaming and removing virtual desktops in the command line. Thanks to that you can keep your fingers on the keyboard :).

When adding a new virtual desktop, you can specify the name of the desktop.

When you run `vdesk remove`, it will first close all the applications running in the virtual desktop and then remove the desktop itself making the process much more pleasant.

Thanks to `vdesk-tools` it's easy for me to find relevant code, `claude` agent or debug information. Actually, I noticed that sometimes contents of the opened windows in a virtual desktop help me remembering what I was supposed to do in the given task easing my mental context switching.

### Usage

%[https://youtu.be/LVznU1eyZGY] 

```bash
git clone https://github.com/r2rstep/vdesk-tools.git
cd vdesk-tools
./install.sh
vdesk add demo
# move window to the new desktop
cd dev/project
my-alias-for-starting-IDE-and-claude-and-docker
# do whatever
vdesk remove
```

### Remaining problems

There are still some annoying problems which make it harder to have all the context in the same virtual desktop. I'm listing them here, cause maybe someone knows how to solve them :)

#### Having multiple Slack windows, each in a separate desktop

That is somewhat doable—Slack allows opening a conversation in a new window which can then be moved to the proper desktop. However, the new window loses the sidebar that lists all conversations.

Another issue occurs when clicking on a new message notification - desktop switches to the one with Slack's main window, even though you may have the conversation open in another window in the desktop which has all the context of the related task.

#### Having windows of the same app recovered to the proper virtual desktop after restart

KDE (and most desktop environments) has a "desktop session" feature that remembers which windows were open when you logged out, and can restore them on login. You can configure KDE to automatically restore these windows.

Sadly, this doesn't work correctly with virtual desktops. Applications like PyCharm open all their windows in the same virtual desktop instead of their original ones. Even KDE's own applications sometimes don't restore to their original desktops. Ideally, the state of the application (e.g. CWD of terminal) should be restored, as well.

### Links

[vdesk-tools](https://github.com/r2rstep/vdesk-tools)
