-
Notifications
You must be signed in to change notification settings - Fork 7
/
flowetch
executable file
·136 lines (109 loc) · 2.69 KB
/
flowetch
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
#! /bin/sh
# ┌─┐┬ ┌─┐┬ ┬┌─┐┌┬┐┌─┐┬ ┬
# ├┤ │ │ ││││├┤ │ │ ├─┤
# └ ┴─┘└─┘└┴┘└─┘ ┴ └─┘┴ ┴
# Packages
if command -v pacman >/dev/null
then
pkg="$(pacman -Qq | wc -l)"
elif command -v dpkg >/dev/null
then
pkg="$(dpkg -l | wc -l)"
elif command -v emerge >/dev/null
then
pkg="$(cd /var/db/pkg/ && ls -d */* | wc -l)"
elif command -v xbps-query >/dev/null
then
pkg="$(xbps-query -l | wc -l)"
else
pkg="$(rpm -qa | wc -l)"
fi
# Get user
user="${USER-$(id -u -n)}"
# Get host
host="$(uname -n)"
# Get OS
. /etc/os-release
os="$NAME"
# Get uptime
uptime="$(echo $(awk '{print $1}' /proc/uptime) / 3600 | bc)"
# Shell
shell="${SHELL##*/}"
[ "$DISPLAY" ] && displayprot="x11"
[ "$WAYLAND_DISPLAY" ] && displayprot="wayland"
[ ! "$displayprot" ] && displayprot="tty"
# GTK 3
while read -r line; do
case $line in
gtk-theme*) theme=${line##*=} ;;
gtk-icon-theme*) icons=${line##*=} ;;
esac
done <"${XDG_CONFIG_HOME:-$HOME/.config}/gtk-3.0/settings.ini"
# GTK theme
wm="$XDG_CURRENT_DESKTOP"
[ "$wm" ] || wm="$DESKTOP_SESSION"
# Window Manager
[ ! "$wm" ] && [ "$DISPLAY" ] && command -v xprop >/dev/null && {
id=$(xprop -root -notype _NET_SUPPORTING_WM_CHECK)
id=${id##* }
wm=$(xprop -id "$id" -notype -len 100 -f _NET_WM_NAME 8t |
grep '^_NET_WM_NAME' | cut -d\" -f 2)
}
# For non-EWH WMs
[ ! "$wm" ] || [ "$wm" = "LG3D" ] &&
wm=$(
ps -e | grep -m 1 -o \
-e "sway" \
-e "kiwmi" \
-e "wayfire" \
-e "sowm" \
-e "catwm" \
-e "fvwm" \
-e "dwm" \
-e "2bwm" \
-e "monsterwm" \
-e "tinywm" \
-e "xmonad"
)
# GTK theme
case $wm in
*GNOME*)
theme=$(dconf read /org/gnome/desktop/interface/gtk-theme | tr -d "'")
icons=$(dconf read /org/gnome/desktop/interface/icon-theme | tr -d "'")
;;
*)
while read -r line; do
case $line in
gtk-theme*) theme=${line##*=} ;;
gtk-icon-theme*) icons=${line##*=} ;;
esac
done <"${XDG_CONFIG_HOME:-$HOME/.config}/gtk-3.0/settings.ini"
;;
esac
# Colors
c0='[0m'
c1='[31m'
c2='[32m'
c3='[33m'
c4='[34m'
c5='[35m'
c6='[36m'
c7='[37m'
c8='[38m'
c9='^[[37m'
# Art
ARTR1="${c1} _ _ "
ARTR2="${c1} (_\_) "
ARTR3="${c1} (__<__) "
ARTR4="${c1} (_/_) "
ARTR5="${c2} \ | "
ARTR6="${c2} \|/ "
# Main Print
cat <<-EOF
${ARTR1} ${c5}host${c0} ${c1}••• ${host}
${ARTR2} ${c5}user${c0} ${c2}••• ${user}
${ARTR3} ${c5}shell${c0} ${c3}••• ${shell}
${ARTR4} ${c5}wm${c0} ${c4}••• ${wm}
${ARTR5} ${c5}theme${c0} ${c5}••• ${theme}
${ARTR6} ${c5}pkg${c0} ${c6}••• ${pkg}
EOF