@@ -9,7 +9,6 @@ function warning_overwrite(){
99 printf " The command below overwrites the destination.\n"
1010 printf " ${STY_RST} "
1111}
12-
1312function auto_backup_configs(){
1413 local backup=false
1514 case $ask in
@@ -38,8 +37,135 @@ function auto_backup_configs(){
3837 printf " ${STY_BLUE} Backup into \" ${BACKUP_DIR} \" finished.${STY_RST} \n"
3938 fi
4039}
40+ function gen_firstrun(){
41+ x mkdir -p " $( dirname ${FIRSTRUN_FILE} ) "
42+ x touch " ${FIRSTRUN_FILE} "
43+ x mkdir -p " $( dirname ${INSTALLED_LISTFILE} ) "
44+ realpath -se " ${FIRSTRUN_FILE} " >> " ${INSTALLED_LISTFILE} "
45+ }
46+ cp_file (){
47+ # NOTE: This function is only for using in other functions
48+ x mkdir -p " $( dirname $2 ) "
49+ x cp -f " $1 " " $2 "
50+ x mkdir -p " $( dirname ${INSTALLED_LISTFILE} ) "
51+ realpath -se " $2 " >> " ${INSTALLED_LISTFILE} "
52+ }
53+ rsync_dir (){
54+ # NOTE: This function is only for using in other functions
55+ x mkdir -p " $2 "
56+ local dest=" $( realpath -se $2 ) "
57+ x mkdir -p " $( dirname ${INSTALLED_LISTFILE} ) "
58+ rsync -a --out-format=' %i %n' " $1 " / " $2 " / | awk -v d=" $dest " ' $1 ~ /^>/{ sub(/^[^ ]+ /,""); printf d "/" $0 "\n" }' >> " ${INSTALLED_LISTFILE} "
59+ }
60+ rsync_dir__sync (){
61+ # NOTE: This function is only for using in other functions
62+ # `--delete' for rsync to make sure that
63+ # original dotfiles and new ones in the SAME DIRECTORY
64+ # (eg. in ~/.config/hypr) won't be mixed together
65+ x mkdir -p " $2 "
66+ local dest=" $( realpath -se $2 ) "
67+ x mkdir -p " $( dirname ${INSTALLED_LISTFILE} ) "
68+ rsync -a --delete --out-format=' %i %n' " $1 " / " $2 " / | awk -v d=" $dest " ' $1 ~ /^>/{ sub(/^[^ ]+ /,""); printf d "/" $0 "\n" }' >> " ${INSTALLED_LISTFILE} "
69+ }
70+ function install_file(){
71+ # NOTE: Do not add prefix `v` or `x` when using this function
72+ local s=$1
73+ local t=$2
74+ if [ -f $t ]; then
75+ warning_overwrite
76+ fi
77+ v cp_file $s $t
78+ }
79+ function install_file__auto_backup(){
80+ # NOTE: Do not add prefix `v` or `x` when using this function
81+ local s=$1
82+ local t=$2
83+ if [ -f $t ]; then
84+ echo -e " ${STY_YELLOW} [$0 ]: \" $t \" already exists.${STY_RST} "
85+ if ${INSTALL_FIRSTRUN} ; then
86+ echo -e " ${STY_BLUE} [$0 ]: It seems to be the firstrun.${STY_RST} "
87+ v mv $t $t .old
88+ v cp_file $s $t
89+ else
90+ echo -e " ${STY_BLUE} [$0 ]: It seems not a firstrun.${STY_RST} "
91+ v cp_file $s $t .new
92+ fi
93+ else
94+ echo -e " ${STY_GREEN} [$0 ]: \" $t \" does not exist yet.${STY_RST} "
95+ v cp_file $s $t
96+ fi
97+ }
98+ function install_dir(){
99+ # NOTE: Do not add prefix `v` or `x` when using this function
100+ local s=$1
101+ local t=$2
102+ if [ -d $t ]; then
103+ warning_overwrite
104+ fi
105+ rsync_dir $s $t
106+ }
107+ function install_dir__sync(){
108+ # NOTE: Do not add prefix `v` or `x` when using this function
109+ local s=$1
110+ local t=$2
111+ if [ -d $t ]; then
112+ warning_overwrite
113+ fi
114+ rsync_dir__sync $s $t
115+ }
116+ function install_dir__skip_existed(){
117+ # NOTE: Do not add prefix `v` or `x` when using this function
118+ local s=$1
119+ local t=$2
120+ if [ -d $t ]; then
121+ echo -e " ${STY_BLUE} [$0 ]: \" $t \" already exists, will not do anything.${STY_RST} "
122+ else
123+ echo -e " ${STY_YELLOW} [$0 ]: \" $t \" does not exist yet.${STY_RST} "
124+ v rsync_dir $s $t
125+ fi
126+ }
127+ function install_google_sans_flex(){
128+ local font_name=" Google Sans Flex"
129+ local src_name=" google-sans-flex"
130+ local src_url=" https://github.com/end-4/google-sans-flex"
131+ local src_dir=" $REPO_ROOT /cache/$src_name "
132+ local target_dir=" ${XDG_DATA_HOME} /fonts/illogical-impulse-$src_name "
133+ if fc-list | grep -qi " $font_name " ; then return ; fi
134+ x mkdir -p $src_dir
135+ x cd $src_dir
136+ try git init -b main
137+ try git remote add origin $src_url
138+ x git pull origin main
139+ x git submodule update --init --recursive
140+ warning_overwrite
141+ rsync_dir " $src_dir " " $target_dir "
142+ x fc-cache -fv
143+ x cd $REPO_ROOT
144+ x mkdir -p " $( dirname ${INSTALLED_LISTFILE} ) "
145+ realpath -se " $2 " >> " ${INSTALLED_LISTFILE} "
146+ }
41147
42148# ####################################################################################
149+ # In case some dirs does not exists
150+ for i in " $XDG_BIN_HOME " " $XDG_CACHE_HOME " " $XDG_CONFIG_HOME " " $XDG_DATA_HOME " ; do
151+ if ! test -e " $i " ; then
152+ v mkdir -p " $i "
153+ fi
154+ done
155+ case " ${INSTALL_FIRSTRUN} " in
156+ # When specify --firstrun
157+ true) sleep 0 ;;
158+ # When not specify --firstrun
159+ * )
160+ if test -f " ${FIRSTRUN_FILE} " ; then
161+ INSTALL_FIRSTRUN=false
162+ else
163+ INSTALL_FIRSTRUN=true
164+ fi
165+ ;;
166+ esac
167+
168+
43169showfun auto_update_git_submodule
44170v auto_update_git_submodule
45171
@@ -51,6 +177,14 @@ case "${EXPERIMENTAL_FILES_SCRIPT}" in
51177 * )source sdata/subcmd-install/3.files-legacy.sh;;
52178esac
53179
180+ showfun install_google_sans_flex
181+ v install_google_sans_flex
182+
183+ #####################################################################################
184+
185+ v gen_firstrun
186+ v dedup_and_sort_listfile " ${INSTALLED_LISTFILE} " " ${INSTALLED_LISTFILE} "
187+
54188# Prevent hyprland from not fully loaded
55189sleep 1
56190try hyprctl reload
0 commit comments