温馨提示×

Ubuntu Compton多显示器支持:如何设置

小樊
46
2025-10-11 23:02:50
栏目: 智能运维

Installing Compton
First, ensure Compton is installed on your Ubuntu system. Open a terminal and run:

sudo apt update && sudo apt install compton

This installs the latest version of Compton available in Ubuntu’s repositories.

Creating/Editing the Compton Configuration File
Compton’s configuration file is typically located at ~/.config/compton.conf. If it doesn’t exist, create it using a text editor like nano:

nano ~/.config/compton.conf

This file will store all settings for Compton, including multi-monitor configurations.

Configuring Multi-Monitor Support
The most critical step for multi-monitor support is specifying which displays Compton should manage. Use the xrandr-output parameter to list your connected monitors. First, find your monitor names by running:

xrandr --query

This outputs a list of active displays (e.g., HDMI-1, eDP-1). Add them to your config file:

xrandr-output HDMI-1 eDP-1;

Replace HDMI-1 and eDP-1 with your actual monitor names. This tells Compton to handle both displays.

Additional Recommended Settings
To optimize performance and visuals for multi-monitors, add these common settings to your config file:

backend "glx";  # Use OpenGL for hardware acceleration (recommended for multi-monitors)
glx-no-stencil false;
glx-copy-from-front true;
glx-hardware true;  # Enable hardware acceleration
damage true;  # Improve rendering efficiency
opacity-rule ["class_g \"Desktop\" A", "class_g \"Gnome-terminal\" A", "class_g \"Firefox\" A"];  # Adjust transparency rules
shadow-exclude ["class_g \"Desktop\"", "class_g \"Gnome-terminal\"", "class_g \"Firefox\""];  # Exclude transparent windows from shadows

These settings balance performance and aesthetics, ensuring smooth animations and transparency across all monitors.

Running Compton with the New Configuration
After saving your changes, start Compton with the configuration file:

compton -c ~/.config/compton.conf

This applies your settings immediately. If you encounter issues, check the terminal output for error messages.

Setting Up Compton for Auto-Start
To avoid manually starting Compton each time you boot, add it to your system’s startup applications. Create a systemd service file:

sudo nano /etc/systemd/system/compton.service

Add the following content:

[Unit]
Description=Compton Window Composer
After=display-manager.service

[Service]
ExecStart=/usr/bin/compton -c ~/.config/compton.conf
Restart=on-failure

[Install]
WantedBy=multi-user.target

Save the file, then enable and start the service:

sudo systemctl enable compton.service
sudo systemctl start compton.service

This ensures Compton launches automatically on login.

0