温馨提示×

Compton在Ubuntu中如何使用

小樊
41
2025-10-07 20:05:22
栏目: 智能运维

Installing Compton on Ubuntu
To use Compton on Ubuntu, start by installing it via the 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.

Configuration File Setup
Compton’s configuration is managed via a config file, typically located at ~/.config/compton.conf (user-specific) or /etc/xdg/compton.conf (system-wide). If the file doesn’t exist, you can generate a default one by running:

compton --config > ~/.config/compton.conf

Common configuration options include:

  • Backend: Set to "glx" (recommended for most systems) or "xrender" for rendering.
  • Shadows: Enable with shadow = true and customize offsets/opacity (e.g., shadow-offset-x = -15, shadow-opacity = 0.75).
  • Transparency: Adjust with inactive-opacity = 0.8 (inactive windows) or active-opacity = 1.0 (active windows).
  • Performance: Optimize with glx-no-stencil = true (disables stencil buffer) or unredir-if-possible = true (redirects OpenGL windows to reduce load).

Starting Compton
To start Compton manually, run the following command in a terminal:

compton -b --config ~/.config/compton.conf &

The -b flag runs Compton in the background, while --config specifies the path to your config file. If you omit --config, Compton will use the default location.

Autostarting Compton
To ensure Compton launches automatically after login, add it to your startup applications:

  1. Open Startup Applications (search for it in the Ubuntu Dash).
  2. Click Add, enter a name (e.g., “Compton”), and set the command to:
    compton -b --config ~/.config/compton.conf
    
  3. Click Add to save. Alternatively, create a systemd user service (advanced users) to manage autostart.

Checking Compton Status
To verify that Compton is running, use:

ps -e | grep compton

If Compton is active, you’ll see a process listed. To stop it, run:

killall compton

This terminates all Compton processes.

Troubleshooting Common Issues

  • Screen Tearing: Enable vertical sync with vsync = "opengl-swc" in your config file.
  • High CPU Usage: Disable unnecessary effects (e.g., shadow = false) or use glx-no-stencil = true to reduce GPU load.
  • Window-Specific Issues: Exclude problematic applications (e.g., Conky, notifications) from effects using shadow-exclude or opacity-rule. For example:
    shadow-exclude = ["name = 'Notification'", "class_g = 'Conky'"]
    

These adjustments help balance visual effects with system performance.

0