debian

Debian Compton的快捷键操作

小樊
44
2025-11-11 07:03:17
栏目: 智能运维

Compton本身不提供内置快捷键功能,其快捷键需通过窗口管理器(如i3、Openbox等)配置实现。以下以Debian系统中常见的i3窗口管理器为例,说明Compton快捷键的设置方法:

1. 前提条件:安装Compton

若未安装Compton,可通过以下命令安装(Debian/Ubuntu通用):

sudo apt update && sudo apt install compton

2. 配置Compton基础参数(可选但建议)

Compton的配置文件通常位于~/.config/compton.conf(若不存在则创建)。可根据需求调整以下基础参数(示例):

# 启用窗口阴影
shadow = true
# 设置窗口透明度(0为完全透明,1为不透明)
opacity = 0.8
# 启用背景模糊(需显卡支持)
blur-background = true
blur-kern = "3x3box"
# 忽略根窗口透明度(避免桌面背景异常)
ignore-root = true

修改后保存,通过以下命令重启Compton使配置生效:

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

3. 通过i3配置Compton快捷键

i3的配置文件通常位于~/.config/i3/config(若不存在则创建)。在文件中添加以下内容,设置常用Compton快捷键:

# 启动/重启Compton(绑定至Mod+Shift+C)
bindsym $mod+Shift+C exec --no-startup-id compton --config ~/.config/compton.conf &
# 停止Compton(绑定至Mod+Shift+X)
bindsym $mod+Shift+X exec --no-startup-id pkill compton
# 切换窗口阴影(绑定至Mod+Alt+S)
bindsym $mod+Mod1+S exec --no-startup-id sh -c "if grep -q 'shadow = true' ~/.config/compton.conf; then sed -i 's/shadow = true/shadow = false/' ~/.config/compton.conf; else sed -i 's/shadow = false/shadow = true/' ~/.config/compton.conf; fi && killall compton && compton --config ~/.config/compton.conf &"
# 调整窗口透明度(绑定至Mod+Up/Down,需配合xdotool或其他工具,此处为示例)
bindsym $mod+Up exec --no-startup-id sh -c "current=$(grep 'opacity =' ~/.config/compton.conf | cut -d'=' -f2); new=$(echo "$current + 0.1" | bc | awk '{print ($1>1)?1:$1}'); sed -i "s/opacity = .*/opacity = $new/" ~/.config/compton.conf && killall compton && compton --config ~/.config/compton.conf &"
bindsym $mod+Down exec --no-startup-id sh -c "current=$(grep 'opacity =' ~/.config/compton.conf | cut -d'=' -f2); new=$(echo "$current - 0.1" | bc | awk '{print ($1<0)?0:$1}'); sed -i "s/opacity = .*/opacity = $new/" ~/.config/compton.conf && killall compton && compton --config ~/.config/compton.conf &"

说明

4. 重新加载i3配置

修改i3配置文件后,按下Mod+Shift+R(或你在i3中设置的其他重新加载快捷键),使配置生效。

注意事项

0
看了该问题的人还看了