kernc / xsuspender

:eyes: :computer: :zzz: :battery: Save battery by auto-suspending unfocused X11 applications.
https://kernc.github.io/xsuspender/
Do What The F*ck You Want To Public License
339 stars 19 forks source link
battery cpu daemon desktop hacktoberfest laptop libvirt libwnck linux powersave powersaving qemu sigstop suspend virt-manager virtualbox window-manager x11 xorg

XSuspender

Build Status

Automatically suspend inactive X11 applications.

XSuspender project website

When an application window loses focus, XSuspender tries to match it to one of the rules in its configuration. If a match is found, the application is sent a SIGSTOP signal (preventing the process from obtaining further CPU time). Upon windows regaining focus, the process is seamlessly continued where it had left off.

Advantages

Quirks

See section BUGS in the manual for the full, updated list.

Installation

Binary packages

Install binary package for your GNU/Linux distribution:

Debian, Ubuntu Arch Linux

From Source

# Install dependencies, namely GLib, Libwnck, procps
# on Debian / Ubuntu / Mint:
sudo apt install libglib2.0-dev \
                 libwnck-3-dev  \
                 procps         \
                 make cmake gcc pkg-config

# on Fedora / RHEL / openSUSE / Solus:
sudo dnf install glib2-devel    \
                 libwnck3-devel \
                 procps-ng      \
                 make cmake gcc pkg-config
# Fetch a copy of the source code
git clone https://github.com/kernc/xsuspender
cd xsuspender

# Move to build directory for an out-of-tree build
cd build

# Configure and make
cmake -DCMAKE_INSTALL_PREFIX=/usr/local ..
make
make test

# Install within chosen prefix
sudo make install

Usage

For brief usage instructions, run:

xsuspender --help

Automatically starting xsuspender

Upon installation there will be a /etc/xdg/autostart/xsuspender.dektop file which allows you to autostart xsuspender on the start of your desktop. You need to explicitly enable autostarting xsuspender in your desktop's session management settings - this amounts to the same as copying /etc/xdg/autostart/xsuspender.dektop to ~/.config/autostart/ and setting Hidden=false.

If you let xsuspender autostart, then you need to be aware of spurious suspended app lock-ups such as in GH-11 and be ready to mitigate them.

Configuration debugging

To have it print verbose debug messages about what it is doing, run the program with environmental variable G_MESSAGES_DEBUG=xsuspender set:

G_MESSAGES_DEBUG=xsuspender xsuspender

This is strongly recommended to confirm your customized configuration rules indeed work as you expect.

Logs

If xsuspender is autostarted by your X session manager, you might find clues to its unexpected behavior in ~/.xsession-errors.

Notes