Is there a way to automatically minimize a program after it hasn't had focus for a set amount of time?
Ubuntu – Automatically minimize program after X time without focus
automationfocusminimizescriptswindow-manager
Related Question
- Automatically Shutdown System After Specific Time – How to
- Ubuntu – Automatically close application after custom time
- Unity – Resolving Window Focus Confusion
- Unity – How to Force New Windows to Open in Background
- Minimize Windows Without Black and White Effect – Kubuntu KDE Guide
- How to Automatically Send Application Window to Lowest Z-Position on Focus Loss
Best Answer
Got it working perfectly, pretty much exactly as you describe.
1. Script to minimize windows after x time without focus
The background script below will minimize windows after an arbitrary time without focus.
The script
How to use
The script needs both
wmctrl
andxdotool
:Copy the script into an empty file, save it as
minimize_timer.py
Test- run it with the required time, in seconds (before minimizing), as argument, e.g.:
...to minimize windows after 5 minutes without focus
If all works fine, add it to startup applications: Dash > Startup Applications > Add. Add the command:
Notes
Explanation
0
xdotool
'swindowminimize
.If a window no longer exists, it is removed from the record list.
2. Application specific version
The vesrion below will minimize all windows of an arbitrary application after x seconds.
The script
How to use
The script needs
xdotool
:Copy the script into an empty file, save it as
minimize_timer.py
Test- run it with the required time, in seconds (before minimizing), as argument, e.g.:
...to minimize windows after 5 minutes without focus
If all works fine, add it to startup applications: Dash > Startup Applications > Add. Add the command: