Shell script to make specific applications open a new window on the current virtual desktop rather than raising an existing window on another desktop if there is not already a window on the current desktop.
X11.
- Ensure dependencies are installed:
awk
,cut
,grep
,wmctrl
. - Download the script: GitHub repository > green top right button Code > Download ZIP > unpack > extract the
open-on-current-desktop
folder. - Make the script executable: right-click on the
.sh
file > Properties > Permissions > checkbox Is executable.
- Find out the window class of the program: Open an instance of the program, run
wmctrl -l -x
in a terminal, and get the window class name from the third column, e.g.Navigator.firefox
oratom.Atom
. - Insert the window class as a string for the variable
win_class
in the script. - Find out the command to open the file in a new window, e.g.
firefox -new-window
oratom -n
. - Insert the launch-new command as a string for the variable
launch_new
in the script. - Find out the command to open the file in an existing window, e.g.
firefox -new-tab
oratom
. - Insert the launch-existing command as a string for the variable
launch_old
in the script. - Make the script the application to open the desired file types: System Settings > Applications > File Associations or ... > Default Applications > select relevant file types > add the path to the script and make it the top preference. Note that some applications may ignore the system-wide settings and define their own program association preferences; e.g. for Thunderbird see these instructions.
- Make the script the command to be executed for any launcher you may have (task bar icon, application menu entry, keyboard shortcut, …).
© 2021-2022 Natalie Clarius <natalie_clarius@yahoo.de>
This work is licensed under the GNU General Public License v3.0.
This program comes with absolutely no warranty.
This is free software, and you are welcome to redistribute and/or modify it under certain conditions.
If you would like to thank me, you can always make me happy with a cup of coffee: