XSuspender is a tool to suspend X11 applications when they are inactive. Its purpose is to reduce CPU usage, which in turn reduces the battery usage, and decreases the CPU temperature and fan noise.
The tool uses SIGSTOP, which prevents the process from obtaining further CPU time, or a custom shell script that you can specify, to suspend an application after its window loses focus. When the window regains focus, it’s immediately resumed so you can continue from where you left off.
Not all applications are suspended when XSuspender is running. This tool uses a configuration file where you must specify which applications to suspend, with the following location:
When installing XSuspender, this file is empty, but you’ll find an example configuration file that comes preconfigured to work with popular software like Chromium browser, Firefox, JetBrains, qBittorrent, VirtualBox, and more. This file is located under
/usr/share/doc/xsuspender/examples/xsuspender.conf and it contains explanations for each option, near the top of the file, so read that before trying to configure XSuspender.
To use the XSuspender example configuration file as your configuration, copy it to
~/.config, like this:
cp /usr/share/doc/xsuspender/examples/xsuspender.conf ~/.config/
It’s worth noting that by default, the XSuspender example configuration file comes with
only_on_battery = yes, which means to only apply the rule when on battery power. So you may want to change that in case your laptop is plugged to a power source and you want to try this.
Now you’re ready to give XSuspender a try. Open a terminal and run:
And try one of the preconfigured applications from
~/.config/xsuspender.conf, like Chromium, Firefox, etc. For example open a YouTube video in one of these web browsers, click play, then unfocus the browser window. The video should pause in about 10 seconds. Focus the browser window and the video should play again without any input from you (other than focusing the window).
You’ll notice that in the
xsuspender.conf file, in order to suspend a window, you must specify the wm_class. You can find a window’s class (the window you want to suspend) by using this command in a terminal:
xprop -notype WM_NAME WM_CLASS
When running the command, your mouse cursor turns into a +. Now you must click on the window for which you want to find out the wm_class. Once the window is clicked, the wm_class is shown in the terminal where you ran the command, e.g.:
$ xprop -notype WM_NAME WM_CLASS
WM_NAME = "XSUSPENDER - Chromium"WM_CLASS = "chromium-browser", "Chromium-browser"
You may also like: auto-cpufreq Is A New CPU Speed And Power Optimizer For Linux
Want to add it to startup? Installing XSuspender adds a file called
xsuspender.desktop to the startup applications (
/etc/xdg/autostart/), but it’s disabled from starting automatically by default. So to add XSuspender to startup, edit the
/etc/xdg/autostart/xsuspender.desktop file and change
Hidden=false. You can do this from the command line using (this is a single line command, so triple click the line to select it):
sudo sed -i 's/Hidden=true/Hidden=false/' /etc/xdg/autostart/xsuspender.desktop
It’s also important to note that not everything will play nice with XSuspender. For example, in case a program was downloading something and it’s unfocused, the download stalls. Also, media playback for unfocused applications will stop, which may or may not be what you want (though this is preventable – just don’t configure XSuspender to suspend that application). Pasting will not work either when the selection source process is suspended. And it only works on X11. You can see all the known issues / quirks in this section on the XSuspender project page.
The developer offers binaries for Debian and Ubuntu-based Linux distributions (Linux Mint, Pop!_OS, Zorin OS, etc.) as well as instructions for installing XSuspender from source. An AUR package for Arch Linux / Manjaro is also available.