Saturday, January 6, 2018

Bash script to make Chromium incognito by default

I never like to leave accounts signed in after I've exited a browser for security reasons, so I always use incognito on Chromium. It's pretty easy to make Chromium launch in incognito mode by default, but whenever I update it gets restored to the default settings and I lose the modifications. So, I made a little bash script to do it for me that I can run whenever I update:
#!/bin/bash

cd /usr/share/applications

sed 's/Exec=chromium-browser/Exec=chromium-browser --incognito/g' <chromium-browser.desktop >chromium-browser.desktop.temp

mv chromium-browser.desktop.temp chromium-browser.desktop

The only part of the script that is doing anything interesting is the sed, which replaces every instance of the Exec call with one that contains the incognito flag. Muy bueno.