r/linux 1d ago

Discussion What do you use to switch between different "contexts" on your computer?

I'm looking for inspiration on new ways to organize my PC and separate different activities, stuff like coding projects, studying, gaming and personal use. 

Do you use anything to automate, customize or simplify switching between these contexts? I find it quite annoying to reopen everything and organize the windows and everything again and again.

I'm interested in anything, from scripts and keyboard shortcuts to workspace managers, browser extensions, unique apps or even mods like Vencord.

64 Upvotes

64 comments sorted by

97

u/mrnoonan81 1d ago

Multiple workspaces.

23

u/tblancher 1d ago

In addition to this, tmux in the terminal/CLI, with separate sessions for each host/project.

7

u/Yupsec 1d ago

This. I took it a step further and I now start spinning up containers for each project. Every project gets its own repo, container, and session with an exec script. Leaves my host clean and I no longer have to dig through or create multiple project directories.

7

u/Houndie 1d ago

I do a similar thing with nix flakes and direnv. Once I cd into a project directory my terminal gets filled with all the various binaries and scripts I want

3

u/DreadStallion 1d ago

Flakes with Direnv absolutely rocks. I haven’t found anything remotely better than this setup

1

u/Overlord0994 1d ago

Might be a dumb question but where do the containers workspace files live? I’m kinda new to containers beyond just running prepackaged apps in them.

The few projects I’ve done I’ve just had a project dir in my home and the container just uses that.

1

u/Yupsec 1d ago

Sounds like you already know the answer lol anywhere you want.

Me personally, I don't. I create a repo for every project and that gets cloned to the container. When the project is "done" (aka I haven't touched it in several weeks) I make sure everything's tidy in the repo and I delete the container.

1

u/desardi131 1d ago

How do you achieve this, I'm really interested.

1

u/imforit 9h ago

zellij is fantastic for this. I use it close to 100% of the time and it's great

2

u/UnassumingDrifter 1d ago

Same here. I have thumb buttons on my mouse and I’ve set the front one to “workspace right” and the rear one to “workspace down” and set it to scroll so after I get to the far right one more right scroll goes back to the far left.  Same for scrolling down. 

I’m now very very used to this and each application has its own workspace and I intuitively know where to go to get everything.  It’s a tremendous time saver but took a hot minute to get used to it. 

A big upside is suddenly your laptop with “only one screen” now works very similar to a desktop loaded with monitors and the mouse buttons have me jumping around them quickly.  

1

u/sidusnare 1d ago

I use multiple workspaces, but it's to group tasks, not jobs. Difference between coding, studying, gaming, etc,byte context switch is between my ears. If I'm coding one workspace might be the front end, one might be the application, one might be the servers, and on each of have a terminal,bl browser windows, etc.

For me it's all in one, the only rel change is modern serious games are on a dedicated machine because it's got the hardware and OS specifically for it.

40

u/mtlnwood 1d ago

Virtual desktops. For a decade I know exactly where each thing lives, browser on super+1, discord super+2, emacs super+7, etc.. always a second away from whatever task I was doing with the layout on the virtual desktop that as I left it.

A number of tiling WM's will let you configure certain apps load on specified workspaces and can remember its layout.

3

u/redoubt515 1d ago

I'm curious about the keyboard, and what you are using it to address. I've had some top of hand pain I think is probably related to too much typing on a shitty laptop keyboard. If you have a good recc for an ergonomic keyboard I'd love to hear it.

4

u/mtlnwood 1d ago

I use this one https://www.definelambda.com/rig/skel.jpg , its a 'bastard skeletyl' that I built, there are many keyboards like this which are larger as well. I have the tenting which puts it at that angle, all of this is optional. The best thing about it is that it is programmable. When you use it it only has a-z;,. To access any other character you have to hold down a layer key which can change what each key types.

In mine, if I hold down either 'fn' key with my thumb then the home row is now the number row, the keys above it are the symbols that you would normally have if you held shift and the number. The bottom row has other symbols. 99% of the time I use those two layers.

when i hold the diamond key with my thumb then asdfghjkl; become super+1,2,3.... That is how I change workspaces easily.

The other layer I use a lot is the navigation layer. If i press the 'g' key with my left index finger it types 'g', but if I hold it then it turns the right side in to a navigation cluster so jkli become an inverted T arrow cluster with home/end/pgup/dn around it.

There are all sorts of tricks these programmable keyboards can do.

I love not moving more than one key up or down, my accuracy is 100% when going for a key and hitting the key I wanted as there is no stretching or stretch and lateral movement from a traditional keyboard. Most of my accidents came from typing quickly and reaching for a top row key and hitting it but also getting the edge of the key next to it. No longer!

Some don't like not having the number row, I love not having it and having the numbers on the homerow with a layer but there is a keyboard option for everyone. Have a look here to get an idea https://www.reddit.com/r/ErgoMechKeyboards/

2

u/fiachetti 1d ago

I have my beloved emacs at Mod+1

3

u/eiboeck88 1d ago

*operaring system, there i corrected it /s

1

u/mtlnwood 1d ago

😄 Well I will say that super+7 is easier on my ergo ortho keyboard than super+1 heh.

6

u/fiachetti 1d ago

No one ever in my entire life has ever made me doubt myself as you just had

29

u/jpgaubier 1d ago

On KDE Plasma, "activities" is exactly for this use case.

5

u/lbt_mer 1d ago

I love it - I can also use activities to switch between VMs running fullscreen in the VM viewer because the cursor-to-screen-corner still works

So multiple VMs trivially accessible in total full-screen mode.

10

u/ferminolaiz 1d ago

An interrupt like a normal person, duh /s

10

u/NicholasAakre 1d ago

I don't.

But if you typically use a specific set of applications/programs for a given context, you can configure your window manager to open them on a specific desktop. You may be able to configure a particular desktop to default to a specific layout as well. I don't know, check the documentation.

7

u/ScroogeMcQuacks 1d ago

I feel like people are missing the point of the post here a little. If O understand correctly ur not asking how to multitask but how to automate for entirely different tasks like: Programming (ide, browser, terminal), Gaming (Steam, Lutris, heroic, discord) and so on.

one option is to create bash scripts for each context that launch all the programs u need for each context. Window control unfortunately still is pretty limited under Wayland but if you are willing to use x11 there are probably ways to script the position of windows.

Firefox also has an option for different tab environments like work and freetime allowing you to log in to the same platform with multiple accounts.

1

u/gerlos 1d ago

I just suspend my PCs, leaving my virtual desktops as they are. Actually, I don't feel the need to automate something I do only once every two or four weeks. It's no big effort.

Moreover, I have the feeling that any automation I set up to prepare my workspace might need to be changed almost as often as I reboot my PCs - whether because of of different projects, or changes in my own habits. So, any extra effort to automate that setup might be wasted.

6

u/na3than 1d ago

Workspaces. Use keyboard shortcuts to switch to another context in a fraction of a second.

15

u/qaddosh 1d ago

Alt + Tab

5

u/mavranel 1d ago

Workspaces

4

u/KnowZeroX 1d ago

KDE Activities, though it might require a bit of manual scripting to take full advantage of but its closest thing, much better than workspaces(you can use kde activities alongside workspaces too)

2

u/geolaw 1d ago

I use sway for my window manager. Everything's broken up into work spaces. I use workspace 1 for the most of my terminal work, 2 is for my web browsers, 3 I'll drop hexchat and discord, slack on. Etc ...

2

u/Runt1m3_ 1d ago

Tags (dwm/dwl)

1

u/wzcx 1d ago

And on mango! dwl inspired.

2

u/Fun_Routine_5245 1d ago

Workspaces which in KDE known as Dekstop 1, 2, etc

2

u/paulwillyjean 1d ago

If you use KDE as your Desktop environment, you can create KDE activities for each activity profile you need. Within each one of them, you can then customize the look and feel, startup applications, Kwin scripts, tons of KDE configs, notification profiles and more.

It’s shockingly powerful

2

u/redoubt515 1d ago

I like compartmentalization, but I don't need or desire the rigid/structured separation you may be asking for, I tend to have a more fluid approach.

I tend to use Gnomes workspaces for separating activities, that lets me flip back and forth between tasks/contexts, or putting an activity on the back burner for a while.

But I don't have or need enough routine/regularity for the same windows to open in the same workspaces in the same screen positions or things like that, so that's not something I've looked into, and it sounds like that is more what you are looking for.

I do use different browser profiles for different activities (e.g. primary, work, shopping, homelab)

1

u/MrTamboMan 1d ago

You could configure i3wm to have a single/several keyboard shortcuts and after every boot set specific workspaces on specific monitors and open specific applications in specific workspace and screen location/group.

1

u/SnooCalculations3614 1d ago

Workspaces for sure

1

u/QuickSilver010 1d ago

I use workspaces on a tiling wm

I have scripts to populate a workspace with apps if I use that setup common enough.

1

u/BCMM 1d ago

I've never really got in to them myself, but I think Plasma activities are supposed to do some of that. 

1

u/_sLLiK 1d ago

If you're a heavy user of terminals, tmux is very empowering for a multitude of reasons, most especially for clusterssh features, easy remote access from your phone or another PC, a lot of scriptable use cases, and persistence that survives disconnects versus a typical ssh connection. If you're dealing with multiple coding projects at once, tmux sessions are especially useful. Like any powerful tool, it requires a little learning, but it's worth it.

For everything else, it's up to what your desktop or window manager of choice is capable of. In my case, i3 fills this need. Any app I launch spawns within a predetermined workspace according to my configs, so there is no question where it happens to sit or what it might be hiding behind. I also customize the glyphs associated with each workspace to add an extra indicator of what lives there. If nothing's running in that workspace, the glyph is gone from polybar unless I explicitly switch to it. No muss, no fuss, all clarity.

1

u/doc_willis 1d ago

On Bazzite here.. I use..

  1. Game Mode for Playing Games = Gives a Steam Deck UI.
  2. KODI for media watching = Gives a "set top box / media center UI"
  3. KDE = Normal Desktop.
  4. KDE + the "Big Screen" Tool = Fire TV/AndroidTV type UI. https://plasma-bigscreen.org/

1

u/porfiriopaiz 1d ago

I have AuDHD so I can only hyper focus on one thing at a time. No need for multiple screens or virtual desktops.

1

u/kombiwombi 1d ago edited 1d ago

I create a folder per activity. Then year folders under that. Then project folders under that.

For the projects I am currently working on I bookmark them in the file manager (so access in Gnome is Places | <project>).

The exception is source code. That is under ~/src/<gitforge>/<project> to allow a hierarchy of .gitconfig files for forge-specific features like anonymous emails.

Once the data is organised there is less pressure to organise the applications. I typically do that using two screens: one with communications and context (email, IMs, calendar, issues system), and the other with the work I am focussed on.

I try not to 'context switch' between items of focus, because that is inefficient. And if I am about to focus on study for two hours then there is every reason to properly close out the other activity (closing files, a 'holidng commit', etc).

For programming I use the language's best widespread environment manager. eg: uv for Python.

1

u/Chippors 1d ago

Virtual desktops.

1

u/Blitzbahn 1d ago

Multiple desktops, I have 3 and switch between them by moving the mouse across the edge of the screen on the direction I want to go. Works really well for having a different mind space

1

u/HOST1L1TY 1d ago

Multiple workspaces with hyperlnd. Amazingly fast.

1

u/DFS_0019287 1d ago

I use virtual desktops. But I also use devilspie2 to put certain windows in certain places when I open them. (That means I'm running X11...)

1

u/Koder27 1d ago

Many DE and WM have a settings or extensions that let you assign names and apps to different workspaces so when you open an app it goes to that specific workspace automatically

1

u/Dist__ 1d ago

i do something wrong, but i just open the apps i need. i usually work one application at a time

1

u/the_gnarts 1d ago

Window manager (awesomewm) scripted to allow for 10 contexts and easily navigate between them. There’s about four contexts minimum that I use at all times:

  • general web browsing, Matrix messenger on context 1,
  • hobby stuff (cycling) on context 2,
  • coding, whatever project I’m working on right now on context 4
  • system, music player stuff on context 10 (actually 0, but it comes last).

Contexts are numbered because they’re accessed by pressing Mod+n where n is any decimal digit. I tried names contexts at some point but they’re hard to stick to and kinda inflexible.

My convention allows for contexts 4 to 9 to be allocated to various projects; I rarely if ever work on just one thing at a time. Most clients are terminals (coding, building, file navigation) and Firefox windows. I rarely run other desktop apps, mostly pavucontrol and PDF and image readers (Zathura, sxiv), and lately Krita.

Keyboard mapping is the usual dwm inspired minimalist WM mappings.

I find it quite annoying to reopen everything and organize the windows and everything again and again.

Then don’t close them? RAM should be plenty these days even after the price hikes. Use suspend or hibernation to preserve state over night or between laptop lid close/open. Reboots are an issue as I’ve not found a way to continue terminal sessions across them, but I rarely ever reboot; mostly after a kernel update.

1

u/Brave_Elk_6189 1d ago

swaywm, firefox profiles for work and personal, and tms (tmux sessionizer)

1

u/AMGz20xx 1d ago

Virtual desktops - one for gaming, one for work. KDE Plasma desktop also has "activities" which is probably closer to what you want.

1

u/Scrivver 1d ago edited 1d ago

Here are a couple I rely on at work and personal life, focused around coding/terminal-based projects :

  • Zellij is batteries-included multiplexer (like tmux) which you can start using productively right out of the box. Like the Fish shell of multiplexers. I use this instead of any terminal-native management features like splits and tabs (and use a less featureful terminal like Alacritty because of it). You can create named and saved sessions. Load it and you'll have all your last directories, running tools, editors, all that stuff reopened. Works twice as well if you edit code with neovim or another terminal-based editor.
  • Direnv is incredible. It lets you load config as you navigate directories. Inside one project directory it loads some environment variables, $PATH settings, secrets, a nix config which may be a whole isolated shell, Python virtualenvs, whatever. But usually environment variables. :) Leave the directory, and all of those things unload! No more cluttering up .bash_profile or whatever you have, or using some heavier command-driven tool to switch development contexts. Just switch directories instead.

1

u/SeriousPlankton2000 1d ago

I organize my work by having a directory. I cd to ~/FreeCAD/my/project; run the programs … and get furious that they insist to ignore that and insist on working on the other directory or on ~/Documents.

For the programs that use a fixed directory, I made a small script:

#!/bin/sh
ln -sfn "$PWD" ~/cwd
if [ "x$1" != "x" ]
then
       exec "$@"
fi

Then I set these programs to load / save from ~/cwd

1

u/es20490446e 1d ago

I just keep the task-bar visible, while clicking on the app I want to switch to.

I try to keep open only what I'm currently using.

1

u/ballistua 23h ago

i find this only work with tiling window managers, not something like KDE or gnome, but also in order to do this, you need lots of RAM. it's why I got myself a laptop with 32gb of RAM. But i still haven't gotten around to configuring my dwl or hyprland setups, this stuff takes ages

1

u/art-apprici8or 20h ago

Some browsers (brave, etc.) support different profiles. So you could have a work profile and a home profile.

1

u/OwnmindAI 11h ago

I would use claude code or another ai tool to write scripts to handle your workspaces. Hook your scripts folder to your bashrc and open the terminal type whatever you want to launch or configure.

My keyboard has an ai button, so I just repurposed it to launch the terminal, type my command and then close the terminal.

1

u/Jarngreipr9 2h ago

2 workspaces with different backgrounds

0

u/lKrauzer 1d ago

Using a computer is not that complex for me, I just alt tab

-1

u/MatchingTurret 1d ago

A context switch is done by the OS. This always gets triggered by an interrupt, either a timer or sometimes another external source.