What environment variable should I use to set a default web browser?
Solution 1
I've found a solution:
xdg-settings set default-web-browser chromium-browser.desktop
you could also use:
xdg-settings set default-web-browser firefox.desktop
or:
xdg-settings set default-web-browser chrome-browser-stable.desktop
If you wish to automate this at login, just put this one liner in your .profile
Solution 2
You would use the command sudo update-alternatives
for this purpose. For the default web browser, sudo update-alternatives --config x-www-browser
will start an interactive dialog that lets you set the default, which will remain the default even across sessions.
If you really want to set the default after every reboot, use
update-alternatives --set x-www-browser /path/to/browser
in something like /etc/rc.local
, as it needs root permission.
Related videos on Youtube
![Brian Sizemore](https://lh6.googleusercontent.com/-zFS_9EBn1_4/AAAAAAAAAAI/AAAAAAAAAD0/pDWfYurHBwk/photo.jpg?sz=256)
Brian Sizemore
Computer Science and Computer Engineering Dual Major at West Virginia University. Member of CyberWVU. http://cyberwvu.lcsee.wvu.edu/
Updated on September 18, 2022Comments
-
Brian Sizemore almost 2 years
I'm trying to set my default web browser as google chromium inside of either my .bashrc or .profile. What Environment Variable do I need to set in order to achieve this?
Edit: Here's some more information:
A. I don't have sudo access to the machine.
B. Due to the nature of the machine, It needs to be rerun every login.
C. Ideally it runs at login with no dialog.
-
0x2b3bfa0 about 9 yearsWorked the Jos answer?
-
-
Brian Sizemore about 9 yearsI've updated my question, and I do not have root/sudo access to the machine, It needs to just set the browser for my user.
-
Jos about 9 yearsIt may be possible to use
update-alternatives
on a user-by-user basis by providing another "alternatives directory" in the command (the--altdir
flag). This directory would contain symlinks to the various browsers available on the system. Please seeman update-alternatives
and experiment a little.