You could use Devilspie2 (http://www.gusnan.se/devilspie2/), a program which performs actions on windows as they are created, using scripts written in Lua (http://www.lua.org/manual/)
Install it with: sudo apt-get install devilspie2
, then run devilspie2
. You should see the error message:
No script files found in the script folder - exiting.
It will have created this folder as ~/.config/devilspie2/
. Create the following file, and save it in this directory with the extension .lua
, e.g. as chromium.lua
:
debug_print("Window Name: " .. get_window_name())
debug_print("Application name: " .. get_application_name())
debug_print("WM_CLASS: " .. get_class_instance_name())
debug_print("Window Class: " .. get_window_class())
if (string.match(get_application_name(),"Chromium$")) then
set_window_below();
end
Then run devilspie2 --debug &
and open Chromium. The terminal should show:
Window Name: Untitled - Chromium
Application name: Untitled - Chromium
All Chromium windows (any application name ending in 'Chromium') opened while Devilspie2 is running will now be set to be below all normal windows.
Opening other programs while Devilspie2 is running with the debug switch, should help you modify this code for other applications.
To automatically run Devilspie2
Create a file ~/.config/autostart/devilspie2.desktop
, containing:
[Desktop Entry]
Type=Application
Name=Devilspie2
Exec=devilspie2
NoDisplay=true
Terminal=false
Adding Additional Conditions
To run a script for an application only sometimes, you could either:
Run Devilspie2 only as needed, e.g. devilspie2 & app ; killall devilspie2
, though it will apply its rules to all new windows created while it is running.
For GTK apps, the option --name=
changes the application name, and --class=
the Window class. Chromium doesn't recognise this despite documentation.
Run the command with a modified environment, e.g. window-below= chromium-browser
, and instead use the following rule:
if (string.match(get_application_name(),"Chromium$")) and
(string.match(io.input("/proc/" .. get_window_property("_NET_WM_PID") .. "/environ"):read("*a"), "window-below="))
then
set_window_below();
end
chromium-browser --set-this-window-below
or so? – Ionică Bizău Jul 21 '15 at 06:42/environ
in the last example above to/cmdline
, andwindow-below=
to--window-below
– Martin Thornton Jul 21 '15 at 18:19