Chromium profiles with a fixed set of tabs
Tags: tools
Keep making a mess of your tabs and accidentally closing your messengers? I might have a solution for you!
There are a bunch of web apps that I generally like to keep open when working on my computer. Mostly messengers: Slack, multiple instances of mattermost, etc. But I usually make a mess of my browser windows and tabs, so I end up opening these apps multiple times or accidentally closing them. This is my attempt to nudge me back to sanity.
Goals
- [x] Open all my important apps in a single chromium window with a single click
- [x] Prevent me from accidentally closing any of these apps
- [ ] Prevent me from cluttering up this window
- [ ] Make my SSG render checkboxes 😕
Prerequisites
You might be able to translate some of this to windows and other browsers, but this guide was created with Chromium on Linux.
Steps
1. Create a designated chromium profile
Top rigt corner (Next to the vertical dots) -> Add profile
The created profile is hereafter referred to as apps-profile.
2. Set all of your apps as start pages
In a chromium window using the apps-profile.
Goto: chrome://settings/onStartup -> Open a specific page or set of pages
Hint: The tabs will open in the order in which you add them here, but you can not reorder them! 😦
3. Prevent yourself from accidentally closing these pages
Install the Tampermonkey Extension.
Add this user script:
// ==UserScript==
// @name PreventClose
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Prompt before closing tab
// @author Niklas Beierl
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant none
// ==/UserScript==
(function() {
'use strict';
const originsToPrompt = [];
function onBeforeUnload(e) {
e.returnValue = "Modern Browsers will ignore this string.";
}
window.addEventListener('beforeunload', onBeforeUnload);
})();This activates the "Changes you made may not be saved."-prompt on any pages you will choose in the next step:
In the settings tab for that user script, add all of your apps, to "User matches". So if you want to prevent yourself from closing tabs on https://some-app.tld add https://some-app.tld/*, e.g.: https://app.slack.com/*
4. Ensure that chromium always opens with my default profile
Now we have introduced a bit of an annoying issue: By default, chromium will open any new window with the least recently used profile. But I only want to open a window for that profile when explicitly selecting it in the profile menu! By default, new windows should open with my "Default" profile. On linux you can simply add --profile-directory="Default" to /home/<user>/.config/chromium-flags.conf to achieve that. See this stackoverflow post for a more detailed explanation. You can of course also have a non-"Default" profile open by default. 😉