温馨提示×

ubuntu compton多显示器设置

小樊
52
2025-10-05 19:21:04
栏目: 智能运维

Installing Compton on Ubuntu
Before configuring multi-monitor settings, ensure Compton is installed. Run the following commands in the terminal to update your package list and install Compton:

sudo apt update sudo apt install compton 

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

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

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

Use a text editor (like nano or vim) to add or modify configuration options. This file stores all settings for Compton’s behavior, including multi-monitor adjustments.

Configuring Multi-Monitor Support
To enable multi-monitor functionality, you need to specify which displays Compton should manage and use a compatible backend. Add the following lines to your compton.conf file:

  • Backend Selection: Use the glx backend for hardware acceleration (recommended for multi-monitor setups):
    backend "glx"; 
  • Display Specification: List all connected monitors to ensure Compton handles them correctly. First, run xrandr in the terminal to get your monitor names (e.g., HDMI-1, eDP-1). Then, add the output parameter to your config:
    output = "HDMI-1 eDP-1"; # Replace with your actual monitor names 
    This tells Compton to manage both the external (HDMI-1) and internal (eDP-1) displays.

Additional Recommended Settings
For better performance and aesthetics, include these optional configurations in your compton.conf:

  • Transparency Rules: Define which windows should have transparency (e.g., exclude desktop and terminal windows):
    opacity-rule = [ "class_g \"Desktop\" A", "class_g \"Gnome-terminal\" A", "class_g \"Firefox\" A" ]; 
  • Shadow Exclusions: Prevent shadows from appearing on certain windows (e.g., desktop, terminal) to avoid visual clutter:
    shadow-exclude = [ "class_g \"Desktop\"", "class_g \"Gnome-terminal\"", "class_g \"Firefox\"" ]; 
  • Frame Rate Limit: Cap the frame rate to reduce CPU/GPU usage (e.g., 60 FPS):
    fps-limit = 60; 

These settings improve compatibility and performance for multi-monitor setups.

Running Compton with Your Configuration
After saving changes to compton.conf, test the configuration by running:

compton -c ~/.config/compton.conf 

The -c flag tells Compton to use your custom config file. If everything works as expected, you’ll see window effects applied across all monitors.

Setting Up Compton for Auto-Start
To ensure Compton launches automatically when you log in, add it to your system’s startup applications:

  1. Open the “Startup Applications” tool from Ubuntu’s application menu.
  2. Click “Add” and enter a name (e.g., “Compton”).
  3. In the “Command” field, enter:
    compton -b -c ~/.config/compton.conf 
    The -b flag runs Compton in the background.

Troubleshooting Common Issues

  • Display Not Detected: If a monitor isn’t listed in xrandr, verify physical connections and try reconnecting the cable.
  • Performance Issues: Lower the fps-limit or disable hardware acceleration (set backend "xrender") if you experience lag.
  • Screen Tearing: Enable vertical sync with glx-vsync true in your config file.

By following these steps, you can configure Compton to support multi-monitor setups on Ubuntu, enabling hardware-accelerated window effects across all displays.

0