I often use Terminal to write code in vim
, and as my Terminal is see-through I am able to see what it behind it, so if I have a manual behind it in a browser window or something like that, then I can refer to it without needing to switch to it or having to have it next to my Terminal window which I prefer not to do as both windows get rather small then.
But there is one downside, I often need to copy and paste text, move down the page behind Terminal, search for things on it, etc.
And to do this, I then have to switch to it which I don't like doing, so what would be better would be if there was a way of making it so that in gnome-terminal
, when I press a certain keyboard shortcut, for it to make my cursor go through the current window (which is see-through and should remain ontop) so that I may be able to interactive with the window behind (for instance to copy and paste text, to move down the page, and to search for things on the page) gnome-terminal
without actually moving to it or putting it infront of the gnome-terminal
window.
Of course pressing they keyboard shortcut again – or maybe a different one if this can't be done with the same shortcut – should return things back to normal and how they were before I first pressed the shortcut which made me interact with the window behind.
I would also like for my keyboard to interact with the window behind and not just my cursor. And I would also like for this to only be the case for the gnome-terminal
application as I don't want this to happen with any other applications.
Can this be done?
I am running Ubuntu GNOME 15.10 with GNOME 3.18.
Best Answer
Not literally what you asked for, but if you have a key combination that would automatically recognize both the
gnome-terminal
-window and the window directly below it, you could switch (toggle) between the two quickly without further effort.The setup does exactly that: If (and only if) either the active window or the window directly below it is a
gnome-terminal
window, the script makes them switch places, as shown in the images. I left a few irrelevant windows to illustrate they don't take part in the toggle:Having a
gnome-terminal
window on top of agedit
window:Pressing the shortcut:
Press it again:
And so on. As mentioned, this will only happen if either one of the topmost windows belongs to
gnome-terminal
.How to set up
The script(s) need
wmctrl
Save both scripts below in one and the same directory, since one of the scripts imports functions from the other:
Script 1
to be saved as (exactly)
z_list.py
:This is actually a background script, keeping track of the z-order of windows. The z-order cannot be determined by the "normal" tools like
wmctrl
orxdotool
. Running a simple script to keep track of the currently active window, will give us the z-order however.Script 2
to be saved as
toggle_terminal.py
:As mentioned, save this script in one and the same directory, together with
z_list.py
.How to use
Since the background script keeps track of active windows and creates the z-order that way, it needs to run before you open (at least) the windows you'd like to toggle, preferably as a Startup Application.
To test:
Open a terminal window, run the background script by the command:
Open a new terminal window and (e.g.) a
gedit
window. Focus thegedit
window and open a new terminal window on top of it. Then run in the terminal window the command:The windows should change places (order). Unfortunately you won't be able to run the command again (in the terminal) to bring the terminal window to top again, since the
gedit
window is now active :). You may assume however it will work from a shortcut key.If all works fine, make the setup permanent:
Add
z_list.py
to Startup Applications: Dash > Startup Applications > Add the command:Add script 2 to a shortcut key combination: choose: System Settings > "Keyboard" > "Shortcuts" > "Custom Shortcuts". Click the "+" and add the command: