Typical situation is that I type something (worst case is my password) in some application, when some other application pops up a window and steals the focus, so my typing (password) goes to something else. I would like to prevent this, at least when I actively type something in an edit box. I always really hated this on Windows, but I never found a way to prevent this. I started using Ubuntu a while ago, and so far I was able to do everything I wanted, so I thought maybe this is also possible. Thanks in advance!

  • 8
    Try to change a setting with the terminal command gsettings set org.gnome.desktop.wm.preferences focus-new-windows 'strict'. Let us know if that works in your case. To reset to default, give the command gsettings reset org.gnome.desktop.wm.preferences focus-new-windows
    – vanadium
    Commented Oct 15, 2018 at 20:13
  • 5
    Thanks. With this change the new windows appear in the background, but interstingly the focus is lost. So for example I start typing in the terminal, and meanwhile I start some application with starts up quite slowly. I click on the application on the left side in the favorites, click back to the terminal window to continue typing. In a few seconds the application starts, its window is put behind the terminal window (which is good) but I lose the focus, and cannot type until I click on the terminal window again.
    – Imre Major
    Commented Oct 16, 2018 at 15:26
  • 2
    A pity this did not work completely. It remains something that is difficult to control. Many related questions over the years unfortunatelly remained unanswered.
    – vanadium
    Commented Oct 16, 2018 at 16:05
  • 2
    ... I haven't tried it yet, but I'm thinking about writing another little app (that my main app can start in the background and subsequently stop when it no longer needs it) that just sits in the background looking for my pop-ups and gives the focus back to them. It appears to be easy enough to write using bash and xdotool, but a lot of things look simple before you try to implement them. This would have to know what windows it was looking for in advance, so it's not a generic solution to your issue.
    – Joe
    Commented Oct 18, 2018 at 4:01
  • 3
    The top and most upvoted comment by @vanadium doesn't work at all. If in the shell I type gedit &[enter]ls", "ls" ends up in gedit, not on the shell.
    – Giszmo
    Commented Jan 5, 2021 at 14:00

5 Answers 5

  1. Install CompizConfig Settings Manager

    • either from Ubuntu Software Center
    • or via terminal:

      sudo apt-get install compizconfig-settings-manager
  2. Open CompizConfig Settings Manager and go to General -> General options -> Focus and raise behaviour

  3. Change the 'Focus prevention level' from 'Low' to 'Normal'.

  • 1
    Not applicable to Ubuntu 18.04 with GNOME 3, it doesn't even have Compiz.
    – pomsky
    Commented May 3, 2020 at 16:18
  • @pomsky I just today did the above steps on my Ubuntu 18.04 and they worked. I don't remember having added Compiz individually, other than the mentioned package. How could it be working? Commented May 3, 2020 at 18:58
  • Is your system upgraded from an older Ubuntu release?
    – pomsky
    Commented May 3, 2020 at 19:00
  • No, it was installed as 18.04.1 and has been upgraded just up to 18.04.4 and I can verify that my window manager is Gnome 3, so I haven't changed it. Have you tried the above steps on your Ubuntu 18.04 and didn't work? I wonder if adding CompizConfig Settings Manager also adds any prerequisite that make this requested feature working. In any case I only did the above and I am no longer experiencing the issue. Commented May 3, 2020 at 19:06
  • 2
    On Ubuntu 20.04 I used this solution and it required one more step for it to work. I had to Alt+F2 and run the "r" command to restart the x server. I assume the settings get reloaded after that and THEN, new windows stopped stealing current window focus.
    – EffectiX
    Commented Aug 31, 2021 at 13:27

If you are using Cinnamon, there is an easy solution which I found here:


Search for 'Windows', then:

Windows > Behaviour > Prevent focus stealing > On.

I was experiencing this issue with Thunderbird Lightning Popups and could now finally resolve this.

enter image description here

  • 1
    This option doesn't exist in cinnamon 5.2.7 (repo version in ubuntu 22.04). There's something similar, but with a "smart" or "strict" mode, as people mentioned in other answers. For me, smart (default) always focus on the opening window (it keeps popping above the others until it fully launches), while strict doesn't (yet. Tested only once so far).
    – marcelocra
    Commented Dec 14, 2023 at 15:41
  • 1
    Update: it didn't work, unfortunately.
    – marcelocra
    Commented Dec 15, 2023 at 14:41

As you haven't accepted an answer yet, perhaps using this bug - a minimized always-on-top window to not even put on-demand new windows on top, would help.

  • 1
    The bug you linked is for elementary OS and Gala. Not sure how useful it is for Ubuntu 18.04 with GNOME 3.
    – pomsky
    Commented May 3, 2020 at 16:21
gsettings set org.gnome.desktop.wm.preferences focus-new-windows 'smart'

(I tried the first comment which set the setting to 'strict' but found this didn't work. I also found a tutorial when I searched this setting, that was trying to make windows steal focus like WindowsOS does(opposite of OP), and he set it to 'strict' to accomplish this, and said 'smart' caused things to NOT steal focus. I tried 'smart' and it worked. I can now type freely into a terminal while programs open and they don't steal focus. Ubuntu 18.04) https://major.io/2015/07/06/allow-new-windows-to-steal-focus-in-gnome-3/#:~:text=Open%20dconf%2Deditor%20and%20navigate,and%20you%20can%20select%20strict.

  • 1
    Doesn't work for me unfortunately. I keep typing in a terminal window, meanwhile start spotify for example. As soon as the spotify window appears my typing stops working. Ubuntu 21.10, GNOME 40.4.0
    – Imre Major
    Commented Feb 25, 2022 at 18:50
  • 1
    I used the "get" version of your command to find that I am already using the 'smart' setting (and suffer from the window focus issue described); i.e. gsettings get org.gnome.desktop.wm.preferences focus-new-windows.
    – user643722
    Commented Oct 7, 2022 at 10:27

Update: I've created an Always On Top! BASH program. It uses a tray icon for window control. It's directly related, so why not. Here's the answer with the script.

If using X Panel (XFCE)

Using "Always On Top" options for the window you need to remain focused. Just right-click the icon on the desktop panel and check the option. That window will behave as you wish.

Also, force certain windows to a particular workspace. Something I use constantly. If your pointer is on the desktop background, mouse scroll will change which workspace is focused.

XFCE Desktop Panel

  • 5
    This doesn't change anything about focus. Commented Aug 26, 2020 at 10:26
  • Especially, even with always on top and always on visible workspace enabled, Skype still steals focus when you switch to another workspace
    – axolotl
    Commented Oct 5, 2020 at 2:50
  • 1
    Also, it doesn't work for MS Teams, which doesn't support the normal window options - there's no way to tell it to stay on any workspace.
    – Rick-777
    Commented Mar 29, 2021 at 9:48
  • Sorry it does not pop up but it steals the active window, so the typing goes to a window in the background which is even worse. Commented May 19, 2021 at 12:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .