-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·166 lines (145 loc) · 7.22 KB
/
configure
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
#!/usr/bin/env bash
# Copyright (c) 2024 Kieran Moy <[email protected]>
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# This script automates the configuration setup for Arch Linux Hyprland Environment.
# It provides functions to generate dotfile manager script, check configure,
# and install necessary packages.
# Usage: ./configure [gendf, check, wallpaper, ...]
set -e
PROGRAM="${0##*/}"
info() { echo -e "\033[0;34m==>\033[0m \033[1;33m$PROGRAM: \033[0m$*" >&2; }
note() { info "\033[01;36mNote: \033[0m$*"; }
warn() { info "\033[01;35mWarning: \033[0m$*"; }
err() { info "\033[01;31mError: \033[0m$*" && exit 1; }
usage() {
echo "./configure [gendf, check, wallpaper, ...]"
return 1
}
generate-df() {
[[ -z $1 ]] && branch="master" || branch=$1
cat <<EOF > df
#!/usr/bin/env bash
git --git-dir=$HOME/.dotfiles --work-tree=$HOME add \$@
git --git-dir=$HOME/.dotfiles --work-tree=$HOME diff origin/$branch \$@
git --git-dir=$HOME/.dotfiles --work-tree=$HOME commit -m "update"
git --git-dir=$HOME/.dotfiles --work-tree=$HOME push origin $branch
EOF
chmod +x df
return 1
}
check() {
for pkg in $(pacman -Qq); do
printf "checking $pkg ... " && pacman -Qkq $pkg >/dev/null 2>&1 && echo 'yes' || (echo 'no' && warn "package \"$pkg\" is broken")
done
zsh -n $0
return 1
}
yn() {
read -p "$@ (Y/n) " yorn
[[ $yorn =~ ^[Yy] ]] || [[ -z $yorn ]]
}
wallpaper() {
declare -a arr=("l8v3ey" "01q59v" "1pwez3" "2yjp6x" "d6mkv3" "l8gg9l" "vqv3p8")
for id in "${arr[@]}"; do
curl https://wallhaven.cc/api/v1/w/$id | jq -s '.[].[].path' | xargs wget -nc -P ~/Wallpapers
done
return 1
}
[[ $(pwd) == $HOME ]] && [[ -d .git ]] && ([[ -d .dotfiles ]] || mv .git .dotfiles)
lockfile="$(pacman-conf DBPath)/db.lck"
while [[ -f $lockfile ]]; do
timer=0
warn "Pacman is currently in use, please wait..."
while [[ -f $lockfile ]] && (( timer < 10 )); do
(( ++timer ))
sleep 3
done
done
if [[ -n $1 ]]; then
trap 'exit 0' EXIT
case $1 in \
-h|--help) usage;; \
gen*) generate-df $2;; \
check*) check;; \
wall*) wallpaper;; \
*) err "unknown argument $1";;
esac
fi
cat /etc/os-release 2>/dev/null
info "Synchronizing package databases..."
sudo pacman -Sy >/dev/null
sudo pacman -S --noconfirm --needed --asexplicit 2>/dev/null alsa-utils \
brightnessctl \
btop \
cava \
cliphist \
dunst \
eog \
fcitx5 \
fcitx5-{chinese-addons,configtool,gtk,pinyin-zhwiki,qt,rime} \
feh \
fzf \
gnome-tweaks \
grim \
helix \
htop \
hyprland \
kdeconnect \
kitty \
nerd-fonts \
nm-connection-editor \
nwg-bar \
opendesktop-fonts \
pavucontrol \
pipewire-{audio,pulse} \
polkit-kde-agent \
{qt5,qt6}{ct,-wayland} \
rofi \
slurp \
swww \
translate-shell \
ttf-arphic-ukai \
ttf-arphic-uming \
ttf-hannom \
thunar \
thunar-archive-plugin \
thunar-volman \
udiskie \
waybar \
wayland \
wayland-protocols \
wireplumber \
wl-clipboard \
wqy-microhei \
wqy-microhei-lite \
wqy-zenhei \
xdg-desktop-portal \
xdg-desktop-portal-hyprland \
xfce4-settings \
xorg-xwayland\
zsh \
zsh-{autosuggestions,completions,syntax-highlighting}
if [[ ! -f /usr/bin/xterm && ! -f /usr/bin/uxterm ]]; then
sudo ln -sf /usr/bin/kitty /usr/bin/xterm
sudo ln -sf /usr/bin/kitty /usr/bin/uxterm
fi
info 'Finished configuring. Enjoy !'
note 'Run "./configure wallpaper" for wallpapers'