-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwconfig
More file actions
executable file
·563 lines (500 loc) · 19.6 KB
/
wconfig
File metadata and controls
executable file
·563 lines (500 loc) · 19.6 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
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
#!/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"
pkg_cmd=""
pkg_update_cmd=""
CURL="curl -C - "
git_url="https://github.com/switchToLinux/dotfiles-wayland"
####################### PROMPT FUNCTION #######################
#### 默认选项 #####
default_confirm="no" # 是否显示提示确认,no-(默认)提示,yes-自动选择yes
PMT=">>>"
READ_TIMEOUT=30 # read timeout seconds
# Define Colors
RED='\e[41m'
BRB='\e[1;7;31;47m' # Blink Red bold
NC='\e[0m' # No color
BG='\e[7m' # Highlighting Background color
TC='\e[1m' # Highlighting Text color
function echo_greenr() { printf "\033[0;32;7m$@\033[0m" ; }
function redr_line() { printf "\033[0;31;7m$@\033[0m\n" ; }
item_index=0 # 记录菜单选项序号
item_line_count=3 # 每行显示菜单数量
ILEN=30 # 单个选项长度
MLEN=$(( (${ILEN}+1) * ${item_line_count})) # 单行最大长度
function print_feed() {
for i in $(seq 1 $item_line_count) ; do
printf "+%${ILEN}s" | tr ' ' '-'
done
printf "+\n"
}
function menu_line() { echo -en "| ${BRB} $@ $NC" ; tput hpa $MLEN ; echo "|" ; }
# 居中显示菜单选项
# 函数: center_line text max_len
function center_line() {
local text="$1"
local width="${2:-$MLEN}" # 默认使用终端宽度
local plain_text
plain_text=$(echo -n "$text" | sed 's/\x1B\[[0-9;]*[JKmsu]//g')
local text_len=${#plain_text}
# 计算左右填充空格
local total_padding=$((width - text_len))
local left_padding=$((total_padding / 2))
local right_padding=$((total_padding - left_padding))
# 构建输出:| + 左空格 + 文本 + 右空格 + |
printf "| %*s${BRB}%s${NC}" "$left_padding" "" "$text" ; tput hpa $width ; printf "|\n"
}
function menu_head() { print_feed; center_line "$@" ; print_feed; }
# 一行可以有 item_line_count 个菜单选项
function menu_item() { let item_index=$item_index+1 ; n=$1 ; shift ; let rlen="$item_index * ($ILEN + 1)" ; echo -en "| $BG ${n} $NC $@" ; tput hpa $rlen ; [[ "$item_index" == "$item_line_count" ]] && echo "|" && item_index=0 ; }
# 输出单行长菜单选项,长度有限制
function menu_iteml() { n=$1 ; shift ; echo -en "| $BG ${n} $NC $@" ; tput hpa $MLEN ; echo "|" ; }
# 用于输入长信息(非菜单选项),不限制结尾长度
function menu_info() { n=$1 ; shift ; echo -e "| $BG ${n} $NC $@" ; }
function menu_tail() { [[ "$item_index" != "0" ]] && echo "|" ; print_feed; item_index=0 ; }
# 日志记录
function output_msg() { LEVEL="$1" ; shift ; echo -e "$(date +'%Y年%m月%d日%H:%M:%S'):${LEVEL}: $@" ; }
function loginfo() { output_msg "${BG}INFO${NC}" $@ ; }
function logerr() { output_msg "${BRB}ERROR${NC}" $@ ; }
function LOG() { output_msg "${BG}INFO${NC}" $@ ; }
function ERR() { output_msg "${BRB}ERROR${NC}" $@ ; }
#### 检测当前终端支持色彩
function check_term() {
# 指定 TERM ,避免对齐问题(已知某些rxvt-unicode终端版本存在对齐问题)
if [[ "`tput colors`" -lt "256" ]] ; then
export TERM=xterm
export COLORTERM=truecolor
fi
}
# 基础依赖命令检测与运行环境 #
function check_basic() {
command -v curl &>/dev/null || sudo $pac_cmd_ins curl
command -v git &>/dev/null || sudo $pac_cmd_ins git
command -v fzf &>/dev/null || sudo $pac_cmd_ins fzf
# 运行环境检测 #
[[ "$(id -u)" -eq 0 ]] && echo "Please run this script by none root user!" && exit 1
! grep -q "ID=arch" /etc/os-release && echo "Sorry! This script only support Arch Linux!" && exit 1
check_term
}
################################################################
# 提示确认函数,如果使用 -y 参数默认为Y确认
function prompt() {
msg="$@"
if [ "$default_confirm" != "yes" ] ; then
read -t $READ_TIMEOUT -r -n 1 -e -p "$msg (y/`echo_greenr N`)" str_answer
case "$str_answer" in
y*|Y*) echo "Confirmed" ; return 0 ;;
*) echo "Canceled" ; return 1 ;;
esac
fi
return 0
}
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
}
# 安装软件集合 , 可以个根据不同发行版选择不同的变量
# 格式: 软件名称: 软件包名称列表
# 默认支持的发行版: 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"
["status_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 [[ "${default_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() {
default_confirm=${1:-"no"}
prompt "start install hyprland" || return 0
# 获取软件包安装命令
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
}
config_hyprland() {
prompt "config hyprland" || return 0
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}
[[ "$?" -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
}
auto_install() {
prompt "ready to auto install and config hyprland?" || return 0
install_hyprland "yes"
config_hyprland
}
config_sddm() {
prompt "config sddm" || return 0
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() {
prompt "config grub" || return 0
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}
[[ "$?" -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
}
config_gtk() {
prompt "config gtk-theme" || return 0
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}
[[ "$?" -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}
[[ "$?" -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}
[[ "$?" -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() {
menu_head "config hyprland"
menu_item 1 config hyprland theme
menu_item 2 config waybar theme
menu_item 3 config gtk theme
menu_tail
}
theme_config() {
LOG "theme config"
while true ; do
show_theme_menu
read -r -n 1 -e -p "`echo_greenr choice:`${PMT} " choice
case "${choice}" in
1) config_hyprland ;;
2) config_waybar ;;
3) config_gtk ;;
q|"") return 0 ;;
*) echo "Invalid choice[$choice]" ;;
esac
done
}
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}
[[ "$?" -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}
[[ "$?" -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."
}
function download_nvidia_driver() {
prompt "ready to download nvidia driver" || return 1
command -v jq >/dev/null || sudo $pac_cmd_ins jq
! command -v jq >/dev/null && logerr "please install jq command first!" && return 1
tmp_json=/tmp/tmp.nvidia.menu.json
# 下载链接(以 NVIDIA GeForce GTX 1660 SUPER 显卡为例,驱动兼容大部分 GeForce系列)
dn_url='https://gfwsl.geforce.cn/services_toolkit/services/com/nvidia/services/AjaxDriverService.php?func=DriverManualLookup&psid=112&pfid=910&osID=12&languageCode=2052&beta=null&isWHQL=0&dltype=-1&dch=0&upCRD=null&qnf=0&sort1=0&numberOfResults=10'
# 检查文件最后修改时间是否为 15天内 , 是就不重复下载,否则就下载新的json文件
old_json_file=`find $tmp_json -type f -mtime -15 2>/dev/null`
if [ "$old_json_file" = "" ] ; then
${CURL} -o $tmp_json $dn_url \
-H 'authority: gfwsl.geforce.cn' \
-H 'accept: */*' \
-H 'accept-language: zh-CN,zh;q=0.9,en;q=0.8,zh-TW;q=0.7' \
-H 'cache-control: no-cache' \
-H 'dnt: 1' \
-H 'origin: https://www.nvidia.cn' \
-H 'pragma: no-cache' \
-H 'referer: https://www.nvidia.cn/' \
-H 'sec-ch-ua: "Google Chrome";v="111", "Not(A:Brand";v="8", "Chromium";v="111"' \
-H 'sec-ch-ua-mobile: ?0' \
-H 'sec-ch-ua-platform: "Linux"' \
-H 'sec-fetch-dest: empty' \
-H 'sec-fetch-mode: cors' \
-H 'sec-fetch-site: cross-site' \
-H 'user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36' \
--compressed
[[ "$?" != "0" ]] && logerr "failed to get nvidia driver package list!" && return 1
fi
file_url=`cat $tmp_json |jq |awk '/DownloadURL/{ print $2 }' | sed -n 's/[",]//g; 1p'`
file_size=`cat $tmp_json |jq |awk '/DownloadURL/{ print $2 }' | sed -n 's/[",]//g; 2p'`
loginfo "download url: $file_url , file size: $file_size MB"
tmp_file="/tmp/`basename $file_url`"
if [ -f "$tmp_file" ] ; then
echo -e "${RED}Tips: ${tmp_file} is already downloaded !${NC}"
fi
prompt "Download nvidia driver package(file size: $file_size )" && ! ${CURL} -o $tmp_file -SL $file_url && logerr "Download nvidia driver failed!" && return 2
loginfo "install nvidia driver: $tmp_file ."
sh ${tmp_file}
loginfo "finish install nvidia driver."
}
install_paru() {
prompt "install paru" || return 0
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}
[[ "$?" -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() {
prompt "install yay" || return 0
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}
[[ "$?" -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"
}
show_aur_menu() {
menu_head "install AUR package manager"
menu_item 1 install yay
menu_item 2 install paru
menu_tail
}
install_aur() {
LOG "install aur"
pkg_cmd=$(get_pack_cmd)
while true ; do
show_aur_menu
read -r -n 1 -e -p "`echo_greenr choice:`${PMT} " choice
case "${choice}" in
1) install_yay ;;
2) install_paru ;;
q|"") return 0 ;;
*) echo "Invalid choice." ;;
esac
done
[[ "$?" -ne "0" ]] && ERR "Install aur failed" && return 1
LOG "Install aur success"
notify "Install aur success"
}
install_fonts() {
# Download JetBrainsMonoNerdFonts
prompt "install fonts" || return 0
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"
}
show_menu_main() {
menu_head "Main menu"
menu_item 0 auto install hyprland
menu_item 1 install hyprland
menu_item 2 config hyprland
menu_item a install aur
menu_item d install nvidia driver
menu_item f install fonts
menu_item s enable sddm
menu_item t theme config
menu_item w config wallpaper
menu_tail
menu_iteml q Quit
menu_tail
}
do_main_menu() {
local choice
while true ; do
show_menu_main
read -r -n 1 -e -p "`echo_greenr choice:`${PMT} " choice
case "${choice}" in
0) auto_install ;;
1) install_hyprland ;;
2) config_hyprland ;;
3) config_sddm ;;
4) config_grub ;;
a) install_aur ;;
d) download_nvidia_driver ;;
f) install_fonts ;;
q | "") return 0 ;;
s) enable_dm ;;
t) theme_config ;;
w) config_wallpaper ;;
*) echo "Invalid choice. Please try again." ;;
esac
done
}
#####################################################
# MAIN:PROCESS
check_basic || exit 1
pkg_cmd=$(get_pack_cmd)
do_main_menu