-
Notifications
You must be signed in to change notification settings - Fork 0
/
pfetch
executable file
·80 lines (74 loc) · 2.51 KB
/
pfetch
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
#!/bin/bash
#It's probably okay to suppress errors from a fetch script.
exec 2> /dev/null
#Show terminal colors
pcs() {
for i in {0..7}; do
echo -en "\e[${1}$((30+$i))m \u2588\u2588 \e[0m"
done
}
# Main information fetching
host="$(hostname)"
os=$(grep "PRETTY_NAME" /etc/os-release|awk -F '"' 'NF>2{print $2}')
kernel="$(uname -sr)"
uptime="$(uptime -p|sed 's/up //')"
shell="$(basename ${SHELL})"
wm=$(xprop -id $(xprop -root _NET_SUPPORTING_WM_CHECK|cut -d\# -f2) -f _NET_WM_NAME 8t|awk -F\" 'NF>2{print $2}')
cpu="$(awk -F: '/name/ {print $2;exit}' /proc/cpuinfo) ($(nproc))"
ram="$(free -hm|grep Mem:|awk '{print $3" / "$2}')"
packages=$(($(pacman -Qq|wc -l)+\
$(rpm -qa|wc -l)+\
$(dpkg -l|wc -l)+\
$(find /var/db/pkg/ -type d|wc -l)+\
$(apk info|wc -l)+\
$(pkg_info|wc -l)))
if [ -z "${wm}" ]; then
if [ "${XDG_CURRENT_DESKTOP}" ]; then
wm="${XDG_CURRENT_DESKTOP}"
elif [ "${DESKTOP_SESSION}" ]; then
wm="${DESKTOP_SESSION}"
else
wm="$(tail -n 1 "${HOME}/.xinitrc" | cut -d ' ' -f 2)"
fi
fi
#non-color effects
bc="$(tput bold)" # bold
rc="$(tput sgr0)" # rc
ul="$(tput smul)" # rc
lu="$(tput rmul)" # rc
#foreground colors
c0="$(tput setaf 0)" # black
c1="$(tput setaf 1)" # red
c2="$(tput setaf 2)" # green
c3="$(tput setaf 3)" # yellow
c4="$(tput setaf 4)" # blue
c5="$(tput setaf 5)" # magenta
c6="$(tput setaf 6)" # cyan
c7="$(tput setaf 7)" # white
#background colors
bc0="$(tput setab 0)" # black
bc1="$(tput setab 1)" # red
bc2="$(tput setab 2)" # green
bc3="$(tput setab 3)" # yellow
bc4="$(tput setab 4)" # blue
bc5="$(tput setab 5)" # magenta
bc6="$(tput setab 6)" # cyan
bc7="$(tput setab 7)" # white
# Text and logo colors
lc="${c5}" # labels
nc="${ul}${c5}" # user and hostname
ic="${rc}" # info
#Draw ascii art and print fetch
cat << EOF
$bc$c7 $rc $nc$USER$ic@$nc$host$rc
$bc$c7 ▄▄▄$rc ${lc}OS: $ic$os$rc
$bc$c7 ▄█████▄▄ $rc ${lc}KERNEL: $ic$kernel
$bc$c7███$bc6▀▀▀▀$bc0▀$bc6▀$bc0▀$bc6▀$rc ${lc}UPTIME: $ic$uptime
$bc$c7███$bc6▄ $c0▀ ▀$rc$c6▀$rc ${lc}PACKAGES: $ic$packages
$bc$c7 ▄$bc6 $rc$bc$c7█████▄ $rc$c1█▄$rc ${lc}SHELL: $ic$shell
$rc$c1▀▀$rc$bc$bc1$c7▄$bc6▄ $bc1▄▄▄$rc$c1▀██▀$rc ${lc}WM: $ic$wm
$bc$c7 ██▀▀▀██▀ $rc$c1▀$rc ${lc}CPU: $ic$cpu$rc
$bc$c7 ▀▀▀▀ ▀▀▀▀$rc ${lc}RAM: $ic$ram$rc
EOF
# Show terminal colors
printf "\n%s\n%s\n\n" "$(pcs)" "$(pcs '1;')"