溫馨提示×

Compton在CentOS中的多顯示器支持

小樊
45
2025-10-07 05:58:34
欄目: 智能運維

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:

  • Check that windows can be dragged between monitors without issues.
  • Confirm that Compton effects (e.g., shadows, transparency) are applied consistently across all displays.
  • If issues arise (e.g., windows not rendering correctly), review the xrandr configuration and Compton logs (use journalctl -u compton to view logs).

Troubleshooting Common Issues

  • Black screens or no Compton effects: Ensure the backend is set to glx (or xrender if OpenGL is unavailable) and that your graphics drivers are up to date.
  • Window lag or high CPU usage: Disable unnecessary effects (e.g., shadows) or limit Compton’s CPU usage with cpulimit (e.g., cpulimit -l 50 -p $(pgrep compton)).
  • Conflicts with other compositors: Disable other compositors (e.g., GNOME’s built-in compositor) before running Compton.

0
亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女