forked from caelestia-dots/caelestia
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.fish
More file actions
executable file
·311 lines (258 loc) · 9.08 KB
/
install.fish
File metadata and controls
executable file
·311 lines (258 loc) · 9.08 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
#!/usr/bin/env fish
argparse -n 'install.fish' -X 0 \
'h/help' \
'noconfirm' \
'spotify' \
'vscode=?!contains -- "$_flag_value" codium code' \
'discord' \
'zen' \
'aur-helper=!contains -- "$_flag_value" yay paru' \
-- $argv
or exit
# Print help
if set -q _flag_h
echo 'usage: ./install.sh [-h] [--noconfirm] [--spotify] [--vscode] [--discord] [--aur-helper]'
echo
echo 'options:'
echo ' -h, --help show this help message and exit'
echo ' --noconfirm do not confirm package installation'
echo ' --spotify install Spotify (Spicetify)'
echo ' --vscode=[codium|code] install VSCodium (or VSCode)'
echo ' --discord install Discord (OpenAsar + Equicord)'
echo ' --zen install Zen browser'
echo ' --aur-helper=[yay|paru] the AUR helper to use'
exit
end
# Helper funcs
function _out -a colour text
set_color $colour
# Pass arguments other than text to echo
echo $argv[3..] -- ":: $text"
set_color normal
end
function log -a text
_out cyan $text $argv[2..]
end
function input -a text
_out blue $text $argv[2..]
end
function sh-read
sh -c 'read a && echo -n "$a"' || exit 1
end
function confirm-overwrite -a path
if test -e $path -o -L $path
# No prompt if noconfirm
if set -q noconfirm
input "$path already exists. Overwrite? [Y/n]"
log 'Removing...'
rm -rf $path
else
# Prompt user
input "$path already exists. Overwrite? [Y/n] " -n
set -l confirm (sh-read)
if test "$confirm" = 'n' -o "$confirm" = 'N'
log 'Skipping...'
return 1
else
log 'Removing...'
rm -rf $path
end
end
end
return 0
end
# Variables
set -q _flag_noconfirm && set noconfirm '--noconfirm'
set -q _flag_aur_helper && set -l aur_helper $_flag_aur_helper || set -l aur_helper paru
set -q XDG_CONFIG_HOME && set -l config $XDG_CONFIG_HOME || set -l config $HOME/.config
set -q XDG_STATE_HOME && set -l state $XDG_STATE_HOME || set -l state $HOME/.local/state
set -l install_dir (path dirname (path resolve (status filename)))
# Startup prompt
set_color magenta
echo '╭─────────────────────────────────────────────────╮'
echo '│ ______ __ __ _ │'
echo '│ / ____/___ ____ / /__ _____/ /_(_)___ _ │'
echo '│ / / / __ `/ _ \/ / _ \/ ___/ __/ / __ `/ │'
echo '│ / /___/ /_/ / __/ / __(__ ) /_/ / /_/ / │'
echo '│ \____/\__,_/\___/_/\___/____/\__/_/\__,_/ │'
echo '│ │'
echo '╰─────────────────────────────────────────────────╯'
set_color normal
log 'Welcome to the Caelestia dotfiles installer!'
log 'Before continuing, please ensure you have made a backup of your config directory.'
# Prompt for backup
if ! set -q _flag_noconfirm
log '[1] Two steps ahead of you! [2] Make one for me please!'
input '=> ' -n
set -l choice (sh-read)
if contains -- "$choice" 1 2
if test $choice = 2
log "Backing up $config..."
if test -e $config.bak -o -L $config.bak
input 'Backup already exists. Overwrite? [Y/n] ' -n
set -l overwrite (sh-read)
if test "$overwrite" = 'n' -o "$overwrite" = 'N'
log 'Skipping...'
else
rm -rf $config.bak
cp -r $config $config.bak
end
else
cp -r $config $config.bak
end
end
else
log 'No choice selected. Exiting...'
exit 1
end
end
# Install AUR helper if not already installed
if ! pacman -Q $aur_helper &> /dev/null
log "$aur_helper not installed. Installing..."
# Install
sudo pacman -S --needed git base-devel $noconfirm
cd /tmp
git clone https://aur.archlinux.org/$aur_helper.git
cd $aur_helper
makepkg -si
cd ..
rm -rf $aur_helper
# Setup
if test $aur_helper = yay
$aur_helper -Y --gendb
$aur_helper -Y --devel --save
else
$aur_helper --gendb
end
end
# Cd into dir
cd $install_dir || exit 1
# Install metapackage for deps
log 'Installing metapackage...'
if test $aur_helper = yay
$aur_helper -Bi . $noconfirm
else
$aur_helper -Ui $noconfirm
end
fish -c 'rm -f caelestia-meta-*.pkg.tar.zst' 2> /dev/null
# Install hypr* configs
if confirm-overwrite $config/hypr
log 'Installing hypr* configs...'
ln -s (realpath hypr) $config/hypr
chmod u+x $config/hypr/scripts/wsaction.fish
hyprctl reload
end
# Starship
if confirm-overwrite $config/starship.toml
log 'Installing starship config...'
ln -s (realpath starship.toml) $config/starship.toml
end
# Foot
if confirm-overwrite $config/foot
log 'Installing foot config...'
ln -s (realpath foot) $config/foot
end
# Fish
if confirm-overwrite $config/fish
log 'Installing fish config...'
ln -s (realpath fish) $config/fish
end
# Fastfetch
if confirm-overwrite $config/fastfetch
log 'Installing fastfetch config...'
ln -s (realpath fastfetch) $config/fastfetch
end
# Uwsm
if confirm-overwrite $config/uwsm
log 'Installing uwsm config...'
ln -s (realpath uwsm) $config/uwsm
end
# Btop
if confirm-overwrite $config/btop
log 'Installing btop config...'
ln -s (realpath btop) $config/btop
end
# Install spicetify
if set -q _flag_spotify
log 'Installing spotify (spicetify)...'
set -l has_spicetify (pacman -Q spicetify-cli 2> /dev/null)
$aur_helper -S --needed spotify spicetify-cli spicetify-marketplace-bin $noconfirm
# Set permissions and init if new install
if test -z "$has_spicetify"
sudo chmod a+wr /opt/spotify
sudo chmod a+wr /opt/spotify/Apps -R
spicetify backup apply
end
# Install configs
if confirm-overwrite $config/spicetify
log 'Installing spicetify config...'
ln -s (realpath spicetify) $config/spicetify
# Set spicetify configs
spicetify config current_theme caelestia color_scheme caelestia custom_apps marketplace 2> /dev/null
spicetify apply
end
end
# Install vscode
if set -q _flag_vscode
test "$_flag_vscode" = 'code' && set -l prog 'code' || set -l prog 'codium'
test "$_flag_vscode" = 'code' && set -l packages 'code' || set -l packages 'vscodium-bin' 'vscodium-bin-marketplace'
test "$_flag_vscode" = 'code' && set -l folder 'Code' || set -l folder 'VSCodium'
set -l folder $config/$folder/User
log "Installing vs$prog..."
$aur_helper -S --needed $packages $noconfirm
# Install configs
if confirm-overwrite $folder/settings.json && confirm-overwrite $folder/keybindings.json && confirm-overwrite $config/$prog-flags.conf
log "Installing vs$prog config..."
ln -s (realpath vscode/settings.json) $folder/settings.json
ln -s (realpath vscode/keybindings.json) $folder/keybindings.json
ln -s (realpath vscode/flags.conf) $config/$prog-flags.conf
# Install extension
$prog --install-extension vscode/caelestia-vscode-integration/caelestia-vscode-integration-*.vsix
end
end
# Install discord
if set -q _flag_discord
log 'Installing discord...'
$aur_helper -S --needed discord equicord-installer-bin $noconfirm
# Install OpenAsar and Equicord
sudo Equilotl -install -location /opt/discord
sudo Equilotl -install-openasar -location /opt/discord
# Remove installer
$aur_helper -Rns equicord-installer-bin $noconfirm
end
# Install zen
if set -q _flag_zen
log 'Installing zen...'
$aur_helper -S --needed zen-browser-bin $noconfirm
# Install userChrome css
set -l chrome $HOME/.zen/*/chrome
if confirm-overwrite $chrome/userChrome.css
log 'Installing zen userChrome...'
ln -s (realpath zen/userChrome.css) $chrome/userChrome.css
end
# Install native app
set -l hosts $HOME/.mozilla/native-messaging-hosts
set -l lib $HOME/.local/lib/caelestia
if confirm-overwrite $hosts/caelestiafox.json
log 'Installing zen native app manifest...'
mkdir -p $hosts
cp zen/native_app/manifest.json $hosts/caelestiafox.json
sed -i "s|{{ \$lib }}|$lib|g" $hosts/caelestiafox.json
end
if confirm-overwrite $lib/caelestiafox
log 'Installing zen native app...'
mkdir -p $lib
ln -s (realpath zen/native_app/app.fish) $lib/caelestiafox
end
# Prompt user to install extension
log 'Please install the CaelestiaFox extension from https://addons.mozilla.org/en-US/firefox/addon/caelestiafox if you have not already done so.'
end
# Generate scheme stuff if needed
if ! test -f $state/caelestia/scheme.json
caelestia scheme set -n shadotheme
sleep .5
hyprctl reload
end
# Start the shell
caelestia shell -d > /dev/null
log 'Done!'