debian

Compton在Debian上的自定义主题支持

小樊
42
2025-10-23 06:32:39
栏目: 智能运维

Note: The original Compton project is no longer actively maintained, and most modern Linux distributions (including Debian) have switched to Picom (a fork of Compton) as the default window compositor. The steps below are adapted for Picom, which retains compatibility with most Compton configuration options.

1. Install Picom on Debian

Before customizing themes, ensure Picom is installed. Run the following command to install it via APT:

sudo apt update && sudo apt install picom

2. Create or Edit the Picom Configuration File

Picom’s configuration file is typically located at ~/.config/picom/picom.conf. If the directory or file doesn’t exist, create it:

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

3. Customize Theme Parameters

Edit the configuration file to define your theme. Key parameters for theming include:

Below is an example configuration for a dark theme:

# Enable shadows (exclude dialogs and tooltips)
shadow = true;
shadow-exclude = [
    "window_type = 'dialog'",
    "window_type = 'dropdown_menu'",
    "window_type = 'tooltip'"
];
shadow-color = "#000000";
shadow-opacity = 0.3;
shadow-offset-x = 0;
shadow-offset-y = 2;

# Set background and foreground colors
background = "#1e1e1e";
foreground = "#d4d4d4";

# Window opacity (0.0 = fully transparent, 1.0 = opaque)
opacity = 0.95;
inactive-opacity = 0.8;

# Border settings
border-width = 1px;
border-color = "#4e4e4e";

# Fading effects
fade = true;
fade-in-step = 0.05;
fade-out-step = 0.05;

# Blur effect (set to 0 to disable)
blur = true;
blur-radius = 5;
blur-background = true;

4. Apply the Custom Theme

After saving the configuration file, restart Picom to apply the changes:

pkill picom && picom -b --config ~/.config/picom/picom.conf

The -b flag runs Picom in the background, and --config specifies the path to your custom configuration.

5. Optional: Advanced Customization with Lua

For advanced theming (e.g., dynamic effects, per-window customization), you can use a Lua script. Install Lua and create a script file (e.g., ~/.config/picom/picom.lua):

sudo apt install lua5.3
nano ~/.config/picom/picom.lua

Add custom logic (example: dynamic shadow adjustment based on window type):

local ffi = require("ffi")
local libpicom = ffi.load("libpicom")

-- Custom shadow exclusion
libpicom.shadow_exclude = {
    {x = 0, y = 0, width = 1920, height = 1080},  -- Exclude primary display
    {x = 1920, y = 0, width = 3840, height = 1080}  -- Exclude secondary display
}

-- Dynamic opacity for specific windows
libpicom.opacity = function(window)
    if window.class == "Firefox" then
        return 0.9  -- Slightly more transparent for Firefox
    else
        return 0.95  -- Default opacity
    end
end

Modify your Picom command to use the Lua script:

pkill picom && picom -b --config ~/.config/picom/picom.conf -l ~/.config/picom/picom.lua

6. Autostart Picom on Login

To ensure Picom starts automatically when you log in, add it to your desktop environment’s startup applications:

By following these steps, you can fully customize Picom’s appearance and behavior on Debian. The process is similar to Compton, but Picom offers better maintenance and compatibility with modern systems.

0
看了该问题的人还看了