Installing Compton on CentOS
Before configuring multi-monitor support, ensure Compton is installed. For CentOS 7 and earlier, use yum
; for CentOS 8/Stream, use dnf
:
# For CentOS 7 and earlier
sudo yum update -y && sudo yum install -y compton
# For CentOS 8/Stream
sudo dnf update -y && sudo dnf install -y compton
This installs Compton and its dependencies, which are required for window composition and multi-monitor effects.
Configuring Compton for Multi-Monitor Support
Compton’s configuration file is typically located at ~/.config/compton.conf
. Create the directory if it doesn’t exist, then open the file in a text editor (e.g., nano
):
mkdir -p ~/.config
nano ~/.config/compton.conf
Add or modify the following settings to optimize multi-monitor performance and compatibility:
backend = "glx" # Use OpenGL for better performance (recommended for most setups)
shadow-exclude = [ ".*", "[class='.*Firefox']", "[title='.*Firefox']" ] # Disable shadows for specific apps (e.g., Firefox) to reduce overhead
alpha-mode = "none" # Disable per-window transparency for smoother rendering
alpha-ignores = [ ".*", "[class='.*Firefox']", "[title='.*Firefox']" ] # Skip transparency for excluded apps
glx-no-stencil = true # Improve performance by disabling stencil buffer
glx-copy-from-front = true # Reduce rendering latency
xrandr-args = "" # Leave empty unless custom xrandr arguments are needed
These settings balance visual effects with performance, which is critical for multi-monitor setups.
Setting Up Multi-Monitors with xrandr
Compton relies on xrandr
to manage multi-monitor configurations. Verify your display setup with:
xrandr --query
This lists all connected monitors (e.g., HDMI-1
, DP-1
, eDP-1
) and their current modes. To configure them in extended mode (side-by-side), use commands like:
xrandr --output HDMI-1 --auto --right-of eDP-1 # Place HDMI-1 to the right of the primary display (eDP-1)
xrandr --output DP-1 --auto --right-of HDMI-1 # Place DP-1 to the right of HDMI-1
Replace HDMI-1
, DP-1
, and eDP-1
with your actual monitor names (from xrandr --query
). For other modes (e.g., cloned or single-display), adjust the --right-of
/--left-of
/--above
/--below
parameters accordingly.
Starting Compton with Multi-Monitor Support
Launch Compton using your custom configuration file to apply the settings:
compton -c ~/.config/compton.conf
This starts Compton with the specified options, enabling window composition across all connected monitors.
Enabling Compton at Startup
To ensure Compton runs automatically after login, create a systemd
service:
sudo nano /etc/systemd/system/compton.service
Add the following content (adjust the path to your config file if needed):
[Unit]
Description=Compton Window Composer
After=display-manager.service # Start after the display manager (e.g., GDM, LightDM)
[Service]
ExecStart=/usr/bin/compton -c ~/.config/compton.conf
Restart=on-failure # Restart if the service fails
[Install]
WantedBy=multi-user.target # Enable for all users
Save the file, then reload systemd
and enable the service:
sudo systemctl daemon-reload
sudo systemctl enable compton.service
sudo systemctl start compton.service
Check the service status to confirm it’s running:
systemctl status compton.service
If the status shows “active (running)”, Compton is active and will start automatically on future logins.
Verifying Multi-Monitor Configuration
After starting Compton, verify that multi-monitor support works as expected:
xrandr
configuration and Compton logs (use journalctl -u compton
to view logs).Troubleshooting Common Issues
backend
is set to glx
(or xrender
if OpenGL is unavailable) and that your graphics drivers are up to date.cpulimit
(e.g., cpulimit -l 50 -p $(pgrep compton)
).