Sample Header Ad - 728x90

Unix & Linux Stack Exchange

Q&A for users of Linux, FreeBSD and other Unix-like operating systems

Latest Questions

3 votes
1 answers
2851 views
Preventing other GUI applications from stealing focus?
How can I prevent other applications from stealing focus from the active window? I have found solutions for other window managers, but nothing for "Metacity (Marco)" (the window manager of the MATE desktop manager). I don't want to have to specify every time which window must be "always on top", unl...
How can I prevent other applications from stealing focus from the active window? I have found solutions for other window managers, but nothing for "Metacity (Marco)" (the window manager of the MATE desktop manager). I don't want to have to specify every time which window must be "always on top", unless it can be done automatically every time I switch to a new window. I have determined the window manager by running wmctrl -m. EDIT: I have tried switching the focus-new-windows flag from smart to strict for both Gnome and Mate(Marco): $ gsettings set org.gnome.desktop.wm.preferences focus-new-windows strict $ gsettings set org.mate.Marco.general focus-new-windows strict But it didn't work.
Eleno (1859 rep)
Feb 9, 2016, 02:28 PM • Last activity: Jul 28, 2025, 11:08 PM
2 votes
3 answers
2918 views
i3wm: How to automatically switch workspace when a window of a specific application requests focus?
I tried `focus_on_window_activation` with `focus`, but it doesn't do anything. I guess it only works on same workspace. Or maybe I am using it wrong? ``` for_window [class="Chromium"] focus_on_window_activation focus ``` For example in a Thunderbird when I click on a link, I want Chromium to get foc...
I tried focus_on_window_activation with focus, but it doesn't do anything. I guess it only works on same workspace. Or maybe I am using it wrong?
for_window [class="Chromium"] focus_on_window_activation focus
For example in a Thunderbird when I click on a link, I want Chromium to get focus and switch to its workspace (only Chromium, not all applications). Currently it only gets the urgency flag (I believe its usually visualized by a red background of a workspace "button" in a bar).
menfon (262 rep)
Aug 22, 2022, 06:52 AM • Last activity: Jul 28, 2025, 11:05 AM
0 votes
0 answers
24 views
debian sddm window manager: set focus-mode to either sloppy or mouse: no effect
On debian version 12.8 fully upgraded, sddm window manager. Using either gsetting or dconf-editor, I can set and verify org.gnome.desktop.wm.preferences focus-mode to either sloppy or mouse but neither takes effect: still have to click in window to raise focus. gsettings set org.gnome.desktop.wm.pre...
On debian version 12.8 fully upgraded, sddm window manager.
Using either gsetting or dconf-editor, I can set and verify org.gnome.desktop.wm.preferences focus-mode to either sloppy or mouse but neither takes effect: still have to click in window to raise focus.
gsettings set org.gnome.desktop.wm.preferences focus-mode sloppy gsettings get org.gnome.desktop.wm.preferences focus-mode 'sloppy'
Steve Dutky (111 rep)
Dec 20, 2024, 06:08 PM
10 votes
2 answers
8290 views
Setup notify-send click action
Given some simple `notify-send` command inside a bash script such as notify-send "test" How can I make a determinate window gain focus when the user clicks that notification? I thought playing around with the `-a` switch would do something, but I can't get it to work either on GNOME Shell and XFCE .
Given some simple notify-send command inside a bash script such as notify-send "test" How can I make a determinate window gain focus when the user clicks that notification? I thought playing around with the -a switch would do something, but I can't get it to work either on GNOME Shell and XFCE .
Waldir Leoncio (377 rep)
Oct 9, 2019, 11:05 AM • Last activity: Feb 15, 2024, 03:09 PM
3 votes
1 answers
1092 views
Nemo file manager - change focus from the sidebar to the main view (automatically)
**Edit:** [GitHub issue report](https://github.com/linuxmint/nemo/issues/1230) I find it hard to change focus (either by keyboard, or automatically) from the sidebar to the contents view in Nemo 2.8.7 on Ubuntu 16.04. Nautilus does not have this problem. I want to be able to navigate through folders...
**Edit:** [GitHub issue report](https://github.com/linuxmint/nemo/issues/1230) I find it hard to change focus (either by keyboard, or automatically) from the sidebar to the contents view in Nemo 2.8.7 on Ubuntu 16.04. Nautilus does not have this problem. I want to be able to navigate through folders quickly, by typing in starting characters of folders, using arrows and pressing enter/backspace, without having to use a mouse, or possibly any shortcut to switch the problematic focus on the sidebar. enter image description here ### How I can switch: - using a mouse - by switching between icon/list/compact views with a shortcut - control+1/2/3 (ridiculous) - by opening the bookmarked folder in a new window - control+return (even more so) - by opening the bookmarked folder in a new tab - shift+return, switching to the previous tab and back with alt+1 and alt+2 (...) ### How I want to switch: - at the first click/return key press on the sidebar. - also with a shortcut (like tab), back and forth What can be done about it?
LogicStuff (133 rep)
May 8, 2016, 10:57 PM • Last activity: Oct 26, 2023, 08:11 PM
1 votes
0 answers
288 views
XFCE fullscreen apps go to background when not in focus
My desktop is running xfce4, and I have sloppy focus, and a multi-monitor setup. When I move the mouse off a fullscreen window (to the other monitor) (be it the web browser in full screen, or an image viewer in presentation mode etc...), the fullscreen window on the initial monitor goes to the backg...
My desktop is running xfce4, and I have sloppy focus, and a multi-monitor setup. When I move the mouse off a fullscreen window (to the other monitor) (be it the web browser in full screen, or an image viewer in presentation mode etc...), the fullscreen window on the initial monitor goes to the background, all other normal windows are now in front of it. Or, to describe it differently, as soon as the full screen window loses focus, it goes into the background. Any idea how to prevent this?
Ro-ee (221 rep)
Mar 11, 2021, 06:56 PM
8 votes
1 answers
2197 views
How do you keep a window from stealing focus in GNOME Shell?
I've got multiple workspaces and two monitors in my GNOME Shell, and I'd like to find a way to exclude a window on my secondary monitor from ever stealing focus. Ideally, it'd be nice to exclude these windows from `Alt+Tab` as well. A really good example of how this can get in the way is the followi...
I've got multiple workspaces and two monitors in my GNOME Shell, and I'd like to find a way to exclude a window on my secondary monitor from ever stealing focus. Ideally, it'd be nice to exclude these windows from Alt+Tab as well. A really good example of how this can get in the way is the following setup: Primary Secondary 1: Thunderbird system monitor 2: (nothing) system monitor 3: Terminal system monitor In this situation if I'm reading my mail in workspace #1 and switch to workspace #3 (terminal) to do something and then come back, my focus is now on the system monitor and not on Thunderbird. I'm unaware of any extensions that can fix this, but if one does exist or if we're just talking a change to dconf or something, I'd be happy with that. If however it turns out that this is currently impossible in GNOME, then I'd like to know that too, just so I can report it as a feature request.
Daniel Quinn (614 rep)
Jan 18, 2017, 06:10 PM • Last activity: Dec 30, 2020, 08:19 AM
1 votes
0 answers
902 views
Is it possible to tell xdg-open (or alikes) to open a window in the background?
I am using `xdg-open` with cronjobs to open our time-management web-app once per hour to log my time (among other repeating things). This works very well, but has an annoying usability problem. Once every hour, at exactly `**:00` the browser-window open in the foreground with focus and steals my foc...
I am using xdg-open with cronjobs to open our time-management web-app once per hour to log my time (among other repeating things). This works very well, but has an annoying usability problem. Once every hour, at exactly **:00 the browser-window open in the foreground with focus and steals my focus that way. If I am typing something at that time and hit enter, something completely unrelated may be posted to our time-management-software. (This only rarely happens, most of the time it is *just* being annoying instead of destructive.) Is there maybe some way of making the window appear in the background and not steal my focus, if it was created from a cronjob? Maybe some parameter to be set or some environment-variable to be defined to make the window appear in the background or maybe another program that solves this problem in a better way? I don't want to just activate the focus-stealing for the whole system, because this would get in the way even more. I would have to focus every summoned window every time to actually use it and otherwise still write into the old window. It should be possible for the window-manager to distinguish between windows that *I* requested directly (foreground please) and windows that were opened automatically by some cronjob, automatic update or outside message (background please). But that is probably wishful thinking, is it? I'm currently on Ubuntu 16.04 (Unity), browsing with Firefox. (Can another desktop- or window-manager maybe do this?) Thank you for taking the time to answer me.
Gerrit Addiks (61 rep)
Oct 2, 2020, 07:18 PM
1 votes
2 answers
888 views
Navigate to previously focused window in xmonad
Is there any module that supports this functionality? If not - does anyone know how to implement this?
Is there any module that supports this functionality? If not - does anyone know how to implement this?
Chris Stryczynski (6603 rep)
Dec 4, 2017, 09:00 AM • Last activity: Aug 30, 2020, 03:51 PM
9 votes
3 answers
4808 views
How do I detect whether my terminal has focus in the GUI from a shell script?
### Problem/Goal description Ideally, I would like a **good** way of detecting from a shell script whether or not the window has focus. By a "good" way, I mean some way which requires minimal steps and preferably does *not* require sifting through each open window blindly to find mine based on title...
### Problem/Goal description Ideally, I would like a **good** way of detecting from a shell script whether or not the window has focus. By a "good" way, I mean some way which requires minimal steps and preferably does *not* require sifting through each open window blindly to find mine based on title. The purpose is for controlling notifications in many different scripts -- so I'm just looking for a general solution that can apply to any and all of them. What I've come up with so far is roundabout and hacky -- it is as follows: 1. Set my title to something unique or mechanically relevant (in my model, it is my PTS path or, more robustly, a UUID). Hope desperately that this title is not overridden by something. 2. Get a list of all open windows, by title. 3. Iterate through list to identify my window by matching it to the title element. (Note the possibility of errors here if another window happens to have that same title element.) 4. Detect whether said window has focus or not. It should be noted that I _do **not**_ want to implement this, and will only do it as a last resort. So what I'm asking for here is *something that is not this*. ### Compromises This solution is obviously terrible, so I'd like to know if there is anything remotely better, in any way. I would prefer something portable, elegant, and perfect, but I recognize the potential need to compromise. By **better** I mean any of the following: 1. A solution that only works with a specific terminal emulator, e.g. by having the terminal emulator itself set an environment variable allowing the script to detect which window it is in. 2. A solution that does not require setting the title, and instead uses some other invisible marker in window state that is accessible and detectable from a shell script attached to said window. 3. Recusing up the parent process ladder to find the parent terminal emulator PID, and working from there (Note that a solution that works by recusing up the the process tree to detect the parent process that started the script will only work if the script is running locally, so this solution is incomplete but still good!) ### Conditions I was getting questions about exactly what conditions my preferred solution is supposed to function under, and the answer is *as many as possible*. But at minimum, I would like something that works: 1. In a single-tab terminal session running natively (default scenario). 2. In terminal multiplexers like tmux. (Portability between different terminal multiplexers is preferred but really not required.) Extras that I'd really appreciate (in order of importance), include: 3. Ability to function on remote connections over telnet and SSH. 4. Ability to distinguish which tab is open in a multi-tab terminal session. --- ### Summary I want a **good** way of finding what terminal emulator window my shell script is attached to, so that I can detect whether it has focus or not. Note that I'm already aware of the mechanics of *how* to to iterate through open windows, and how to detect whether they have focus or not and what titles they have. I am aware of the existance of xdotool and xprop and this question is not about the basic mechanics of those tools (unless there is some hidden black magic feature I don't know about that side-steps the intrinsic hackiness of my current solution.) The reason I don't want to that is because it's terrible. Any other solution that accomplishes the same thing?
Alexandria P. (179 rep)
Nov 6, 2018, 07:38 AM • Last activity: Aug 25, 2020, 09:36 PM
1 votes
1 answers
905 views
how to prevent input focus for a single window in gnome-shell window manager?
I need a single window to be on top and never gain focus when any other window is closed. In this case it is a gnome-terminal window w/o decorations, where I am running nethogs, it has a single text line in height. But when I close yakuake that gnome-terminal always get focus and messes my work flow...
I need a single window to be on top and never gain focus when any other window is closed. In this case it is a gnome-terminal window w/o decorations, where I am running nethogs, it has a single text line in height. But when I close yakuake that gnome-terminal always get focus and messes my work flow (the browser, or netbeans or geany should receive focus but that ontop terminal always receive it). I get the window id $nWID with xwininfo, and try all these commands but nothing works:
xprop -set WM_TAKE_FOCUS false -id $nWID
xprop -remove WM_TAKE_FOCUS -id $nWID
xprop -remove WM_PROTOCOLS -id $nWID
wmctrl -i -r $nWID -b add,skip_pager
wmctrl -i -r $nWID -b add,skip_taskbar
xprop -id $nWID -format WM_HINTS 32cbcxxiixx -set WM_HINTS 3,False,1,0x0,0x0,0,0,0x0,0x0
to remove decorations, I use this: https://gist.github.com/muktupavels/d03bb14ea6042b779df89b4c87df975d could the only way to do that, may be... to tweak the above code to add such functionality? related: https://stackoverflow.com/q/56559726/5648245
VeganEye (101 rep)
Jun 1, 2020, 05:41 PM • Last activity: Jun 7, 2020, 09:18 PM
0 votes
1 answers
192 views
How to make "Focus follow mouse" for Dolphin File Explorer?
I use Dolphin file explorer, within which I frequently switch back and forth to the terminal panel. So I was wondering how to make "Focus follow mouse" **within Dolphin**, so that I don't need to click the terminal each time I have to enter something. I am **not asking about a top-level window. I am...
I use Dolphin file explorer, within which I frequently switch back and forth to the terminal panel. So I was wondering how to make "Focus follow mouse" **within Dolphin**, so that I don't need to click the terminal each time I have to enter something. I am **not asking about a top-level window. I am asking about panes within one window**. Dolphin has two parts an upper pane a graphical file explorer, and a lower pane containing a terminal. I noticed that the terminal panel doesn't register as a separate window, as shown by xprop.
Utkarsh Verma (329 rep)
Apr 2, 2020, 03:02 PM • Last activity: Apr 3, 2020, 11:38 PM
3 votes
1 answers
1712 views
Switching automatically between 2 windows on Linux
Hi I need to switch focus between two windows periodically and automatically (with software or w/e). Can this be achieved on linux?
Hi I need to switch focus between two windows periodically and automatically (with software or w/e). Can this be achieved on linux?
Robert (31 rep)
Apr 14, 2014, 07:25 AM • Last activity: Jul 28, 2018, 02:41 PM
1 votes
0 answers
791 views
Focus preservation in i3wm
***tl;dr:*** **How do I implement the no_focus directive in i3wm and how do I dynamically assign a program to a workspace based on the workspace where I key the binding to open the program (i.e., I press the keybinding on `workspace n` and it opens on `workspace n` even if my focus has changed to `w...
***tl;dr:*** **How do I implement the no_focus directive in i3wm and how do I dynamically assign a program to a workspace based on the workspace where I key the binding to open the program (i.e., I press the keybinding on workspace n and it opens on workspace n even if my focus has changed to workspace n + 1 before the program has fully loaded)?** **Context:** I have a handful of keybindings in i3wm (i3-gaps on Arch, to be specific) that I use, e.g. bindsym $mod+Shift+W exec chromium bindsym $mod+Shift+I exec chromium --incognito bindsym $mod+Shift+F exec firefox But I dislike the focus stealing of newly opened windows and especially dislike the behavior where I'm on workspace n, jump to workspace n + 1 to hit my keybinding, jump back to workspace n to continue performing some task in terminal while I wait for the program to load, and, lo, the program loads on my current workspace n instead of workspace n + 1 where I hit the keybinding. I have found [this explanation](https://i3wm.org/docs/userguide.html#_don_8217_t_focus_window_upon_opening) in the i3wm documentation discussing exactly what I want in terms of window focusing but cannot find a single example command that I can modify: no_focus [window_role="pop-up"], the example they give, does not make sense to me. I have tried exec no_focus chromium, no_focus exec chromium and a handful of less sensible combinations and none of them seem to work: I do not know how to implement the command. I also am unsure, once I get it to work, if keying in a binding on a work space will force the program to open on that work space rather than following me to my new workspace. I know of workspace assignment (never implemented it, but that is another question) but would prefer to have a dynamic workspace assignment like I've been detailing: workspace assignment based on the workspace the keybinding is executed.
mas (1919 rep)
Jul 25, 2018, 07:30 PM • Last activity: Jul 27, 2018, 02:54 PM
3 votes
1 answers
3746 views
Xdotool action without focusing
Is there a way to automatically click at a specific place in specific window without getting the window focused?
Is there a way to automatically click at a specific place in specific window without getting the window focused?
Nerijus Pocevičius (33 rep)
Nov 5, 2017, 03:49 PM • Last activity: Jan 15, 2018, 05:56 AM
7 votes
2 answers
4319 views
How do I run a KWin script from the console (to set focus to a specific window in KDE)?
I need to set focus to VirtualBox in KDE, I've written a KWin script for the purpose but I cannot figure out how to run it from console. **What I have tried:** This KWin script works in the **Desktop Shell Scripting Console** How to open the Desktop Shell Scripting Console: 1. Press Alt + F2 , type...
I need to set focus to VirtualBox in KDE, I've written a KWin script for the purpose but I cannot figure out how to run it from console. **What I have tried:** This KWin script works in the **Desktop Shell Scripting Console** How to open the Desktop Shell Scripting Console: 1. Press Alt+F2, type 2. Run wm console The script: // Main reference: http://techbase.kde.org/Development/Tutorials/KWin/Scripting // API: https://techbase.kde.org/Development/Tutorials/KWin/Scripting/API_4.9 // Sets focus to VirtualBox var clients = workspace.clientList(); for (var i=0; iaccording to this method ) scripting does not seem to be setup as I get these errors: Error org.freedesktop.DBus.Error.ServiceUnknown: The name org.kde.kwin.Scripting was not provided by any .service files Error org.freedesktop.DBus.Error.ServiceUnknown: The name org.kde.kwin.Scripting was not provided by any .service files *I don't know how dbus works internally so from here on I just try things.* I tried to fix these problems caused by things changing in newer versions of KDE: **QDBusViewer** So I run the **qdbusviewer** to have a look. It should be KWin instead of kwin.Scripting. I find org.kde.KWin in the left hand list and Scripting to the right, under org.kde.kwin.Scripting I find the methods loadScript and start. I'm able to use these methods manually by double clicking on them, loading my script file and it works, my script gets run and VirtualBox receives focus. So I try to modify the loading commands accordingly: dbus-send --print-reply --dest=org.kde.KWin /Scripting org.kde.kwin.Scripting.loadScript string:"/home/jk/msexcel_setfocus.kwinscript" dbus-send --print-reply --dest=org.kde.KWin /Scripting org.kde.kwin.Scripting.start These commands does not give an error but it does not work either. **Is dbus working at all?** I try something else just to see if dbus is working at all, and this works (enabling/disabling the FPS effect): dbus-send --print-reply --session --dest=org.kde.KWin /Effects org.kde.kwin.Effects.loadEffect string:"showfps" dbus-send --print-reply --session --dest=org.kde.KWin /Effects org.kde.kwin.Effects.unloadEffect string:"showfps" **Numbered entries** So there is this business in the script linked to above with a numbered path of some kind, I find that in QDBusViewer sometimes there are numbered entries in the right pane (they come and go). And there actually a Scripting item and a run method in there when a number exists. So I try this: This command does give a number that corresponds to the number appearing in QDBusViewer. num=$(dbus-send --print-reply --dest=org.kde.KWin /Scripting org.kde.kwin.Scripting.loadScript string:"/home/jk/msexcel_setfocus.kwinscript" | awk 'END {print $2}') echo $num dbus-send --print-reply --dest=org.kde.KWin /$num org.kde.kwin.Scripting.run But the last command does not work, neither does it work run the start method (as above) before the run method, then it complains that the number is gone. Error org.freedesktop.DBus.Error.UnknownObject: No such object path '/1'
JKAbrams (253 rep)
Aug 12, 2017, 04:40 PM • Last activity: Dec 30, 2017, 10:32 PM
1 votes
0 answers
297 views
XFCE Focus/Event Handling
In XFCE I defined Ctrl + Shift + Space to open the system menu. After installing Intellij I noticed that it uses that shortcut in a useful way. However, if I press it the system menu pops up. This is confusing to me since the application has the focus and the key events should be caught by the appli...
In XFCE I defined Ctrl+Shift+Space to open the system menu. After installing Intellij I noticed that it uses that shortcut in a useful way. However, if I press it the system menu pops up. This is confusing to me since the application has the focus and the key events should be caught by the application before the OS consumes it. In other words, the OS should be the last resort. How do I make XFCE work my preferred way? If it can't, which window manager can do that and isn't that much different to XFCE so I don't have to relearn everything? _A [similar question](https://stackoverflow.com/q/21497412/483113) has been asked, but didn't receive much attention and is also already 30 months old..._
sjngm (547 rep)
Sep 11, 2017, 09:16 AM • Last activity: Sep 11, 2017, 09:19 AM
10 votes
2 answers
4293 views
WM-independent way to focus/raise URGENT window
I would like to have a keyboard shortcut to "go to" (focus + raise) window with URGENT flag set which looks like URGENT: it appears on the taskbar (Gnome + Metacity) even if it is on desktop other than current and starts to blink (thanks to @slm for pointing it out). This window might be on other vi...
I would like to have a keyboard shortcut to "go to" (focus + raise) window with URGENT flag set which looks like URGENT: it appears on the taskbar (Gnome + Metacity) even if it is on desktop other than current and starts to blink (thanks to @slm for pointing it out). This window might be on other virtual desktop than current. In this particular case it is Skype windows which set urgency flag, and so they appear in alt-tab popup (metacity WM) but I can't switch to this window if it is not on current virtual desktop. I was looking into xdotool and wmctrl command with no luck. Any ideas or clues? --- **Update:** It appears, that I'm talking about _NET_WM_STATE = _NET_WM_STATE_DEMANDS_ATTENTION ...
roomcays (311 rep)
Aug 7, 2013, 11:10 AM • Last activity: Aug 12, 2017, 05:00 PM
2 votes
1 answers
1058 views
How to make x2go’s windows get focus on click?
### The problem I use x2go and both client and server side have i3 as wm. So, the problem is the conflict between each key bindings. When I press Super + w on the distant system’s window it affect the local system… so it’s very painful. ### A kind of solution I search So, with Virtualbox, the hosted...
### The problem I use x2go and both client and server side have i3 as wm. So, the problem is the conflict between each key bindings. When I press Super+w on the distant system’s window it affect the local system… so it’s very painful. ### A kind of solution I search So, with Virtualbox, the hosted system’s windows get the entire focus on click. All key-binding I press goes to it. When I want to left the hosted system’s window, I press a button (typically left Control). So how can I get the same behavior with x2go ?
fauve (1529 rep)
Aug 21, 2016, 11:15 PM • Last activity: Jul 28, 2017, 08:49 PM
2 votes
0 answers
1437 views
Set mouse focus on current screen's active window
I was using Synergy from Symless. It shares the mouse and keyboard between computers. So it is similar to having secondary or third screen attached to your computer. The Scenario is: having a laptop and a PC. - On laptop screen, I do some typing with a text editor (Active window). - On PC screen, th...
I was using Synergy from Symless. It shares the mouse and keyboard between computers. So it is similar to having secondary or third screen attached to your computer. The Scenario is: having a laptop and a PC. - On laptop screen, I do some typing with a text editor (Active window). - On PC screen, the browser is open (Not fullscreen, but active). Under it, there is music player (Fullscreen, but not active). - When I move my mouse to laptop screen, the focus is on the text editor (even if the mouse is not hovering on the text editor) - When I move my mouse to PC screen, the focus is on the browser (even if the mouse is hovering on the music player) **=> That is the desired behavior, and that is how Synergy works.** Now I want mimic that behavior with one computer but multiple screens. I'm using Elementary. Under Tweak Tool, there is a focus option. The options are Click (Change focusing window in click), Mouse (Change focusing window by hovering the mouse) and Sloppy (Same as Mouse, actually don't know how it is different from Mouse). The nearest I got to mimic the behavior in the scenario is to use Mouse focus mode. But you have to move the mouse onto the window you want to focus. This mode is annoying when you open a new window, but the focus is not on that new window because the mouse is off somewhere. **So what I want is probably Click focus mode, but each screen has a different Active Window of itself. When I move my mouse to a screen, the Active Window of that screen should raise up.** Do anyone happen to know how to achieve what I described? The goal is to unify the work flow. At home I have my laptop and my PC, but at the office I have my laptop and the secondary screen. So the different setup pause me and sometimes irritating. ----------
Tantan (21 rep)
Jun 9, 2017, 11:31 AM
Showing page 1 of 20 total questions