Written by Jacob Vlijm: http://askubuntu.com/a/615754/34298
A background script to automatically set the resolution per application, while you can set different resolutions for different (multiple) applications at once.
It can handle different applications with a different (required) resolution, running at the same time. The background script will keep track of what is the front most application, and will set the resolution accordingly. It also works fine with Alt+Tab.
Note that this behaviour might be annoying if you switch a lot between the desktop and listed applications; the frequent resolution switch might be too much.
An example of a default resolution of
gedit, automatically changing to
gnome-terminal, automatically changing to
When the application is closed, the resolution is automatically set back to
sudo apt-get install wmctrl xdotool
###How to use
Copy the script below into an empty file, save it as
In the head of the script, set your default resolution and scaling factor:
#--- set default settings below default = "3200x1800" defaultScalingFactor = 2 #---
In the very same directory (folder), create a textfile, exactly named:
procsdata.txt. Define one application or script per line:
- the desired application or process
- followed by a space
- followed by the desired resolution
- followed by a space
- followed by the desired scaling factor. .
java 1920x1080 1 gedit 1920x1080 1
Run the script by the command:
###Figure out the descriptor for applications
If you want to find out the name, you have to write into the config file, you can use this command:
sleep 5 && cat "/proc/$(xdotool getwindowpid "$(xdotool getwindowfocus)")/comm"
Once you started this, you have 5 seconds to focus the desired app.
The script use
pgrep -f <process>, which catches all matches, including scripts. The possible downside is that it can cause name clashes when opening a file with the same name as the process.
If you run into issues like that, change:
matches.append([p, subprocess.check_output(["pgrep", "-f", p]).decode("utf-8")])
matches.append([p, subprocess.check_output(["pgrep", p]).decode("utf-8")])
###Explanation When the script starts, it reads the file in which you defined your applications and their corresponding desired screen resolutions.
It then keeps an eye on the running processes (running
pgrep -f <process> for each of the applications) and sets the resolution if the application starts up.
pgrep -f <process> does not produce output for any of the listed applications, it sets the resolution to "default".
- Although I have it running for several hours without an error now, please test it thoroughly. If an error might occur, please leave a comment here: http://askubuntu.com/a/615754/34298
- The script -as it is- works on a single monitor setup.