-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathwconfig
More file actions
executable file
·425 lines (387 loc) · 13.7 KB
/
wconfig
File metadata and controls
executable file
·425 lines (387 loc) · 13.7 KB
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
#!/usr/bin/env bash
#############################
# wconfig : wayland config tools
#
# wayland 界面配置工具: 默认使用 hyprland 窗口管理器
#
#
# Author : Awkee
# Github: https://github.com/switchToLinux/dotfiles-wayland
#
# License : GPLv3
# 菜单显示命令: 可选 fzf / wofi
# MENU_CMD="wofi --dmenu --width 400 --height 400"
MENU_CMD="fzf"
need_confirm="yes"
pkg_cmd=""
pkg_update_cmd=""
ERR_FILE="/tmp/wconfig.err.log"
git_url="https://github.com/switchToLinux/dotfiles"
notify() {
local title="${1}"
local message="${2}"
local urgency="${3:-normal}" # low, normal, critical
# notify-send "${title}" "${message}" -u "${urgency}"
# 检查是否安装了 notify-send
if command -v notify-send &>/dev/null; then
notify-send "${title}" "${message}" -u "${urgency}"
else
echo "${title}: ${message}"
fi
}
LOG() {
printf "\033[0;32m INFO: %s - %s \033[0m\n" "$(date +'%Y-%m-%d %H:%M:%S')" "$@"
}
ERR() {
printf "\033[0;31;7m ERROR: %s - %s \033[0m\n" "$(date +'%Y-%m-%d %H:%M:%S')" "$@"
notify "Error" "$@" "critical"
}
LOG "Start wconfig , log file: ${ERR_FILE}"
# 检查依赖软件是否安装
check_depends() {
local depends=(
"fzf"
"git"
)
for depend in "${depends[@]}"; do
if ! command -v "${depend}" &>/dev/null; then
notify "Error: ${depend} is not installed. Please install it first."
exit 1
fi
done
}
# 安装软件集合 , 可以个根据不同发行版选择不同的变量
# 格式: 软件名称: 软件包名称列表
# 默认支持的发行版: arch 系列
declare -A package_set=(
["display_manager"]="sddm qt6-svg qt6-virtualkeyboard qt6-multimedia-ffmpeg"
["compositor"]="hyprland hyprutils hyprlock hyprcursor hyprpaper hypridle xdg-desktop-portal xdg-desktop-portal-hyprland"
["bar"]="waybar"
["launcher_menu"]="wofi"
["notification"]="mako dunst"
["file_manager"]="thunar yazi ueberzugpp" # 支持terminal图片预览
["wallpaper"]="swww zenity"
["cliphist"]="cliphist wl-clipboard"
["terminal"]="xfce4-terminal kitty zsh tmux"
["bluetooth"]="blueman"
["brightnessctl"]="brightnessctl"
["browser"]="firefox"
["input_method"]="fcitx5 fcitx5-chinese-addons fcitx5-gtk fcitx5-configtool fcitx5-qt"
["media_player"]="mpv mpv-mpris ffmpeg"
["password_manager"]="keepassxc"
["screen_shot"]="flameshot grim slurp"
["devel_tools"]="base-devel code"
["video_recorder"]="wf-recorder"
["network_manager"]="networkmanager network-manager-applet"
["audio_processor"]="pipewire pipewire-alsa pipewire-pulse pipewire-jack wireplumber qpwgraph playerctl pavucontrol pamixer"
["fonts"]="ttf-jetbrains-mono-nerd ttf-jetbrains-mono noto-fonts-cjk powerline noto-fonts-emoji"
["theme_config"]="qt5ct qt6ct nwg-look"
["utils"]="jq yq yt-dlp unzip unarchiver"
)
get_pack_cmd() {
local pack_cmd=$(command -v apt || command -v yay || command -v paru || command -v pacman || command -v yum || command -v dnf || command -v zypper)
cmd_name="$(basename ${pack_cmd})"
if [[ "${need_confirm}" != "yes" ]]; then
# 增加不需要确认参数
case "${cmd_name}" in
apt)
pack_cmd="apt install -y"
pkg_update_cmd="apt update -y"
;;
pacman | yay | paru)
pack_cmd="${cmd_name} -Sy --noconfirm --needed"
pkg_update_cmd="${cmd_name} -Sy --noconfirm --needed"
;;
yum)
pack_cmd="yum install -y"
pkg_update_cmd="yum update -y"
;;
dnf)
pack_cmd="dnf install -y"
pkg_update_cmd="dnf update -y"
;;
zypper)
pack_cmd="zypper install -y"
pkg_update_cmd="zypper update -y"
;;
esac
else
case "${cmd_name}" in
apt)
pack_cmd="apt install "
pkg_update_cmd="apt update -y"
;;
pacman | yay | paru)
pack_cmd="${cmd_name} -Sy --noconfirm --needed"
pkg_update_cmd="${cmd_name} -Sy --noconfirm --needed"
;;
yum)
pack_cmd="yum install "
pkg_update_cmd="yum update -y"
;;
dnf)
pack_cmd="dnf install "
pkg_update_cmd="dnf update -y"
;;
zypper)
pack_cmd="zypper install "
pkg_update_cmd="zypper update -y"
;;
esac
fi
if [[ "$(id -u)" -ne "0" && ! "$cmd_name" =~ ^(yay|paru) ]]; then
echo "sudo ${pack_cmd}"
else
echo "${pack_cmd}"
fi
}
install_hyprland() {
need_confirm=${1:-"yes"}
# 获取软件包安装命令
pkg_cmd=$(get_pack_cmd)
# 更新软件包列表
$pkg_update_cmd
# 检查依赖软件是否安装
for pack_name in "${!package_set[@]}"; do
LOG "DEBUG: installing module_name: [${pack_name}] ,packages: ${package_set[${pack_name}]}"
${pkg_cmd} ${package_set[${pack_name}]}
# 安装错误退出
[[ "$?" -ne "0" ]] && ERR "Install ${pack_name} failed" && return 1
LOG "Install ${pack_name} success"
done
}
auto_install() {
install_hyprland "no"
config_hyprland
}
config_hyprland() {
dest_dir="~/.config/dotfiles-wayland"
[[ -d "${dest_dir}" ]] && read -p "dest_dir ${dest_dir} already exists, do you want to continue? (y/n) " choice && [[ ! "${choice}" =~ ^[Yy]$ ]] && return 0
[[ -d "${dest_dir}" ]] && rm -rf ${dest_dir}
git clone ${git_url} ${dest_dir} >>${ERR_FILE} 2>&1
[[ "$?" -ne "0" ]] && ERR "git clone ${git_url} failed" && return 1
cd ${dest_dir}
[[ "$?" -ne "0" ]] && ERR "cd ${dest_dir} failed" && return 1
cp -rp hypr mako waybar wofi xfce4 mpd yazi Thunar ~/.config/
[[ "$?" -ne "0" ]] && ERR "config failed" && return 1
}
config_sddm() {
LOG "config sddm"
sudo git clone -b master --depth 1 https://github.com/keyitdev/sddm-astronaut-theme.git /usr/share/sddm/themes/sddm-astronaut-theme
[[ "$?" -ne "0" ]] && ERR "git clone sddm-astronaut-theme failed" && return 1
sudo cp -r /usr/share/sddm/themes/sddm-astronaut-theme/Fonts/* /usr/share/fonts/
sudo cp -r /usr/share/sddm/themes/sddm-astronaut-theme/Fonts/* /usr/share/fonts/
echo -e "[Theme]\nCurrent=sddm-astronaut-theme" | sudo tee /etc/sddm.conf
[[ -d "/etc/sddm.conf.d" ]] || sudo mkdir -p /etc/sddm.conf.d
echo -e "[General]\nInputMethod=qtvirtualkeyboard" | sudo tee /etc/sddm.conf.d/virtualkbd.conf
[[ "$?" -ne "0" ]] && ERR "config sddm failed" && return 1
notify "config sddm success"
}
config_grub() {
LOG "config grub"
grub_url="https://github.com/vinceliuice/grub2-themes"
dest_dir="/tmp/grub2-themes"
[[ -d "${dest_dir}" ]] && read -p "dest_dir ${dest_dir} already exists, do you want to continue? (y/n) " choice && [[ ! "${choice}" =~ ^[Yy]$ ]] && return 0
[[ -d "${dest_dir}" ]] && rm -rf ${dest_dir}
git clone --depth=1 ${grub_url} ${dest_dir} >>${ERR_FILE} 2>&1
[[ "$?" -ne "0" ]] && ERR "git clone ${grub_url} failed" && return 1
cd ${dest_dir}
[[ "$?" -ne "0" ]] && ERR "cd ${dest_dir} failed" && return 1
#sudo ./install.sh -t whitesur -c 1366x768
sudo ./install.sh -t whitesur
}
config_gtk() {
LOG "config gtk-theme"
dest_dir="/tmp/gtk-themes"
[[ -d "${dest_dir}" ]] && read -p "dest_dir ${dest_dir} already exists, do you want to continue? (y/n) " choice && [[ ! "${choice}" =~ ^[Yy]$ ]] && return 0
[[ -d "${dest_dir}" ]] && rm -rf ${dest_dir}
git clone https://github.com/vinceliuice/WhiteSur-gtk-theme.git --depth=1 ${dest_dir} >>${ERR_FILE} 2>&1
[[ "$?" -ne "0" ]] && ERR "git clone https://github.com/vinceliuice/WhiteSur-gtk-theme.git failed" && return 1
cd ${dest_dir}
[[ "$?" -ne "0" ]] && ERR "cd ${dest_dir} failed" && return 1
./install.sh -t all
[[ "$?" -ne "0" ]] && ERR "install gtk-theme failed" && return 1
LOG "config gtk-icon-theme"
dest_dir="/tmp/gtk-icon-themes"
[[ -d "${dest_dir}" ]] && read -p "dest_dir ${dest_dir} already exists, do you want to continue? (y/n) " choice && [[ ! "${choice}" =~ ^[Yy]$ ]] && return 0
[[ -d "${dest_dir}" ]] && rm -rf ${dest_dir}
git clone https://github.com/vinceliuice/WhiteSur-icon-theme.git --depth=1 ${dest_dir} >>${ERR_FILE} 2>&1
[[ "$?" -ne "0" ]] && ERR "git clone https://github.com/vinceliuice/WhiteSur-icon-theme.git failed" && return 1
cd ${dest_dir}
[[ "$?" -ne "0" ]] && ERR "cd ${dest_dir} failed" && return 1
./install.sh -t all
[[ "$?" -ne "0" ]] && ERR "install gtk-icon-theme failed" && return 1
LOG "config cursor-theme"
dest_dir="/tmp/cursor-themes"
[[ -d "${dest_dir}" ]] && read -p "dest_dir ${dest_dir} already exists, do you want to continue? (y/n) " choice && [[ ! "${choice}" =~ ^[Yy]$ ]] && return 0
[[ -d "${dest_dir}" ]] && rm -rf ${dest_dir}
git clone https://github.com/guillaumeboehm/Nordzy-cursors.git --depth=1 ${dest_dir} >>${ERR_FILE} 2>&1
[[ "$?" -ne "0" ]] && ERR "git clone https://github.com/guillaumeboehm/Nordzy-cursors.git failed" && return 1
cd ${dest_dir}
[[ "$?" -ne "0" ]] && ERR "cd ${dest_dir} failed" && return 1
./install.sh -p
[[ "$?" -ne "0" ]] && ERR "install cursor-theme failed" && return 1
notify "config gtk-theme success"
}
show_theme_menu() {
echo "1. config hyprland theme"
echo "2. config waybar theme"
echo "3. config gtk theme(gtk-icon-theme, icon-theme, cursor-theme)"
}
theme_config() {
LOG "theme config"
choice=$(show_theme_menu | ${MENU_CMD} | awk -F'.' '{printf $1}')
case "${choice}" in
1) config_hyprland ;;
2) config_waybar ;;
3) config_gtk ;;
*) echo "Invalid choice. Please try again." ;;
esac
}
config_wallpaper() {
wallpaper_dir="$HOME/wallpapers"
wall_url=https://github.com/D3Ext/aesthetic-wallpapers
[[ -d "${wallpaper_dir}" ]] && return 0
git clone --depth=1 ${wall_url} ${wallpaper_dir} >>${ERR_FILE} 2>&1
[[ "$?" -ne "0" ]] && ERR "git clone ${wall_url} failed" && return 1
LOG "config wallpaper success"
notify "config wallpaper success"
}
install_video_driver() {
LOG "install video driver"
pkg_cmd=$(get_pack_cmd)
nvidia_driver="nvidia-dkms nvidia-utils"
# 检查是否安装了 nvidia 显卡设备
if lspci | grep -i nvidia | grep -i vga; then
LOG "Detected NVIDIA GPU, installing drivers..."
${pkg_cmd} ${nvidia_driver} >>${ERR_FILE} 2>&1
[[ "$?" -ne "0" ]] && ERR "Install nvidia driver failed" && return 1
# 配置 nvidia 到 grub
if [ -f /etc/default/grub ]; then
sudo sed -i -e '/GRUB_CMDLINE_LINUX_DEFAULT=/ s/"$/ nvidia-drm.modeset=1 nvidia_drm.fbdev=1"/' /etc/default/grub
sudo grub-mkconfig -o /boot/grub/grub.cfg
LOG "Config nvidia to grub success"
fi
LOG "Install nvidia driver success"
notify "Install nvidia driver success"
return 0
fi
LOG "No NVIDIA GPU detected, skipping driver installation."
}
install_paru() {
LOG "install paru"
LOG "install paru"
paru_url="https://aur.archlinux.org/paru.git"
paru_dir="/tmp/paru"
[[ -d "${paru_dir}" ]] && rm -rf ${paru_dir}
git clone --depth=1 ${paru_url} ${paru_dir} >>${ERR_FILE} 2>&1
[[ "$?" -ne "0" ]] && ERR "git clone ${paru_url} failed" && return 1
cd ${paru_dir}
[[ "$?" -ne "0" ]] && ERR "cd ${paru_dir} failed" && return 1
makepkg -si
[[ "$?" -ne "0" ]] && ERR "makepkg -si failed" && return 1
LOG "Install paru success"
notify "Install paru success"
}
install_yay() {
LOG "install yay"
aur_url="https://aur.archlinux.org/yay.git"
aur_dir="/tmp/yay"
[[ -d "${aur_dir}" ]] && rm -rf ${aur_dir}
git clone --depth=1 ${aur_url} ${aur_dir} >>${ERR_FILE} 2>&1
[[ "$?" -ne "0" ]] && ERR "git clone ${aur_url} failed" && return 1
cd ${aur_dir}
[[ "$?" -ne "0" ]] && ERR "cd ${aur_dir} failed" && return 1
makepkg -si
[[ "$?" -ne "0" ]] && ERR "makepkg -si failed" && return 1
LOG "Install aur success"
notify "Install aur success"
}
install_aur() {
LOG "install aur"
# 选择 install_paru 或者 install_yay
pkg_cmd=$(get_pack_cmd)
choice=$({
echo "1. install_paru"
echo "2. install_yay"
} | ${MENU_CMD} | awk -F'.' '{printf $1}')
case "${choice}" in
1)
install_paru
;;
2)
install_yay
;;
*)
echo "Invalid choice. Please try again."
;;
esac
[[ "$?" -ne "0" ]] && ERR "Install aur failed" && return 1
LOG "Install aur success"
notify "Install aur success"
}
install_fonts() {
# Download JetBrainsMonoNerdFonts
LOG "install fonts"
fonts_url="https://github.com/ryanoasis/nerd-fonts/releases/download/v3.4.0/JetBrainsMono.tar.xz"
download_folder="/tmp/JetBrainsMono"
[[ ! -d "${download_folder}" ]] && mkdir ${download_folder}
curl -o $download_folder/JetBrainsMono.tar.xz -L "$fonts_url"
[[ "$?" -ne "0" ]] && ERR "Download fonts failed" && return 1
mkdir -p ~/.local/share/fonts/JetBrainsMonoNerd
tar -Jxf $download_folder/JetBrainsMono.tar.xz -C ~/.local/share/fonts/JetBrainsMonoNerd
[[ "$?" -ne "0" ]] && ERR "Extract fonts failed" && return 1
LOG "Install fonts success"
notify "Install fonts success"
}
enable_dm() {
LOG "enable sddm"
sudo systemctl set-default graphical.target
sudo systemctl enable --now bluetooth.service
sudo systemctl enable --now NetworkManager.service
sudo systemctl enable --now sddm
[[ "$?" -ne "0" ]] && ERR "Enable sddm failed" && return 1
LOG "Enable sddm success"
notify "Enable sddm success"
}
# 主菜单
main_menu() {
echo "0. install hyprland and config"
echo "-------------------------"
echo "1. install hyprland"
echo "2. config hyprland"
echo "-------------------------"
echo "a. install aur"
echo "d. install video driver"
echo "f. install fonts"
echo "s. enable sddm"
echo "t. theme config"
echo "w. config wallpaper"
echo "-------------------------"
echo "q. quit"
}
show_main_menu() {
main_menu | ${MENU_CMD} | awk -F'.' '{printf $1}'
}
do_main_menu() {
local choice
choice=$(show_main_menu)
case "${choice}" in
1) install_hyprland ;;
2) config_hyprland ;;
3) config_sddm ;;
4) config_grub ;;
0) auto_install ;;
d) install_video_driver ;;
f) install_fonts ;;
s) enable_dm ;;
t) theme_config ;;
q | "") return 0 ;;
w) config_wallpaper ;;
a) install_aur ;;
*) echo "Invalid choice. Please try again." ;;
esac
}
check_depends || exit 1
pkg_cmd=$(get_pack_cmd)
do_main_menu