Linux: Default browser
Contents
Problem
When I click on a link from within Pidgin, the Google Chrome webbrowser opens, although I have specified in KDE { System Settings | Default Applications | Web Browser } that my default webbrowser is Firefox.
Environment:
- Pidgin-2.10.3
- KDE-4.8.5
Solution 1. Per-user, set BROWSER environment variable
Set the BROWSER
environment variable in ~/.profile
:
# Indicate preferred webbrowser for graphical or text terminal respectively [ $DISPLAY ] && export BROWSER=firefox || export BROWSER=w3m
If your login-shell is set to /bin/bash
(see /etc/passwd
), and you have a file called ~/.bash_profile
, make sure, ~/.profile
gets included when you login on a text terminal:
#--- ~/.bash_profile ------ [[ -f ~/.profile ]] && . ~/.profile
Why set BROWSER in .profile and not .bash_profile ?Because the latest display manager, LightDM - which boots the graphical desktop - sources just .bash_profile (see: /etc/kde4/kdm/Xsession ), but starting from Kubuntu-12.10, lightdm will be used. |
Why not set BROWSER in .bashrc ?Because you want the .bashrc gets sourced every time you start a new bash shell, so setting BROWSER in .bashrc would run each time you start a new bash shell, whereas you'd like to set/export BROWSER once for all bash shells. |
Solution 2. System-wide, setup symlinks
Depending on your distribution, check if these chains of symlinks below, end up pointing to your preferred webbrowser, e.g. firefox or w3m for a graphical or text terminal respectively. You can modify a symlink like this:
sudo ln -sf /usr/bin/firefox /usr/bin/x-www-browser
Debian/Ubunu/Kubuntu
Graphical terminal
/usr/bin/gnome-www-browser |-> /etc/alternatives/gnome-www-browser |-> /usr/bin/firefox /usr/bin/x-www-browser |-> /usr/bin/firefox
Text terminal
/usr/bin/www-browser |-> /etc/alternatives/www-browser |-> /usr/bin/w3m
Solution 3. Configure your desktop environment
KDE
Go to { System Settings | Workspace Appearance And Behavior | Default Applications | Web Browser } and set your preferred webbrowser.
Solution 4. Configure your application
Pidgin
Go to { Tools | Preferences | Browser } and set your preferred webbrowser.
See also
- The Default Browser on Linux Debacle | Evan Teran's Blog
- Similar blog about the default browser problem
- Make path environment set in .bashrc available in krunner • KDE Community Forums
- Forum thread. One solution proposes setting environment variables in
~/.kde/env
.
- Setting Up Shell Initialization Files
- Article on how to setup initialization files, depending on your login shell (C Shell, Bourne Shell or Korn Shell)
Journal
20170719
Test2
20130129
From within Pidgin I can see at { Tools | Preferences | Browser } that the browser selection is set to "Manual" and the executed command is "sensible-browser". This actually is a shell script:
$ type sensible-browser sensible-browser is /usr/bin/sensible-browser $ file /usr/bin/sensible-browser /usr/bin/sensible-browser: POSIX shell script, ASCII text executable
The sensible-browser
script first looks for a BROWSER
environment variable and if that doesn't exist it executes /usr/bin/gnome-www-browser
which is symlinked to:
/usr/bin/gnome-www-browser |-> /etc/alternatives/gnome-www-browser |-> /usr/bin/google-chrome
So that's why Google Chrome is started.
Setting BROWSER to "firefox" in .bashrc only has effect when "pidgin" is started from bash. When "pidgin" is started from "krunner", the default browser is still Chromium?
From this command it can be seen that "krunner" has no BROWSER setting:
$ cat /proc/$(pidof krunner)/environ | tr '\000' '\012' | grep BROWSER
To have the BROWSER environment variable set for krunner, the BROWSER environment variable must be set in ~/.profile
not ~/.bashrc
20130130
Try changing shebang of /usr/bin/startkde from #!/bin/sh to #!/bin/bash and see if that makes the BROWSER setting from .bashrc into KRunner.
- Re: kde startup, .profile, env.vars., etc.:
- Analysis of Ryo Furue what's going on when starting kdm
Apparently, this is what's started on Kubuntu-12.04:
kdm \_ kdmrc \_ Xsession
- Why .profile, .bash_profile, and .bash_login? - Life and Opinions
- Tristram Brelstaff attempt of understanding the differences between the bash login files. The conclusion is to use
.bash_profile
as the appropriate place to put bash-specific commands to be run when starting a login shell.
20130131
I encounter this process tree on Ubuntu-12.04, running KDE:
lightdm \_ /usr/bin/X :0 ... \_ lightdm --session-child ... \_ /bin/sh /usr/bin/startkde
Because startkde contains the shebang "#!/bin/sh", only /etc/profile and .profile are sourced?
- Bug #794315 “lightdm forgets to source /etc/profile and ~/.profi...” : Bugs : “lightdm” package : Ubuntu
- But if I don't have a /etc/lightdm/Xsession, who's sourcing /etc/profile and .profile then?
- lightdm - What happens under the covers to log me in and start up the Unity Graphics User Interface? - Ask Ubuntu
- From this article it becomes apparent that /usr/sbin/lightdm-session sources /etc/profile and ~/.profile.