Skip to content

Commit c023db3

Browse files
author
fadeouter
committed
version 0.4 release
1 parent ef67253 commit c023db3

File tree

4 files changed

+196
-79
lines changed

4 files changed

+196
-79
lines changed

README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,27 @@
11
<h2>System monitor extension for Argos with real CPU graph</h2>
22

33
This extension created specially for [Argos](https://github.com/p-e-w/argos) and linux-powered computers w/ GNOME shell.
4-
It is based on **free**, **top**, **df** and **vmstat** output and uses power of SVG to draw charts.
4+
This script uses power of SVG to draw charts.
55

6-
Please note that the CPU consumption is **very** approximate. It calculates only by first 6 processes of **top** output. See previous releases to
6+
As you see at screenshot, CPU chart has 3 colors: green for iowait consumption, dark grey for user comsumption, and light gray for overall CPU consumption.
7+
8+
Please note that the CPU consumption is approximate. It calculates by **/proc/stat** output, also as memory by **free**, temperature by **/sys/class/thermal/thermal_zone0/temp** and disks by **df** outputs.
79

810
<h3>TODO</h3>
911

10-
* beautify charts with power of SVG
1112
* rewrite script in another lang
12-
* adopt code from [native System Monitor extension for GNOME Shell](https://github.com/paradoxxxzero/gnome-shell-system-monitor-applet)
13+
* find workaround for top issue
14+
* add another improvements
1315

1416
<h3>Known bugs</h3>
1517

16-
Different configurations of **top** utility doesn't allow to show processes and it's CPU consumtion (see opened issue here).
17-
To fix this, open script in text editor and replace `$9 / 2` to `$7 / 2`. Also you may need to change `head -n 10` to `head -n 13`. Also, you may need to change 2 to 4 - this is how many cores in your CPU.
18+
Different configurations of **top** utility doesn't allow to show processes list (see opened issue here).
19+
To fix this, open script in text editor and replace `$9 / 2` to `$7 / 2`. Also you may need to change `head -n 10` to `head -n 13`. Also, you may need to change number of CPU cores (2, 4).
1820
In further releases I will fix this by more elegant way.
1921

2022
<h2>Screenshot</h2>
2123

22-
<img src="https://raw.githubusercontent.com/fadeouter/sysinfo/master/screenshot.png"> <img src="https://raw.githubusercontent.com/fadeouter/sysinfo/master/screenshot_w.png">
24+
<img src="https://raw.githubusercontent.com/fadeouter/sysinfo/master/screenshot.png">
2325

2426
<h2>License</h2>
2527
GNU GPL v3.0 - https://www.gnu.org/licenses/gpl-3.0.en.html

screenshot.png

33.6 KB
Loading

screenshot_w.png

-40.6 KB
Binary file not shown.

sysinfo.1s.sh

Lines changed: 187 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -3,125 +3,214 @@
33
# this is simple and usable script from a newbie
44
# based on some findings on the internet
55
# based on Ganesh V BitBar script (https://github.com/ganeshv/mtop)
6+
# and Leo-G script (https://github.com/Leo-G/DevopsWiki/wiki/How-Linux-CPU-Usage-Time-and-Percentage-is-calculated)
67
# author: fadeouter (https://github.com/fadeouter/)
78

89

9-
scale="2" # if you have HIDPI screen
10-
svg_font_size="9" # probably you won't change this
11-
svg_font_family="Ubuntu" # set as theme font
12-
#symbolic="-symbolic" # uncomment to use multicolour icons
1310

11+
# IMPORTANT! Go to line 114 and set your number of CPU cores
1412

15-
### LIGHT THEME
13+
graphWidth="50" # CPU chart width in pixels, also a number of chart points
14+
scale="1" # if you have HIDPI screen, set appropriate coeff. for scaling
15+
svg_font_size="9" # probably you won't change this
16+
svg_font_family="Ubuntu" # set as GNOME Shell theme font
17+
symbolic=""
18+
#symbolic="-symbolic" # uncomment to use monocolor icons
1619

17-
chart_color="rgba(0,0,0,0.7)" # CPU chart main color
18-
pie_fg_color="rgba(0,0,0,0.5)" # pie foreground color
19-
pie_bg_color="rgba(125,125,125,0.2)" # pie background color
20-
text_muted="#555555" # font color of partition mountpoint
21-
diskbar_font="#333333" # font color of disk used space
20+
21+
### LIGHT THEME (swap with DARK THEME to enable)
22+
23+
chart_system_color="silver" # CPU chart main color
24+
chart_user_color="dimgray" # CPU chart main color
25+
chart_io_color="greenyellow" # CPU chart main color
26+
27+
pie_fg_color=$chart_user_color # pie foreground color
28+
pie_bg_color=$chart_system_color # pie background color
29+
text_muted=$chart_user_color # font color of partition mountpoint
30+
diskbar_font="#333333" # font color of disk used space
2231
diskbar_font_highlighted="green" # font color of disk free space
2332
diskbar_bg_color=$pie_bg_color # disk bar bg color
2433

25-
26-
### DARK THEME
2734

28-
chart_color="rgba(255,255,255,0.8)" # CPU chart main color
29-
pie_fg_color="rgba(255,255,255,0.8)" # pie foreground color
30-
pie_bg_color="rgba(0,0,0,0.3)" # pie background color
31-
text_muted="#ccc" # font color of partition mountpoint
32-
diskbar_font="white" # font color of disk used space
33-
diskbar_font_highlighted="#7eff35" # font color of disk free space
34-
diskbar_bg_color=$pie_fg_color # disk bar bg color
35+
### DARK THEME
3536

37+
chart_system_color="silver" # CPU chart main color
38+
chart_user_color="dimgray" # CPU chart main color
39+
chart_io_color="greenyellow" # CPU chart main color
3640

41+
pie_fg_color=$chart_user_color # pie foreground color
42+
pie_bg_color=$chart_system_color # pie background color
43+
text_muted=$chart_user_color # font color of partition mountpoint
44+
diskbar_font="#ffffff" # font color of disk used space
45+
diskbar_font_highlighted="#7eff35" # font color of disk free space
46+
diskbar_bg_color=$pie_bg_color # disk bar bg color
3747

38-
### SIZES OF SVG OBJECTS
48+
49+
### SIZES AND POSITION OF SVG OBJECTS
3950

4051
icon_h=$(expr 12 \* $scale)
41-
graph_h=$(expr 16 \* $scale)
42-
graph_w=$(expr 32 \* $scale)
52+
graph_h=$(expr 14 \* $scale)
53+
graph_svg_w=$(expr $graphWidth + 14)
54+
mem_bar_pos=$(expr $graphWidth + 5)
4355
diskbar_h=$(expr 18 \* $scale)
4456
diskbar_w=$(expr 120 \* $scale)
4557
px='px'
4658

4759

4860
################################################################
4961
#
50-
# CPU
62+
# 0. Settings
5163
#
5264
################################################################
5365

54-
### SET XXX to number of CPU cores '{ printf("%-4s %-s\n", $9 / XXX, $NF); }'
55-
56-
top=$(top -o "%CPU" -bn 1 | tr -d '[]|' | sed 's\`-\ \g' | sed 's\+\…\g' | head -n 14 | tail -n 6 | awk '{ printf("%-4s %-s\n", $9 / 4, $NF); }' | awk 1 ORS="\\\n")
57-
CPU=$(echo $top | sed 's/\\n/ /g' | awk '{ print $1 + $3 + $5 + $7 + $9 + $12}' | awk '{ printf("%.0f\n", $1"%"); }')
5866

59-
########### cpu graph ################
67+
SETTINGS="${HOME}/.argos-sysinfo.settings"
6068

61-
HISTORY_FILE="${HOME}/.cpu.history"
62-
touch "${HISTORY_FILE}"
63-
PREVIOUS=$(tail -20 "${HISTORY_FILE}")
64-
echo "$PREVIOUS" > "${HISTORY_FILE}"
65-
echo "$CPU" >> "${HISTORY_FILE}"
66-
67-
CPU_GRAPH=$(cat $HISTORY_FILE | tr "\n" "\t" | awk '{print(100-$1,"L 5,"100-$2,"10,"100-$3,"15,"100-$4,"20,"100-$5,"25,"100-$6,"30,"100-$7,"35,"100-$8,"40,"100-$9,"45,"100-$10,"50,"100-$11,"55,"100-$12,"60,"100-$13,"65,"100-$14,"70,"100-$15,"75,"100-$16,"80,"100-$17,"85,"100-$18,"90,"100-$19,"95,"100-$20)}')
69+
if [ ! -f "${SETTINGS}" ]; then
70+
touch "${SETTINGS}"
71+
echo "%on" > "${SETTINGS}"
72+
echo "memon" >> "${SETTINGS}"
73+
fi
6874

69-
cpu_icon=$(echo "<svg xmlns='http://www.w3.org/2000/svg' width='56px' height='56px' viewBox='0 0 100 100'> <g transform='translate(0,0)'> <path style='fill:$chart_color;fill-opacity:1;fill-rule:evenodd;' d='M 0,100 V $CPU_GRAPH l 0,100' /> </g></svg>" | base64 -w 0) # fill style
75+
showPercents=$(grep -E "(%on|%off)" ${SETTINGS})
76+
showMembar=$(grep -E "(memon|memoff)" ${SETTINGS})
7077

71-
########### cpu graph end ############
7278

73-
echo "| image=$cpu_icon imageHeight=$graph_h imageWidth=$graph_w"
74-
echo "---"
75-
echo "<b>$CPU%</b> CPU | image=$cpu_icon imageHeight=$icon_h font=monospace size=10"
76-
echo "$top| font=monospace size=9 iconName=utilities-system-monitor$symbolic bash=gnome-system-monitor terminal=false"
77-
echo "---"
79+
if [ "$showMembar" == "memoff" ]; then
80+
graph_svg_w=$graphWidth
81+
fi
7882

7983

8084
################################################################
8185
#
82-
# Mem
86+
# 01. Memory
8387
#
8488
################################################################
8589

8690
raw_mem=$(free -m | grep Mem)
87-
raw_swap=$(free -m | grep Swap)
8891
mem_used=$(echo $raw_mem | awk '{print $2 - $7}')
89-
mem_D=$(echo $raw_mem | awk '{print (($2 - $7) / $2) * 10}' | awk '{ printf("%.0f\n", $1); }' | awk '{print $0"0"}')
9092
mem_full=$(echo $raw_mem | awk '{print $2}')
93+
memPercent=$(echo $raw_mem | awk '{print ($3 / $2) * 100 }')
94+
memPercentPie=$(echo $raw_mem | awk '{print 174 + (($3 / $2) * 174) }')
95+
96+
raw_swap=$(free -m | grep Swap)
9197
swap_used=$(echo $raw_swap | awk '{print $3}')
9298
swap_full=$(echo $raw_swap | awk '{print $2}')
93-
swap_D=$(echo $raw_swap | awk '{print ($3 / $2) * 10 }' | awk '{ printf("%.0f\n", $1); }' | awk '{print $0"0"}')
99+
swapPercent=$(echo $raw_swap | awk '{print ($3 / $2) * 100 }')
100+
swapPercentPie=$(echo $raw_swap | awk '{print 174 + (($3 / $2) * 174) }')
101+
102+
mempie=$(echo "<svg xmlns='http://www.w3.org/2000/svg' width='$icon_h' height='$icon_h' viewBox='0 0 94.997788 94.997783' transform='translate($icon_h,0) scale(-1,1)'><circle cx='47.5' cy='47.5' r='47.5' fill='$pie_bg_color' /><circle cx='47.5' cy='47.5' r='9' fill='$pie_fg_color' /><path d='M47.499 19.844c15.273 0 27.655 12.381 27.655 27.655 0 15.273-12.382 27.655-27.655 27.655-15.274 0-27.655-12.382-27.655-27.655 0-15.273 12.381-27.655 27.655-27.655' fill='none' stroke='$pie_fg_color' stroke-width='39.688' stroke-dasharray='174' stroke-dashoffset='$memPercentPie' /></svg>" | base64 -w 0)
103+
104+
swappie=$(echo "<svg xmlns='http://www.w3.org/2000/svg' width='$icon_h' height='$icon_h' viewBox='0 0 94.997788 94.997783' transform='translate($icon_h,0) scale(-1,1)'><circle cx='47.5' cy='47.5' r='47.5' fill='$pie_bg_color' /><circle cx='47.5' cy='47.5' r='9' fill='$pie_fg_color' /><path d='M47.499 19.844c15.273 0 27.655 12.381 27.655 27.655 0 15.273-12.382 27.655-27.655 27.655-15.274 0-27.655-12.382-27.655-27.655 0-15.273 12.381-27.655 27.655-27.655' fill='none' stroke='$pie_fg_color' stroke-width='39.688' stroke-dasharray='174' stroke-dashoffset='$swapPercentPie' /></svg>" | base64 -w 0)
105+
106+
107+
108+
################################################################
109+
#
110+
# 02. CPU graph calculation
111+
#
112+
################################################################
113+
114+
# XXX must be equal to number of CPU cores: '...{ printf("%-4s %-s\n", $9 / XXX, $NF); }...'
115+
top=$(top -o "%CPU" -bn 1 | head -n 14 | tail -n 7 | awk '{ printf("%-4s %-s\n", $9 / 4, $NF); }' | awk 1 ORS="\\\n")
116+
117+
HISTORY_FILE="${HOME}/.argos-sysinfo.cpu"
118+
touch "${HISTORY_FILE}"
119+
PREVIOUS=$(tail -$graphWidth "${HISTORY_FILE}")
120+
PREV=$(tail -n 1 "${HISTORY_FILE}")
121+
echo "$PREVIOUS" > "${HISTORY_FILE}"
122+
123+
if [$PREV == '']; then
124+
PREV="0 0 0 0"
125+
fi
126+
127+
PREV_TOTAL=$(echo $PREV | awk '{print $1}' )
128+
PREV_IDLE=$(echo $PREV | awk '{print $2}' )
129+
PREV_USER=$(echo $PREV | awk '{print $3}' )
130+
PREV_IO=$(echo $PREV | awk '{print $4}' )
131+
132+
STAT=(`sed -n 's/^cpu\s//p' /proc/stat`)
133+
IDLE=${STAT[3]}
134+
135+
TOTAL=0
136+
for VALUE in "${STAT[@]}"; do
137+
let "TOTAL=$TOTAL+$VALUE"
138+
done
139+
140+
let "USER=$TOTAL-${STAT[0]}"
141+
let "IO=$TOTAL-${STAT[4]}"
142+
let "DIFF_IDLE=$IDLE-$PREV_IDLE"
143+
let "DIFF_TOTAL=$TOTAL-$PREV_TOTAL"
144+
let "DIFF_USER=$USER-$PREV_USER"
145+
let "DIFF_IO=$IO-$PREV_IO"
146+
let "CPU=(1000*($DIFF_TOTAL-$DIFF_IDLE)/$DIFF_TOTAL+5)/10"
147+
let "CPU_USER=CPU-((1000*($DIFF_USER-$DIFF_IDLE)/$DIFF_USER+5)/10)"
148+
let "CPU_IO=CPU-((1000*($DIFF_IO-$DIFF_IDLE)/$DIFF_IO+5)/10)"
149+
150+
151+
echo "$TOTAL $IDLE $USER $IO $CPU $CPU_USER $CPU_IO" >> "${HISTORY_FILE}"
152+
153+
154+
COUNTER=0
155+
while [ $COUNTER -lt $graphWidth ]; do
156+
fullCpuBar=$(sed -n $COUNTER\p ${HISTORY_FILE} | awk '{print $5}')
157+
ioCpuBar=$(sed -n $COUNTER\p ${HISTORY_FILE} | awk '{print ($5-$7)}')
158+
userCpuBar=$(sed -n $COUNTER\p ${HISTORY_FILE} | awk '{print $6}')
159+
old_string=$svg_string
160+
new_string="<path fill='none' stroke='$chart_system_color' stroke-width='1' d='M$COUNTER,0 $COUNTER,$fullCpuBar'/><path fill='none' stroke='$chart_io_color' stroke-width='1' d='M$COUNTER,$ioCpuBar $COUNTER,$fullCpuBar'/><path fill='none' stroke='$chart_user_color' stroke-width='1' d='M$COUNTER,0 $COUNTER,$userCpuBar'/>"
161+
svg_string=$old_string$new_string
162+
let COUNTER=COUNTER+1
163+
done
164+
165+
cpu_icon=$(echo "<svg xmlns='http://www.w3.org/2000/svg' width='$graph_svg_w' height='100' viewBox='0 0 $graph_svg_w 100'> <g transform='translate(0,100) scale(1,-1)'>
166+
$svg_string
167+
<g transform='translate($mem_bar_pos,0)'><path fill='none' stroke='$chart_system_color' stroke-width='4' d='M0,0 0,$memPercent'/>
168+
<path fill='none' stroke='$chart_system_color' stroke-width='4' d='M7,0 7,$swapPercent'/>
169+
</g></g></svg>" | base64 -w 0)
170+
94171

95172

96-
pie_start="<svg width='$hw' height='$hw' viewBox='0 0 90.146759 90.144005'><g transform='translate(-59.928 -103.428)'><circle cx='105' cy='148.5' r='45.979' fill='$pie_bg_color'/>"
97-
pie_00="</g></svg>"
98-
pie_10="<path d='M105 103.52a44.98 44.98 0 0 1 26.438 8.592L105 148.5z' fill='$pie_fg_color' /></g></svg>"
99-
pie_20="<path d='M105 103.52a44.98 44.98 0 0 1 42.777 31.08L105 148.5z' fill='$pie_fg_color' /></g></svg>"
100-
pie_30="<path d='M105 103.52a44.98 44.98 0 0 1 36.388 18.542 44.98 44.98 0 0 1 6.39 40.337L105 148.5z' fill='$pie_fg_color' /></g></svg>"
101-
pie_40="<path d='M105 103.52a44.98 44.98 0 0 1 44.98 44.98A44.98 44.98 0 0 1 105 193.48V148.5z' fill='$pie_fg_color' /></g></svg>"
102-
pie_50="<path d='M105 103.52a44.98 44.98 0 0 1 44.98 44.98A44.98 44.98 0 0 1 105 193.48V148.5z' fill='$pie_fg_color' /></g></svg>"
103-
pie_60="<path d='M105 103.52a44.98 44.98 0 0 1 42.777 31.08 44.98 44.98 0 0 1-16.34 50.288 44.98 44.98 0 0 1-52.875 0L105 148.5z' fill='$pie_fg_color' /></g></svg>"
104-
pie_70="<path d='M105 103.52a44.98 44.98 0 0 1 44.732 40.278 44.98 44.98 0 0 1-35.38 48.698 44.98 44.98 0 0 1-52.13-30.097L105 148.5z' fill='$pie_fg_color' /></g></svg>"
105-
pie_80="<path d='M105 103.52a44.98 44.98 0 0 1 42.777 31.08 44.98 44.98 0 0 1-16.34 50.288 44.98 44.98 0 0 1-52.875 0 44.98 44.98 0 0 1-16.34-50.287L105 148.5z' fill='$pie_fg_color' /></g></svg>"
106-
pie_90="<path d='M105 103.52a44.98 44.98 0 0 1 44.425 37.944 44.98 44.98 0 0 1-30.526 49.813 44.98 44.98 0 0 1-53.976-22.357 44.98 44.98 0 0 1 13.638-56.808L105 148.5z' fill='$pie_fg_color' /></g></svg>"
107-
pie_100="<circle cx='105' cy='148.5' r='44.979' fill='$pie_fg_color' /></g></svg>"
173+
################################################################
174+
#
175+
# 03. Temperature
176+
#
177+
################################################################
108178

109-
pie_sw="pie_$swap_D"
110-
pie_sw=$(echo "${!pie_sw}")
111-
pie_sw=$(echo "$pie_start$pie_sw" | base64 -w 0)
179+
temp=$(cat /sys/class/thermal/thermal_zone0/temp | awk '{print $1/1000 }')
112180

113-
pie_mem="pie_$mem_D"
114-
pie_mem=$(echo "${!pie_mem}")
115-
pie_mem=$(echo "$pie_start$pie_mem" | base64 -w 0)
116181

117-
echo "Mem: ${mem_used%%.*} / ${mem_full%%.*} MiB | image=$pie_mem"
118-
echo "Swap: ${swap_used%%.*} / ${swap_full%%.*} MiB | image=$pie_sw"
182+
183+
################################################################
184+
#
185+
# 04. Output
186+
#
187+
################################################################
188+
189+
IMAGE_CPU="$CPU%"
190+
191+
if [ "$showPercents" == "%off" ]; then
192+
IMAGE_CPU=''
193+
fi
194+
195+
196+
echo "$IMAGE_CPU| image=$cpu_icon imageHeight=$graph_h imageWidth=$graph_svg_w"
119197

120198
echo "---"
121199

200+
echo "<span color='$text_muted'>CPU </span>\t$CPU% | iconName=utilities-system-monitor"
201+
echo "<span color='$text_muted'>Mem</span>\t${mem_used%%.*} / ${mem_full%%.*} MiB | image=$mempie imageHeight=$icon_h"
202+
echo "<span color='$text_muted'>Swap</span>\t${swap_used%%.*} / ${swap_full%%.*} MiB | image=$swappie imageHeight=$icon_h"
203+
echo "<span color='$text_muted'>Temp</span>\t$temp C° | imageHeight=$icon_h image=PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHZpZXdCb3g9JzAgMCAxMzUuNDY2NjcgMTM1LjQ2NjY3JyBoZWlnaHQ9JzY0JyB3aWR0aD0nNjQnPjxkZWZzPjxtYXJrZXIgb3JpZW50PSdhdXRvJyBpZD0nYicgb3ZlcmZsb3c9J3Zpc2libGUnPjxwYXRoIGQ9J00uOTggMGExIDEgMCAxIDEtMiAwIDEgMSAwIDAgMSAyIDB6JyBmaWxsPScjZjU1JyBmaWxsLXJ1bGU9J2V2ZW5vZGQnIHN0cm9rZT0nI2Y1NScgc3Ryb2tlLXdpZHRoPScuMjY3Jy8+PC9tYXJrZXI+PG1hcmtlciBvcmllbnQ9J2F1dG8nIGlkPSdhJyBvdmVyZmxvdz0ndmlzaWJsZSc+PHBhdGggZD0nTS45OCAwYTEgMSAwIDEgMS0yIDAgMSAxIDAgMCAxIDIgMHonIGZpbGw9JyNjY2MnIGZpbGwtcnVsZT0nZXZlbm9kZCcgc3Ryb2tlPScjY2NjJyBzdHJva2Utd2lkdGg9Jy4yNjcnLz48L21hcmtlcj48L2RlZnM+PGcgc3Ryb2tlLXdpZHRoPScxNC43NzknPjxwYXRoIGQ9J002Ni4zNzggMTEyLjU5NmMuMDEzLTMxLjcyNi4wMjctNS42My4wNC05NS4yMzUnIGZpbGw9JyNjY2MnIHN0cm9rZT0nI2NjYycgc3Ryb2tlLWxpbmVjYXA9J3JvdW5kJyBtYXJrZXItc3RhcnQ9J3VybCgjYSknIHRyYW5zZm9ybT0ndHJhbnNsYXRlKC0xLjE4MiAtNC42ODcpIHNjYWxlKDEuMDM4MjQpJy8+PHBhdGggZD0nTTY2LjM3OCAxMTIuNTk2Yy4wMi0xNi4zMzguMDQtMi45LjA2LTQ5LjA0MycgZmlsbD0nI2Y1NScgc3Ryb2tlPScjZjU1JyBtYXJrZXItc3RhcnQ9J3VybCgjYiknIHRyYW5zZm9ybT0ndHJhbnNsYXRlKC0xLjE4MiAtNC42ODcpIHNjYWxlKDEuMDM4MjQpJy8+PC9nPjwvc3ZnPgo=c@t"
204+
205+
echo "---"
206+
207+
echo "$top| font=monospace size=9 iconName=utilities-system-monitor$symbolic bash=gnome-system-monitor terminal=false"
208+
209+
210+
122211
################################################################
123212
#
124-
# Disk cap
213+
# 05. Disk
125214
#
126215
################################################################
127216

@@ -136,7 +225,7 @@ get_disk_stats() {
136225
local IFS=$'\n'
137226
local i dfdata
138227

139-
dfdata=($(df -H | grep "/dev/mapper*\|/dev/sd*" | grep -v "/boot\|/shm" ))
228+
dfdata=($(df -lH | grep "/dev/mapper*\|/dev/sd*" | grep -v "/boot\|/shm" ))
140229

141230
IFS=$OLDIFS
142231
for ((i = 0; i < ${#dfdata[@]}; i++)); do
@@ -159,18 +248,44 @@ for ((i = 0; i < ${#capacity[@]}; i++)); do
159248
if [[ ${name[$i]} = \/media* ]]; then
160249
disk_icon="drive-removable-media$symbolic"
161250
fi
251+
echo "---"
162252
echo "${cap[$i]} <span color='$text_muted' font='10'>${name[$i]}</span> | iconName=$disk_icon imageHeight=$icon_h length=20 bash='nautilus ${name[$i]}' terminal=false"
163253
#echo "${used[$i]} / <span color='green'>${free[$i]}</span> (${capacity[$i]} %)| refresh=false iconName=image-filter$symbolic"
164254
diskbar_green=$(echo ${capacity[$i]} | awk '{print 255 - $0 * 2.55 }' | awk '{ printf("%.0f\n", $1); }')
165255
diskbar_red=$(echo ${capacity[$i]} | awk '{print $0 * 2.55 }' | awk '{ printf("%.0f\n", $1); }')
166256
diskbar_color="rgba($diskbar_red,$diskbar_green,0,0.7)"
167257
diskbar=$(echo "<svg xmlns='http://www.w3.org/2000/svg' width='$diskbar_w$px' height='$diskbar_h$px' viewBox='0 0 100 11'> <rect width='100' height='2' x='0' y='$height' fill='$diskbar_bg_color' rx='1px'/> <rect width='${capacity[$i]}' height='2' x='0' y='$height' fill='$diskbar_color' rx='1px'/> <text x='0' y='7' font-size='$svg_font_size' font-family='$svg_font_family'><tspan fill='$diskbar_font'>${used[$i]} / <tspan fill='$diskbar_font_highlighted'>${free[$i]}</tspan> (${capacity[$i]} %)</tspan></text> </svg>" | base64 -w 0)
168258
echo "|image=$diskbar iconName=baobab$symbolic imageHeight=$diskbar_h"
169-
echo "---"
170259
done
171260

172261

173-
echo "Check free space | iconName=baobab$symbolic bash=baobab terminal=false"
174-
echo "Open System Monitor | iconName=utilities-system-monitor$symbolic bash=gnome-system-monitor terminal=false"
175-
print
262+
################################################################
263+
#
264+
# 6. Settings rendering
265+
#
266+
################################################################
267+
268+
269+
echo "---"
270+
echo "Settings | iconName=gnome-settings$symbolic"
271+
272+
slon="PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHdpZHRoPScyNCcgaGVpZ2h0PScyNCcgdmlld0JveD0nMCAwIDM3MCAzNzAnPjxwYXRoIGQ9J00yNzMgODhIOTdjLTUzLjUgMC05NyA0My42LTk3IDk3czQzLjUgOTcgOTcgOTdoMTc2YzUzLjUgMCA5Ny00My42IDk3LTk3cy00My41LTk3LTk3LTk3em0tMTE3LjYgOTdjMCAyOC44LTIzLjQgNTIuMi01Mi4yIDUyLjItMjguOCAwLTUyLjItMjMuNC01Mi4yLTUyLjIgMC0yOC44IDIzLjQtNTIuMiA1Mi4yLTUyLjIgMjguOCAwIDUyLjIgMjMuNCA1Mi4yIDUyLjJ6JyB0cmFuc2Zvcm09J3RyYW5zbGF0ZSgzNzAsIDApIHNjYWxlKC0xLCAxKScgZmlsbD0nZ3JlZW4nIC8+PC9zdmc+Cg=="
273+
sloff="PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHdpZHRoPScyNCcgaGVpZ2h0PScyNCcgdmlld0JveD0nMCAwIDM3MCAzNzAnPjxwYXRoIGQ9J00yNzMgODhIOTdjLTUzLjUgMC05NyA0My42LTk3IDk3czQzLjUgOTcgOTcgOTdoMTc2YzUzLjUgMCA5Ny00My42IDk3LTk3cy00My41LTk3LTk3LTk3em0tMTE3LjYgOTdjMCAyOC44LTIzLjQgNTIuMi01Mi4yIDUyLjItMjguOCAwLTUyLjItMjMuNC01Mi4yLTUyLjIgMC0yOC44IDIzLjQtNTIuMiA1Mi4yLTUyLjIgMjguOCAwIDUyLjIgMjMuNCA1Mi4yIDUyLjJ6JyBmaWxsPSdyZWQnIC8+PC9zdmc+Cg=="
274+
275+
276+
if [ "$showPercents" == "%on" ]; then
277+
echo "--Show CPU usage | refresh=true bash='sed -i -e s/%on/%off/g ${SETTINGS}' terminal=false image=$slon"
278+
elif [ "$showPercents" == "%off" ]; then
279+
echo "--Show CPU usage | refresh=true bash='sed -i -e s/%off/%on/g ${SETTINGS}' terminal=false image=$sloff"
280+
fi
281+
282+
283+
if [ "$showMembar" == "memon" ]; then
284+
echo "--Show memory bars | refresh=true bash='sed -i -e s/memon/memoff/g ${SETTINGS}' terminal=false image=$slon"
285+
elif [ "$showMembar" == "memoff" ]; then
286+
echo "--Show memory bars | refresh=true bash='sed -i -e s/memoff/memon/g ${SETTINGS}' terminal=false image=$sloff"
287+
fi
288+
289+
290+
176291

0 commit comments

Comments
 (0)