ubuntu

ubuntu compton如何配置双屏

小樊
38
2025-09-18 16:23:47
栏目: 智能运维

Installing Compton on Ubuntu
Before configuring dual screens, ensure Compton is installed. Run the following commands to update your package list and install Compton:

sudo apt update
sudo apt install compton

Creating/Editing the Compton Configuration File
Compton’s default configuration file is located at ~/.config/compton.conf. If it doesn’t exist, create the directory and file manually:

mkdir -p ~/.config
touch ~/.config/compton.conf

Open the file with a text editor (e.g., nano ~/.config/compton.conf) to add or modify settings.

Configuring Dual Screens in Compton
The most critical part of dual-screen setup is defining monitor layouts. Use the screen section to specify each display’s position relative to the others. First, identify your monitor names with:

xrandr --query

This command lists all connected displays (e.g., HDMI-1, eDP-1). Replace these names in the example below to match your setup:

screen0 {
    output HDMI-1  # Replace with your secondary monitor name (e.g., HDMI-1, DP-1)
    position LeftOf eDP-1  # Place secondary monitor to the left of the primary (replace eDP-1 with your primary monitor name)
}
screen1 {
    output eDP-1  # Primary monitor
    position RightOf HDMI-1  # Place primary monitor to the right of the secondary
}

Key parameters:

Additional Optional Settings
Optimize performance and visuals with these common configurations:

# Enable OpenGL acceleration for smoother rendering
backend "glx"
glx-no-stencil true  # Disables stencil buffer for better performance
glx-copy-from-front false  # Improves performance in multi-monitor setups

# Configure shadows (exclude panels/windows to avoid visual glitches)
shadow-exclude = [
    "class_g = 'gnome-panel'",  # Exclude GNOME panel
    "class_g = 'gnome-terminal'",  # Exclude terminal windows
    "class_g = 'firefox'"  # Exclude Firefox windows
]
shadow-radius = 5  # Softens shadow edges
shadow-opacity = 0.5  # Adjusts shadow transparency

# Set frame rate limit to reduce CPU/GPU usage
fps-limit = 60

Save changes after editing.

Starting Compton with the New Configuration
Test your configuration by running Compton with the custom config file:

compton -c ~/.config/compton.conf

If the dual-screen setup works as expected, proceed to set up automatic startup.

Setting Up Compton to Start on Boot
To ensure Compton launches automatically after login, create a systemd service:

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

Add the following content (replace YourUsername with your actual username):

[Unit]
Description=Compton Compositor
After=display-manager.service  # Starts after the display manager (e.g., GDM, LightDM)

[Service]
ExecStart=/usr/bin/compton -c ~/.config/compton.conf
Restart=always  # Restarts Compton if it crashes
User=YourUsername

[Install]
WantedBy=multi-user.target

Save the file, then enable and start the service:

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

Verify Compton is running with:

systemctl --user status compton

You should see an “active (running)” status.

Troubleshooting Common Issues

For further customization, refer to the official Compton documentation.

0
看了该问题的人还看了