3

I am using Xfce with Kde Plamsa5 as Window Manager. I cant open Xfce Window Settings anymore but KDE System Settings. I cant find an option to automatically focus to newly created windows.

When I open up a new window the focus stays on the window it was on before, but I want the new window to be raised and focused automatically.

  • It could be "fixed" with a small addition, but more useful would be to find out why this happens Did you use this combination before? – Jacob Vlijm May 23 '15 at 7:53
  • I used KDE before, then I installed Xfce and used that. Then I replaced the windows manager. In Xfce Windows Setting there are two options to focus and raise new windows - i also switched back to xf-window-manager and checked that settings and they are set, but of course they dont affect kwin_x11. – Peter Fleix May 23 '15 at 8:05
  • i think i found - its "focus stealing prevention" in kwin window settings. if its set to "medium" newly opened windows get the focus. – Peter Fleix May 23 '15 at 8:36
  • AHA, great, I'll remove my answer then. Maybe you should post it as an answer? – Jacob Vlijm May 23 '15 at 8:37
  • thanks! yes, but first i'm testing it a little bit, there's so much stuff that changes over a sessions life and is different after a reboot.. could you then post your script as comment or so, it was very interessting. – Peter Fleix May 23 '15 at 8:39
3

It's "focus stealing prevention" in the Kwin Window Settings. If it's set to "medium", newly opened windows get the focus automatically.

| improve this answer | |
  • Do you still want my answer around? If not I'll delete it, this is the clean solution I was referring to :) – Jacob Vlijm May 23 '15 at 10:17
  • maybe you could append it as comment, i think for some users it could still be interesting. thx – Peter Fleix May 23 '15 at 10:41
1

The clean solution

I do not use plasma, so I cannot look into what causes the issue. No need to explain that eliminating the cause would be the "cleanest" solution.

If that seems impossible, and you do want to use this combination, you can however use the bandage below to make it work. The solution is an extremely "light" background script, keeping an eye on newly created windows, raising them if they appear.

How to use

  1. The script uses wmctrl

    sudo apt-get install wmctrl
    
  2. Copy the script below into an empty file, save it as raise_window.py

  3. Test-run it from a terminal by the command:

    python3 /path/to/raise_window.py
    

    Open some applications and see if their windows are automatically raised.

  4. If all works fine, add it to your startup applications: Dash > Startup Applications > Add the command.

The script

#!/usr/bin/env python3
import subprocess
import time
import os

get = lambda cmd: subprocess.check_output(cmd).decode("utf-8").strip()
curr_1 = get(["wmctrl", "-l"]).splitlines()

while True:
    try:
        curr_2 = get(["wmctrl", "-l"]).splitlines()
        new = [w for w in curr_2 if not w in curr_1]
        for w in new:
            w = w.split()[0]
            command = "wmctrl -ia "+w
            subprocess.Popen(["/bin/bash", "-c", command])
    except:
        pass
    curr_1 = curr_2
    time.sleep(1)
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.