-
Notifications
You must be signed in to change notification settings - Fork 3
/
screenfetch
executable file
·99 lines (81 loc) · 1.71 KB
/
screenfetch
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
#!/bin/bash
#
# Minimalist sysinfo script
#################################
# color escapes
BLK="\e[30m"
RED="\e[31m"
GRN="\e[32m"
YLW="\e[33m"
BLU="\e[34m"
PUR="\e[35m"
CYN="\e[36m"
BRED="\e[31m"
BGRN="\e[32m"
BYLW="\e[33m"
BBLU="\e[34m"
BPUR="\e[35m"
BCYN="\e[36m"
WHT="\e[37m"
RST="\e[0m"
# build the color bars
BAR="━━━━━"
((LEN = ${#BAR} * 6))
OUTT="$RED$BAR$GRN$BAR$YLW$BAR$BLU$BAR$PUR$BAR$CYN$BAR$RST"
OUTB="$BRED$BAR$BGRN$BAR$BYLW$BAR$BBLU$BAR$BPUR$BAR$BCYN$BAR$RST"
# array for info entries
ENTS=()
# function for creating entries
mkent() {
if [[ "$#" != 2 ]]; then
printf "!! invalid number of arguments to make_entry().\n"
exit
fi
local ENT="$2"
while ((${#ENT} < LEN - ${#1})); do
ENT=" $ENT"
done
ENT="$CNAME""$1""$CTEXT""$ENT""$RST"
ENTS+=("$ENT")
}
# entry settings
CNAME="$BLU" # color of entry name
CTEXT="$WHT" # color of entry text
#
# add entries here!
# format: mkent NAME TEXT
#
# examples:
#
mkent "OS" "Arch"
mkent "User" "$(printenv USER)"
mkent "Shell" "$(basename $(printenv SHELL))"
mkent "Packages" "$(pacman -Q | wc -l)"
mkent "Date" "$(date '+%d %B %Y')"
# find the center of the screen
COL=$(tput cols)
ROW=$(tput lines)
((PADY = ROW / 2 - 1 - ${#ENTS[@]} / 2))
((PADX = COL / 2 - LEN / 2))
for ((i = 0; i < PADX; ++i)); do
PADC="$PADC "
done
for ((i = 0; i < PADY; ++i)); do
PADR="$PADR\n"
done
# print everything
# but clear the screen first
clear
# vertical padding
printf "%b" "$PADR"
# sysinfo
printf "%s%b" "$PADC" "$OUTT\n"
for ENT in "${ENTS[@]}"; do
printf "%s%b" "$PADC" "$ENT\n"
done
printf "%s%b" "$PADC" "$OUTB\n"
# hide the cursor and wait for user input
tput civis
read -n 1
# give the cursor back
tput cnorm