開發者的 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

安裝 Clash for Windows

GitHub - Fndroid/clash_for_windows_pkg 下載 CFW,注意下載 Clash.for.Windows-x.xx.x-x64-linux.tar.gz

將其解壓到 ~/.local/share/cfw

mkdir $HOME/.local/share/cfw
chown debianuser:debianuser $HOME/.local/share/cfw
tar zxvf Clash.for.Windows-x.xx.x-x64-linux.tar.gz -C $HOME/.local/share/cfw --strip-components 1

創建 ~/.local/share/applications/cfw.desktop 用於顯示桌面圖標

touch ~/.local/share/applications/cfw.desktop
tee ~/.local/share/applications/cfw.desktop <<-'EOF'
[Desktop Entry]
Version=1.0
Name=Clash For Windows
GenericName=Clash For Windows
Comment=Clash For Windows for Linux
Exec=/home/debianuser/.local/share/cfw/cfw
Terminal=false
Type=Application
Icon=/home/debianuser/.local/share/cfw/logo.png
Categories=Network
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
        • 關閉 在桌面按下任意按鍵時激活
        • 關閉 記住過去的搜索
        • 關閉 重新打開時保留上次搜索
        • 關閉 活動感知
  • 網絡設置
    • 代理
      • 選擇 使用手動配置的代理服務器
      • HTTP 代理: 127.0.0.1 端口: 7890
      • 打開 所有協議都使用同樣的代理服務器
  • 電源管理
    • 節能
      • 屏幕節能: 關閉前等待時間 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 來生成配置文件


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM