Archlinux 安装桌面环境 dwm + polybar
2023.1.31,修改部分内容,去掉几个dwm补丁
2023.2.2,修改补丁列表
接上一篇:单EFI分区Archlinux + Windows 10 双启动安装记录
使用普通用户登录,以下所有操作都是在这个基础之上进行
关于git
如果你连接github有困难,使用ssh 连接github,能改善一下
说明:下面的git clone操作都是基于ssh连接的命令,注意github.com后面是 " : "
git clone git@github.com:xxxx/xxx
如果你没有设置ssh连接,就改成下面这样,注意github.com后面是 " / "
git clone https://github.com/xxxx/xxx
一、安装一些必要软件
1. 壁纸、状态栏等软件
sudo pacman -S xorg xorg-xinit polkit-gnome nitrogen numlockx powerpill
关于powerpill,自己查ARCHLINUX
nitrogen,需要进入桌面后先运行一次,设置一下图片目录,再选择一张壁纸
2. 安装dwm和st
提示:如果你不用st,那么就安装其他的终端模拟器
比如:alacritty,kitty等
刚刚发现另一个用rust写的终端:wezterm ,打算尝试一下
我打算从ST切换到wezterm了,st做为备用
wezterm的配置文件需要自己从头开始写,保存后即时生效
官网上的文档写的比较详细,照抄就行了
关于dwm和st,我懒得手动打补丁,而且补丁多了要解决冲突很让人头大,幸好github上有这个项目:dwm-flexipatch和这个项目:st-flexipatch,还有dmenu的dmenu-flexipatch,
省掉了手动打补丁的步骤,只需要简单的选择你需要的补丁就OK
mkdir ~/workspaces && cd ~/workspaces
git clone git@github.com:bakkeby/dwm-flexipatch.git
git clone git@github.com:bakkeby/st-flexipatch.git
在patches.def.h里根据自己需要开启相应的补丁选项
有的补丁还需要在config.mk中取消相应的注释,不然是无法编译成功的
cd ~/workspaces/dwm-flexipatch
vi patches.def.h
把需要的补丁后面的 “0” ,改为 “1”
本文只写使用polybar的方法
需要注意的是:按照本文的方法,在dwm中使用polybar,那么IPC补丁是必须要的,BAR选项只能选ANYBAR和EWMHTAGS,其他的BAR选项全部置0
我的补丁列表,反正不用手动打补丁…随便选吧… 😃
dwm补丁列表 | st补丁列表 | dmenu补丁列表 |
---|---|---|
BAR_ANYBAR_PATCH | ALPHA_PATCH | ALPHA_PATCH |
BAR_EWMHTAGS_PATCH | ALPHA_FOCUS_HIGHLIGHT_PATCH | CASEINSENSITIVE_PATCH |
ATTACHBOTTOM_PATCH | ANYSIZE_PATCH | DYNAMIC_OPTIONS_PATCH |
ANYSIZE_SIMPLE_PATCH | FUZZYHIGHLIGHT_PATCH | |
FUZZYMATCH_PATCH | ||
COMBO_PATCH | BOLD_IS_NOT_BRIGHT_PATCH | FZFEXPECT_PATCH |
COOL_AUTOSTART_PATCH | BOXDRAW_PATCH | GRID_PATCH |
CYCLELAYOUTS_PATCH | CLIPBOARD_PATCH | HIGHPRIORITY_PATCH |
DELKEY_PATCH | INSTANT_PATCH | |
FONT2_PATCH | PREFIXCOMPLETION_PATCH | |
FULLSCREEN_PATCH | HIDECURSOR_PATCH | XRESOURCES_PATCH |
IPC_PATCH | HIDE_TERMINAL_CURSOR_PATCH | |
KEYMODES_PATCH | LIGATURES_PATCH | |
KILLUNSEL_PATCH | SCROLLBACK_PATCH | |
LOSEFULLSCREEN_PATCH | SCROLLBACK_MOUSE_PATCH | |
SCROLLBACK_MOUSE_ALTSCREEN_PATCH | ||
SIXEL_PATCH | ||
MOVESTACK_PATCH | USE_XFTFONTMATCH_PATCH | |
VERTCENTER_PATCH | ||
NO_TRANSPARENT_BORDERS_PATCH | WIDE_GLYPHS_PATCH | |
ONLY_ONE_RULE_MATCH_PATCH | XRESOURCES_PATCH | |
PERTAG_PATCH | XRESOURCES_RELOAD_PATCH | |
PLACEMOUSE_PATCH | UNIVERSCROLL_PATCH | |
PUSH_NO_MASTER_PATCH | ||
RESIZEPOINT_PATCH | ||
RESTARTSIG_PATCH | ||
SCRATCHPADS_PATCH | ||
SEAMLESS_RESTART_PATCH | ||
SELFRESTART_PATCH | ||
STICKY_PATCH | ||
SWAPFOCUS_PATCH | ||
SWITCHTAG_PATCH | ||
VANITYGAPS_PATCH | ||
XRDB_PATCH | ||
GAPPLESSGRID_LAYOUT | ||
FIBONACCI_SPIRAL_LAYOUT | ||
MONOCLE_LAYOUT |
有的补丁需要在config.mk中开启相应的选项
patches.def.h里的补丁说明都有提示,照着弄就行了,按我上面打的那么多补丁,也只需要取消几条注释而已
vi config.mk
按照上面的补丁说明
使用polybar,需要先修改配置文件
vi config.def.h
// 在这一段里添加一条
static const BarRule barrules[] = {
{ -2 }, // 加入这一句
...
};
编译前先安装这个,不然编译会报错
sudo pacman -S yajl
然后就可以编译了
make
正常情况应该只有一条警告信息,不用管他,只是提醒你有一个变量你定义了但是没有使用
如果没有错误,那么就用到了这位大神的另一个工具:
flexipatch-finalizer
这个工具会去掉所有未使用的补丁代码,重新生成所选补丁的最终版本
重新生成的这个版本编辑起来会轻松一些…
cd ~/workspaces
git clone git@github.com:bakkeby/flexipatch-finalizer.git
生成最终版本
注意:这个命令会把目标文件夹(就是下面的命令中 -o 后面的目录)中的所有内容删除,并且不可恢复
cd ~/workspaces/flexipatch-finalizer
./flexipatch-finalizer.sh -r -d ~/workspaces/dwm-flexipatch -o ~/.config/dwm
编辑一下这个文件,修改部分内容
比如字体,颜色,边框大小
需要注意的是一定要设置一下终端,dwm默认是使用st作为终端,如果你不用st,需要修改一下代码,把你的终端写上去,不然进了桌面无法打开终端
cd ~/.config/dwm
vi config.def.h
// 边框宽度
static const unsigned int borderpx = 2;
//屏幕间隙
static const unsigned int gappih = 2;
static const unsigned int gappiv = 2;
static const unsigned int gappoh = 2;
static const unsigned int gappov = 2;
static const int smartgaps_fact = 2;
// polybar运行脚本
// 我个人是比较喜欢Forest主题,根据自己喜好修改
static const char *altbarcmd = "$HOME/.config/polybar/launch.sh --forest";
// 字体,根据自己的字体名称填
static const char *fonts[] = { "FiraCode Nerd Font Mono:size=10" };
//启用了COOL_AUTOSTART才会出现下面这段,加入dwm启动时自动运行的程序
我注释掉的第一条是个通过命令运行脚本的例子
可以根据自己需要添加删除
格式:"命令名", "参数1", "参数2", "参数n”, NULL,
static const char *const autostart[] = {
//"sh", "-c", "$HOME/.dwm/autostart.sh", NULL,
"numlockx", "on", NULL,
"fcitx5", NULL,
"nitrogen", "--restore", NULL,
"picom", NULL,
NULL /* terminate */
};
// 如果不用st,就改成其他终端模拟器
//const char *spcmd1[] = {"st", "-n", "spterm", "-g", "120x34", NULL };
const char *spcmd1[] = {"wezterm", "-n", "spterm", "-g", "120x34", NULL };
// 标签名,可以使用图标
{
[DEFAULT_TAGS] = { "", "", "", "", "", "6", "7", "8", "9" },
[ALTERNATIVE_TAGS] = { "A", "B", "C", "D", "E", "F", "G", "H", "I" },
[ALT_TAGS_DECORATION] = { "<1>", "<2>", "<3>", "<4>", "<5>", "<6>", "<7>", "<8>", "<9>" },
};
//static const char *termcmd[] = { "st", NULL };
static const char *termcmd[] = { "wezterm", NULL };
不要忘了安装终端模拟器
paru wezterm
每次修改完config.def.h都需要重新编译安装
rm config.h
make && sudo make clean install
cp /etc/X11/xinit/xinitrc ~/.xinitrc
vi ~/.xinitrc
最下面的5行删除,加上
exec dwm
进入桌面
startx
st和dmenu和dwm是一样的步骤,弄一遍就OK
三、安装Polybar
通过startx,进入只有一个鼠标指针的桌面,别慌,继续往下看
按快捷键打开终端
alt+shift+enter
在dwm上使用Polybar需要先安装一个补丁
这一步会安装polybar和相关的依赖,如果你之前安装了Polybar,那么会让你选择是否卸载,当然选y…
paru -S polybar-dwm-module
到这里克隆一个polybar主题
cd ~/workspaces
git clone git@github.com:adi1090x/polybar-themes
cd polybar-themes
./setup.sh
// 选择 "1"并回车,adi1090x的所有主题都安装到了 ~/.config/polybar 里
编辑一下config.ini文件
修改一下字体部分
字体部分说明:
一共分四部分
1、font-0,font-1中的0,1是字体编号,注意引用的时候序号是从1开始,就是font-0 是 1,font-1是2
2、后面接字体名
3、字体大小
4、字体大小后面的数字,是控制文字在状态栏中的纵向位置,需要根据自己的状态栏高度调整
cd ~/.config/polybar/forest
vi config.ini
font-0 = "Hack Nerd Font:size=8;2"
font-1 = "FiraCode Nerd Font:size=8;2"
font-2 = "feather:size=9;2"
font-3 = "FiraCode Nerd Font:size=11;2"
font-4 = "feather:size=12;3"
font-5 = "feather:size=10;3"
控制polybar上要显示的模块,根据自己需要在同文件夹下的module.ini和user_module.ini里找到相应的名字填上去就可以了
modules-left = launcher sep dwm sep title
modules-center = date
modules-right = volume sep updates
再修改修改一下这个文件
vi module.ini
在文件最后加入下面的代码,
简单说明一下需要修改的部分:
1、padding是控制间距的
2、foreground和background分别是前景色和背景色,在color.ini文件中可以定义颜色,通过color.颜色 ,进行引用,比如: color.red
3、font就是字体,根据config.ini中的字体编号引用
[module/dwm]
type = internal/dwm
; format = <label-tags> <label-layout> <label-floating> <label-title>
; 我使用polybar的title显示title,所以去掉了<label-title>
format = <label-tags> <label-layout> <label-floating>
;socket-path = /tmp/dwm.sock
enable-tags-click = true
enable-tags-scroll = true
tags-scroll-empty = false
tags-scroll-reverse = false
tags-scroll-wrap = true
enable-layout-click = true
enable-layout-scroll = true
layout-scroll-wrap = true
layout-scroll-reverse = true
; If enable-layout-click = true, clicking the layout symbol will switch to this layout
secondary-layout-symbol = [M]
; Tagas:
; Available tokens:
; %name%
label-floating = F
; 我使用polybar的title模块,所以这里的title我注释掉
;label-title = %title%
;label-title-maxlen = 35
;label-title-padding = 1
;label-title-foreground = ${colors.foreground}
;label-title-background = ${colors.background}
label-layout = %symbol%
label-layout-padding = 1
label-layout-foreground = ${colors.foreground}
label-layout-background = ${colors.background}
; focused = Active tag on focused monitor
label-focused = %name%
label-focused-background = ${colors.background}
label-focused-foreground = ${colors.foreground}
label-focused-padding = 1
label-focused-font = 4
; unfocused = Inactive tag on any monitor
label-unfocused = %name%
label-unfocused-background = ${colors.background}
label-unfocused-foreground = ${colors.foreground}
label-unfocused-padding = 1
label-unfocused-font = 4
; visible = Active tag on unfocused monitor
label-visible = %name%
label-visible-background = ${colors.background}
label-visible-foreground = ${colors.foreground}
label-visible-padding = 1
label-visible-font = 4
; urgent = Tag with urgency hint set
label-urgent = %name%
label-urgent-background = ${colors.background}
label-urgent-padding = 1
label-urgent-font = 4
; empty = Tags with no windows assigned
; This can be set to an empty string to hide empty tags
label-empty =
; Separator in between workspaces
; label-separator = |
目前使用中发现的问题:通过鼠标滚轮切换layout,dwm会崩溃,原因未知,所以我禁用了滚轮切换layout
在github上问了一下,作者给出了解决办法并且主线也更新了,所以现在不存在这个问题了,可以正常滚轮切换
四、Fish Shell
sudo pacman -S fish
// or
paru fish
Fisher , fish 的插件管理器
curl -sL https://git.io/fisher | source && fisher install jorgebucaran/fisher
安装插件
fisher install kidonng/zoxide.fish
fisher install decors/fish-colored-man
fisher install meaningful-ooo/sponge
fisher install jorgebucaran/autopair.fish
fisher install jorgebucaran/spark.fish
fisher install shoriminimoe/fish-extract
fisher install mattmc3/themepack.fish
fisher install acomagu/fish-async-prompt
fisher install PatrickF1/fzf.fish
fisher install gazorby/fish-abbreviation-tips
fisher install nickeb96/puffer-fish
五、 登录管理器
根据喜好安装,sddm,lightdm,gdm 等等
我个人选择用ly,就输个密码而已,不用搞那么复杂
paru -S ly
sudo systemctl enable ly
六、一些个人使用的工具
软件名 | 安装方式 | 说明 | 官网 |
---|---|---|---|
asciinema | pacman | 一个终端录制工具 | 网站 |
bat | pacman | cat的替代版本,使用rust编写 | 网站 |
copyq | pacman | 剪贴板管理软件 | 网站 |
dunst | pacman | 通知程序 | 网站 |
dust | pacman | 类似du,使用rust编写 | 网站 |
exa | pacman | ls的替代版本,使用rust编写,具体查看:man exa | 网站 |
fd | pacman | find的替代版本,使用rust编写 | 网站 |
bottom | pacman | 系统实时监控,类似的有htop等,运行命令: btm | 网站 |
gitui | pacman | 终端 git 管理 | 网站 |
maim | pacman | 截图工具 | 网站 |
nsxiv | paru | 看图工具 | 网站 |
procs | pacman | 替换 ps ,rust编写,需要sudo权限,具体查看网站说明 | 网站 |
ripgrep | pacman | grep的替代版本,使用rust编写, 运行命令: rg | 网站 |
rofi | pacman | 程序运行器 | 网站 |
sd | pacman | 类似sed的查找和替换工具, rust编写 | 网站 |
tealdeer | pacman | tldr的rust版,速度更快,和tldr冲突,安装时会自动卸载tldr | 网站 |
pacman | 文件管理器 | 网站 | |
pacman | 文件管理器,类似ranger | 网站 | |
xplr | pacman | 另一个文件管理器,rust编写 | 网站 |
zoxide | pacman | 一个更智能的 CD 命令,如果用fish shell可以用插件替代 | 网站 |
uutils-coreutils | pacman | 用rust重写的GNU工具包,我正犹豫用不用… | 网站 |
其他网站
rust编写的软件合辑,非常多的工具 |
---|
https://github.com/rust-unofficial/awesome-rust |
NVIM 预配置方案
NVIM配色:everForest
NVIM配色:gruvbox
NVIM配色:tokyonight
截图(配色:tokyonight):
截图是leftwm的纪念…dwm基本是一个样子,只不过不显示空标签
2023.2.5 上传一张截图
还是leftwm…将就用吧 😃