Sabayon Linux: Set the default web browser for Gnome (eg. for Python Apps)

This article is from 2012 and has been archived. It's old and probably outdated.

In my particular use case I wanted links in Gwibber to open in Chromium instead of Firefox. Gwibber is a Twitter client written in Python. Unfortunately all the proposed solutions from above didn’t work. Fortunately I found a solution. There are lots of articles in the web dealing with the right way to set the default web browser in Gnome or the system in general:

When I tried to open an URL in the Python Shell, the page opened in Firefox:

>>> import webbrowser
>>> webbrowser.open(http://heise.de)  # Opened in Firefox

I set the environment variable $BROWSER:

$ export BROWSER="chromium"

When I ran the Python code again the page opened in Chromium. So far so good, but of course it was still not working in Gwibber. I tried to set it automatically by storing the variable in .bashrc - no luck.

Eventually I found out that I should set the variable in the file ~/.pam_environment: It is a storage for environment variables - session-wide used, even when running a desktop environment. After editing the file I had to logout of my current graphical session and login again.

Since then Gwibber is opening links in Chromium. ;-)

Jan Beilicke

About the author

Long-time IT professional and full-time nerd. Open source enthusiast, advocating security and privacy. Sees the cloud as other people's computers. Find me on Mastodon or Twitter.