14 September 2011

Change window behavior to prevent focus stealing (under KDE and Gnome)

Bored of programs stealing focus ?
For instance, you launch an application which takes time to start, you switch to something else to work, and after some time the main window of your just launched program pops up and steals focus (including keyboad ...).

This article gives instructions to change this behavior both under
KDE and Gnome.

Under KDE:
 - open 'System Settings' application
 - open 'Window Behavior' menu
 - select 'Window Behavior' left panel
 - select 'Focus' right panel
 - update 'Focus stealing prevention level' and policy to your needs

Under Gnome:
 - check 'focus new windows' configuration (it is defined to 'smart' by default):
gconftool-2 --get /apps/metacity/general/focus_new_windows
 - change 'focus new windows' from 'smart' to 'strict':
gconftool-2 --set /apps/metacity/general/focus_new_windows --type string strict

Under Gnome-Shell:
In addition to previous instructions for Gnome, which don't seem enough for Gnome-Shell (Gnome 3), you can:
  - check 'no focus windows' configuration (empty by default):
gconftool-2 --get /apps/metacity/general/no_focus_windows
 - change 'no focus windows' to fully disable focus for ANY windows:
gconftool-2 --set /apps/metacity/general/no_focus_windows --type string "(not true)"

You won't be annoyed anymore by windows stealing focus.

8 comments:

  1. Damn, this was useful! Thanks a bunch!

    ReplyDelete
  2. It fixed my Unity that kept losing focus on changing windows. Thanks a lot!!

    ReplyDelete
  3. thanks! I wonder if there exists a GUI for these advanced options. In openSuse 11 gnome-control-center do not let me do this kind of advanced stuff.

    ReplyDelete
  4. No joy unless you're using Metacity. A big problem for Ubuntu-proper users.

    ReplyDelete
  5. OMG! Yes! Thank you!

    ReplyDelete
  6. I'm afraid the Gnome-shell (Gnome 3) option does not work, as there is no no_focus_windows key.

    ReplyDelete
  7. In Gnome-shell, the new corresponding property is 'org.gnome.desktop.wm.preferences.focus-new-windows'.
    You can edit it with gsettings.

    ReplyDelete
  8. In Cinnamon 2.2.14 the following worked for me 'gsettings set org.cinnamon.desktop.wm.preferences focus-new-windows strict'

    ReplyDelete

Thank you for your visit, let's share your point of view: