bin/info (view raw)
1#!/usr/bin/env bash
2# icyinfo, but better
3
4BLK="\e[30m"
5RED="\e[31m"
6GRN="\e[32m"
7YLW="\e[33m"
8BLU="\e[34m"
9PUR="\e[35m"
10CYN="\e[36m"
11BRED="\e[31m"
12BGRN="\e[32m"
13BYLW="\e[33m"
14BBLU="\e[34m"
15BPUR="\e[35m"
16BCYN="\e[36m"
17WHT="\e[37m"
18RST="\e[0m"
19
20BAR="▁▁▁▁"
21((LEN = ${#BAR} * 6))
22COLOR_BARS="$RED$BAR$GRN$BAR$YLW$BAR$BLU$BAR$PUR$BAR$CYN$BAR$RST"
23
24user=$(whoami)
25host=$(hostname)
26kernel=$(uname -r)
27uptime=$(uptime -p) # too long to print
28shell=$(basename $SHELL)
29
30os() {
31 os=$(source /etc/os-release && echo $ID)
32 export os
33}
34
35wm() {
36 id=$(xprop -root -notype _NET_SUPPORTING_WM_CHECK)
37 id=${id##* }
38 wm=$(xprop -id "$id" -notype -len 100 -f _NET_WM_NAME 8t)
39 wm=${wm/*_NET_WM_NAME = }
40 wm=${wm/\"}
41 wm=${wm/\"*}
42 wm=${wm,,}
43 export wm
44}
45
46
47os
48wm
49
50COL=$(tput cols)
51ROW=$(tput lines)
52((PADY = ROW / 2 - 1 - ${#ENTS[@]} / 2))
53((PADX = COL / 2 - LEN / 2))
54
55for ((i = 0; i < PADX; ++i)); do
56 PADC="$PADC "
57done
58
59for ((i = 0; i < PADY; ++i)); do
60 PADR="$PADR\n"
61done
62
63clear
64
65printf "%b" "$PADR"
66printf "%s%b" "$PADC" "$COLOR_BARS\n\n"
67
68printf "%s%b" "$PADC" "${CYN}$user${RST}@${CYN}$host${RST} ${CYN} |\___/|${RST}\n"
69printf "%s%b" "$PADC" " ${CYN}/ \\ ${RST} \n"
70printf "%s%b" "$PADC" " ${CYN}/__${RST}${PUR}^ ^${RST}${CYN}__\\ ${RST} \n"
71printf "%s%b" "$PADC" " ${CYN}\o/ ${RST}\n\n"
72printf "%s%b" "$PADC" "os: ${CYN}$os${RST}\n"
73printf "%s%b" "$PADC" "kernel: ${CYN}$kernel${RST}\n"
74#printf "%s%b" "$PADC" "uptime: ${CYN}$uptime${RST}\n"
75printf "%s%b" "$PADC" "wm: ${CYN}$wm${RST}\n"
76printf "%s%b" "$PADC" "shell: ${CYN}$shell${RST}\n"
77printf "%s%b" "$PADC" "$COLOR_BARS\n"
78
79tput civis
80read -n 1
81tput cnorm