温馨提示×

Ubuntu Compton与Gnome:完美搭配指南

小樊
45
2025-10-11 22:56:50
栏目: 智能运维

Installing Compton on Ubuntu
To begin, install Compton using Ubuntu’s package manager. Open a terminal and run:

sudo apt update && sudo apt install compton

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

Configuring Compton for GNOME
Compton’s behavior is controlled by a configuration file typically located at ~/.config/compton.conf. If this directory or file doesn’t exist, create it:

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

Add the following essential settings to balance performance and aesthetics. These settings enable OpenGL rendering (for smoother animations), exclude Firefox from shadows (to avoid visual glitches), and enable fading for window transitions:

backend = "glx";
shadow-exclude = ["class='.*Firefox'"];
fade = true;
fade-delta = 30;

Save the file (Ctrl+O, Enter) and exit the editor (Ctrl+X). For advanced customization, refer to Compton’s official documentation to tweak parameters like shadow opacity (shadow-opacity), refresh rate (force-frame-rate), or transparency thresholds (alpha-threshold).

Starting Compton Automatically in GNOME
To ensure Compton launches every time you log into GNOME, add it to your startup applications. You can do this via the terminal or GNOME’s graphical interface:

  • Graphical Method:
    1. Open Settings > Startup Applications.
    2. Click Add, enter a name (e.g., “Compton”), and set the command to:
      compton --config ~/.config/compton.conf
      
    3. Click Add to save.
  • Terminal Method:
    Run the following command to create a desktop entry in ~/.config/autostart:
    echo -e "[Desktop Entry]\nType=Application\nExec=compton --config ~/.config/compton.conf\nHidden=false\nNoDisplay=false\nX-GNOME-Autostart-enabled=true\nName=Compton" > ~/.config/autostart/compton.desktop
    
    This ensures Compton starts silently in the background with your custom configuration.

Verifying the Setup
After logging out and back in (or running compton --config ~/.config/compton.conf manually), check if Compton is active. You should see window shadows (unless excluded) and smooth fade effects when minimizing/maximizing windows. If you encounter issues (e.g., window flickering), press Alt+F2, type r, and press Enter to restart GNOME Shell—this often resolves temporary glitches.

Troubleshooting Common Issues

  • Black Screen/Performance Lag: Switch Compton’s backend from glx to xrender in the configuration file (change backend = "glx" to backend = "xrender"). This reduces GPU load but may disable some advanced effects.
  • Missing Shadows: Ensure shadow-exclude doesn’t include the application you want shadows for. For example, to add Chrome to the exclusion list, modify the line to:
    shadow-exclude = ["class='.*Firefox'", "class='.*Chrome'"];
    
  • Compton Not Starting: Verify the configuration file path and permissions (should be readable by your user). Run compton --config ~/.config/compton.conf --log-level debug to view detailed logs and identify errors.

0