-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpfetch
More file actions
executable file
·82 lines (73 loc) · 3.01 KB
/
pfetch
File metadata and controls
executable file
·82 lines (73 loc) · 3.01 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
#!/bin/bash
#It's probably okay to suppress errors from a fetch script.
exec 2> /dev/null
#Show terminal colors
pcs() {
local mode="$1" # "" or "bright"
local base=30
[[ "$mode" == "bright" ]] && base=90
for i in {0..7}; do printf "\e[$((base+i))m██\e[0m "; done
}
pcb() {
local mode="$1" # "" or "bright"
local base=40
[[ "$mode" == "bright" ]] && base=100
for i in {0..7}; do printf "\e[$((base+i))m \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
# attributes
bc="$(tput bold)" # bold on
rc="$(tput sgr0)" # reset
ul="$(tput smul)" # underline on
lu="$(tput rmul)" # underline off
# normal 0..7 (foreground/background)
c0="$(tput setaf 0)"; c1="$(tput setaf 1)"; c2="$(tput setaf 2)"; c3="$(tput setaf 3)"
c4="$(tput setaf 4)"; c5="$(tput setaf 5)"; c6="$(tput setaf 6)"; c7="$(tput setaf 7)"
bc0="$(tput setab 0)"; bc1="$(tput setab 1)"; bc2="$(tput setab 2)"; bc3="$(tput setab 3)"
bc4="$(tput setab 4)"; bc5="$(tput setab 5)"; bc6="$(tput setab 6)"; bc7="$(tput setab 7)"
# true BRIGHT 90..97 / 100..107 (not bold!)
C0=$'\e[90m'; C1=$'\e[91m'; C2=$'\e[92m'; C3=$'\e[93m'
C4=$'\e[94m'; C5=$'\e[95m'; C6=$'\e[96m'; C7=$'\e[97m'
BC0=$'\e[100m'; BC1=$'\e[101m'; BC2=$'\e[102m'; BC3=$'\e[103m'
BC4=$'\e[104m'; BC5=$'\e[105m'; BC6=$'\e[106m'; BC7=$'\e[107m'
# label/identity colors
lc="${C5}" # labels (bright magenta)
nc="${ul}${C5}" # user@host (underlined bright magenta)
ic="${rc}" # info (default fg)
#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 "%s\n%s\n\n" "$(pcs)" "$(pcs bright)"