ArchLinux安装指南

ArchLinux是一款灵活、强大、可定制的Linux发行版,提供丰富的软件包和工具,支持滚动更新和多种桌面环境,拥有庞大的社区支持和方便的包管理器,适合各种用户需求和使用场景。Endeavour 是一个基于ArchLinux的轻量级和用户友好的发行版,预装了桌面环境和预配置的软件包,旨在提供一个无忧的ArchLinux体验。

Linux版本选择

ArchLinux的安装镜像是没有安装桌面环境的,只安装了一些必备的软件,它的安装需要在命令行中进行,如果您已经有一定的Linux基础,那建议您直接按照本教程安装ArchLinux。如果您是一名初学者,不熟悉Linux命令,只要您尝试过UbuntuDebianLinuxMintLinuxDeepin等发行版,那您完全可以选择ArchLinux的衍生版Endeavour, Endeavour 让你有机会学习 Arch,而无需同时学习 EFI、驱动搜索和安装(看着你的 nVidia)、桌面环境/窗口管理器、显示管理器等。它可以一次性设置好所有东西,让你有时间按照自己的节奏学习 Arch Linux 的内部工作。由于图形化安装的简便性,本文不打算详述,直接参考Endeavour的官方文档(相当详细):BTRFS InstallationEndeavour Wiki

刚刚入门的小白往往选择宣传的比较多的Ubuntu,但是我想告诉您,尝试一下其他发行版,您会找到更好的。下面的文章可以帮您做出选择:

从运行速度的角度讲,执行systemctl list-unit-files --state=enabled --no-pager得到默认情况下运行的服务和守护进程的数量,Ubuntu 为90个,Manjaro 为24个, Endeavour 为 17个,而按我的教程配置好的 ArchLinux 仅11个,所以原生的ArchLinux才是最佳选择。

最低硬件要求

ArchLinux 对硬件需求并没有特别严格的要求,它可以在较老的硬件上运行,也可以在最新的硬件上运行。一般来说,以下是ArchLinux的最低系统要求:

  • 64位处理器
  • 512MB RAM(建议1GB或更多)
  • 800MB可用磁盘空间
  • 支持网络连接的网络适配器
  • Gnome桌面环境:
    • 双核2 GHz处理器或更高
    • 4 GB系统内存
    • 25 GB磁盘存储空间
  • 2.5GB 系统内存
  • 双核处理器(64位x86-64, amd64)
  • 15G磁盘存储空间
  • 安装程序仍支持仅使用旧版 BIOS 的系统,但建议运行新式 EFI(UEFI) 系统,而不是在旧版 (CSM) 模式下。
  • Endeavour默认安装KDE桌面环境

ArchLinux安装流程

制作启动盘

设置U盘启动

  • 一般笔记本电脑的BIOS快捷键为F12F2F8F9ESC, 这个顺序按使用的频率给出,可以逐个尝试。具体对应关系可以对照下表,如若没有请考虑常用启动热键或自行百度。
主板品牌 启动按键 笔记本品牌 启动按键 台式机品牌 启动按键
华硕主板 F8 联想笔记本 F12 联想台式机 F12
技嘉主板 F12 宏基笔记本 F12 惠普台式机 F12
微星主板 F11 华硕笔记本 ESC 宏基台式机 F12
映泰主板 F9 惠普笔记本 F9 戴尔台式机 ESC
梅捷主板 ESC或F12 Thinkpad F12 神州台式机 ESC
七彩虹主板 ESC或F11 戴尔笔记本 F12 华硕台式机 F8
华擎主板 F11 神州笔记本 F12 方正台式机 F12
斯巴达克主板 ESC 东芝笔记本 F2 清华同方台式机 F12
昂达主板 F11 三星笔记本 F12 海尔台式机 F12
双敏主板 ESC IBM笔记本 F12 明基台式 F8
翔升主板 F10 富士通笔记本 F12
精英主板 ESC或F11 海尔笔记本 F12
冠盟主板 F11或F12 方正笔记本 F12
富士康主板 ESC或F12 清华同方笔记本 F12
顶星主板 F11或F12 微星笔记本 F11
盈通主板 F8 技嘉笔记本 F12
捷波主板 ESC Gatway笔记本 F12
Intel主板 F12 eMachines笔记本 F12
捷微主板 ESC或F8 索尼笔记本 ESC
致铭主板 F12 苹果笔记本 长按"option"键
盤英主板 ESC 微星笔记本 F11
盤正主板 ESC
冠铭方板 F9
  • 将U盘插入电脑,开机或重启,当开机画面出现时按下快捷键,进入启动项选择界面,这时候我们就将带有“USB”字样的选项设置为U盘启动

WiFi联网

  • 如果是有线网,且网络已经连通,时,则已经联网成功,可以跳过。
  • 在校园里使用校园网是需要验证的,最佳的做法是用手机联网, 使用数据线连接电脑USB接口, 打开手机: 设置连接移动热点和网线共享USB网络共享
  • 检测联网成功:ping www.baidu.com 看到较快的返回值,证明已经联网成功。
查看网卡
1
2
iwctl
device list

执行完以上命令后,获得无线网卡信息:

1
2
3
4
5
                                   Devices                                   *
--------------------------------------------------------------------------------
Name Address Powered Adapter Mode
--------------------------------------------------------------------------------
wlan0 d0:ab:d5:c0:08:00 on phy0 station
转接无线网线
1
2
3
station <无线网卡名> scan
station <无线网卡名> get-networks
station <无线网卡名> connect <网络名>
接下来他会让你输入wifi密码,输入完毕,再执行命令exit退出,网络就连接好了。

硬盘分区

下面给出的是Windwos11Archlinux双系统的安装方案,分区后应当先安装好Windows11再安装Archlinux,这样在构建GrubLinux可以自动探测到windows的启动引导菜单,反之Windwos11安装程序会覆盖LinuxGrub,因此

分区方案

执行lsblk 得到分区结果
1
2
3
4
5
6
7
8
NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
nvme0n1 259:0 0 953.9G 0 disk
├─nvme0n1p1 259:1 0 501M 0 part /boot/efi
├─nvme0n1p2 259:2 0 100G 0 part /
├─nvme0n1p3 259:3 0 8G 0 part [SWAP]
├─nvme0n1p4 259:4 0 790G 0 part /home
├─nvme0n1p5 259:5 0 16M 0 part
└─nvme0n1p6 259:6 0 55.4G 0 part

上图是我当前的分区方案,各部分作用为

  1. nvme0n1p1/boot/efi分区,安装grub、存放Linux kernel 以及 initrd 映像。这些都是启动时必需的东西,单独存在 boot 区便于管理。
  2. nvme0n1p2/分区, 安装Linux系统及其默认软件。
  3. nvme0n1p3swap分区,当内存不够时充当虚拟内存, Linux的swap分区格式为内存交换做过专门优化。
  4. nvme0n1p4/home分区,是用户的文档、视频等文件存放的目录,对于单用户而言这部分要尽可能设置大一些。
  5. nvme0n1p5nvme0n1p6 是安装windows11留出的空间,其中p5windows11安装过程中自动生成的,由于安装windows11的空间不允许小于54G,所以给了它55.4G, 由于我的电脑安装了单独的2242 m2硬盘,windows11可以自动识别,所以只给windows11留一个可以安装启动的空间就可以了。

windows10 调整efi分区大小

由于Windows11随着更新导致功能越来越复杂,失去了刚发布时的简洁,于是决定换回windows10 LTSC. 但是使用原版的window10 安装系统时,其默认建立100Mefi分区,当安装多系统时显然这个空间应当保持在300M以上,如果是从windows11的基础上重新安装windows10, 那系统会直接使用原来300Mefi分区。如果是全新安装一台电脑,则需要在安装windows10的分区前预留出足够的空间,后期用来调整efi分区。

  1. 先安装windows10 LTSC, 进入到windows, 安装傲梅分区
  2. 调整efi分区大小,参考:如何在不丢失数据的情况下调整EFI分区大小?

格式化和挂载分区

1
2
3
4
5
6
7
8
9
10
mkfs.fat -F32 /dev/nvme0n1p1
mkfs.ext4 /dev/nvme0n1p2
mkswap /dev/nvme0n1p3
mkfs.ext4 /dev/nvme0n1p4
mount /dev/nvme0n1p2 /mnt/
mkdir /mnt/boot
mkdir /mnt/boot/efi
mount /dev/nvme0n1p1 /mnt/boot/efi
mkdir /mnt/home
mount /dev/nvme0n1p4 /mnt/home

如果您不熟悉命令行分区操作,可以启动一个Live发行版,使用其内置的磁盘分区工具在图形界面下分区,然后再转回到文本安装Archlinux。推荐基于ArchlinuxManjaro,启动镜像后使用Gparted来分区即可。

如果是重装系统,那,因为里面保存有Windows的启动引导程序,直接挂载就可以了。

扩展硬盘

在电脑的使用过程中,有时候硬盘的容量会不够用,这种情况可以在添加新硬盘以扩容。同时,由于我们的方案中安装的是双系统,且windows作为辅助系统而出现,所以给windows系统分配的固态系统盘刚好满足要求即可。但是,如果在windows中保存文件则其容量显然不够。综上,我们给出一个方案:在电脑中加装一块新硬盘,将其格式化为NTFS格式,这样LinuxWindows都可以读取和写入文件. 在Windows中,系统会自动分配盘符而挂载,在Linux中需要手动设置新的挂载点,设置系统开机自动挂载,方法为:

  1. 使用命令sudo blkid查询新添加硬盘的UUID:
sudo blkid
1
2
3
4
5
6
7
8
/dev/nvme0n1p7: UUID="99c16664-0d77-4911-bfe1-d08a14d5db9e" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="ba86420f-3b39-4604-aa56-7be64a51ff24"
/dev/nvme0n1p5: UUID="b4f5ab83-c06d-4f09-86b9-af00fa6acfeb" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="69e0d3e9-ebca-4a91-94ca-1c011f8ca136"
/dev/nvme0n1p3: UUID="5A1B-4E5F" BLOCK_SIZE="512" TYPE="vfat" PARTLABEL="EFI system partition" PARTUUID="aec2b0dc-2d92-4d54-b710-d9f1a40b4ee1"
/dev/nvme0n1p1: BLOCK_SIZE="512" UUID="04A17097256A219A" TYPE="ntfs" PARTUUID="53c32223-c32b-4cfd-9874-66d2b78bf8c9"
/dev/nvme0n1p6: UUID="f6cd758c-87f2-45e8-a641-c49456f059f1" TYPE="swap" PARTUUID="7af559d1-110f-45c0-bf3e-2dc0d985e39c"
/dev/nvme0n1p2: BLOCK_SIZE="512" UUID="5AE068C2E068A64B" TYPE="ntfs" PARTUUID="732d0157-3c76-423d-925c-72191352ba57"
/dev/nvme1n1p1: BLOCK_SIZE="512" UUID="63C1B9F11137E5C9" TYPE="ntfs" PARTLABEL="DATA" PARTUUID="c87d1cf3-4e82-41e3-873b-dbae52e0fdbb"
/dev/nvme0n1p4: PARTLABEL="Microsoft reserved partition" PARTUUID="21015bba-93cf-47e7-b20c-422eeb882ed1"

在上述结果中,我们新增加的硬盘为DATA, 其UUID号为63C1B9F11137E5C9

  1. /etc/fstab最后一行添加挂载信息:
/etc/fstab
1
2
# /dev/nvme1n1
UUID=63C1B9F11137E5C9 /home/feng/DATA ntfs rw,relatime 0 2

经过上述设置后,重启系统后/home/feng/DATA将会自动挂载新的硬盘,同时在启动到Windows时,新的硬盘将被识别为D盘,从而实现了扩容和共享存储空间的目的。也有的人把新的硬盘整体当作/home挂载点,这因人而异,请自己合理规划。参考文章:Linux加装硬盘

换国内源

  1. 国内常用的:选择在,并且是位于中国的12个镜像,然后根据下载速度进行排序,最后将结果覆写到 /etc/pacman.d/mirrorlist 文件

    切换为国内最快的12个ArchLinux源
    1
    2
    reflector --verbose -c China --latest 12 --sort rate --threads 100 --save /etc/pacman.d/mirrorlist
    pacman -Syu

  2. 需要全球最新:下载速度进行排序,并筛选出前5个最近同步的镜像,最后将结果覆写到 /etc/pacman.d/mirrorlist 文件

    全球最新
    1
    2
    reflector --verbose --latest 5 --sort rate --save /etc/pacman.d/mirrorlist
    pacman -Syu

全球最新可以让您将获得最新的系统,但是并不意味在国内速度最快,因为国内镜像源肯定比国外快,但是却不一定是最新的,如果选择国内常用的,那您将获得国内最新的系统。二选一,请您自己决定。 2024年01月19日, 在更新系统时发现reflector返回错误error: no mirrors found, 在问题没有被官方解决前可以使用手动方法切换镜像,对于低频率操作影响不大。

  1. 点击官方镜像源列表网址: https://archlinux.org/mirrorlist/

  2. Country选择框中选择:China

  3. 在最下面点击Generate List按扭

  4. 复制生成的镜像源,粘贴到/etc/pacman.d/mirrorlist ,为了方便读者使用直接上生成的源码:

/etc/pacman.d/mirrorlist
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
##
## Arch Linux repository mirrorlist
## Generated on 2024-02-22
##
## China
#Server = http://mirrors.163.com/archlinux/$repo/os/$arch
#Server = http://mirrors.aliyun.com/archlinux/$repo/os/$arch
#Server = https://mirrors.aliyun.com/archlinux/$repo/os/$arch
#Server = http://mirrors.bfsu.edu.cn/archlinux/$repo/os/$arch
#Server = https://mirrors.bfsu.edu.cn/archlinux/$repo/os/$arch
#Server = http://mirrors.cqu.edu.cn/archlinux/$repo/os/$arch
#Server = https://mirrors.cqu.edu.cn/archlinux/$repo/os/$arch
#Server = http://mirrors.hit.edu.cn/archlinux/$repo/os/$arch
#Server = https://mirrors.hit.edu.cn/archlinux/$repo/os/$arch
#Server = http://mirrors.jlu.edu.cn/archlinux/$repo/os/$arch
#Server = https://mirrors.jlu.edu.cn/archlinux/$repo/os/$arch
#Server = http://mirrors.jxust.edu.cn/archlinux/$repo/os/$arch
#Server = https://mirrors.jxust.edu.cn/archlinux/$repo/os/$arch
#Server = http://mirror.lzu.edu.cn/archlinux/$repo/os/$arch
#Server = http://mirrors.neusoft.edu.cn/archlinux/$repo/os/$arch
#Server = https://mirrors.neusoft.edu.cn/archlinux/$repo/os/$arch
#Server = http://mirrors.nju.edu.cn/archlinux/$repo/os/$arch
#Server = https://mirrors.nju.edu.cn/archlinux/$repo/os/$arch
#Server = https://mirrors.njupt.edu.cn/archlinux/$repo/os/$arch
#Server = http://mirror.nyist.edu.cn/archlinux/$repo/os/$arch
#Server = https://mirror.nyist.edu.cn/archlinux/$repo/os/$arch
#Server = https://mirrors.qlu.edu.cn/archlinux/$repo/os/$arch
#Server = http://mirror.redrock.team/archlinux/$repo/os/$arch
#Server = https://mirror.redrock.team/archlinux/$repo/os/$arch
#Server = http://mirrors.shanghaitech.edu.cn/archlinux/$repo/os/$arch
#Server = https://mirrors.shanghaitech.edu.cn/archlinux/$repo/os/$arch
#Server = https://mirrors.sjtug.sjtu.edu.cn/archlinux/$repo/os/$arch
#Server = http://mirrors.tuna.tsinghua.edu.cn/archlinux/$repo/os/$arch
#Server = https://mirrors.tuna.tsinghua.edu.cn/archlinux/$repo/os/$arch
#Server = http://mirrors.ustc.edu.cn/archlinux/$repo/os/$arch
#Server = https://mirrors.ustc.edu.cn/archlinux/$repo/os/$arch
#Server = http://mirrors.wsyu.edu.cn/archlinux/$repo/os/$arch
#Server = https://mirrors.wsyu.edu.cn/archlinux/$repo/os/$arch
#Server = https://mirrors.xjtu.edu.cn/archlinux/$repo/os/$arch
#Server = http://mirrors.zju.edu.cn/archlinux/$repo/os/$arch

安装基础系统

1
2
pacstrap /mnt base base-devel linux linux-firmware
genfstab -U /mnt >> /mnt/etc/fstab

设置系统

切换到安装在硬盘中的系统

1
arch-chroot /mnt

安装必要软件

  • 最小系统必备工具
    1
    pacman -S grub efibootmgr vim neovim wpa_supplicant dhcpcd sudo networkmanager os-prober openssh

    2024年09月01日, 将无线网管理器由iwd切换为wpa_supplicant. 因为后者是networkmanager默认的后端管理程序,最初安装好系统后一直可以正常使用。但是从8月份升级系统后发现蓝牙无法使用,通过一些网络上的方法修复。但是近期又现wifi总是不停的自动断开,相当不稳定,百度后从archlinux 吐槽一下自己刚刚踩到的坑得知是iwdwpa_supplicant冲突了,由于后者默认的原因,同时不再愿意花时间去配置所谓性能更好的iwd, 所以做出了此处调整。如果您一定要使用iwd请参考使用 iwd 作为 NetworkManager 的 WiFi backend进行设置。

可选网络管理器

管理一个无线网络连接需要一个基本的工具。此处据ArchWiki 网络配置/无线网络配置 列出可用选项:

软件 软件包 WEXT nl80211 WEP WPA/WPA2/WPA3 Archiso
wireless_tools wireless_tools yes no yes no yes
iw iw no yes yes no yes
wpa_supplicant wpa_supplicant yes yes no yes yes
iwd iwd no yes no yes yes
  • 压缩软件、下载软件等必备软件
    1
    pacman -S p7zip-natspec unarchiver lzop lrzip arj zip unzip reflector git curl vifm ntfs-3g fastfetch
  • fastfetch 在终端上输出本机信息,另外还有 screenfetch 和 neofetch, 因为 fastfetch 是用 C 语言写的,所以速度极快。
  • 2024年04月14日, 添加压缩软件及次必备软件,以确保后面安装软件解压缩的需要。

启用网络

1
systemctl enable dhcpcd NetworkManager wpa_supplicant

设置root密码

1
passwd

新增用户

1
2
useradd -m -G wheel <用户名>
passwd <用户名>

加入sudo

1
EDITOR=vim visudo

找到 %wheel All=(ALL:ALL) ALL把前面的注释去掉

安装grub引导

1
vim /etc/default/grub

找到 GRUB_DISABLE_OS_PROBER=false 去掉前面的注释(应该是文件的最后一行)

安装引导

1
2
grub-install  --target=x86_64-efi  --efi-directory=/boot/efi  --bootloader-id=ArchLinux
grub-mkconfig -o /boot/grub/grub.cfg

设置语言

1
vim /etc/locale.gen

去掉 en_US.UTF-8zh_CN.UTF-8前的注释,再执行

1
locale-gen

设置时区

1
ln -sf  /usr/share/zoneinfo/Asia/Shanghai  /etc/localtime

设置硬件时间

1
hwclock --systohc --utc

安装桌面环境

桌面环境踩坑日记

2024年03月07日 Archlinux执行更新命令sudo pacman -Syu后桌面环境由Plasma5升级为Plasma6, 其最大的变化是显示服务器由xorg默认改为wayland, 而wayland是下一代显示服务器,比xorg更加现代。如果您的软件失效,多半与wayland有关,不过我个人测试效果尚可。

最初我从Plasma4转到Gnome3是因为Plasma4经常崩溃,但是到了Plasma5就稳定了。在使用Gnome3的过程中,发现它也很优秀,它很干净整洁,没有过多的配置选项,美观独特,但是想要提高工作效率还必须安装一些Gnome3的插件才行,比如hide-top-bardash-to-dock,这两个是必备插件,但是这也成为了它的致命缺点,每次Gnome3大版本升级时,一大批插件就会挂掉,而且不能做到同步更新,插件失效的空白期是相当影响工作效率的。

2024年04月14日 在升级Archlinux时,发现Plasma6彻底漰溃,导致无法工作。唉,好在Gnome45的插件hide-top-bar目前可用了,综合考虑后,由于显示效果上讲Gnome3Plasma 更早支持wayland, 而Plasma6刚刚支持wayland,虽然效果很好,但是刚开始,太不稳定,所以再次回到Gnome3, 工作第一,升级前需要确认好系统的稳定性。

安装Gnome3
1
2
3
sudo pacman -S gnome gdm wqy-microhei gnome-tweaks gnome-console gnome-backgrounds gnome-calculator gnome-calendar gnome-text-editor loupe
sudo echo LANG=zh_CN.UTF-8 > /etc/locale.conf
sudo systemctl enable gdm

执行上述命令后会出现一个选择菜单,由您自己决定安装组件,对于不太确定的组件请选择安装,这样可以避免不必要的麻烦。

Gnome3包括的默认组件(2024年06月10日)
gnome-2048 gnome-info-collect gnome-shell-extension-arc-menu
gnome-appfolders-manager gnome-initial-setup gnome-shell-extension-caffeine
gnome-applets gnome-keybindings gnome-shell-extension-dash-to-dock
gnome-autoar gnome-keyring gnome-shell-extension-dash-to-panel
gnome-backgrounds gnome-klotski gnome-shell-extension-desktop-icons-ng
gnome-bluetooth gnome-latex gnome-shell-extension-fixed-ime-list
gnome-bluetooth-3.0 gnome-logs gnome-shell-extension-gsconnect
gnome-boxes gnome-mahjongg gnome-shell-extension-gsconnect-git
gnome-break-timer gnome-maps gnome-shell-extension-kimpanel-git
gnome-browser-connector gnome-menus gnome-shell-extension-net-speed
gnome-builder gnome-mines gnome-shell-extensions
gnome-calculator gnome-mplayer gnome-shell-extension-vitals
gnome-calendar gnome-multi-writer gnome-shell-extension-weather-oclock
gnome-characters gnome-music gnome-shell-pomodoro
gnome-chess gnome-nettool gnome-shell-pomodoro-debug
gnome-clocks gnome-nibbles gnome-software
gnome-color-manager gnome-notes gnome-sound-recorder
gnome-common gnome-online-accounts gnome-subtitles
gnome-connections gnome-packagekit gnome-sudoku
gnome-console gnome-panel gnome-system-monitor
gnome-contacts gnome-photos gnome-taquin
gnome-control-center gnome-pie gnome-terminal
gnome-desktop gnome-podcasts gnome-tetravex
gnome-desktop-4 gnome-power-manager gnome-text-editor
gnome-desktop-common gnome-recipes gnome-themes-extra
gnome-devel-docs gnome-remote-desktop gnome-tour
gnome-dictionary gnome-robots gnome-tweaks
gnome-disk-utility gnome-screenshot gnome-usage
gnome-epub-thumbnailer gnome-session gnome-user-docs
gnome-firmware gnome-settings-daemon gnome-user-share
gnome-flashback gnome-shell gnome-video-effects
gnome-font-viewer gnome-shell-docs gnome-weather
gnome-games gnome-shell-extension-appindicator
安装KDE-Plasma
1
2
3
sudo pacman -S xorg plasma-desktop kwallet-pam plasma-nm plasma-pa powerdevil firefox spectacle gwenview dolphin konsole
sudo pcaman -S sddm sddm-kcm
sudo systemctl enable sddm.service
  • Simple Desktop Display Manager (SDDM)是一个显示管理器。它是KDE PlasmaLXQt桌面环境推荐的显示管理器。
  • sddm-kcm 软件包(包含在plasma包组 用户组)提供了一个图形用户界面以在Plasma系统设置中配置SDDM
  • SDDM-ArchWiki
Plasma6 默认包括组件(2024年06月10日)
plasma-activities plasma-integration plasma-settings
plasma-activities-stats plasma-meta plasma-settings-debug
plasma-applet-window-buttons plasma-mobile plasma-systemmonitor
plasma-bigscreen-git plasma-mobile-debug plasma-systemmonitor-git
plasma-bigscreen-git-debug plasma-nano-git plasma-thunderbolt
plasma-browser-integration plasma-nano-git-debug plasma-vault
plasma-desktop plasma-nm plasma-wayland-protocols
plasma-disks plasma-pa plasma-welcome
plasma-firewall plasma-pass plasma-workspace
plasma-framework5 plasma-sdk plasma-workspace-wallpapers

安装Nvidia显卡

  1. 安装Nvidia软件

    1
    sudo pacman -S nvidia nvidia-settings

    如果是笔记本电脑则需要按装上nvidia-prime, 它的作用是切换显卡,安装成功之后,如果要使用Nvidia独显,则在相应的命令前加上prime-run即可。比如使用mesa-demo包提供的glxinfo来测试显卡是否安装成功,则使用命令prime-run glxinfo |grep OpenGL, 如查输出Nvidia显卡的信息,则独显安装成功。另外还可以使用nvidia-smi来查看Nvidia独显的使用信息,类似于任务管理器的效果。

  2. 设置环境变量

    /etc/environment
    1
    2
    GBM_BACKEND=nvidia-drm
    __GLX_VENDOR_LIBRARY_NAME=nvidia

  3. 系统启动时载入Nvidia模块

    /etc/mkinitcpio.conf
    1
    MODULES=(nvidia nvidia_modeset nvidia_uvm nvidia_drm)

  4. 继续往下翻,找到HOOKS, 其上面一行为

    /etc/mkinitcpio.conf
    1
    2
    # user and fsck hooks
    HOOKS=(base udev autodetect microcode modconf kms keyboard keymap consolefont block)
    去掉括号中的kms.

  5. 重新生成initramfs

    1
    sudo mkinitcpio -P

执行命令时,会出现“WARNING: Possibly missing firmware for module…”警告信息,这些信息可以忽略,因为它没有什么影响。

  1. 开启DRM, 在配置文件/etc/default/grub中找到GRUB_CMDLINE_LINUX_DEFAULT,修改如下

    /etc/default/grub
    1
    2
    3
    4
    5
    6
    7
    8
    # GRUB boot loader configuration

    #GRUB_DEFAULT=0
    GRUB_DEFAULT="1>2"
    GRUB_TIMEOUT=5
    GRUB_DISTRIBUTOR="Arch"
    GRUB_CMDLINE_LINUX_DEFAULT="loglevel=3 quiet nvidia-drm.modeset=1"
    GRUB_CMDLINE_LINUX=""

  2. 重新生成grub

    1
    2
    sudo grub-mkconfig -o /boot/grub/grub.cfg
    sudo cat /sys/module/nvidia_drm/parameters/modeset

注意:重启后执行第二条命令,如果得到Y,则表示NVIDIA DRM开启成功,否则不成功。

  1. 配置电源管理

    /etc/modprobe.d/nvidia-power-management.conf
    1
    options nvidia NVreg_PreserveVideoMemoryAllocations=1 NVreg_TemporaryFilePath=/var/tmp

  2. 配置Wayland, 如果不启用wayland则自动进入到xorg.

    1
    2
    sudo systemctl enable nvidia-suspend.service nvidia-hibernate.service nvidia-resume.service
    sudo ln -s /dev/null /etc/udev/rules.d/61-gdm.rules

  • 2024年07月02日, 我配置好了我的台式机,其CPUAMD ryzen 7 3700X, 其不带集成显卡,所以只能使用独立的nvidia显卡,而按笔记本的dkms配置,也能正常工作,但不是足够流畅(会出现画面撕裂),按教程配置好独立显卡后,运行良好。
  • 2024年07月08日, 按此教程配置好ThinkpadT490, 工作良好,不再使用dkms方式配置笔记本电脑。

一般笔记本携带的Nvidia显卡,默认并不启动。有些较强显示需求的软件可以单独打开Nvidia,不需要时就默认使用集成显卡,这有利于笔记本电脑节省电量。

1
sudo pacman -S  dkms  nvidia-dkms nvidia-utils glxgears

注意:在我安装完ArchLinux后,原本按nvidia官方的方法配置了显卡,但是发现系统启动后不能正常加载模块,在2024-01-01升级完系统后,更是无法启动系统,这让我误以为滚挂系统但问题绝对不会是nvidia官方显卡的使用方式,但是排查下来发现问题确实还真是它。在没有足够时间研究这个问题的时候,我决定安装Endeavour,结果发现表现良好!于是直接借用了Endeavour的配置方式,使用dkms的方式使用nvidia, 详细技术请参考:DKMSglxgears命令会出现一个转动的齿轮,用来测试独立显卡是否工作。经测试均正常工作。此命令没有实质性作用,测试完成后可以删除。2024年07月08日, dkms一般针对自己定制的内核来安装,如果使用通用的linuxlinux-lts则不宜使用dkms

安装电源管理软件

Endeavour的默认电源管理

1
sudo pacman -S power-profiles-daemon

高级电源管理工具TLP

对于笔记本电脑而而言,需要安装TLP,否则会出现电源消耗过大,风扇逛转,睡眠或休眠后无法唤醒等问题,特别是睡眠无法唤醒问题会严重影响使用体验!下面根据TLP官网记录具体操作步骤:

  1. 安装软件

    1
    2
    sudo pacman -S tlp tlp-rdw smartmontools
    paru --skipreview --noconfirm -S tp_smapi-dkms

  2. 启动服务

    1
    2
    sudo systemctl enable tlp.service
    sudo systemctl enable NetworkManager-dispatcher.service

  3. 屏蔽与TLP冲突的服务

    1
    sudo systemctl mask systemd-rfkill.service systemd-rfkill.socket

ThinkPads only: External Kernel Modulestp_smapi, 显示tlp-stat中的S.M.A.R.T数据smartmontools. 在2024年01月04日发现系统又一次提示登录模块错误,于是判断为这个外加的tp_smapi, 本想直接删除这个模块,但是使用paru找到了其dkms版本,于是通过paru安装了tp_smapi-dkms, 重启后发现不再有模块登录失败的提示。

安装蓝牙服务

1
2
3
sudo pacman -S --needed --noconfirm bluez bluez-utils pipewire-pulse bluedevil blueman
sudo systemctl enable bluetooth.service
sudo systemctl start bluetooth.service

上述命令是启动蓝牙服务,archlinux 默认不启用蓝牙服务。然后修改蓝牙配置文件/etc/bluetooth/main.conf,找到AutoEnable=true 取消注释,使其默认启动蓝牙服务。

1
2
3
sudo pacman -S --needed --noconfirm bluez bluez-utils pipewire-pulse bluedevil blueman
sudo systemctl enable bluetooth.service
sudo systemctl start bluetooth.service

以前的教程中安装的pulseaudio-bluetooth与现在pipewire-pulse冲突,但是当前的pipewire-pulse是自动安装上的,所以从依赖角度讲它是最新的,因此不准备删除,经测试确实效果很好。

安装fwupd升级系统固件()

ThinkPad 可以用fwupd来更新固件,如果您的电脑可以正常工作,请勿执行此操作。

1
2
3
sudo pacman -S fwupd
sudo fwupdmgr get-updates
sudo fwupdmgr update

上述第一行是安装软件fwupd, 第二行查看是否存在更新,如果存在更新,则通过第三行的命令来更新固件,注意更新固件时请保持电脑连接电源。

  • 2023年12月29日, 我执行了固件升级命令sudo fwupdmgr update, 然后我的Thinkpad T490 就更新了固件,然后直接导致了电脑再次无法唤醒睡眠!同时半解决状态的2242固态硬盘变成睡眠也无法识别出来的无法解决状态。重启电脑后直接进入到了Windows11, 在Windows11下安装Lenovo官方ThinkVantage, 然后自动检测后升级相应的BIOS组件后终于恢复了睡眠唤醒。经过这件事情,想告诫同学,如果BIOS工作正常,非必要不升级,如果要升级也请切换到Windows下使用官的固件升级软件处理。

  • 2024年01月30日, 由于升级固件后ArchLinux无法识别2242硬盘,即便是没有升级BIOS前,也是需要休眠后才有识别,使用体验不佳。基于日常办公,Archlinux已经成为我的主力,而Windows11是作为双系统安装的,几乎不使用,所以决定将些2242硬盘做成固态硬盘使用。同时,又测试出,如果在BIOS中开启了CSM兼容模块,则再次出现两个系统都无法休眠唤醒问题,所以需要

退出换根并重启

1
2
exit
reboot

重新启动后拔掉U盘完成安装。


ArchLinux配置流程

基础设置

配置高速DNS

要实现快速上网,选择一个高速稳定的DNS是必须的,经过测试在我当前的环境下的最快配置(IPV4不到1ms)为

厂家 IPV4 IPV6
Cloudflare 1.1.1.1 2606:4700:4700::1111

请读者根据自己的具体网络环境选择对应的DNS服务器: 免费公共 DNS 服务器大全

配置国内镜像源

在安装阶段我们已经配置了镜像源,但那是在Live系统上做的配置,为了方便安装系统和软件。 安装好的ArchLinux默认镜像源也是由安装阶段所设置的,刚刚安装的镜像与Live系统不 一样,它不包括自动选择镜像的程序reflector, 它是一个Python编写的脚本,会自动从 https://archlinux.org/mirrors/status/ 上获取镜像地址,可以通过参数筛选出自己需要的镜像地址。为了方便自己设置,需要先安装一下,然后切换到自己想要的源就可以了。

切换为国内最快的12个ArchLinux源
1
2
sudo reflector --verbose -c China --latest 12 --sort rate --threads 100 --save /etc/pacman.d/mirrorlist
sudo pacman -Syu

配置国内CN源

Arch Linux 中文社区仓库是由 Arch Linux 中文社区驱动的非官方用户仓库。包含中文用户常用软件、工具、字体/美化包等。

  1. /etc/pacman.conf 文件末尾添加以下两行

    /etc/pacman.conf
    1
    2
    [archlinuxcn]
    Server = https://repo.archlinuxcn.org/$arch

  2. 安装 archlinuxcn-keyring 包以导入 GPG key

    安装archlinuxcn-keyring
    1
    2
    3
    sudo pacman -Syu
    sudo pacman-key --lsign-key "farseerfc@archlinux.org"
    sudo pacman -S archlinuxcn-keyring

pacman -Sy archlinuxcn-keyring 出错
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
$ sudo pacman -Sy archlinuxcn-keyring
:: Synchronizing package databases...
core is up to date
extra is up to date
multilib is up to date
archlinuxcn 3.4 MiB 964 KiB/s 00:04 [#################################] 100%
resolving dependencies...
looking for conflicting packages...

Package (1) New Version Net Change Download Size

archlinuxcn/archlinuxcn-keyring 20230923-1 0.36 MiB 0.26 MiB

Total Download Size: 0.26 MiB
Total Installed Size: 0.36 MiB

:: Proceed with installation? [Y/n]
:: Retrieving packages...
archlinuxcn-keyring-202309... 262.7 KiB 949 KiB/s 00:00 [#################################] 100%
(1/1) checking keys in keyring [#################################] 100%
(1/1) checking package integrity [#################################] 100%
error: archlinuxcn-keyring: signature from "Jiachen YANG (Arch Linux Packager Signing Key) <farseerfc@archlinux.org>" is marginal trust
:: File /var/cache/pacman/pkg/archlinuxcn-keyring-20230923-1-any.pkg.tar.zst is corrupted (invalid or corrupted package (PGP signature)).
Do you want to delete it? [Y/n]
error: failed to commit transaction (invalid or corrupted package (PGP signature))
Errors occurred, no packages were upgraded.

解决方法为:

1
sudo pacman-key --lsign-key "farseerfc@archlinux.org"

  1. 安装 archlinuxcn-mirrorlist-git 包可以获得一份镜像列表

    安装archlinuxcn-mirrorlist-git
    1
    sudo pacman -S archlinuxcn-mirrorlist-git
    安装完成后,会生成文件/etc/pacman.d/archlinuxcn-mirrorlist, 其包含最新的国内镜像。

  2. 在 pacman.conf 中直接引入archlinuxcn-mirrorlist

    /etc/pacman.conf末尾追加,同时注释掉Server
    1
    2
    3
    [archlinuxcn]
    #Server = https://repo.archlinuxcn.org/$arch
    Include = /etc/pacman.d/archlinuxcn-mirrorlist

  3. 编辑/etc/pacman.d/archlinuxcn-mirrorlist文件,去掉要引用的源前面的注释符即可。

配置arch4edu源

Arch4edu是面向高校用户推出的非官方软件仓库,支持Arch LinuxArch Linux ARM, 主要包含高校用户常用的科研、教学及开发软件。

  1. 导入 GPG key

    1
    2
    3
    sudo pacman-key --recv-keys 7931B6D628C8D3BA
    sudo pacman-key --finger 7931B6D628C8D3BA
    sudo pacman-key --lsign-key 7931B6D628C8D3BA

  2. /etc/pacman.conf文件末尾添加以下内容

    1
    2
    [arch4edu]
    Server = https://mirrors.cernet.edu.cn/arch4edu/$arch

    上述镜像源是CERNET-校园网联合镜像站(mirrorz-302智能选择), 由于他的自动选择属性以及使用sudo的安全属性,所以我设置了这个镜像站点。

  3. 安装pkgstats帮助了解我们维护包的均势。

    1
    sudo pacman -S pkgstats

  4. 其他arch4edu镜像:arch4edu-mirrorlist

Arch4edu 一个面向全球高校用户的社区源, 初衷是实验室的服务器都有装同一批软件的需求,后来干脆就做成软件源了. 支持 Arch Linux 和 Arch Linux ARM, 主要包含高校用户常用的科研、教学及开发软件。现在arch4edu主要涵盖以下方向的包:

  • 机器学习工具:tensorflow, caffe, torch等等
  • IDE及编辑器:android-studio, pycharm, vs code, sublime等等
  • Android开发:android-studio, android-sdk, android-ndk等等
  • 语音信号处理:kaldi, cmusphinx, opensmile等等
  • 图像处理:opencv-git
  • 通用:anaconda, zotero, atlas-lapack, openblas等等
共104个包。理论上说至少大学生常用的,不限于上述方向的包都可以加,欢迎大家发Package Request. 现在的更新频率是日更。由于结构是仿照archlinuxcn搭建的,所以git版本的包会及时更新。

安装中文字体

安装windows10下拷贝来的fonts字体、founder及adobe 等到系统的指定目录/usr/share/fonts/:

1
2
3
4
sudo cp -r ./Fonts/Adobe/ /usr/share/fonts/
sudo cp -r ./Fonts/windows10/ /usr/share/fonts/
sudo cp -r ./Fonts/founder_GBK/ /usr/share/fonts/
sudo fc-cache -vf

设置系统为中文

要设置整个系统使用的区域设置,需要在 /etc/locale.conf 中写入 LANG 变量,以下的 zh_CN.UTF-8 应为 /etc/locale.gen 中某个未注释条目的第一列:

/etc/locale.conf
1
2
#LANG="C.UTF-8"
LANG=zh_CN.UTF-8

由于前面已经配置好了语言,据Local-ArchLinux, 当做完以上配置,同时重起系统后设置区域和语言语言设置成简体中文, 后系统仍然不能完全汉化,对于KDE Plasma, 这一点本人测试成功。

全局配置gitgithub.com镜像

  1. 安装git

    前面已经安装,若否请执行命令:
    1
    pacman -S git curl

  2. 修改全局配置文件~/.gitconfig

    ~/.gitconfig
    1
    2
    3
    4
    5
    6
    7
    8
    9
    [user]
    email = fengzhenhua@outlook.com
    name = fengzhenhua
    : [url "https://521github.com/"]
    [url "https://githubfast.com/"]
    ; [url "https://kkgithub.com/"]
    ; [url "https://github.hscsec.cn/"]
    ; [url "https://gitclone.com/github.com/"]
    insteadOf = https://github.com/

注意:此配置全局gitgithub.com镜像是最简单的一劳永逸的方法,稍微麻烦但更加有效的方法参考:使用Git下载Github资源的有效方法 . 使用时请将我的配置中的emailname替换成您自己的github帐号,方便使用git clone git@github.com:等命令。

安装paruyay

安装paruyay, 最新的paru表现更好,建议安装。

  1. 安装paru
1
sudo pacman --needed --noconfirm -S paru
  1. 使用paru时跳过审阅并自动确认安装
1
paru --skipreview --needed --noconfirm -S foobar
  1. 关闭默认审阅流程的方法: 在配置文件/etc/paru.conf 内增加SkipReview。参考 Paru默认关闭审阅流程
  • archlinuxcn源安装
1
sudo pacman --needed --noconfirm -S yay
  • 编译安装
1
2
3
4
pacman --needed --noconfirm -S git base-devel
git clone https://aur.archlinux.org/yay-bin.git
cd yay-bin
makepkg -si
  • 源码安装
1
2
3
git clone https://aur.archlinux.org/yay.git
cd yay
makepkg -si

在2022年7月20日安装ArchLinux时发现如此安装不成功,解决方案参考:yay安装失败的解决方案。使用go语言换源解决,临时换源解决方案代码如下

1
2
3
4
5
6
$ go env -w GO111MODULE=on
$ go env -w GOPROXY=https://goproxy.cn,direct
$ export GO111MODULE=on
$ export GOPROXY=https://goproxy.cn
$ makepkg -si

配置paruyay多线程下载

使用本人定制的axel多线程下载工具可以提高下载速度,获得更佳的使用体验:

配置Paru和yay多线程下载
1
2
3
4
5
6
7
sudo curl -o ParuAxel.7z https://gitlab.com/fengzhenhua/zipconf/-/raw/main/ParuAxel.7z\?inline\=false
unar ParuAxel.7z
cd ./ParuAxel
chmod +x install.sh
./install.sh
cd ..
rm -rf ParuAxel.7z ParuAxel

Paru 高级用户配置

基本命令

  • paru <用户输入>:搜索并安装“用户输入”
  • paru -:paru -Syu 的别名
  • paru -Sua:仅升级 AUR 包。
  • paru -Qua:打印可用的 AUR 更新
  • paru -Gc <用户输入>:显示“用户输入”的 AUR 评论

编辑 PKGBUILD (对于高级用户)

如果你是一个有经验的 Linux 用户,你可以通过 paru 编辑 AUR 包。要做到这一点,你需要在 paru 配置文件中启用该功能,并设置你所选择的文件管理器。在此例中,我将使用配置文件中的默认值,即 vifm 文件管理器。如果你还没有使用过它,你可能需要安装它。

  • 安装vifm

    1
    sudo pacman --needed --noconfirm -S vifm

  • 修改配置文件/etc/paru.conf,取消注释

    /etc/paru.conf
    1
    2
    3
    4
    [bin]
    FileManager = vifm
    #MFlags = --skippgpcheck
    #Sudo = doas

系统会提示你审查该软件包→输入 Y 并按下回车→从文件管理器中选择 PKGBUILD →按下回车查看软件包→做出修改。你所做的任何改变都将是永久性的,下次升级软件包时,你的改变将与上游软件包合并。

配置桌面环境

桌面环境选择请参考:8 款最佳 Linux 桌面环境推荐(2024)

  • 安装gnome3必备插件

在安装gnome插件前,需要先安装浏览器插件才能通过https://extensions.gnome.org 安装插件。

1
paru --needed --noconfirm -S gnome-browser-connector gnome-shell-extension-hidetopbar-git gnome-shell-extension-dash-to-dock gnome-shell-extension-kimpanel-git gnome-shell-extension-blur-my-shell-git
  • 2022年11月01日插件chrome-gnome-shell更名为gnome-browser-connector
  • gnome-browser-connector 用于配合firefox安装gnome拓展
  • hide-top-bar 自动隐藏顶部的顶栏
  • dash-to-dock 类似于苹果系统的程序坞
  • kimpanel 输入法面板,提供与苹果系统相当的界面
  • blue-my-shell 令顶栏和程序坞随系统变色,同时按下win徽标键后界面与苹果系统相当
  • 安装Gnome 主题
1
2
3
4
5
6
7
8
9
10
11
12
paru --skipreview --needed --noconfirm -S whitesur-icon-theme whitesur-cursor-theme-git
git clone https://github.com/vinceliuice/WhiteSur-gtk-theme.git --depth=1
git clone https://github.com/vinceliuice/WhiteSur-wallpapers.git
git clone https://github.com/vinceliuice/grub2-themes.git
./WhiteSur-gtk-theme/install.sh
./WhiteSur-gtk-theme/install.sh -l -c Light
./WhiteSur-gtk-theme/install.sh --shell -i apple
./WhiteSur-wallpapers/install-wallpapers.sh
./WhiteSur-gtk-theme/tweaks.sh -f alt
sudo ./WhiteSur-gtk-theme/tweaks.sh -g
sudo ./WhiteSur-wallpapers/install-gnome-backgrounds.sh
sudo ./grub2-themes/install.sh -t whitesur
  • 2024年09月03日, 升级WhiteSur-gtk-theme之后发现修改部分较多,其中install.sh -i apple调整为install.sh --shell -i apple
./install.sh [OPTIONS...] (点击打开)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79

-d, --dest DIR
Set destination directory. Default is '/home/USER/.themes'

-n, --name NAME
Set theme name. Default is 'WhiteSur'

-o, --opacity [normal|solid]
Set theme opacity variants. Repeatable. Default is all variants

-c, --color [Light|Dark]
Set theme color variants. Repeatable. Default is all variants

-a, --alt [normal|alt|all]
Set window control buttons variant. Repeatable. Default is 'normal'

-t, --theme [default|blue|purple|pink|red|orange|yellow|green|grey|all]
Set theme accent color. Repeatable. Default is BigSur-like theme

-m, --monterey
Set to MacOS Monterey style.

-N, --nautilus [stable|normal|mojave|glassy]
Set Nautilus style. Default is BigSur-like style (stabled sidebar)

-l, --libadwaita
Install theme into gtk4.0 config for libadwaita. Default is dark version

-HD, --highdefinition
Set to High Definition size. Default is laptop size

--shell, --gnome-shell
Tweaks for gnome-shell. Options:

1. -i, -icon [apple|simple|gnome|ubuntu|tux|arch|manjaro|fedora|debian|void|opensuse|popos|mxlinux|zorin|budgie|gentoo]
Set gnome-shell panel 'Activities' icon. Default is 'standard'

2. -b, -background [default|blank|IMAGE_PATH]
Set gnome-shell background image. Default is BigSur-like wallpaper

3. -p, -panelopacity [default|30|45|60|75]
Set gnome-shell panel transparency. Default is 15%

4. -h, -height [default|smaller|bigger]
Set gnome-shell panel height size. Default is 32px

5. -g, -general, -normal
Set gnome-shell show apps button style to general/normal. Default is BigSur

6. -s, -smaller
Set gnome-shell font size to smaller (10pt). Default is 11pt

--round, --roundedmaxwindow
Set maximized window to rounded. Default is square

--right, --rightplacement
Set Nautilus title button placement to right. Default is left

--black, --blackfont
Set panel font color to black. Default is white

--darker, --darkercolor
Install darker 'WhiteSur' dark themes.

--nord, --nordcolor
Install 'WhiteSur' Nord ColorScheme themes.

--dialog, --interactive
Run this installer interactively, with dialogs.

--silent-mode
Meant for developers: ignore any confirm prompt and params become more strict.

-r, --remove, -u, --uninstall
Remove all installed WhiteSur themes.

-h, --help
Show this help.

2024年08月02日, paru更新时提示whitesur-icon-theme-git无人维护,于是更新为whitesur-icon-theme. 2024年08月05日, firefoxalt主题,最上面为地址栏,下面是并排的标签列,更中合理,所以本文默认采用了firefox alt主题。 2024年08月25日, 修复Nautilus主题关闭、最大化、最小化等按钮无法切换为苹果主题的bug, 方法即是./WhiteSur-gtk-theme/install.sh -l, 默认安装暗色主题,要安装明亮主题执行./WhiteSur-gtk-theme/install.sh -l -c Light

Paru 安装Sonoma皮肤
1
2
3
4
5
paru --skipreview --needed --noconfirm -S whitesur-icon-theme-git
paru --skipreview --needed --noconfirm -S whitesur-cursor-theme-git
git clone --depth 1 https://github.com/vinceliuice/MacSonoma-kde.git
cd ./MacSonoma-kde
./install.sh

存在的问题:

  1. sddm主题不能正常工作,和之前遇到的问题类似,但是使用默认的Breeze 微风主题,更改其背景图片为MacSonoma-kde/sddm/images/Background-Light.jpg后效果相差不大,区别在登录框Breeze 微风是直角,而MacSonoma-kde的为圆解,这点等待MacSonoma-kde主题官方修复。

  2. grub尚没有推出MacSonoma-kde对应的主题, 所以导致相似度不能100%还原,于是也可以采用类似的方法安装whitesurgrub主题,然后将背景换成Sonoma的背景即可。

  3. 替换grub-WhiteSur主题的背景图片为MacSonoma-kde/sddm/images/Background-Light.jpg

    1
    sudo cp ~/MacSonoma-kde/sddm/images/Background-Light.jpg /boot/grub/themes/whitesur/background.jpg

  4. 系统设置颜色和主题图标WhiteSur-light, 这样子系统显示为通常的Mac图标。

  • 2024年03月16日发现在Plasma6的系统配置全局主题获取新全局主题中出现了Apple Sonoma LightApple Sonoma Dark两款高仿苹果主题,于是对两款主题进行了测试,发现基本上可用,但是细节上需要调整。

  • 2024年03月08日, archlinux 系统升级后KDE-Plasma5自动升级为KDE-Plasma6, WhitSur-kde主题有些不适配Plasma6,于是决定删除WhitSur主题,使用Plasma6的默认主题。

对于桌面环境的配置,主要是配置MacOSWhitSur主题,由于已经配置了ArchLinuxCN源和安装了Paru也可以使用Aur所以使用PacmanParu来安装皮肤比自行下载手动安装要好。本教程使用Aur源安装:

paru安装WhitSur皮肤
1
2
3
4
5
6
7
8
9
10
11
paru --skipreview --needed --noconfirm -S plasma5-themes-whitesur-git
paru --skipreview --needed --noconfirm -S whitesur-icon-theme-git
paru --skipreview --needed --noconfirm -S whitesur-cursor-theme-git
git clone --depth 1 https://github.com/vinceliuice/grub2-themes.git
git clone --depth 1 https://github.com/vinceliuice/WhiteSur-gtk-theme.git
chmod +x ./grub2-themes/*.sh
chmod +x ./WhiteSur-gtk-theme/*.sh
cd ./grub2-themes/
./install.sh -b -t whitesur -i whitesur -s 1080p
cd ../WhiteSur-gtk-theme
./tweaks.sh -f

有时候在系统更新后sddm主题不再生效,此时需要重新安装一下sddm主题,而sddm主题位于 WhiteSur-kde中的文件夹sddm中,于是先克隆下这个文件目录,即

1
2
3
git clone https://kkgithub.com/vinceliuice/WhiteSur-kde.git
cd ./WhiteSur-kde/sddm
sudo ./install

之后sddm主题就再次启用了。

一般安装好后系统自动配置好了,同时如果有更新也可以及时更新。需要做的工作:

  • 启用全局主题: 系统设置外观全局主题WhitSur(选中桌面和窗口布局)。 之后系统的桌面就配置成WhitSur主题了,但是桌面背景还是黑色的,说明这几个包设计的不是很完善,这时只要右键设置背景图片就可以了。
  • 启用登录屏: 设置开机与关机登录屏幕(SDDM), 选择WhitSur
  • 配置启动Latte停靠栏: 在Latte上右键→配置Latte,选中开机启动。然后对应布局编辑器选择WhitSur
  • 配置状态状态栏,安装好主题后状态栏并没有配置好,配置步骤:状态栏上右键编辑模式更多选项最大化面板 ,否则状态栏上的内容会显示不出来。
  • 配置Fcitx5使用自带皮肤,完成第一步时其实就可以了。如果第一步没有输入法面板, 那需要添加系统托盘,此时显示就正常了。参考KDE下设置Fcitx5
  • 手动安装WhitSur主题请参考: ArchLinux安装Plasma5
  • 由于Grub主题使用paru安装时不能自动配置,所以改成了手动安装。而WhiteSur-gtk-theme仅用来设置firefox主题,需要再安装主题。

关闭文件索引

由于文件索引会消耗大量的资源,这就导致了电脑温度过高,风扇逛转不停,而现实的使用过程中对于搜索的要求并不高,一般人都能够合理的安排自己的文件位置。于是关闭这项服务可以更好的发挥计算机性能,总体来讲利大于弊。

  1. 使用gsettings禁用tracker-miner应用
    1
    2
    gsettings set org.freedesktop.Tracker3.Miner.Files crawling-interval -2
    gsettings set org.freedesktop.Tracker3.Miner.Files enable-monitors false

在Gnome45之前是命令Tracker, 之后是Tracker3, 于是2024年04月15日之后的新系统则用最新的命令。

  1. 或者禁止tracker-*软件启动
    1
    2
    sudo sed -i "s/X-GNOME-Autostart-enabled=true/X-GNOME-Autostart-enabled=false/g" /etc/xdg/autostart/tracker-*.desktop
    tracker reset -sr

在Gnome45之前清除索引命令为tracker reset --hard, 之后的命令为tracker3 reset -sr, 于是2024年04月15日之后的新系统必用最新的命令。

  1. 使用命令关闭

    1
    2
    3
    balooctl disable
    balooctl suspend
    balooctl status

  2. 通过图形界面关闭:点击系统设置搜索文件搜索去掉启用文件索引前的对号→右下角应用

删除多余的EFI启动项

有时候重装系统的时候为了保留原来的启动项而不对EFI分区重新格式化,这导致了每安装一次系统都会在EFI分区留下一下之前的启动项。这时为了纯净可以删除之前的启动项,不过一定要仔细判别,不要删错了文件。文件目录在

1
/boot/efi/EFI

Linux修改启动选项grub

/boot/grub/grub.cfg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### WindowsManager删除多余的启动项 ###

1. 打开电脑并进入电脑桌面。
2. Win+R调出运行窗口,输入msconfig。
3. 点击打开,进入系统配置,然后打开引导选项卡。
4. 在这里,您可以看到所有的启动项。选中不需要的启动项,点击下面的删除按钮即可。
5. 删除完成后,点击确定并重启计算机,多余的启动项就不会再出现。

### BEGIN /etc/grub.d/00_header ###
insmod part_gpt
insmod part_msdos
if [ -s $prefix/grubenv ]; then
load_env
fi
if [ "${next_entry}" ] ; then
set default="${next_entry}"
set next_entry=
save_env next_entry
set boot_once=true
else
set default="0"
fi

if [ x"${feature_menuentry_id}" = xy ]; then
menuentry_id_option="--id"
else
menuentry_id_option=""
fi

export menuentry_id_option

if [ "${prev_saved_entry}" ]; then
set saved_entry="${prev_saved_entry}"
save_env saved_entry
set prev_saved_entry=
save_env prev_saved_entry
set boot_once=true
fi

function savedefault {
if [ -z "${boot_once}" ]; then
saved_entry="${chosen}"
save_env saved_entry
fi
}

function load_video {
if [ x$feature_all_video_module = xy ]; then
insmod all_video
else
insmod efi_gop
insmod efi_uga
insmod ieee1275_fb
insmod vbe
insmod vga
insmod video_bochs
insmod video_cirrus
fi
}

if [ x$feature_default_font_path = xy ] ; then
font=unicode
else
insmod part_gpt
insmod ext2
search --no-floppy --fs-uuid --set=root 143fbcc6-9ae2-4a88-ad96-12c7f3de3d95
font="/usr/share/grub/unicode.pf2"
fi

if loadfont $font ; then
set gfxmode=auto
load_video
insmod gfxterm
set locale_dir=$prefix/locale
set lang=zh_CN
insmod gettext
fi
terminal_input console
terminal_output gfxterm
insmod part_gpt
insmod ext2
search --no-floppy --fs-uuid --set=root 143fbcc6-9ae2-4a88-ad96-12c7f3de3d95
insmod gfxmenu
loadfont ($root)/usr/share/grub/themes/monterey-grub-theme/Poppins-14.pf2
loadfont ($root)/usr/share/grub/themes/monterey-grub-theme/Poppins-16.pf2
loadfont ($root)/usr/share/grub/themes/monterey-grub-theme/Poppins-18.pf2
loadfont ($root)/usr/share/grub/themes/monterey-grub-theme/Poppins-20.pf2
loadfont ($root)/usr/share/grub/themes/monterey-grub-theme/Poppins-48.pf2
loadfont ($root)/usr/share/grub/themes/monterey-grub-theme/terminus-12.pf2
loadfont ($root)/usr/share/grub/themes/monterey-grub-theme/terminus-14.pf2
loadfont ($root)/usr/share/grub/themes/monterey-grub-theme/terminus-16.pf2
insmod png
set theme=($root)/usr/share/grub/themes/monterey-grub-theme/theme.txt
export theme
if [ x$feature_timeout_style = xy ] ; then
set timeout_style=menu
set timeout=5
# Fallback normal timeout code in case the timeout_style feature is
# unavailable.
else
set timeout=5
fi
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/10_linux ###
menuentry 'Arch Linux' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-143fbcc6-9ae2-4a88-ad96-12c7f3de3d95' {
load_video
set gfxpayload=keep
insmod gzio
insmod part_gpt
insmod ext2
search --no-floppy --fs-uuid --set=root 143fbcc6-9ae2-4a88-ad96-12c7f3de3d95
echo '载入 Linux linux ...'
linux /boot/vmlinuz-linux root=UUID=143fbcc6-9ae2-4a88-ad96-12c7f3de3d95 rw loglevel=3 quiet
echo '载入初始化内存盘...'
initrd /boot/initramfs-linux.img
}
submenu 'Arch Linux 的高级选项' $menuentry_id_option 'gnulinux-advanced-143fbcc6-9ae2-4a88-ad96-12c7f3de3d95' {
menuentry 'Arch Linux,Linux linux' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-linux-advanced-143fbcc6-9ae2-4a88-ad96-12c7f3de3d95' {
load_video
set gfxpayload=keep
insmod gzio
insmod part_gpt
insmod ext2
search --no-floppy --fs-uuid --set=root 143fbcc6-9ae2-4a88-ad96-12c7f3de3d95
echo '载入 Linux linux ...'
linux /boot/vmlinuz-linux root=UUID=143fbcc6-9ae2-4a88-ad96-12c7f3de3d95 rw loglevel=3 quiet
echo '载入初始化内存盘...'
initrd /boot/initramfs-linux.img
}
menuentry 'Arch Linux, with Linux linux (fallback initramfs)' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-linux-fallback-143fbcc6-9ae2-4a88-ad96-12c7f3de3d95' {
load_video
set gfxpayload=keep
insmod gzio
insmod part_gpt
insmod ext2
search --no-floppy --fs-uuid --set=root 143fbcc6-9ae2-4a88-ad96-12c7f3de3d95
echo '载入 Linux linux ...'
linux /boot/vmlinuz-linux root=UUID=143fbcc6-9ae2-4a88-ad96-12c7f3de3d95 rw loglevel=3 quiet
echo '载入初始化内存盘...'
initrd /boot/initramfs-linux-fallback.img
}
}

### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/20_linux_xen ###
### END /etc/grub.d/20_linux_xen ###

### BEGIN /etc/grub.d/30_os-prober ###
menuentry 'Windows Boot Manager (在 /dev/nvme0n1p1)' --class windows --class os $menuentry_id_option 'osprober-efi-2B71-22FB' {
insmod part_gpt
insmod fat
search --no-floppy --fs-uuid --set=root 2B71-22FB
chainloader /EFI/Microsoft/Boot/bootmgfw.efi
}
### END /etc/grub.d/30_os-prober ###

### BEGIN /etc/grub.d/30_uefi-firmware ###
menuentry 'UEFI Firmware Settings' $menuentry_id_option 'uefi-firmware' {
fwsetup
}
### END /etc/grub.d/30_uefi-firmware ###

### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
### END /etc/grub.d/40_custom ###

### BEGIN /etc/grub.d/41_custom ###
if [ -f ${config_directory}/custom.cfg ]; then
source ${config_directory}/custom.cfg
elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then
source $prefix/custom.cfg
fi
### END /etc/grub.d/41_custom ###

Linux下EFIBOOTMGR的使用,删除UEFI主板多余的启动项

用uefi装过几次系统后,uefi启动项就会多出好多启动项。这东西格硬盘也不好用,我们借助efibootmgr可以编辑启动项,事实上我的电脑正是这样操作的:

1
2
3
4
5
6
7
8
9
10
11
12
# efibootmgr
BootCurrent: 0008
Timeout: 5 seconds
BootOrder: 0008,0007,0006,0004,0005,0000,0001,0002
Boot0000* UEFI KBG40ZNS128G NVMe KIOXIA 128GB 80SPG7BZQ2B1 1
Boot0001* ONBOARD NIC (IPV4)
Boot0002* ONBOARD NIC (IPV6)
Boot0004* Manjaro
Boot0005* Windows Boot Manager
Boot0006* endeavouros
Boot0007* -id
Boot0008* ArchLinux

删除一个引导项 Manjaro

1
efibootmgr -b 0004 -B

添加一个引导项

1
#efibootmgr -c -w -L “BootOptionName” -d /dev/sda -p 1 -l \\EFI\\asianux\\elilo.efi

其中-d 参数后面是系统所在的硬盘设备名称,例如/dev/hda/dev/hdb -p 参数是vfat 分区的分区编号/dev/hda1-p 1 /dev/sda2-p 2 -l 参数后面是该引导项指向的efi 启动文件在该分区上的位置。请注意使用“\”来表示目录的分级。 例如:/EFI/asianux/elilo.efi 应写成:\\EFI\\asianux\\elilo.efi

解决LinuxWindows时间不一致问题

日常工作中多数人使用的是Windows, 当使用Linux作为工作的主力时,安装双系统是一个最佳的选择,但是双系统会导致LinuxWindows时间不一致问题。

GMT:Greenwich Mean Time,即格林尼治标准时间,也就是世界时。GMT 以地球自转为基础的时间计量系统,但由于地球自转不均匀,导致 GMT 不精确,现在已经不再作为世界标准时间使用。

UTC:Universal Time Coordinated,即协调世界时。UTC 是以原子时秒长为基础,在时刻上尽量接近于 GMT 的一种时间计量系统。为确保 UTC 与 GMT 相差不会超过 0.9 秒,在有需要的情况下会在 UTC 内加上正或负闰秒。UTC 现在作为世界标准时间使用。

RTC:Real-Time Clock,即实时时钟,在计算机领域作为硬件时钟的简称。

世界上不同地区所在的时区是不同的,这些时区决定了当地的本地时间。比如北京处于东八区,即北京时间为 UTC + 8,如果 UTC 时间现在是上午 6 点整,那么北京时间为 14 点整。

Windows 与 Linux 看待硬件时间的方式不同。Windows 把电脑的硬件时钟(RTC)看成是本地时间,即 RTC = Local Time,Windows 会直接显示硬件时间;而 Linux 则是把电脑的硬件时钟看成 UTC 时间,即 RTC = UTC,那么 Linux 显示的时间就是硬件时间加上时区。

解决办法

既然知道了问题原因,我们就知道如何去解决,大概思路分为两种,一是让 Windows 认为硬件时钟是 UTC 时间,二是让 Linux 认为硬件时钟是本地时间。

  1. 以管理员身份打开 「PowerShell」,输入以下命令:
1
> Reg add HKLM\SYSTEM\CurrentControlSet\Control\TimeZoneInformation /v RealTimeIsUniversal /t REG_DWORD /d 1
  1. 或者打开「注册表编辑器」,定位到计算机目录:
1
\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation
  1. 新建一个 DWORD 类型,名称为 RealTimeIsUniversal 的键,并修改键值为 1 即可。

这里大家可以根据自己 Linux 发行版的方法来修改。我这里给出现在大多数发行版由 timedatectl 来管理时间的修改方法。

在终端中,输入以下命令:

1
$ timedatectl set-local-rtc 1 --adjust-system-clock

这两种方法中,本人推荐第一种方法,修改 Windows 的时间管理。因为在 Linux 系统中修改后,输入 timedatectl 命令后,会出现警告,提示你使用 RTC 时钟会导致一些程序错误;并且 Windows 也在更改时间管理方式为 UTC 时间。

系统的稳定性保障

考虑到ArchLInux 滚动升级的特性,在工作环境中我们需要一个更加稳定的系统,在前面的安装过程中虽然有锁定桌面环境的技巧支持,但是并没有锁定内核,因为内核滚挂的可能性不太大,但也不是没有。为了确保系统滚挂,需要再追加一个稳固系统的方法:安装长期支持版内核linux-lts, 在系统滚挂的时候增加一个可选择的保障方案。

安装linux-lts
1
2
sudo pacman -S linux-lts  linux-lts-header
sudo grub-mkconfig -o /boot/grub/grub.cfg

第1条命令安装lts内核,第2条命令重新生成grub, 这样在启动的时候就可以选择高级lts内核启动。

打开/etc/pacman.conf文件,找到IgnorPkgIgnoreGroup, 在等号后添加上桌面环境软件,确保工作环境的稳定可靠。

/etc/pacman.conf
1
2
3
# Pacman won't upgrade packages listed in IgnorePkg and members of IgnoreGroup
#IgnorePkg =
IgnoreGroup = gnome gnome-extra plasma kde-applications

虽然长期支持版比较稳定,但是有时候滚动升级导致严重的问题后需要回滚系统。在问题解决前不应当升级,同时在工作过程中也会安装一些必要的软件,此时保持软件和当前版本的系统相对应是一个相当稳定的解决方案。综合考虑后,使用锁定升级日期的方法,既可以回滚到稳定版本的最新状态,又可以确保任意安装相应版本的软件。

1. 在pacman配置文件中追加上指定日期的镜像

/etc/pacman.d/mirrorlist
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

################################################################################
################# Arch Linux mirrorlist generated by Reflector #################
################################################################################

# With: reflector --verbose -c China --latest 12 --sort rate --threads 100 --save /etc/pacman.d/mirrorlist
# When: 2024-03-08 12:06:34 UTC
# From: https://archlinux.org/mirrors/status/json/
# Retrieved: 2024-03-08 12:06:30 UTC
# Last Check: 2024-03-08 11:46:39 UTC
#
# Server = http://archive.archlinux.org/repos/2024/09/18/$repo/os/$arch
# Server = http://archive.archlinux.org/repos/2024/09/18/$repo/os/$arch
# Server = https://america.archive.pkgbuild.com/repos/2024/09/19/$repo/os/$arch
# Server = https://asia.archive.pkgbuild.com/repos/2024/09/19/$repo/os/$arch
# Server = https://europe.archive.pkgbuild.com/repos/2024/09/19/$repo/os/$arch
# Server = https://arch-archive.tuna.tsinghua.edu.cn/2024/09-16/$repo/os/$arch
# Server = https://mirrors.bfsu.edu.cn/archlinux-archive/2024/09-16/$repo/os/$arch
Server = http://mirrors.tuna.tsinghua.edu.cn/archlinux/$repo/os/$arch
Server = https://mirrors.neusoft.edu.cn/archlinux/$repo/os/$arch
Server = https://mirrors.jlu.edu.cn/archlinux/$repo/os/$arch
Server = http://mirrors.jlu.edu.cn/archlinux/$repo/os/$arch
Server = http://mirrors.ustc.edu.cn/archlinux/$repo/os/$arch
Server = https://mirrors.tuna.tsinghua.edu.cn/archlinux/$repo/os/$arch
Server = http://mirrors.shanghaitech.edu.cn/archlinux/$repo/os/$arch
Server = https://mirrors.xjtu.edu.cn/archlinux/$repo/os/$arch
Server = rsync://mirrors.neusoft.edu.cn/archlinux/$repo/os/$arch
Server = rsync://rsync.mirrors.ustc.edu.cn/archlinux/$repo/os/$arch
Server = rsync://mirrors.tuna.tsinghua.edu.cn/archlinux/$repo/os/$arch
Server = rsync://mirrors.jlu.edu.cn/archlinux/$repo/os/$arch

前四个源是官方源及全球的存档镜像,它保存了每一天的镜像,而后面两个分别是清华大学和北京外国语大学的存档镜像,它们每周存档一次。如果您指定的日期在两个国内存档源中时则使用这两个,因为速度快。如果您的指定日期不在它们之中,则使用前四个源中的某一个都可以,2024年09月21日使用第一个官方存档库回滚系统到2024年09月18日, 这是我的电脑正常工作的最新日期,测试的速度比较快。

2. 锁定日期和解封升级

在上述配置中,注释部分锁定了仓库镜像日期为2024年9月19日等,此时系统可以连续升级。需要锁定日期时,请将日期改为指定的日期,然后取消注释并将非日期仓库注释掉。

3. 强制更新到目标版本

1
sudo pacman -Syyuu

更新完成后,重新启动系统, 您现在已将所有包恢复到之前的特定日期(在我们的示例中为 2024年 9 月 19 日)。但是请注意,我们不建议使用过时的软件包,待您需要Gnome插件或其他特定版本的软件及时跟进更新后请及时将系统升级到最新,若出现问题则再锁定到最新的稳定系统日期,等待下一次全部软件稳定后再次更新。如果操作后可以保证一直稳定使用ArchLinux.

安装解压缩软件

自动选择压缩软件
1
2
sudo pacman -S --needed --noconfirm p7zip-natspec unarchiver lzop lrzip arj zip unzip
if [ "$XDG_CURRENT_DESKTOP" = "GNOME" ]; then pacman --needed --noconfirm -S file-roller ; else pacman --needed --noconfirm -S ark ; fi
  • KDE桌面,安装 ark
  • GNOME桌面,安装 file-roller

在Linux解压缩Windows下考备过来的zip压缩文件时,不仅ark浏览时乱码,实际解压也是乱码。根本原因是编码问题,windows下默认gb2312与linux中默认utf-8不兼容, 直接原因是Ark中用于zip打开和解压的插件不支持gb2312. 解决方案为

  1. 安装。p7zip-natspec (cn源中就有)

    1
    sudo pacman -S p7zip-natspec

  2. Ark中禁用libzip插件(该插件优先级高于p7zip): Ark菜单→设置→配置Ark→插件→取消Libzip插件对应的复选框→应用。同时应当确保p7zip插件使用中。

  3. 由于已经安装了unarchiver, 所以直接使用命令unar解压zip文件也是可以解决文件名乱码问题的,但是前述方法更加方便。

  4. 其他选择,使用unzip-natspecunzip-iconv.

配置中文输入法Fcitx5

安装Fcitx5组件

from archlinuxcn
1
sudo pacman -S fcitx5 fcitx5-gtk fcitx5-qt fcitx5-configtool fcitx5-chinese-addons fcitx5-material-color fcitx5-nord

设置Fcitx5变量

根据Environment variables (2.1.1 Using shell initialization files), 环境变量的设置文件为/etc/environment/etc/profile.

/etc/environment
1
2
3
XMODIFIERS=@im=fcitx
GTK_IM_MODULE=fcitx
QT_IM_MODULE=fcitx
/etc/environment
1
2
3
4
5
GTK_IM_MODULE=fcitx
QT_IM_MODULE=fcitx
XMODIFIERS=@im=fcitx
SDL_IM_MODULE=fcitx
GLFW_IM_MODULE=ibus

注意:pam-env已经不再读取文件~/.pam_environment, 所以不可以设置此文件。同时部分登录器(如LightDM)支持部分读取~/.xprofile,也可以将其设置为和/etc/environment相同的上述内容。

配置vim和neovim

如果您是Linux初学者,或者不习惯使用vimneovim,那下面这部分可以不去配置。下面的配置主要是配置neovimvim安装一些工作中可以提高效率的插件,如果没有需要请省略此处配置。

1
2
3
4
5
6
7
8
9
10
11
12
curl -o vim-all.7z https://gitlab.com/fengzhenhua/zipconf/-/raw/main/vim-all.7z\?inline\=false
unar vim-all.7z
cd vim
chmod +x ./install.sh
./install.sh
cd ..
curl -o nvim-all.7z https://gitlab.com/fengzhenhua/zipconf/-/raw/main/nvim-all.7z\?inline\=false
cd nvim
chmod +x ./install.sh
./install.sh
cd ..
rm -rf vim-all.7z vim nvim-all.7z nvim

在安装neovim时,由于packer.nvim不再维护,故更新为lazy.nvim插件管理器,安装完插件时要手动在nvim中执行:qa 退出nvim。 安装结束后最后一行命令删除vim-all.7z, nvim-all.7z, vim, nvim

  1. 安装必备依赖

    1
    sudo pacman -S --needed --noconfirm ctags &> /dev/null

  2. 导入初始配置

    1
    curl -o $HOME/.vimrc https://gitlab.com/fengzhenhua/fzhconfig/-/raw/main/vimrc_init\?inline\=false

  3. 安装插件管理器vim-plug

  • 官方安装法

    1
    2
    sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs \
    https://raw.kkgithub.com/junegunn/vim-plug/master/plug.vim'

  • 自动升级安装法

    1
    2
    git clone --depth 1 https://github.com/junegunn/vim-plug $HOME/.vim/vim-plug
    ln -s $HOME/.vim/plugged/vim-plug/plug.vim $HOME/.vim/autoload/plug.vim

注意:已经配置vim-plug 通过命令:PlugUpdate自动更新,请勿执行:PlugUpgrade !!

  1. 安装vim-plug插件

    1
    vim +PlugInstall +qall

  2. 导入完整配置

    1
    2
    rm $HOME/.vimrc
    curl -o $HOME/.vimrc https://gitlab.com/fengzhenhua/fzhconfig/-/raw/main/vimrc\?inline\=false

packer插件管理器已经于停止维护,故本教程已经切换为lazy作为默认管理器,请放心lazy配置更加方便、稳定、快速。但是作为学习,此处仍然保留packer的配置方法,工作使用请参考Auto

  1. 安装依赖软件

    1
    2
    3
    4
    sudo pacman -S --needed --noconfirm neovim python3 yarn ranger
    sudo pacman -S --needed --noconfirm python-pip tree-sitter-cli python-pynvim
    sudo pacman -S --needed --noconfirm nerd-fonts-complete nerd-fonts-complete ttf-nerd-fonts-symbols
    sudo fc-cache -vf

  2. 下载neovim配置文件

    1
    2
    git clone https://gitlab.com/fengzhenhua/fzhconfig  fzhconfig
    cd fzhconfig

  3. 安装插件管理器packer

    1
    2
    NeoPacker="/home/$USER/.local/share/nvim/site/pack/packer/start/packer.nvim"
    git clone --depth 1 https://github.com/wbthomason/packer.nvim $NeoPacker

  4. 安装配置文件

    1
    2
    3
    cp -rf ./nvim /home/$USER/.config/nvim
    cp ./init.vim /home/$USER/.config/nvim/init.vim
    cp -rf ./vsnip /home/$USER/.vsnip

  5. 安装插件

    1
    nvim +PackerSync
    注意:插件安装完成后,请输入:qa 退出neovim

  6. 安装完整配置

    1
    cp  ./nvim/init.vim /home/$USER/.config/nvim/init.vim

  7. 安装vim-latex插件

    1
    2
    NeoTexPath="/home/$USER/.local/share/nvim/site/pack/packer/start/vim-latex/ftplugin/latex-suite/templates"
    cp ./latex-templates $NeoTexPath

  8. 更改vim-templates插件的默认模板

    1
    cp ./vim-templates/*   ~/.local/share/nvim/site/pack/packer/start/vim-template/templates/

Neovim健康检查

在安装Neovim后自检发现还有一些插件的依赖程序,没有安装,执行下述命令:

fix neovim's checkhealth
1
2
3
sudo pacman --needed --noconfirm -S wget cargo composer php luarocks ruby julia ripgrep fd jdk-openjdk wl-clipboard go xclip cpanminus python-neovim
sudo npm install -g neovim
sudo cpanm -n Neovim::Ext

neovim使用clipboard粘贴板

Install clipboard
1
if [ $XDG_SESSION_TYPE = "wayland" ]; then sudo pacman --needed --noconfirm -S wl-clipboard ; else sudo pacman --needed --noconfirm -S xclip ; fi
  • 如果使用的是wayland, 安装wl-clipboard:
  • 如果使用的是xorg, 安装xclip

解决 WARNING "Neovim::Ext" cpan module is not installed

1
2
sudo pacman -S --needed --noconfirm cpanminus
sudo cpanm -n Neovim::Ext

perl 无法写入到文件夹问题

perl
1
2
3
4
5
6
7
8
9
10
11
Perl provider (optional) ~
- perl executable: /usr/bin/perl
- WARNING Can't write to /usr/share/perl5/site_perl and /usr/bin: Installing modules to /home/feng/perl5
- ADVICE:
- To turn off this warning, you have to do one of the following:
- - run me as a root or with --sudo option (to install to /usr/share/perl5/site_perl and /usr/bin)
- - Configure local::lib in your existing shell to set PERL_MM_OPT etc.
- - Install local::lib by running the following commands
-
- cpanm --local-lib=~/perl5 local::lib && eval $(perl -I ~/perl5/lib/perl5/ -Mlocal::lib)
- OK Latest "Neovim::Ext" cpan module is installed: 0.06

按照提示,执行第2条的配置路径和第3条的安装命令,由于配置路径到文件~/.zshrc可以保证不必每次重装都重新设置,所以更推荐使用配置路径的方式。

~/.zshrc
1
2
3
4
5
6
export PERL_BASE="/usr/local/perl"
export PERL_MM_OPT="INSTALL_BASE=$PERL_BASE"
export PERL_MB_OPT="--install_base $PERL_BASE"
export PERL5LIB="$PERL_BASE/lib/perl5"
export PATH="$PERL_BASE/bin${PATH:+:$PATH}"
export MANPATH="$PERL_BASE/man${MANPATH:+:$MANPATH}"

执行下面的命令,但是为了目录纯净将per15隐藏,即

1
cpanm --local-lib=~/.perl5 local::lib && eval $(perl -I ~/.perl5/lib/perl5/ -Mlocal::lib)

javac命令找不到的问题

nvim运行checkhealth就会发出警告:javac 找不到!

注意:

模块 解释
JRE(Java Runtime Environment) Java程序所必须的环境,包括JVM和一些核心类库,用于运行字节码。
JDK(Java Development Kit) Java程序所必须的环境,包括JRE和一些编译工具比如javac.exe。
openJDK JDK的开源,有很多种实现,可以自由选择。

所以javac命令找不到应当安装一下jdk-openjdk, 这样问题就解决了。

linux下支持多个版本的jdk-openjdk, 当安装了多个版本java时,可以使用archlinux-java进行选择和设置默认。

1
2
3
4
sudo pacman -S jdk-openjdk
sudo pacman -S java-runtime-common
sudo archlinux-java unset
sudo archlinux-java fix

python-pynvim 的支持问题

nvim运行checkhealth后出现错误

pynvim错误
1
2
3
4
5
6
7
8
Python 3 provider (optional) ~
- `g:python3_host_prog` is not set. Searching for python3 in the environment.
- Multiple python3 executables found. Set `g:python3_host_prog` to avoid surprises.
- Executable: /usr/bin/python3
- Other python executable: /bin/python3
- Python version: 3.11.7
- pynvim version: 0.4.3 (outdated; from ~/.local/lib/python3.11/site-packages/neovim)
- WARNING Latest pynvim is NOT installed: 0.5.0

解决方法为删除~/.local/lib/python*, 然后nvim就会调用系统安装的python-pynvim,这样可以保证pynvim是最新的。

vim和neovim配置fcitx5自动切换

当使用vimnvim时,经学在插入模式和命令模式切换,而在命令模式需要英文输入法,特别是编辑中文文件时,每次切换都需要切换输入法特别麻烦。于是根据网络上的方法我修改得到一个更好的方法,同时原理相同在archlinux官网上给出了更加简洁的写法,此处都列出来,供大家自由选择。

Fcitx5-ArchWiki

If you are using Vim9, then the code should be

~/.vimrc
1
2
3
4
# Only taking affect after using vim9script grammar or has `vim9script` keyword.
var fcitx5state = system("fcitx5-remote")
autocmd InsertLeave * :silent fcitx5state = system("fcitx5-remote")[0] | silent !fcitx5-remote -c
autocmd InsertEnter * :silent if fcitx5state == '2' | call system("fcitx5-remote -o") | endif

If you are using neovim, then append the above code to ~/.config/nvim/init.vim.

It is recommended to use the fcitx.vim plugin. This plugin will keep different buffer-specific input method states in their respective insert modes.

For a simple solution, you can append the code to ~/.vimrc:

~/.vimrc
1
2
3
let fcitx5state=system("fcitx5-remote")
autocmd InsertLeave * :silent let fcitx5state=system("fcitx5-remote")[0] | silent !fcitx5-remote -c
autocmd InsertEnter * :silent if fcitx5state == 2 | call system("fcitx5-remote -o") | endif

If you are using VSCodeVim, add the following snippet into your configuration file:

1
2
3
4
"vim.autoSwitchInputMethod.enable": true,
"vim.autoSwitchInputMethod.defaultIM": "1",
"vim.autoSwitchInputMethod.obtainIMCmd": "/usr/bin/fcitx5-remote",
"vim.autoSwitchInputMethod.switchIMCmd": "/usr/bin/fcitx5-remote -t {im}",

我之前使用的方案

~/.vimrc or ~/.config/nvim/init.vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
let g:input_toggle = 0
function! Fcitx2en()
let s:input_status = system("fcitx5-remote")
if s:input_status == 2
let g:input_toggle = 1
let l:a = system("fcitx5-remote -c")
endif
endfunction
function! Fcitx2zh()
let s:input_status = system("fcitx5-remote")
if s:input_status != 2 && g:input_toggle == 1
let l:a = system("fcitx5-remote -o")
let g:input_toggle = 0
endif
endfunction
set ttimeoutlen=150
"退出插入模式
autocmd InsertLeave * call Fcitx2en()
"进入插入模式
autocmd InsertEnter * call Fcitx2zh()

注意:由于Fcitx5-ArchWiki给出的方法更加简法,所以建议使用Fcitx5-ArchWiki方法,而此处方法是本人多年前努力改进的办法,所以放在此处作为学习之前。

必备工具一键安装

archlinuxcn源
1
sudo pacman --needed --noconfirm -S  guake thunderbird  thunderbird-i18n-zh-cn libreoffice-still libreoffice-still-zh-cn calibre zotero goldendict-ng-git python-requests mplayer speech-dispatcher fdupes rmlint firefox-ublock-origin thunderbird-ublock-origin

上述工具依次为:下拉式终端、邮件客户端、办公套装libreoffice、 电子图书库、文献管理、电子词典、视频播放、语音合成(firefox依赖)、删除重复文件、广告过滤

aur源
1
paru --skipreview --noconfirm -S xdman-beta-bin wemeet-bin linuxqq listen1-desktop-appimage  aliyunpan-gaozhangmin-bin baidunetdisk-bin

上述工具依次为:下载工具、腾讯会议、腾讯QQ、音乐播放器、小白羊阿云盘、百度网盘

安装deb转换工具debtap

虽然archlinux的软件包足够多,但有时遇到某些专门针对debianubuntu的软件,要在archlinux使用它就可以借助转换工具debtap,安装配置如下:

  1. 由于Arch仓库中不含软件debtap, 于是借助Aur助手paru安装

    1
    paru -S debtap

  2. 切换debtap为国内源(下述两条命令同时执行),否则因限速问题容易升级失败

    1
    2
    sudo sed -i "s|http://ftp.debian.org/debian/dists|https://mirrors.ustc.edu.cn/debian/dists|g" /usr/bin/debtap
    sudo sed -i "s|http://archive.ubuntu.com/ubuntu/dists|https://mirrors.ustc.edu.cn/ubuntu/dists|g" /usr/bin/debtap

  3. 升级debtap

    1
    sudo debtap -u 

  4. 转换软件

    1
    sudo debtap xxxx.deb

  5. 安装转换生成的软件

    1
    sudo pacman -U x.tar.zst

安装配置zsh

Zsh(Z-shell)是一款用于交互式使用的shell,也可以作为脚本解释器来使用。其包含了 bash,ksh,tcsh 等其他shell中许多优秀功能,也拥有诸多自身特色。多数发行版中都默认安装了Zsh, 安装配置如下:

  1. 安装zsh和必要插件

    安装zsh的和必要插件
    1
    sudo pacman -S --needed --noconfirm zsh nerd-fonts zsh-autosuggestions zsh-autosuggestions zsh-completions zsh-theme-powerlevel10k zsh-syntax-highlighting-git zoxide exa

  2. zsh的配置文件

    ~/.zshrc
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    # 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

    source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
    source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
    source /usr/share/zsh-theme-powerlevel10k/powerlevel10k.zsh-theme

    # History file for zsh
    HISTFILE=~/.zsh_history
    # How many commands to store in history
    HISTSIZE=10000
    SAVEHIST=10000
    # Share history in every terminal session
    setopt SHARE_HISTORY
    # 配置zsh-autosuggestions
    ZSH_AUTOSUGGEST_STRATEGY=(history completion)
    # ZSH_AUTOSUGGEST_STRATEGY=(match_prev_cmd)

    # set for zsh-z-git
    # source /usr/share/zsh/plugins/zsh-z/zsh-z.plugin.zsh
    # set for z.lua 功能上不如zsh-z-git完善
    # eval "$(lua /usr/share/z.lua/z.lua --init zsh enhanced once)"
    # set for zoxide instead of z.lua
    eval "$(zoxide init zsh)"
    # To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
    [[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh

    # 开启拼写检查,带颜色
    autoload U colors && colors
    setopt correct
    export SPROMPT="Correct $fg[red]%R$reset_color to $fg[green]%r$reset_color [Yes, No, Abort, Edit]"

    # 补全大小写敏感
    autoload -Uz compinit && compinit
    zstyle ':completion:*' matcher-list '' 'm:{a-z}={A-Z}' '+m:{A-Z}={a-z}'
    # 切换npm为淘宝的cnpm,加速下载
    # alias npm=cnpm
    # 配置Pel
    export PERL_BASE="/usr/local/perl"
    export PERL_MM_OPT="INSTALL_BASE=$PERL_BASE"
    export PERL_MB_OPT="--install_base $PERL_BASE"
    export PERL5LIB="$PERL_BASE/lib/perl5"
    export PATH="$PERL_BASE/bin${PATH:+:$PATH}"
    export MANPATH="$PERL_BASE/man${MANPATH:+:$MANPATH}"
    # For a full list of active aliases, run `alias`.
    # Example aliases
    # alias paru="paru --needed --noconfirm"
    UGIT_COMMIT="${USER}@$(fastfetch |grep Host| awk -F'(' '{print $2}'|awk -F')' '{print $1}')"
    UGIT_COMMIT=$(echo $UGIT_COMMIT | sed 's/ /\-/g')
    alias \
    zpull="git pull" \
    zpush="git add . && git commit -m "$UGIT_COMMIT" && git push" \
    del='trash-put' \
    nvimdiff="nvim -d" \
    ip="ip -color=auto" \
    e="exa --long --header --color=auto --icons -a" \
    ls="exa --header --color=auto --icons " \
    grep="grep --color=auto" \
    diff="diff --color=auto" \
    bat="bat --color=auto" \
    make="colormake" \
    ping="gping" \

安装配置TexLive

ArchLinux中包含了软件包texlive其包括了所有的宏包,同时也有texlive-doc软件包,其包括了所有包的说明文档,体积较大,如果电脑一直联网则可以不安装texlive-doc, 当使用texdoc来查阅说明文档时,它会自动连网查询。

Install Texlive
1
sudo pacman -S texlive texlive-langchinese texlive-doc 

注意:当安装完texlive后,其自动安装了命令texdoc, 这方便查询宏包说明。在我的新台式机上采用了pacman安装方式,以取代Texlive.iso镜像的安装方法, 因为使用pacman管理texlvie可以不受每年都安装一遍texlive的麻烦,实现一劳永逸。具体问题可以参考: Texlive-ArchWiki

由于TexLive每年都会有新的版本,可以下载带年份的也可以下载不带年份的ISO镜像。

  1. 下载安装镜像Texlive.iso
  2. 挂载ISO镜像
1
2
3
sudo mount -o loop texlive2024.iso  /mnt/
cd /mnt
sudo ./install-tl

出现选项后,输入 I 直接安装(也可以更改选项)。不出意外的话,5 分钟应该就 OK 了, 然后退出 root 用户。

  1. 设置环境变量

如果在安装过程中选择了建立超链接,则不必考虑环境变量,所以,这样子可方便一些。texlive-en.pdf 中说明:

If you elected to create symlinks in standard directories (described in section 3.2.4), then there is no need to edit environment variables. Otherwise, on Unix systems, the directory of the binaries for your platform must be added to the search path. (On Windows, the installer takes care of this.)

  1. 卸载ISO镜像并更新texlive
1
2
3
sudo umount /mnt/
sudo tlmgr update --self
sudo tlmgr update --all
  • 默认情况下,会自动搜索合适的镜像来更新,也可以使用–repository 选项指定了要使用哪一个CTAN镜像。例如使用USTC镜像:
1
2
sudo tlmgr update --self --repository http://mirrors.ustc.edu.cn/CTAN/systems/texlive/tlnet/
sudo tlmgr update --all --repository http://mirrors.ustc.edu.cn/CTAN/systems/texlive/tlnet/
  • 为了方便我们也可以直接设置texlive 源为国内源,例如切换为清华源或华中科技大学源
1
2
sudo tlmgr option repository https://mirrors.tuna.tsinghua.edu.cn/CTAN/systems/texlive/tlnet
sudo tlmgr repository set http://mirror.hust.edu.cn/CTAN/systems/texlive/tlnet
  1. 字体设置

XeTeX和LuaTeX可以直接使用系统字体, 但Texlive自带的字体不在系统的字体目录中,所以当使用XeLaTeX 编译文件时,如果使用了texlive里面带的字体,就会出错,这时需要进行如下配置,让系统可以识别texlive所带的字体就可以了.

1
2
sudo cp /usr/local/texlive/2024/texmf-var/fonts/conf/texlive-fontconfig.conf   /etc/fonts/conf.d/09-texlive.conf
sudo fc-cache -fsv
  1. 大版本升级。下载新的ISO镜像,然后直接删除旧版镜像或者备份

    1
    sudo rm -rf /usr/local/texlive/2023
    清空路径
    1
    sudo tlmgr path remove
    重复步骤1-5, 重新安装最新版本。另外也可以直接参考官方不重装升级法:Upgrade from TeX Live 2023 to 2024, 这个方法我没有测试成功,感觉还是重新安装一下吧,问题较少。如果你能够提供一个标准的安装方法,请邮件联系本人,先行谢过了。

  2. 卸载旧版TexLive20**的其他方法

    • 执行内置命令sudo tlmgr remove --all
    • 直接删除对应目录:
      1
      2
      3
      4
      5
      6
      sudo rm -rf /usr/local/texlive/20**
      sudo rm -rf ~/.texlive20**
      sudo rm -rf /usr/local/share/texmf
      sudo rm -rf /var/lib/texmf
      sudo rm -rf /etc/texmf
      sudo rm -rf ~/.texlive

自定义宏包的安装路径,为了确保在使用pacman安装texlvie和使用镜像texlive202*.iso安装texlive均能使用自定义宏包,应当把自定义的宏包存放在latex的默认路径中,此处根据使用xelate编译文件时的输入信息确定为:

1
/usr/share/texmf-dist/tex/latex/YourPackage/xxxx.sty

安装TeXmacs

  • 安装基本程序和建立系统字体链接,确保可以输入中文:

    1
    2
    sudo pacman -S texmacs
    ln -s /user/share/fonts/Windows11 $HOME/.TeXmacs/fonts/truetype/Windows11

  • 下载官方中文字体: Chinese fonts(6.8Mb) , 将字体保存到~/.TeXmacs下,然后执行命令:

    1
    2
    gunzip -c TeXmacs-language-fonts.tar.gz | tar xvf -
    rm ~/.TeXmacs/TeXmacs-chinese-fonts.tar.gz

  • 立刻使字体生效:

    1
    texmacs --delete-font-cache

参考资料:Texmacs 的安装配置


其他替代品或分别安装命令

安装USB无线网卡驱动

在使用有线网络台式机,如果有一个USB的无线网卡提供无线网络服务,那我们的手机、平板等设备会方便不少。偶然机会获得一个TRL8188GU无线网卡,经过互联网查询在Archlinux成功启用此无线网卡,实现无线网分享上网。具体可以参考我的另一篇文章Archlinux安装USB无线网卡驱动, 安装软件为:

  1. 克隆下rtl8xxxu的源文件:

    1
    git clone https://github.com/a5a5aa555oo/rtl8xxxu.git

  2. 如果您使用的USB Wifi发射器基于RTL8188GURTL8192FU芯片,您需要首先使用命令usb_modeswitcheject切换到Wifi模式。

  3. 安装构建模块需要的软件包:gcc,make,linux-headers,dkms和其他的依赖软件。

  4. 构建和安装模块

    • 使用传统方式

      make clean modules && sudo make install

    • 使用 DKMS 方式(推荐)

      sudo dkms install $PWD

    • 基于ArchLinux的发行版用户

      AUR中安装软件包: rtl8xxxu-dkms-git

      1
      paru -S rtl8xxxu-dkms-git

  5. 为芯片 RTL8188EU/RTL8188FU/RTL8188GU/RTL8192EU/RTL8192FU 安装固件(关键)

    sudo make install_fw

  6. 载入模块

    sudo modprobe rtl8xxxu_git

驱动rtl8xxxu-dkms-git是为利用 Linux mac80211 堆栈而编写的各种 Realtek RTL8XXX 部件的替代驱动程序。 已知该驱动程序适用于许多 RTL8723AURL8188CURTL8188RURTL8191CURTL8192CU 设备 此驱动程序正在开发中,功能有限集。特别是,它还不支持 40MHz 信道 和电源管理。但是,它应该比供应商驱动程序和内核 mac80211 堆栈中的 benetifs 内存占用量小。 它可以与 drivers/staging/rtl8723audrivers/staging/rtl8192udrivers/net/wireless/rtlwifi 的驱动程序共存, 但您需要控制要加载的模块. 已启用RTL8XXXU_UNTESTED。 此选项可以检测尚未由驱动程序直接测试的 Realtek 8723/8188/8191/8192 WiFi USB 设备 作者或报告由第三方处理. 引用自package: kmod-rtl8xxxu

安装绘图软件

1
sudo pacman --needed --noconfirm -S pinta

此处提供两个绘图软件pintadrawing,替代windows中的画图软件,个人在使用中感觉pinta相对更好用一些。除此之外还有一款适用于KDE桌面环境的krita, 它比pinta功能更加强大,但是其要求电脑有更好的性能,所以电脑性能有限的情况下安装pinta, 足够的话建议使用krita.

安装截图工具

1
sudo pacman --needed --noconfirm -S flameshot

安装图像查看器

1
2
3
4
5
sudo pacman --needed --noconfirm -S nomacs
or
sudo pacman --needed --noconfirm -S feh imagemagick
or
sudo pacman --needed --noconfirm -S xnviewmp

安装浏览器firefox

1
sudo pacman --needed --noconfirm -S firefox xdg-desktop-portal xdg-desktop-portal-kde

注意:2023年12月24日发现,cn源内去除了tor-browser, 所以不能使用pacman安装了, 如果执行sudo pacman -S torbrowser 将会出现一个torbrowser的安装器,它不是浏览器本身。

安装下载软件Xtreme Download Manager

Xtreme下载管理器是一款强大的工具,能提高下载速度达500%,保存流媒体视频,恢复中断下载,并安排和转换下载。XDM与Chrome、Firefox Quantum、Opera、Vivaldi等基于Chromium和Firefox的浏览器无缝集成,接管下载并保存网络流媒体视频。内置的视频转换器可将下载的视频转换为多种格式,支持100多种设备。

Install Xtreme Download Manager
1
paru --skipreview --noconfirm -S xdman-beta-bin

xdm官网,点开链接→解压缩→切换到解压后的文件夹 xdm-setup-7.2.11→执行脚本安装程序.

1
2
3
cd ./xdm-setup-7.2.11
chmod +x install.sh
./install.sh

安装词典软件Goldendict

1
sudo pacman --needed --noconfirm -S goldendict-ng-git mplayer
  • 配置词典:打开软件goldendict→点击编辑词典 →设置词典软件路径。
  • 配置构词法规则:点击构词法规则→设置好构词法路径。
  • 关闭全文搜索:点击编辑首选项全文搜索 关闭全文搜索。
  • 配置播放声音:切换到音频播放使用外部程序播放:mplayer
translatorGD.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#! /usr/bin/env python3
# vim:fenc=utf-8
import json
import requests
import random
from hashlib import md5
import time
import sys
import io
import threading
caiyunxiaoyiKey=""
baiduKey={"id":"YourID","secret":"YourSecret"}
xiaoniuKey="YourKey"
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8")
originalText = sys.argv[1]
css = """<style type="text/css">
.engine {
font-family: "MiSansVF";
font-size: 18px;
color: #578bc5;
}
.originalText {
font-size: 120%;
font-family: "MiSansVF";
font-weight: 600;
display: inline-block;
margin: 0rem 0rem 0rem 0rem;
color: #2a5598;
margin-bottom: 0.6rem;
}
.frame {
margin: 1rem 0.5rem 0.5rem 0;
padding: 0.7rem 0.5rem 0.5rem 0;
border-top: 3px dashed #eaeef6;
}
definition {
font-family: "MiSansVF";
color: #2a5598;
height: 120px;
padding: 0.05em;
font-weight: 500;
font-size: 16px;
}
</style>"""
print(css)
print( '<div class="originalText">' + originalText + '</div>')
print('<br><br>')
def output(engineName:str,definition:str):
print('<span class="engine">' + engineName + "</span>")
print('<div class="frame">')
print('<definition>' + definition + '</definition>')
print("</div>")
print("<br>")
def Youdao():
global originalText
headers = {
'authority': 'aidemo.youdao.com',
'accept': 'application/json, text/javascript, */*; q=0.01',
'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
'origin': 'https://ai.youdao.com',
'referer': 'https://ai.youdao.com/',
'sec-ch-ua': \
'"Chromium";v="106",\
"Microsoft Edge";v="106",\
"Not;A=Brand";v="99"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',
'sec-fetch-dest': 'empty',
'sec-fetch-mode': 'cors',
'sec-fetch-site': 'same-site',
'user-agent': \
'Mozilla/5.0 (Windows NT 10.0; Win64; x64)\
AppleWebKit/537.36 (KHTML, like Gecko)\
Chrome/106.0.0.0 Safari/537.36 Edg/106.0.1370.47',
}
data = {
'q': originalText,
'from': 'Auto',
'to': 'Auto',
}
try:
output("有道翻译",
requests.post('https://aidemo.youdao.com/trans',
headers=headers, data=data).json()["translation"][0])
except:
output("有道翻译","错误")
def Google():
global originalText
definition=""
try:
for x in requests.get("https://translate.googleapis.com/translate_a/single?\
client=gtx&sl=auto&tl=&dt=at&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&\
dt=rm&dt=ss&dt=t&q="+originalText,\
headers={"user-agent":\
"Mozilla/5.0 (Windows NT 10.0;\
Win64; x64; rv:59.0)"}).json()[0]:
if x[0]:
definition += x[0]
output("谷歌翻译",definition)
except:
output("谷歌翻译","错误")
def Caiyun():
global originalText
global caiyunxiaoyiKey
payload = {
"source": originalText,
"trans_type": "auto2zh",
"request_id": "demo",
"detect": True,
}
headers = {
"content-type": "application/json",
"x-authorization": "token " + caiyunxiaoyiKey,
}
try:
output("彩云小译",
json.loads(requests.post(
"http://api.interpreter.caiyunai.com/v1/translator",
data=json.dumps(payload), headers=headers).text)["target"])
except Exception as e:
output("彩云小译","错误:"+str(e))
def Baidu():
global originalText
global baiduKey
salt = random.randint(32768, 65536)
s=baiduKey["id"] + originalText + str(salt) + baiduKey["secret"]
sign = md5(s.encode('utf-8')).hexdigest()
try:
output("百度翻译",
requests.post(
'http://api.fanyi.baidu.com/api/trans/vip/translate',
params={'appid': baiduKey["id"],
'q': originalText, 'from': 'auto', 'to': 'zh',
'salt': salt, 'sign': sign}
).json()["trans_result"][0]["dst"])
except Exception as e:
output("百度翻译","错误"+str(e))
def Xiaoniu():
global originalText
global xiaoniuKey
try:
output("小牛翻译",
json.loads(requests.post(
"http://api.niutrans.com/NiuTransServer/translation?",
data={"from": 'en', "to": 'zh',\
"apikey": xiaoniuKey,\
"src_text": originalText}).text)['tgt_text'])
except Exception as e:
output("小牛翻译","错误"+str(e))
threads=[]
# threads.append(threading.Thread(target=Caiyun))
# threads.append(threading.Thread(target=Google))
threads.append(threading.Thread(target=Xiaoniu))
threads.append(threading.Thread(target=Baidu))
threads.append(threading.Thread(target=Youdao))
for t in threads:
t.start()

translatorGD脚本配置方法

  • 在使用脚本前,请输入申请到的百度帐号和密钥,小牛的密钥

  • Linux中配置

    命令行
    1
    python "/home/feng/软件/goldendict/translatorGD.py" %GDWORD%

  • Windows配置 translatorGD配置方法

安装腾讯会议和QQ

1
paru --skipreview -S wemeet-bin linuxqq

安装音乐播放器

1
paru --skipreview -S listen1-desktop-appimage

安装小白羊云盘

完美运行版本
1
2
3
sudo pacman -S nodejs-lts-hydrogen
paru --skipreview -S electron22-bin
paru --skipreview -S aliyunpan-gaozhangmin-bin
  • aur中有两个版本的小白羊云盘,分别是xbydriver-binaliyunpan-gaozhangmin-bin,前者更新快一些,但是会导致一些错误,同时基本的下载也不能保证,后者更新慢一些,估计应该是作者在修复问题,这一版可以完美运行,所以此处推荐安装后者。
  • 使用paru安装electron22-bin是因为bin版已经编译好,不再需要系统编译,成功率更高。
  • 虽然aliyunpan-gaozhangmin-bin依赖于nodejs-lts-hydrogen,但是在安装成功之后使用pacman再安装最新的nodejs后,小白羊云盘仍然可以正确运行。

关于Windows与Linux的双系统设置

文章前述是先安装好 Windows, 然后再安装 Linux 的操作步骤。但是在使用过程中不可避免的会遇到重装 windows的情况,比如我的 ThinkpadT490 由于安装的Windows11 随着升级变的越来越不好用,于是决定重新换回 Windows10 LTSC 版本,但是在安装完成后如前所述 Windows的安装程序会覆盖掉 Linux的引导程序grub. 但是Linux系统却没有受到影响,于是要恢复双系统在grub 中选择启动,需要重新构建一下grub

  1. 将启动U盘插入电脑USB口,重启电脑使其U盘启动。

  2. 由于Ventoy是多系统启动盘,原来的系统安装的是ArchLinux, 于是选择ArchLinux的镜像启动。

  3. 在我的电脑分区情况下执行:

    恢复grub双系统启动
    1
    2
    3
    4
    5
    6
    7
    mount /dev/nvme0n1p2  /mnt/
    mount /dev/nvme0n1p1 /mnt/boot/efi
    mount /dev/nvme0n1p4 /mnt/home
    arch-chroot /mnt
    grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id= ArchLinux
    grub-mkconfig -o /boot/grub/grub.cfg
    exit
    这样Linux系统就完成了grub的安装, 退出系统后重新启动。

  4. 此时grub并没有识别到windows的启动项,进入Linux后,再次执行命令

    1
    sudo grub-mkconfig -o /boot/grub/grub.cfg
    此时grub识别到windows系统,重新系统则实现了双系统的完美选择启动。

软件故障修复

SDDM启动时英文改中文

当KDE升级为Plasma6后,发现刚安装的系统启动时登录界面一直显示英文,解决方法为:

修改文件/usr/lib/systemd/system/sddm.service, 在[Service]下添加Environment=LANG=zh_CN.UTF-8, 即

/usr/lib/systemd/system/sddm.service
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[Unit]
Description=Simple Desktop Display Manager
Documentation=man:sddm(1) man:sddm.conf(5)
Conflicts=getty@tty1.service
After=systemd-user-sessions.service getty@tty1.service plymouth-quit.service systemd-logind.service
PartOf=graphical.target
StartLimitIntervalSec=30
StartLimitBurst=2

[Service]
ExecStart=/usr/bin/sddm
Restart=always
Environment=LANG=zh_CN.UTF-8

[Install]
Alias=display-manager.service

Guake终端F12失效

2024年03月08日, 升级Archlinux后,KDE桌面环境由Plasma5升级为Plasma6, 其默认启用了wayland, 这会导致guakeF12快捷键失效。解决方法为:

  1. 打开Guake 首选项键盘快捷键切换Guake是否可见, 点右侧的快捷键后,再按Backspace键取消F12绑定。
  2. 系统设置键盘快捷键新增命令或脚本→输入guake-toggleguake -v添加自定义快捷键→按F12→右下角应用

文件管理器Dolphin挂载双系统的Windows11 NTFS分区失败

1
2
sudo pacman --needed --noconfirm -S ntfs-3g
sudo ntfsfix -d /dev/nvme0n1p6

注意:此命令是删除了之前系统挂载NTFS硬盘时,产生的多余错误标签, 并不会格式硬盘,不会造成资料损失,放心使用。如果您并没有遇到Dolphin无法挂载NTFS分区的情况,请忽视此问题修复。

Grub丢失导致系统无法启动

2023年12月29日, 由于设置BIOS时,点了F9,导致BIOS恢复了默认设置。启动项中的Grub丢失,系统无法启动。解决方法为:插入安装系统时的启动U盘,然后按前述安装过程依次挂载各硬盘到指定目录(), 由于ArchLinux Live默认没有安装os-prober, 而此程序的作用就是自动探测操作系统,于是执行命令:

1
2
3
4
5
6
7
8
9
mount /dev/nvme0n1p2  /mnt/
mount /dev/nvme0n1p1 /mnt/boot/efi
mount /dev/nvme0n1p4 /mnt/home
arch-chroot /mnt
pacman -S os-prober
grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id= ArchLinux
grub-mkconfig -o /boot/grub/grub.cfg
exit
reboot -h now
  1. 播放多媒体时不出声音了

2022-06-14 在使用firefox 版本号为 V101.0.1(64位)收看视频时,发现都默认禁用了声音自动播放,这里给出设置方法。 2023-12-12 firefox 版本号 V120.0.1(64位) 再次遇到这个问题。

点击右上角三个横杠 →点击左侧隐私与安全 → 点击右侧权限 → 向下自动播放 → 向右设置... → 最上面所有网站的默认值设置为音频和视频

  1. 安装 firefox-ublock 插件

2022-10-07 在新安装的Archlinux上安装此插件时,由于网络原因不能正常访问uBlock的发布网站,但是在Archlinux下可以使用yayparu 安装,安装到firefox的命令如下:

1
2
3
paru --skipreview -S firefox-ublock-origin
or
yay -S firefox-ublock-origin
  1. 升级KDE-Plasma6后不显示最大化最小化按钮

参考Firefox-ArchWik,采用4.5 KDE integration 的第二种方法:

fix firefox missing min and max button
1
sudo pacman --needed --noconfirm -S xdg-desktop-portal xdg-desktop-portal-kde

不知道从何时开始,火狐Firefox禁止中国大陆IP访问商店内的广告拦截扩展页面。当打开uBlockOrigin , AdGuard,AdBlocker 等页面时,会显示“此页面在您的地区不可用” 。所以本节记录手动安装uBlock的方法。

  1. 打开uBlock发布页https://github.com/gorhill/uBlock/releases
  2. 点击发页页上对应Firefox的发布链接,等待安装即可。

ThinkPad-T490 识别M2. 2248固态硬盘

在安装好TLP之后解决了ArchLinux无法从睡眠中唤醒的问题,意外的部分解决了M2. 2248固态硬盘的识别问题。说其部分解决,因为系统正常启动后并不识别这个外加于WWAN口上的固态硬盘,其在睡眠后再唤醒,文件管理器Dolphin左侧就可以识别出此硬盘。在Windows下启动后就是识别的,而在Linux下部分的识别也是一大进步。

关于这个问题,或许是系统启动机制导致的,Linux启动时会扫描硬盘识别硬件,但是这个WWAN口本是一个无线网卡槽,所以不是标准设计,系统就没有识别。但是,睡眠后再唤醒,这期间电脑肯定又触发了某一个操作,此操作使得系统识别了这个M2. 2248固态硬盘,只是目前我还没有确定是哪一个操作,如果把这个操作添加到开机启动中,那么这个问题也就完全解决了。当前时间, 先记录下这个问题,待后面研究透后,再来修改。

修复ASUS华硕主板在AMD CPU下的启动BUG

最近入手一台组装机,主板型为华硕TUF-GAMING-B550M, 出厂日期为2020年,每次启动时会出现错误提示信息No irq handler for vector, 经过文章"No irq handler for vector" messages during boot with AMD CPU, 得到答案,这个错误提示是原来的BIOSBUG, 更新到最新的BIOS即可解决。解决方法为:

  • 到华硕官网下载对应型号的BIOS:
  • 解压缩TUF-GAMING-B550M-PLUS-WIFI-ASUS-3607.zipU盘中,得到TUF-GAMING-B550M-PLUS-WIFI-ASUS-3607.CAP
  • 重启系统,按DEL键进入到BIOS, 再切换到Tool选项卡,并点击ASUS EZ Flash. 选择Storage模式(本地更新更安全), 找到U盘中存放的文件TUF-GAMING-B550M-PLUS-WIFI-ASUS-3607.CAP, 稍后便开始自动更新。
  • 确保电源稳定,不乱动鼠标,静等更新完毕。更新BIOS完成后,重新启动电脑,再次进入到BIOS中就可以看到更新好的最新版本BIOS版本了。
  • 更新BIOS固件后,错误提示消失,电脑正常工作。
  • 参考文章:

台式机接耳机时有嗒嗒声

在淘宝上买了一个14元的音响,连接电脑后发现有电流的噪音,于是今天暂时替换掉这个音响,转而使用蓝牙音响,此噪音消失。晚上插上耳机测试时,发现总是有规律的发出嗒嗒声,百度之后有人说是连接耳机孔的线与其他USB线的缠在一起,会有电磁感应,理论上这不可避免,但是如此有规律声响应当就是电脑运行时发出的电磁波产生的干扰。解决问题的关键应该是!真正的原因是,耳机的连线较长,它恰好充当了天线的作用!电脑工作时发现的有规律的电磁波会被它接收到,于是就有了这个有规律噪声, 而好一些的耳机在线上会有金属膜屏蔽外界信号或耳机有降噪功能,这样就不会嗒嗒声了。记住换个好点的耳机哈^_^

Nautilus卡死

这两天实然NautilusFirefox都变的很不稳定,总是卡死,今天找到问题所在:因为对系统升级或安装卸载软件,导致一些系统不再需要的软件包仍有残余,从而使一些软件变的不稳定。解决方法是,当升级或安装卸载一些软件后,要及时使用命令sudo pacman -Rns $(pacman -Qtdq)清理掉无用的软件包。

蓝牙无法打开

由于系统升级等操作有可能造成蓝牙无法打开, 在文章Ubuntu 20.04出现蓝牙无法打开的问题(已解决)中共找到以下四种解决方案:

1. 卸载并重新加载btusb内核模块(支持蓝牙设备的内核模块)

1
2
3
4
sudo rmmod btintel
sudo rmmod btusb
sudo modprobe btusb
sudo modprobe btintel

2024年08月02日遇到此问题,通过重新加载btusb解决。2024年08月29日升级ArchLinux后再次遇到此问题,通过上述方法成功修复,于是做出修改。

2. 安装蓝牙工具和工具包

1
sudo pacman -S --needed --noconfirm bluez bluez-utils pipewire-pulse bluedevil blueman

3. 启动蓝牙服务

1
sudo service bluetooth start

4. 重新解除蓝牙设备的阻止

1
2
rfkill block bluetooth
rfkill unblock bluetooth

硬件故障修复

电脑开机噪音变大

  • 如果是用润滑油的风扇,那么时间用长了之后里面的润滑油会渐渐挥发掉,再加上现在气温很低,必然出现噪音的现象,建议给风扇加润滑油。打开机箱开机,仔细听听是哪个风箱发出的噪声,然后把风扇拆下,揭开风扇上的标签,会看到一个轴承,滴二滴润滑油就行了。

  • 跟机箱内灰尘也有一定关系,建议定期除尘。

  • 机箱外壳与机体衔接不紧,风扇在运转的时候会产生轻微振动导致外壳和机体连接不紧处产生噪音,建议重新安装机箱外壳,再不行就把外壳稍稍弄弯一点点,使得外壳与机体衔接更紧密。

  • 电脑主机要放在一个平稳而坚固的台面上(比如地上)。

  • 如机箱发出噪音应在适当的地方贴上泡沫塑料条,再盖紧机箱盖。

  • 如果用户的电源噪音是由于开机的瞬间高电流造成的,可以安装滤波器或者是换用一个质量更好的电源,防止大电流冲击产生噪音。还可以购买一些具有滤波器功能的智能电源插座连接主机,以确保电脑电源不受到外界电流的干扰。

2.4G无线键盘延迟

2.4G无线键盘使用相当广泛,相对而言罗技、雷柏等大品牌对于无线信号处理较好,所以其不会发生无线电干扰。相对而言,一些国产的无线键盘鼠标都使用的公版2.4G发射接收装置,对于有多个无线装备的电脑,特别是台式机后机箱的USB插孔会导致2.4G频段的信号发生干扰,从而导致无线信号的丢失,于是出现了漏掉字母,输入延迟等故障。解决方法很简单:使用一根USB延长线,将2.4G发射器放在远离主机箱前后的位置。

附录:Windows纯净版系统下载

注意:上述链接为磁力链,请使用迅雷下载; 非LTSC版本,请到Windows官网下载。

参考文章

  1. 安装教程参考
  1. Pacman 使用手册
  1. 配置国内源参考
  1. 配置电源管理参考
  1. 配置nvim参考
  1. 配置Goldendict参考

ArchLinux相关