I use SpaceFM as my primary file manager on Ubuntu. I typically open folder directly by keyboard shortcuts, so, e.g. Ctrl+Super+W opens my Work folder.
Specifically, I use execute the command spacefm -w /home/rasmus/Work/
by the above shortcut, with the -w
ensuring that SpaceFM opens a new window.
However, this new window is not always open on top of the last active window on the workspace. This is rather annoying, as it means I sometimes have to "dig" for the newly opened window.
So, my question is: Is there something additional I can add to the executed command that will ensure that the fresh window is opened on top?
Alternative solutions to the same effect are welcome.
As
spacefm
used single process. New command just pass signal to the running process and this creates the new window at level just above its last created window.With function: It has 1sec delay.
spacefm
with same arguments$*
were passed to the function,&
in backgroundpgrep spacefm | head -1
get PID of main process which is in the head then store it inpid
variablesleep 1
wait for new process to terminal, to avoid raise of two windows (I don't know why, try removing it)wmctrl -lp
get window list| grep " $pid"
filter related ones to$pid
,| tail -1
filter last line/window then| awk '{ print $1 }'
filter out window id (WID) which is in the first column$1
wmctrl -i -R WID
Move the window WID to the current desktop, raise the window, and give it focus.With alias: This will raise 2 windows the new one on the top but simpler.
wmctrl -lp
get window list| grep " $pid"
filter related ones tospacefm
,| tail -1
filter last line/window then| awk '{ print $1 }'
filter out window id (WID) which is in the first column$1
wmctrl -i -R WID
Move the window WID to the current desktop, raise the window, and give it focus.spacefm
with arguments coming after. The new window will be created on the top.- How to use: similar way to the original command.
References: Please look for the
man
pages.It's an old question but still relevant, so I'll add an alternative solution.
This sounds like a result of Compiz' focus prevention, trying to prevent windows from "stealing" focus while you're working somewhere else.
Focus prevention can be set to different levels (default: low) or completely disabled through CompizConfig Settings Manager.
If not installed yet, do this by running:
Then, run it with
ccsm
, navigate to General Options, switch to the tab Focus & Raise Behaviour and change the field Focus Prevention Level (in your case, you'll probably want Off).