-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcutefetch
More file actions
executable file
·318 lines (288 loc) · 8.69 KB
/
cutefetch
File metadata and controls
executable file
·318 lines (288 loc) · 8.69 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
#!/usr/bin/env bash
# ------------------------------------------------------------------- #
#
# Tiny coloured fetch script with cute little animals
#
# Authored by: elenapan (https://github.com/elenapan)
# Modified by: strafe (https://github.com/strafe)
# Modified by: cybardev (https://github.com/cybardev)
# And others: https://github.com/cybardev/cutefetch/graphs/contributors
# ------------------------------------------------------------------- #
readonly VERSION_INFO="v3.1.2"
# ---------------------------- Utilities ---------------------------- #
# help information
help_info() {
echo "Cutefetch - Tiny coloured fetch script to display sysinfo"
echo ""
echo "USAGE: $(basename $0) [-m MODE] [-e EYES] [-r] [-v] [-h]"
echo ""
echo " [MODE]:"
echo " cat, kitty : show kitty ascii art with sysinfo"
echo " catfull, cat2, kitty2 : show kitty ascii art with sysinfo (full body)"
echo " bunny, rabbit : show bunny ascii art with sysinfo"
echo " dog, doggo, doggy : show doggy ascii art with sysinfo"
echo " penguin, pengu, pingu : show penguin ascii art with sysinfo"
echo " minimal, simple : show sysinfo with no ascii art"
echo " none, noglyph, text : show sysinfo with text only"
echo ""
echo " [EYES]:"
echo " Numbers from 0 to 15:"
echo " Selects eyes for cats, bunny, and dog"
echo ""
for i in {0..14}; do
printf " %2d: %3s\n" "$i" "$(eyes $i)"
done
echo ""
printf " no/other number:\n"
printf " %3s (kitty)\n" "$(eyes 6)"
printf " or %3s (bunny)\n" "$(eyes 0)"
printf " or %3s (doggy)\n" "$(eyes 1)"
echo ""
echo " [-r] : use randomized ascii art"
echo " [-v] : print the version number"
echo " [-h] : print this help message"
echo " [no option] : same as: $(basename $0) -m cat -e 6"
echo " [unkown option] : print this help message"
echo " and return status code 1"
echo ""
}
# set the eyes, ^.^ by default
eyes() {
case "$1" in
0) echo ". ." ;;
1) echo "· ·" ;;
2) echo "^ ^" ;;
3) echo "- -" ;;
4) echo "~ ~" ;;
5) echo "* *" ;;
7) echo "-.-" ;;
8) echo "~.~" ;;
9) echo "*.*" ;;
10) echo "0.0" ;;
11) echo "0 0" ;;
12) echo "o o" ;;
13) echo "o.o" ;;
14) echo "° o" ;;
*) echo "^.^" ;;
esac
}
# ------------------------- Fetch Functions ------------------------- #
# sysinfo with cute kitty
kittyfetch() {
echo " $c1$w$t $wm"
echo " /\_/\ $c3$k$t $kern"
echo " ( $(eyes $1) ) $c2$s$t $shell"
echo " $c1> $c3^ $c1< $c5$r$t $res"
echo " $c4$n$t $up"
}
# sysinfo with cute kitty (2nd variant)
kittyfetch2() {
echo " /'._ $c1$w$t $wm"
echo " ($(eyes $1) 7 $c3$k$t $kern"
echo " |'-'\"~. . $c2$s$t $shell"
echo " Uu^~C_J._.\" $c5$r$t $res"
echo " $c4$n$t $up"
}
# sysinfo with cute bunny
bunnyfetch() {
echo " $c1$w$t $wm"
echo " (\ /) $c3$k$t $kern"
echo " ( $(eyes $1)) $c2$s$t $shell"
echo " c($c1\"$t)($c1\"$t) $c5$r$t $res"
echo " $c4$n$t $up"
}
# sysinfo with cute puppy
puppyfetch() {
echo " $c1$w$t $wm"
echo "$c3 /^ ^\ $k$t $kern"
echo "$c3 /$t$c7 $(eyes $1) $c3\ $c2$s$t $shell"
echo "$c3 V\\$t$c0 Y $c3/V $c5$r$t $res"
echo " $c1 U$t $c4$n$t $up"
}
# sysinfo with cute penguin
pingufetch() {
echo "$c3 W $c1$w$t $wm"
echo "$c0 ($t$c7'$c3> $k$t $kern"
echo "$c0 /$t$c7/‾\\$c0\\ $c2$s$t $shell"
echo "$c0 ($t$c7\_/$c0) $c5$r$t $res"
echo "$c3 ~ ~ $c4$n$t $up"
}
# sysinfo with cute icons
simplefetch() {
echo " $c1$w$t $wm"
echo " $c3$k$t $kern"
echo " $c2$s$t $shell"
echo " $c5$r$t $res"
echo " $c4$n$t $up"
}
# sysinfo with text only
textfetch() {
echo "$c1 wm $t : $wm"
echo "$c3 krn$t : $kern"
echo "$c2 sh $t : $shell"
echo "$c5 res$t : $res"
echo "$c4 up $t : $up"
}
# ------------------------- Info Collectors ------------------------- #
# set necessary variable and clear the screen
init() {
# store colour codes in variables
for i in {0..7}; do
printf -v "c${i}" '%b' "\e[3${i}m" # make following text have this colour
done
readonly d=$'\e[1m' # make following text bold
readonly t=$'\e[0m' # end previously applied effects (colours, bold, etc.)
readonly v=$'\e[7m' # swap text and background colours
# icons for the sysinfo
readonly w="" # window manager
readonly k="" # kernel
readonly s="" # shell
readonly r="" # resolution
readonly n="" # uptime
# system information
case "$(uname -s)" in
Linux*)
readonly wm="$(xprop -id $(xprop -root -notype | awk '$1=="_NET_SUPPORTING_WM_CHECK:"{print $5}') -notype -f _NET_WM_NAME 8t | grep -m 1 "WM_NAME" | cut -f2 -d \")"
readonly kern="$(uname -r | cut -f1 -d '-')"
readonly shell=$(basename $SHELL)
readonly res="$(xdpyinfo | grep 'dimensions' | grep -oE '[0-9]+x[0-9]+' | head -n 1)"
readonly up="$(get_uptime)"
;;
Darwin*)
readonly wm="$(get_wm_mac)"
readonly kern="$(uname) $(uname -r)"
readonly shell="$(basename "$SHELL")"
readonly res="$(get_res_mac)"
readonly up="$(get_uptime)"
;;
*)
echo "We do not support $1 yet."
echo "Sorry for the inconvenience."
exit 1
;;
esac
tput clear # clear terminal screen
}
get_uptime() {
local up=$(uptime)
up=${up#*up } # remove everything before "up "
up=${up%%,*} # remove everything after first comma
echo $up | xargs # trim whitespace
}
# get the name of window manager (Mac OS)
get_wm_mac() {
# From neofetch (https://github.com/dylanaraps/neofetch).
local -r ps_line="$(ps -e | grep -o \
-e "[A]ero[S]pace" \
-e "[y]abai" \
-e "[A]methyst" \
-e "[R]ectangle" \
-e "[c]hun[k]wm" \
-e "[k]wm" \
-e "[S]pectacle")"
case $ps_line in
*AeroSpace*) echo AeroSpace ;;
*yabai*) echo yabai ;;
*Amethyst*) echo Amethyst ;;
*Rectangle*) echo Rectangle ;;
*chunkwm*) echo chunkwm ;;
*kwm*) echo Kwm ;;
*Spectacle*) echo Spectacle ;;
*) echo Quartz ;;
esac
}
# get the screen resolution (Mac OS)
get_res_mac() {
# print resolution of multiple displays, separated by commas
system_profiler SPDisplaysDataType | awk '/Resolution:/ {printf $2"x"$4"\n"}' | xargs | sed 's/ /, /g'
# print resolution of retina display
# echo "$(system_profiler SPDisplaysDataType | grep Retina | awk '/Resolution:/ {printf $2"x"$4"\n"}')"
}
# --------------------------- Handle Args --------------------------- #
# parse CLI arguments
OPTSTRING=":e:m:hrv"
while getopts ${OPTSTRING} opt; do
case ${opt} in
v)
echo "${VERSION_INFO}"
exit 0
;;
h)
help_info
exit 0
;;
m)
MODE_CHOICE="${OPTARG}"
;;
e)
EYES_CHOICE="${OPTARG}"
;;
r)
RAND_CHOICE=true
;;
:)
echo "Option -${OPTARG} requires an argument."
echo ""
help_info
exit 1
;;
?)
help_info
exit 1
;;
esac
done
# randomization
if [[ "${RAND_CHOICE}" = true ]] ||
[[ "${MODE_CHOICE}" =~ [,] ]] ||
[[ "${EYES_CHOICE}" =~ [,] ]]
then
if [[ -z "${EYES_CHOICE}" ]]; then
EYES_LIST="$(seq -s "," 0 15)"
EYES_LIST="${EYES_LIST::-1}"
else
EYES_LIST="${EYES_CHOICE}"
fi
if [[ -z "${MODE_CHOICE}" ]]; then
MODE_LIST="cat catfull bunny dog penguin"
else
MODE_LIST="${MODE_CHOICE}"
fi
EYES_LIST="${EYES_LIST//,/ }"
MODE_LIST="${MODE_LIST//,/ }"
EYES_CHOICE="$(shuf -e -n 1 ${EYES_LIST})"
MODE_CHOICE="$(shuf -e -n 1 ${MODE_LIST})"
fi
# print the fetch info, kitty by default
main() {
init
echo ""
case "$1" in
cat | kitty | "")
kittyfetch $2
;;
catfull | cat2 | kitty2)
kittyfetch2 $2
;;
bunny | rabbit)
[[ -z $2 ]] && eye="0" || eye="$2"
bunnyfetch $eye
;;
dog | doggo | doggy)
[[ -z $2 ]] && eye="1" || eye="$2"
puppyfetch $eye
;;
penguin | pengu | pingu)
pingufetch
;;
minimal | simple)
simplefetch
;;
none | noglyph | text)
textfetch
;;
esac
echo ""
}
# call the main function
main "${MODE_CHOICE}" "${EYES_CHOICE}"