Skip to content

Commit e4da262

Browse files
updated
1 parent 2a23c4f commit e4da262

19 files changed

Lines changed: 929 additions & 978 deletions

README.md

Lines changed: 211 additions & 210 deletions
Large diffs are not rendered by default.

application.sh

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ fzf__title=''
5959
main_item="$(pipe_to_fzf "${main_items[@]}")" && wrap_fzf_choice "$main_item" || exit 37
6060

6161
case "$main_item" in
62-
install ) ## {{{
62+
install )
6363
install_items=( 'pacman' 'yay' 'yay + torsocks' 'local' 'download (no install)' 'reinstall all packages' 'lts kernel & header' 'search: normal' 'search: detailed summary' 'search: in local repository' )
6464
fzf__title=''
6565
install_item="$(pipe_to_fzf "${install_items[@]}")" && wrap_fzf_choice "$install_item" || exit 37
@@ -105,8 +105,8 @@ case "$main_item" in
105105
'search: in local repository' )
106106
pacman -Slq | fzf --preview 'pacman -Si {1}' | xargs -ro pacman -Qs && accomplished ;;
107107
esac ;;
108-
## }}}
109-
remove ) ## {{{
108+
109+
remove )
110110
remove_items=( 'normal' 'with all dependencies' 'forceful' 'yay' 'latest kernel' )
111111
fzf__title=''
112112
remove_item="$(pipe_to_fzf "${remove_items[@]}")" && wrap_fzf_choice "$remove_item" || exit 37
@@ -123,8 +123,8 @@ case "$main_item" in
123123
'remove latest kernel' )
124124
sudo pacman -R linux && accomplished ;;
125125
esac ;;
126-
## }}}
127-
packages ) ## {{{
126+
127+
packages )
128128
packages_items=( 'count' 'names' 'AUR packages' 'pacman tools' 'system stats (using yay)' )
129129
fzf__title=''
130130
packages_item="$(pipe_to_fzf "${packages_items[@]}")" && wrap_fzf_choice "$packages_item" || exit 37
@@ -142,8 +142,8 @@ case "$main_item" in
142142
'system stats (using yay)' )
143143
yay -Ps && accomplished ;;
144144
esac ;;
145-
## }}}
146-
'clear cache and clipboard' ) ## {{{
145+
146+
'clear cache and clipboard' )
147147
action_now 'clearing clipboard'
148148
greenclip_clear
149149
action_now "cache size: $(du -sh /var/cache/pacman/pkg/)" ## installed apps database dir: var/lib/pacman/
@@ -175,8 +175,8 @@ case "$main_item" in
175175
2 ) shutdown -r now ;;
176176
esac
177177
accomplished ;;
178-
## }}}
179-
update ) ## {{{
178+
179+
update )
180180
update_items=( 'pacman' 'yay' 'yay + torsocks' 'sync repos' 'available updates' 'last update' )
181181
fzf__title=''
182182
update_item="$(pipe_to_fzf "${update_items[@]}")" && wrap_fzf_choice "$update_item" || exit 37
@@ -222,8 +222,8 @@ case "$main_item" in
222222
dur="$(relative_date "$last_update_date")"
223223
printf 'last update: %s (on %s)\n' "$dur" "$last_update_date"
224224
esac ;;
225-
## }}}
226-
systemd ) ## {{{
225+
226+
systemd )
227227
systemd_items=( 'systemd-analyze' 'systemd-analyze blame' 'reload systemd' 'reload systemd units' )
228228
fzf__title=''
229229
systemd_item="$(pipe_to_fzf "${systemd_items[@]}")" && wrap_fzf_choice "$systemd_item" || exit 37
@@ -238,8 +238,8 @@ case "$main_item" in
238238
'reload systemd units' )
239239
systemctl daemon-reload && accomplished ;; ## a reboot might be required
240240
esac ;;
241-
## }}}
242-
systemctl ) ## {{{
241+
242+
systemctl )
243243
systemctl_items=( 'status' 'services' 'running units' 'failed units' 'start a unit' 'stop a unit' 'restart a unit' 'unit status' 'reload configuration' 'check if enabled' 'enable' 'disable' 'mask' 'unmask' )
244244
fzf__title=''
245245
systemctl_item="$(pipe_to_fzf "${systemctl_items[@]}")" && wrap_fzf_choice "$systemctl_item" || exit 37
@@ -284,8 +284,8 @@ case "$main_item" in
284284
prompt -u
285285
sudo systemctl unmask "$unit" && accomplished ;;
286286
esac ;;
287-
## }}}
288-
help ) ## {{{
287+
288+
help )
289289
display_help ;;
290-
## }}}
290+
291291
esac

awesome-widgets-network.sh

Lines changed: 51 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,19 @@ source ~/main/scripts/gb-network.sh
1414
## ⮟ U+2B9F
1515
## ⮜ U+2B9C
1616
## ⮞ U+2B9E
17-
down_icon="<span color=\"${gruvbox_blue_d}\">⮟ </span>"
18-
up_icon="<span color=\"${gruvbox_purple_d}\">⮝ </span>"
17+
## ▲ ▼
18+
down_icon="<span color=\"${gruvbox_blue_d}\">⮟</span>"
19+
up_icon="<span color=\"${gruvbox_purple_d}\">⮝</span>"
20+
21+
total_color_low="$gruvbox_gray_d"
22+
total_color_medium="$gruvbox_gray_d"
23+
total_color_high="$gruvbox_purple"
24+
total_color_ultRRRigh="$gruvbox_red"
25+
26+
diff_color_low="$gruvbox_fg"
27+
diff_color_medium="$gruvbox_fg"
28+
diff_color_high="$gruvbox_blue"
29+
diff_color_ultRRRigh="$gruvbox_green"
1930

2031
diff_text=''
2132
total_text=''
@@ -32,45 +43,41 @@ connection_text="${wf_conn}${eth_conn}${if_simcard}${if_wf_down}${vpn_conn}"
3243
## total and diff -----------------------
3344
## https://www.adminsehow.com/2010/03/shell-script-to-show-network-speed/
3445

35-
for interface in 'wifi' 'ethernet'; {
36-
case "$interface" in
46+
for adapter in 'wifi' 'ethernet'; {
47+
case "$adapter" in
3748
wifi )
3849
device_name="$wf_devc"
39-
interface_state="$wf_state"
50+
adapter_state="$wf_state"
4051
;;
4152
ethernet )
4253
device_name="$eth_devc"
43-
interface_state="$eth_state"
54+
adapter_state="$eth_state"
4455
;;
4556
esac
4657

47-
[ "$interface_state" == 'connected' ] || continue
58+
[ "$adapter_state" == 'connected' ] || continue
4859

49-
down_last_file=~/main/scripts/.last/network_"${interface}"_down
50-
up_last_file=~/main/scripts/.last/network_"${interface}"_up
60+
## get total last
61+
down_total_last="$(redis-cli GET "awesome_widget__${adapter}_down")" ## 19410508
62+
up_total_last="$( redis-cli GET "awesome_widget__${adapter}_up")" ## 19410508
63+
##
64+
[ "$down_total_last" ] || down_total_last=0
65+
[ "$up_total_last" ] || up_total_last=0
5166

52-
## get last total down/up
53-
down_total_last="$(< "$down_last_file")" || down_total_last=0 ## 19410508 ## NOTE do NOT add 2>/dev/null
54-
up_total_last="$(< "$up_last_file")" || up_total_last=0 ## 19410508 ## NOTE do NOT add 2>/dev/null
5567

56-
## get down_total_now/up_total_now
57-
## NOTE do NOT replace " with ' in awk
58-
totals_now="$(\grep "$device_name" /proc/net/dev | awk '{print "down_total_now="$2, "up_total_now="$10}')"
59-
eval "$totals_now" ## 19410509 789384
68+
## get total now
69+
## NOTE do NOT " -> ' in awk
70+
_totals_now="$(\grep "$device_name" /proc/net/dev | awk '{print "down_total_now="$2, "up_total_now="$10}')"
71+
eval "$_totals_now" ## 19410509 789384
6072

61-
## save down_total_now/up_total_now as last
62-
## for our next read
73+
74+
## save for our next read
6375
## (in bytes, before converting them)
64-
printf '%s\n' "$down_total_now" > "$down_last_file"
65-
printf '%s\n' "$up_total_now" > "$up_last_file"
76+
redis-cli SET "awesome_widget__${adapter}_down" "$down_total_now" || msgn 'ERROR saving down_total_now'
77+
redis-cli SET "awesome_widget__${adapter}_up" "$up_total_now" || msgn 'ERROR saving up_total_now'
6678

6779
## ---
68-
69-
## set color for down_total_now/up_total_now
70-
total_color_low="$gruvbox_gray_d"
71-
total_color_medium="$gruvbox_gray_d"
72-
total_color_high="$gruvbox_purple"
73-
total_color_ultRRRigh="$gruvbox_red"
80+
## set total color
7481

7582
if (( down_total_now < "$K" )); then down_total_color="$total_color_low" ## is B
7683
elif (( down_total_now < "$M" )); then down_total_color="$total_color_low" ## is K
@@ -79,7 +86,6 @@ for interface in 'wifi' 'ethernet'; {
7986
elif (( down_total_now < "$G" )); then down_total_color="$total_color_high" ## is below 1G
8087
else down_total_color="$total_color_ultRRRigh" ## is 1G or higher
8188
fi
82-
down_total_conv="<span color=\"${down_total_color}\">$(convert_byte "$down_total_now" 1 1)</span>" ## 4.32G
8389

8490
if (( up_total_now < "$K" )); then up_total_color="$total_color_low" ## is B
8591
elif (( up_total_now < "$M" )); then up_total_color="$total_color_low" ## is K
@@ -88,47 +94,48 @@ for interface in 'wifi' 'ethernet'; {
8894
elif (( up_total_now < "$G" )); then up_total_color="$total_color_high" ## is below 1G
8995
else up_total_color="$total_color_ultRRRigh" ## is 1G or higher
9096
fi
91-
up_total_conv="<span color=\"${up_total_color}\">$(convert_byte "$up_total_now" 1 1)</span>" ## 4.32G
9297

9398
## ---
94-
## calculate down_diff/up_diff
99+
## convert total
95100

96-
## for n seconds (i.e. network_refresh_interval seconds)
97-
(( down_diff="down_total_now - down_total_last" )) ## 1341440
98-
(( up_diff="up_total_now - up_total_last" )) ## 1341440
99-
##
100-
## average for one second
101-
(( down_diff="down_diff / network_refresh_interval" ))
102-
(( up_diff="up_diff / network_refresh_interval" ))
101+
down_total_conv="<span color=\"${down_total_color}\">$(convert_byte "$down_total_now" 1 1)</span>" ## 4.32G
102+
up_total_conv="<span color=\"${up_total_color}\">$(convert_byte "$up_total_now" 1 1)</span>" ## 4.32G
103103

104104
## ---
105-
## set color for down_diff/up_diff
105+
## calculate diff
106+
107+
## devided by network_refresh_interval
108+
## to get average for 1 second
109+
(( down_diff="(down_total_now - down_total_last) / network_refresh_interval" )) ## 1341440
110+
(( up_diff="(up_total_now - up_total_last) / network_refresh_interval" )) ## 1341440
106111

107-
diff_color_low="$gruvbox_fg"
108-
diff_color_medium="$gruvbox_fg"
109-
diff_color_high="$gruvbox_blue"
110-
diff_color_ultRRRigh="$gruvbox_green"
112+
## ---
113+
## set diff color
111114

112115
if (( down_diff < "$K" )); then down_diff_color="$diff_color_low" ## is B
113116
elif (( down_diff < "$K_400" )); then down_diff_color="$diff_color_low" ## is below 400K
114117
elif (( down_diff < "$K_700" )); then down_diff_color="$diff_color_medium" ## is below 700K
115118
elif (( down_diff < "$M" )); then down_diff_color="$diff_color_high" ## is below 1M
116119
else down_diff_color="$diff_color_ultRRRigh" ## is M or G
117120
fi
118-
down_diff_conv="<span color=\"${down_diff_color}\">$(convert_byte "$down_diff" 1 1)</span>" ## 1.31M
119121

120122
if (( up_diff < "$K" )); then up_diff_color="$diff_color_low" ## is B
121123
elif (( up_diff < "$K_400" )); then up_diff_color="$diff_color_low" ## is below 400K
122124
elif (( up_diff < "$K_700" )); then up_diff_color="$diff_color_medium" ## is below 700K
123125
elif (( up_diff < "$M" )); then up_diff_color="$diff_color_high" ## is below 1M
124126
else up_diff_color="$diff_color_ultRRRigh" ## is M or G
125127
fi
128+
129+
## ---
130+
## convert diff
131+
132+
down_diff_conv="<span color=\"${down_diff_color}\">$(convert_byte "$down_diff" 1 1)</span>" ## 1.31M
126133
up_diff_conv="<span color=\"${up_diff_color}\">$(convert_byte "$up_diff" 1 1)</span>" ## 1.31M
127134

128135
## ---
129136

130-
diff_text+=" | ${down_icon}${down_diff_conv} ${up_icon}${up_diff_conv}" ## 317K 2.31M
131-
total_text+=" | ${down_icon}${down_total_conv} ${up_icon}${up_total_conv}" ## 4.32G 4.32G
137+
diff_text+=" | ${down_icon} ${down_diff_conv} ${up_icon} ${up_diff_conv}" ## 317K 2.31M
138+
total_text+=" | ${down_icon} ${down_total_conv} ${up_icon} ${up_total_conv}" ## 4.32G 4.32G
132139
}
133140

134141
## remove leading ' | '

0 commit comments

Comments
 (0)