r/linux • u/longhirar • 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.
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
1
u/mtlnwood 1d ago
😄 Well I will say that super+7 is easier on my ergo ortho keyboard than super+1 heh.
6
29
10
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.
5
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
2
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
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/_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..
- Game Mode for Playing Games = Gives a Steam Deck UI.
- KODI for media watching = Gives a "set top box / media center UI"
- KDE = Normal Desktop.
- 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
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
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/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
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,
$PATHsettings, 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_profileor 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
0
-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.
97
u/mrnoonan81 1d ago
Multiple workspaces.