开发者的 Debian 12 KDE 配置优化指南

博客地址

开发者的 Debian 12 KDE 配置优化指南

0x00 简介

本文仅适用于配置 Debian 12 Bookworm

文中包含 KDE Plasma X11 桌面配置

文中使用 debianuser 代替用户名,执行命令或复制配置时请注意替换

文中涉及的带版本号的软件包/环境,版本号使用 xxx 代替,请根据实际情况安装最新版本或自己需要的版本

本文编辑整理时间距离实践时间相隔过长,编辑过程中可能出现不准确内容,如果在您的时间过程中发现与本文不符的情况,请尽量在评论区留言,我将尽快确认更新

0x01 基础配置

该步骤中大部分操作需要重启,所以不要根据配置完成后的应用运行状态来判断配置是否成功

在该步骤末尾会重启一次应用所有配置

使用英文重命名 /home 目录下文件夹

cd ~
mkdir Desktop Download Templates Public Documents Music Pictures Videos
rm -rf 公共 模板 视频 图片 文档 下载 音乐 桌面
xdg-user-dirs-update --set DESKTOP ~/Desktop
xdg-user-dirs-update --set DOWNLOAD ~/Download
xdg-user-dirs-update --set TEMPLATES ~/Templates
xdg-user-dirs-update --set PUBLICSHARE ~/Public
xdg-user-dirs-update --set DOCUMENTS ~/Documents
xdg-user-dirs-update --set MUSIC ~/Music
xdg-user-dirs-update --set PICTURES ~/Pictures
xdg-user-dirs-update --set VIDEOS ~/Videos

将用户添加到 sudoers 中

该步骤需要先切换到 root 身份

Ctrl + Alt + F3 切换到纯命令行界面的新终端,并以 root 身份登录进行操作

结束后使用 exit 退出终端,按 Ctrl + Alt + F1/F2 切换回用户身份图形界面

根据桌面环境及发行版本不同,快捷键可能有差异,但大多都是 Ctrl + Alt + F1-F12

以下命令在 root 身份下执行

chmod +w /etc/sudoers
cat >> /etc/sudoers << EOF
debianuser ALL=(ALL:ALL) ALL
EOF
chmod -w /etc/sudoers
exit

以上命令在 root 身份下执行

更换软件源

sudo tee /etc/apt/sources.list <<-'EOF'
deb http://mirrors.ustc.edu.cn/debian stable main contrib non-free non-free-firmware
# deb-src http://mirrors.ustc.edu.cn/debian stable main contrib non-free non-free-firmware

deb http://mirrors.ustc.edu.cn/debian stable-updates main contrib non-free non-free-firmware
# deb-src http://mirrors.ustc.edu.cn/debian stable-updates main contrib non-free non-free-firmware

deb http://mirrors.ustc.edu.cn/debian stable-proposed-updates main contrib non-free non-free-firmware
# deb-src http://mirrors.ustc.edu.cn/debian stable-proposed-updates main contrib non-free non-free-firmware

# deb https://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware
# deb-src https://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware
EOF
sudo apt update
sudo apt upgrade
sudo apt dist-upgrade

其他软件源

Docker CE
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
sudo tee /etc/apt/sources.list.d/docker-ce.list <<-'EOF'
deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.gpg] https://mirrors.ustc.edu.cn/docker-ce/linux/debian bookworm stable
EOF
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

配置基础软件包

sudo apt install vim wget curl htop git proxychains4 screenfetch tmux bash-completion fcitx5-rime chromium fcitx5 zsh fonts-powerline fzf net-tools openssh-server firewalld bat

卸载无用软件包

主要卸载一些多语言支持和游戏包,可跳过

KDE

注意:卸载包时请注意同时卸载了哪些依赖,防止出现依赖问题导致卸载掉整个桌面环境

sudo apt remove --purge ibus* goldendict
sudo apt autoremove --purge

无线网卡驱动

如果你的电脑存在无线网卡,并且在安装好操作系统之后发现无线网卡无法使用,请尝试如下步骤

sudo apt install firmware-iwlwifi
sudo modprobe -r iwlwifi
sudo modprobe iwlwifi

Nvidia 显卡驱动

如果你的电脑存在 Nvidia 显卡,并且在安装好操作系统之后发现显卡无法使用,请尝试如下步骤

sudo apt install nvidia-detect
sudo nvidia-detect

该步骤会根据硬件检测应该安装哪些驱动,请按照输出安装对应的驱动,例如提示 nvidia-driver

sudo apt install nvidia-driver

tmux 快捷键

sudo tee /etc/tmux.conf <<-'EOF'
set -g prefix C-a
unbind C-b
bind C-a send-prefix
EOF

配置 ZSH

切换到 zsh

chsh -s /bin/zsh
# If you have a specific zshrc
sudo cp ~/.zshrc /root

完成以上步骤后切换到 root 用户将自动为其配置 zsh, zinit 及 .zshrc 中配置的插件

自行配置 p10k 主题前请先按照 0x05 其他优化配置 正确配置字体

重启

sudo reboot

0x02 安装应用

下载 Google Chrome

下载 Microsoft Visual Studio Code

下载 JetBrains Toolbox App

下载 Go for Linux

下载 nvm

sudo apt install ./google-chrome-stable_current_amd64.deb
sudo apt install ./code_xxx_amd64.deb
sudo apt remove --purge 'firefox-esr*'

JetBrains Toolbox

用于管理 JetBrains IDE

tar zxvf jetbrains-toolbox-xxx.tar.gz
./jetbrains-toolbox-xxx/jetbrains-toolbox
Activate by code

访问 jetbra.in/s,网站使用 IPFS 存储,跳转到 JETBRA.IN CHECKER | IPFS,在列表中选择任意可用节点访问即可

下载页面顶部的 jetbra.zip,按照 README 说明配置即可

Go & nvm & Java

建议将 go 和 nvm 分别安装到 /usr/local/go/usr/local/nvm

为 java 创建 /usr/local/java 目录,将各版本 jdk 统一解压到该目录下便于管理

mkdir $HOME/.local/go
mkdir $HOME/.local/nvm
tar zxvf Downloads/goxxxlinux-amd64.tar.gz -C $HOME/.local/go/ --strip-components=1
chmod +x nvm_install.sh
NVM_DIR="$HOME/.local/nvm" ./nvm_install.sh
tee $HOME/.profile <<-'EOF'

source /etc/profile

export NVM_NODEJS_ORG_MIRROR=https://npmmirror.com/mirrors/node

export GOROOT="$HOME/.local/go"

export JAVA_HOME="$HOME/.local/java/jdk-xxx"

export PATH="$PATH:$GOROOT/bin"
export PATH="$PATH:$JAVA_HOME/bin"
EOF

配置 Go Modules,Go 代理并切换 npm 源

go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.cn,https://goproxy.io,direct
nvm install --lts
nvm alias default lts/*
npm config set registry https://registry.npmmirror.com/

安装 VSCode 扩展

以下仅为推荐扩展,请根据自己的技术栈及个人喜好自行选择

  • ms-vscode.cpptools
  • ms-azuretools.vscode-docker
  • dbaeumer.vscode-eslint
  • golang.go
  • yzhang.markdown-all-in-one
  • shd101wyy.markdown-preview-enhanced
  • DavidAnson.vscode-markdownlint
  • ms-python.vscode-pylance
  • ms-python.python
  • Vue.volar

0x03 KDE 桌面优化

系统设置

  • 外观
    • 全局主题
      • 获取新的全局主题: Fluent kde theme
    • 应用程序风格
      • 配置 GNOME/GTK 应用程序风格
        • 获取新 GNOME/GTK 应用程序风格: Fluent gtk theme
        • GTK 应用程序风格:Fluent
    • Plasma 视觉风格: Fluent
    • 窗口装饰元素: Fluent
    • 图标: Fluent
    • 欢迎屏幕: Fluent
  • 工作区行为
    • 常规行为
      • 单击文件、文件夹时: 选中
    • 锁屏
      • 自动锁定屏幕: 如果空闲 30 分钟
      • 锁屏多久后需要密码解锁: 0
    • 最近文件
      • 记住打开过的文档: 不要记住
  • 窗口管理
    • 窗口行为
      • 标题栏操作
        • 标题栏和边框操作
          • 中击: 无操作 无操作
    • 任务切换器
      • 获取新任务切换器: MediumDefault
      • 主窗口
        • 可视化: MediumDefault
  • 开机与关机
    • 桌面会话
      • 会话恢复
        • 登录时启动之前打开的应用程序: 启动为空会话
  • 搜索
    • Plasma 搜索
      • 关闭 浏览器历史记录
      • 关闭 网络搜索关键词
      • 配置 KRunner
        • 关闭 在桌面按下任意按键时激活
        • 关闭 记住过去的搜索
        • 关闭 重新打开时保留上次搜索
        • 关闭 活动感知
  • 电源管理
    • 节能
      • 屏幕节能: 关闭前等待时间 30 分钟
      • 关闭 挂起会话
      • 合上笔记本盖时: 无操作

面板配置

  • 面板高度: 46
  • 图标任务管理器
    • 行为
      • 分组: 不分组
      • 显示的任务: 打开 当前屏幕的任务
  • 数字时钟
    • 外观
      • 打开 显示秒
      • 时间显示: 24 小时制

Konsole 配置

  • 设置
    • 显示工具栏
      • 关闭 主工具栏
      • 关闭 会话工具栏
    • 配置 Konsole
      • 常规
        • 关闭 记住窗口大小
      • 配置方案: 新建
        • 常规
          • Default
          • 打开 默认配置方案
          • 初始终端尺寸: 14030
        • 外观
          • 配色方案和字体
            • 获取新的: Nordic konsole
        • 滚动
          • 回滚: 无限制

0x05 其他优化配置

字体优先级

本文环境下广泛使用 Hack Nerd Font 显示图标,使用 Sarasa Term SC 作为等宽字体

创建 /etc/fonts/local.conf 配置字体优先级如下

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
    <alias>
        <family>serif</family>
        <prefer>
            <family>Sarasa Term SC</family>
            <family>Hack Nerd Font</family>
        </prefer>
    </alias>
    <alias>
        <family>sans-serif</family>
        <prefer>
            <family>Sarasa Term SC</family>
            <family>Hack Nerd Font</family>
        </prefer>
    </alias>
    <alias>
        <family>monospace</family>
        <prefer>
            <family>Sarasa Term SC</family>
            <family>Hack Nerd Font</family>
        </prefer>
    </alias>
</fontconfig>

ZSH 配置参考

.zshrc

# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
  source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi

# apt install fonts-powerline
# Download https://github.com/ryanoasis/nerd-fonts/releases/download/v3.0.2/Hack.zip
# Extract the files and copy all font files to user font folder like ~/.local/share/fonts
# fc-cache -f -v

### Added by Zinit's installer
if [[ ! -f $HOME/.local/share/zinit/zinit.git/zinit.zsh ]]; then
  print -P "%F{33} %F{220}Installing %F{33}ZDHARMA-CONTINUUM%F{220} Initiative Plugin Manager (%F{33}zdharma-continuum/zinit%F{220})…%f"
  command mkdir -p "$HOME/.local/share/zinit" && command chmod g-rwX "$HOME/.local/share/zinit"
  command git clone https://github.com/zdharma-continuum/zinit "$HOME/.local/share/zinit/zinit.git" && \
    print -P "%F{33} %F{34}Installation successful.%f%b" || \
    print -P "%F{160} The clone has failed.%f%b"
fi

source /etc/zsh/zprofile
source $HOME/.profile
source "$HOME/.local/share/zinit/zinit.git/zinit.zsh"
autoload -Uz _zinit
(( ${+_comps} )) && _comps[zinit]=_zinit
### End of Zinit's installer chunk

HISTFILE="$HOME/.zsh_history"
HISTSIZE=10000
SAVEHIST=10000
setopt BANG_HIST                 # Treat the '!' character specially during expansion.
setopt EXTENDED_HISTORY          # Write the history file in the ":start:elapsed;command" format.
setopt INC_APPEND_HISTORY        # Write to the history file immediately, not when the shell exits.
setopt SHARE_HISTORY             # Share history between all sessions.
setopt HIST_EXPIRE_DUPS_FIRST    # Expire duplicate entries first when trimming history.
setopt HIST_IGNORE_DUPS          # Don't record an entry that was just recorded again.
setopt HIST_IGNORE_ALL_DUPS      # Delete old recorded entry if new entry is a duplicate.
setopt HIST_FIND_NO_DUPS         # Do not display a line previously found.
setopt HIST_IGNORE_SPACE         # Don't record an entry starting with a space.
setopt HIST_SAVE_NO_DUPS         # Don't write duplicate entries in the history file.
setopt HIST_REDUCE_BLANKS        # Remove superfluous blanks before recording entry.
setopt HIST_VERIFY               # Don't execute immediately upon history expansion.
setopt HIST_BEEP                 # Beep when accessing nonexistent history.

# apt install fzf
zinit ice depth='1' lucid wait='0' atload='_zsh_autosuggest_start'
zinit light zsh-users/zsh-autosuggestions
zinit ice depth='1' lucid wait='0'
zinit light zsh-users/zsh-syntax-highlighting
zinit ice depth='1'
zinit light zsh-users/zsh-completions
zinit ice depth='1'
zinit light romkatv/powerlevel10k
zinit ice lucid wait='0'
zinit snippet OMZ::plugins/jsontools/jsontools.plugin.zsh
zinit ice lucid wait='0'
zinit snippet OMZ::plugins/fzf/fzf.plugin.zsh
zinit ice lucid wait='0'
zinit snippet OMZ::lib/completion.zsh

autoload -U compinit && compinit

# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
if [ ${DISPLAY} ]; then
  [[ ! -f ~/.p10k.gui.zsh ]] || source ~/.p10k.gui.zsh
else
  export LANG=en_US.UTF-8
  [[ ! -f ~/.p10k.terminal.zsh ]] || source ~/.p10k.terminal.zsh
fi

alias ls='ls --color=auto'
alias grep='grep --color=auto'
alias ll='ls -lh'
alias la='ls -A'
alias l='ls -CF'
# advcpmv Site: https://github.com/jarun/advcpmv
# ===== advcpmv Step Start =====
# ===== from source code
# wget http://ftp.gnu.org/gnu/coreutils/coreutils-9.4.tar.xz
# tar Jxvf coreutils-9.4.tar.xz
# cd coreutils-9.4/
# wget https://raw.githubusercontent.com/jarun/advcpmv/master/advcpmv-0.9-9.4.patch
# patch -p1 -i advcpmv-0.9-9.4.patch
# ./configure
# make
# sudo chmod +x ./src/cp ./src/mv
# sudo chown root. ./src/cp ./src/mv
# sudo mv ./src/cp /usr/local/bin/cpg
# sudo mv ./src/mv /usr/local/bin/mvg
# ===== advcpmv Step Finish =====
alias cp='/usr/local/bin/cpg -g'
alias mv='/usr/local/bin/mvg -g'
# bat Site: https://github.com/sharkdp/bat
# ===== bat Step Start =====
# ===== from github
# Download release from https://github.com/sharkdp/bat/releases
# apt install ./bat-musl_x.xx.x_amd64.deb
# ===== bat Step Finish =====
alias cat='batcat --paging=never -p'

Powerlevel10k 配置

Powerlevel10k 是 zsh 的主题,在 .zshrc 中我们声明了在桌面环境和终端环境下使用不同的 p10k 配置,即桌面环境使用图标更多更友好的终端主题配置,而在终端环境下使用更保守的终端主题配置以保证兼容性,执行 p10k configure 来生成配置文件

  • 14
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值