-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathya5lfetch.sh
executable file
·155 lines (134 loc) · 2.83 KB
/
ya5lfetch.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
#!/bin/sh
ui=$(tty)
case $ui in /dev/tty*) false; esac &&
if [ "${DE+x}" = x ] || [ "${WM+x}" = x ]; then
ui="${DE:+DE}${DE:+${WM:+/}}${WM:+WM}: ${DE:+${WM:+$'\33[3D'}}$DE${DE:+${WM:+/}}$WM"
elif [ "${XDG_CURRENT_DESKTOP:-${DESKTOP_SESSION-}}" != '' ]; then
ui="DE: ${XDG_CURRENT_DESKTOP:-}${XDG_CURRENT_DESKTOP:+${DESKTOP_SESSION:+, }}${DESKTOP_SESSION:-}"
elif [ -r ~/.xinitrc -o -r ~/.xsession ]; then
uiexec=
for i in $(sed -ne 's/^exec //p' ~/.xinitrc ~/.xsession 2>/dev/null); do
case $(pidof -- "$uiexec") in ?*) uiexec=$uiexec${i##*/}; esac
done
[ "${uiexec% }" != '' ] && ui="WM: ${uiexec% }"
else
false
fi || {
ui="TTY: ${ui#/dev/}${SSH_TTY:+, ssh}"
}
# [[ $os ]] || os=$(sed -ne 's/PRETTY_NAME=//p' "$PREFIX/etc/os-release" || echo "$MACHTYPE"); os=${os#[\'\"]}; os=${os%[\'\"]}
case ${os+x} in '')
. "$PREFIX/etc/os-release"
os=${PRETTY_NAME:-${NAME:-$MACHTYPE}}
esac
IFS=$(printf \\33)
unset w
c=4 # default color blue (Arch, BTW)
_os=${os%[Ll][Ii][Nn][Uu][Xx]}
_os=${_os%%" "*}
case $_os in
[Aa]rch)a=\
' .
/ \
/ _ \
/ / \ \
/` `\'
;;
[Aa]rco)a=\
' .
/ \
/ . \
/ / _ \
/` `\'
;;
artix*)a=\
" .
/ \\
/. \\
/ * \\
/ ' \\"
c=6;;
artix2)a=\
" .
/ \\
/'. \\
/ .'\\
/ ' \\"
c=6;;
artix3)a=\
'
/\
/ \
/ 🎨 \
/ \'
c=6;w=9;;
[Aa]lpine)a=\
'
.
/ \
/ \'$IFS' /\'$IFS'
/'$IFS'◁'$IFS' \'$IFS' \'
c='4 8 4 8 4 8 4';w=12;;
[Aa]ndroid)a=\
'
╲_____╱
╱ . . ╲
▕ ▏
▔▔▔▔▔▔▔ '
c=2;w=9;;
KISS|[Kk]iss)a=\
'
+----+
| |/ |
| |\ |
+----+'
c=1;w=8;;
[Mm]anjaro)a=\
'
█████ ██
██ ▄▄ ██
██ ██ ██
██ ██ ██'
c=2;w=10;;
[Dd]ebian)a=\
' ,--.
/ _ \
| (__/
\
`-. '
c=1;w=9;;
# Space Invaders
*)a=\
'░░▀▄░░░▄▀░░
░▄█▀███▀█▄░
█▀███████▀█
█░█▀▀▀▀▀█░█
░░░▀▀░▀▀░░░'
c=$(( ${RANDOM:-$(\dd if=/dev/random 2>/dev/null | tr -dc 0-9 | head -c 1)} % 7 + 1 ));w=12;;
esac
# printf '\33[3'"$c"'m%s\33[m\n\33[5A' "$a"
set -f; for i in $a; do
printf "\\33[3${c%%" "*}m%s" "${i}"
c=${c#*" "} # note: last val wont be auto removed
done
printf '\33[m\n\33[5A'
p=$( # prompt
printf '\33[3%im%s\33[m@%s \33[3%im%s\33[m' \
"$(( ${EUID:-$(id -u)} == 0 ? 1 : 3 ))" \
"${USER:-$(id -un)}" \
"${HOSTNAME:-$(hostname)}" \
"${c#*" "}" \
"${PWD:-$(pwd)}"
)
b= # detect battery level
for i in /sys/class/power_supply/{{BAT,axp288_fuel_gauge,CMB}*,battery}; do
[ -r "$i"/capacity ] || continue
b=$b${b:+, }$(cat "$i"/capacity)"% "$(cat "$i"/status);
done
printf "\\33[${w:-11}C%s\\n" \
"$p" \
"OS: $os" \
"KERNEL: $(uname -r)" \
"${b:+BATTERY: }${b:-SHELL: $(basename -- ${SHELL:-$0})}" \
"$ui" \
;