温馨提示×

ubuntu compton如何与其他桌面环境配合

小樊
37
2025-11-02 10:02:46
栏目: 编程语言

Installing Compton on Ubuntu
To use Compton with any desktop environment on Ubuntu, first install it via the package manager. For Debian-based systems (including Ubuntu), run:

sudo apt update && sudo apt install compton

This installs the latest version available in Ubuntu’s repositories. If you need newer features, consider adding a PPA (e.g., ppa:richardgv/compton) or using picom (a maintained fork of Compton).

General Configuration for Compton
Compton’s primary configuration file is located at ~/.config/compton.conf (create it if it doesn’t exist). Key settings to customize include:

  • Backend: Choose between glx (better performance, requires OpenGL) or xrender (more compatible, but slower). Example:
    backend = "glx";
    
  • Shadows: Enable shadows with shadow = true, and exclude problematic windows (e.g., docks, menus) using shadow-exclude. Example:
    shadow = true;
    shadow-exclude = ["class_g = 'Plank'", "class_g = 'KRunner'"];
    
  • Transparency: Adjust global opacity with opacity (1.0 = fully opaque, 0.8 = 80% transparent) or set rules for specific apps (e.g., Firefox):
    opacity = 0.9;
    transparency-rule = ["class_g = 'Firefox'", "class_g = 'Thunderbird'"];
    
  • Performance: Enable vertical sync (vsync = true) to reduce screen tearing, and disable unneeded effects (e.g., fade = false) for older hardware.

Integrating Compton with Specific Desktop Environments
While Compton works with most X11-based desktop environments, each requires slightly different setup to avoid conflicts:

GNOME

GNOME’s default window manager (Mutter) conflicts with Compton, so you must disable Mutter’s built-in compositing.

  1. Open GNOME TweaksWindows and disable “Animations” and “Enable Workspaces”.
  2. Add Compton to GNOME’s startup applications:
    • Create a file ~/.config/autostart/compton.desktop with these contents:
      [Desktop Entry]
      Type=Application
      Exec=compton -b -c ~/.config/compton.conf
      Hidden=false
      NoDisplay=false
      X-GNOME-Autostart-enabled=true
      Name=Compton
      
  3. Restart GNOME (press Alt + F2, type r, and hit Enter).

KDE Plasma

KDE uses KWin as its window manager, which also includes compositing. To use Compton:

  1. Disable KWin’s compositing: Go to System SettingsDisplay and MonitorCompositor and uncheck “Enable compositor on startup”.
  2. Add Compton to KDE’s autostart:
    • Open System SettingsStartup and ShutdownAutostart and click “Add Program”.
    • Browse to /usr/bin/compton and add the command:
      compton -b -c ~/.config/compton.conf
      
  3. Restart your session to apply changes.

XFCE

XFCE is lightweight and works well with Compton. Disable XFCE’s compositing:

  1. Go to SettingsWindow Manager TweaksCompositor and uncheck “Enable display compositing”.
  2. Add Compton to XFCE’s autostart:
    • Open SettingsSession and StartupApplication Autostart and click “Add”.
    • Enter a name (e.g., “Compton”) and the command:
      compton -b -c ~/.config/compton.conf
      
  3. Log out and back in to enable Compton.

LXDE/Openbox/i3

These minimal window managers (Openbox, i3) do not include compositing by default, so Compton integrates seamlessly:

  1. Add Compton to your window manager’s startup file (e.g., ~/.config/openbox/autostart for Openbox, ~/.config/i3/config for i3):
    compton -b -c ~/.config/compton.conf &
    
  2. Restart your window manager (e.g., i3-msg restart for i3) to apply changes.

Troubleshooting Common Issues

  • Conflicts with Desktop Compositors: Always disable the built-in compositing of your desktop environment (e.g., GNOME’s Mutter, KDE’s KWin) to avoid graphical glitches.
  • Performance Problems: If Compton slows down your system, try:
    • Switching the backend to xrender (less resource-intensive but less smooth).
    • Disabling shadows (shadow = false) or transparency (opacity = 1.0).
    • Lowering the frame rate (frame-rate = 30).
  • Configuration Errors: Check the Compton log for errors (run compton -c ~/.config/compton.conf -v) and validate your config file syntax (e.g., ensure no missing semicolons or brackets).

Note on Compton’s Status
Compton is no longer actively maintained, and Ubuntu recommends using picom (a fork with bug fixes and new features) as a replacement. Installation and configuration are similar to Compton, but check the picom documentation for updated options.

0