-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetfont.sh
executable file
·155 lines (149 loc) · 4.61 KB
/
setfont.sh
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
#!/data/data/com.termux/files/usr/bin/bash
# SetFont
# Author : KasRoudra
# Github : https://github.com/KasRoudra
# Email : kasroudrakrd@gmail.com
# Contact : https://m.me/KasRoudra
# Description: Change font of termux. Apply font of any directory
white="\033[1;37m"
red="\033[1;31m"
green="\033[1;32m"
yellow="\033[1;33m"
purple="\033[0;35m"
cyan="\033[0;36m"
blue="\033[1;34m"
info="${cyan}[${white}+${cyan}] ${yellow}"
ask="${cyan}[${white}?${cyan}] ${purple}"
error="${cyan}[${white}!${cyan}] ${red}"
success="${cyan}[${white}√${cyan}] ${green}"
re='^[0-9]+$'
if ! [ -d "$HOME/setfont/fonts" ]
then
cd $HOME
mkdir setfont
cd setfont
mkdir fonts
fi
export DIR="$HOME/setfont/fonts"
clear
echo -e "
${blue} ____ _ _____ _
${green}/ ___| ___| |_| ___|__ _ __ | |_
${red}\___ \ / _ \ __| |_ / _ \| '_ \| __|
${blue} ___) | __/ |_| _| (_) | | | | |_
${yellow}|____/ \___|\__|_| \___/|_| |_|\__|
${purple} [By KasRoudra]
"
if [ -f font.ttf ]; then
rm -rf font.ttf
fi
loop=true
while $loop; do
trap '' 2
printf "\n${yellow}SetFont > ${purple}"
read cmd
if [ "$cmd" = "help" ]; then
echo -e "\n${info}${cyan}List of commands:${yellow}
${purple}> help ${yellow}Shows this help
${purple}> list ${yellow}Shows fontlist
${purple}> chdir${green} <path>${yellow} Changes fontlist directory (current: $blue$DIR$yellow)
${purple}> apply${green} <number>${yellow} Applies that font
${purple}> backup ${yellow}Backup the current font ${cyan}(Recommended before random change)
${purple}> restore ${yellow}Restores the backed up font
${purple}> reset ${yellow}Resets to a default ${blue}Fira ${yellow}font
${purple}> exit ${yellow}Exit from this program"
elif [ "$cmd" = "list" ]; then
echo
getlist=$(ls $DIR | grep ttf)
replace=${getlist// /%%}
n=1
if ! [[ $replace == "" ]]; then
for font in $replace; do
if (( $n % 2 == 0 )) ; then
echo -e "${yellow}[$n]${blue} ${font//%%/ }"
else
echo -e "${green}[$n]${purple} ${font//%%/ }"
fi
((n++))
done
else
echo -e "${error}No font here!"
fi
elif echo "$cmd" | grep -q "apply"; then
arg=$(echo "$cmd" | cut -d " " -f 2)
if [[ $arg =~ $re ]] ; then
getlist=$(ls $DIR | grep ttf)
replace=${getlist// /%%}
list=()
for m in $replace; do
list+=("$m")
done
font=${list[(($arg-1))]}
if [[ ${font//%%/ } == "" ]]; then
echo -e "\n${error}Font not found!"
else
cp "$DIR/${font//%%/ }" "font.ttf"
if [ -f $HOME/.termux/font.ttf ]; then
rm -rf $HOME/.termux/font.ttf
fi
mv -f font.ttf $HOME/.termux
termux-reload-settings
echo -e "\n${success}Font applied successfully!"
fi
else
echo -e "\n${error}Not a number!"
fi
elif echo "$cmd" | grep -q "reset"; then
if [ -f "$HOME/setfont/fira.ttf" ]; then
cp "$HOME/setfont/fira.ttf" "font.ttf"
if [ -f $HOME/.termux/font.ttf ]; then
rm -rf $HOME/.termux/font.ttf
fi
mv -f font.ttf $HOME/.termux
termux-reload-settings
echo -e "\n${success}Font reset successfully!"
else
echo -e "\n${error}Reset font not found"!
fi
elif echo "$cmd" | grep -q "backup"; then
if [ -f "$HOME/.termux/font.ttf" ]; then
if [ -f "$HOME/.termux/backup.ttf" ]; then
rm -rf $HOME/.termux/backup.ttf
fi
cp "$HOME/.termux/font.ttf" "backup.ttf"
mv -f backup.ttf $HOME/.termux
termux-reload-settings
echo -e "\n${success}Font backed up successfully!"
else
echo -e "\n${error}Font to be backed up not found. Please apply one!"
fi
elif echo "$cmd" | grep -q "restore"; then
if [ -f "$HOME/.termux/backup.ttf" ]; then
cd $HOME/.termux
if [ -f $HOME/.termux/font.ttf ]; then
rm -rf $HOME/.termux/font.ttf
fi
mv backup.ttf font.ttf
termux-reload-settings
echo -e "\n${success}Font restored successfully!"
else
echo -e "\n${error}No backup found!"
fi
elif echo "$cmd" | grep -q "chdir"; then
path="$(echo "$cmd" | cut -d " " -f 2)"
if [[ -d "$path" ]]; then
export DIR="${path}"
if [ -f font.ttf ]; then
rm -rf font.ttf
fi
echo -e "\n${success}Directory changed!"
else
echo -e "\n${error}Path do not exist!"
fi
elif [ "$cmd" = "exit" ]; then
echo -e "${white}"
exit
else
echo -e "\n${error}Sorry, wrong input! Please type 'help'."
fi
done