XSuspender It is a tool to suspend X11 applications in an inactive state. Its purpose is to reduce CPU usage, thereby reducing battery usage, and reducing CPU temperature and fan noise.
The tool uses SIGSTOP, which prevents the process from acquiring more CPU time or you can specify a custom shell script to suspend the application after the window loses focus. When the window regains focus, it will resume immediately, so you can continue where you left off.
When XSuspender is running, not all applications are suspended. This tool uses a configuration file, in which you must specify the application to be suspended, and located in the following location:
When XSuspender is installed, the file is empty, but you will find a sample configuration file that is pre-configured to work with popular software such as Chromium browser, Firefox, JetBrains, qBittorrent, VirtualBox, etc.The file is in
/usr/share/doc/xsuspender/examples/xsuspender.conf A description of each option is included near the top of the file, so please read the description before attempting to configure XSuspender.
To use the XSuspender sample configuration file as a 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 sample configuration file comes with
only_on_battery = yes, Which means that the rule is only applied when using battery power. Therefore, if your laptop is plugged into a power source and you want to try this power source, you may need to change this setting.
Now, you can try XSuspender. Open a terminal and run:
And try one of the pre-configured apps from
~/.config/xsuspender.conf(Such as Chromium, Firefox, etc.). For example, open a YouTube video in one of these web browsers, click play, and then remove the focus of the browser window. The video should pause after about 10 seconds. Focus the browser window and the video should replay without you having to enter any information (except for the focused window).
You will notice
xsuspender.conf File, in order to suspend the window, wm_class must be specified. You can find the window class (the window to be suspended) by using the following command in the terminal:
xprop -notype WM_NAME WM_CLASS
When running this command, the mouse cursor will change to +. Now, you must click on the window where you want to find wm_class. After clicking the window, wm_class will be displayed in the terminal where the command is run, for example:
$ xprop -notype WM_NAME WM_CLASS
WM_NAME = "XSUSPENDER - Chromium"WM_CLASS = "chromium-browser", "Chromium-browser"
You might also like: auto-cpufreq is a new CPU speed and power optimizer for Linux
Do you want to add it to startup?Installing XSuspender will add a file named
xsuspender.desktop To start the application (
/etc/xdg/autostart/), but it cannot be started automatically by default.Therefore, to add XSuspender to the startup, edit
/etc/xdg/autostart/xsuspender.desktop Archive and change
Hidden=false. You can do this in the command line with the following command (this is a one-line command, so please click the line three times to select it):
sudo sed -i 's/Hidden=true/Hidden=false/' /etc/xdg/autostart/xsuspender.desktop
It should also be noted that not everything can work well on XSuspender. For example, if a program is downloading something without focusing on it, the download will stop. In addition, media playback for unfocused applications will stop, which may or may not be what you want (although this can be avoided, just do not configure XSuspender to pause the application). When the selection source process is suspended, the paste will not work. And only applies to X11.You can see all known issues/quirks In this part On the XSuspender project page.
The developer provided binary files for Debian and Ubuntu-based Linux distributions (Linux Mint, Pop!_OS, Zorin OS, etc.), as well as instructions for installing XSuspender from source code.One AUR package Can also be used for Arch Linux / Manjaro.