Hello,
after switching to i3vm in Qubes 3.2 as primary window manager I'm working on
tweaking it to my needs.
I've learned that Qubes is adding a small script to generate the status bar in
i3:
/usr/bin/qubes-i3status
I'd like to add the total consumed RAM in the status bar, but my scripting is
not good enough to make it work, can someone give me a hint?
My current approach:
1) get the used RAM for each AppVM from running 'xl list' in dom0
[USER@dom0 ~]$ xl list
Name ID Mem VCPUs State Time(s)
dom0 0 4061 4 r----- 902.7
sys-net 1 297 2 -b---- 61.1
sys-firewall 2 1424 2 -b---- 74.3
sys-usb 3 1023 2 -b---- 54.3
win7 4 4095 2 -b---- 298.9
win7-dm 5 44 1 -b---- 92.2
untrusted 6 3999 2 -b---- 492.9
2) Extracted only the column which includes the RAM with
[USER@dom0 ~]$ xl list | awk '{print $3}'
Mem
4061
297
1424
1023
4095
44
3999
**************
QUESTION: How can I remove the first line?
**************
3) If I get rid of the first line, I could add everything up.
Looking here:
https://unix.stackexchange.com/questions/320217/how-to-calculate-the-the-value-of-each-line-with-awk-command
the command to do so would be:
[USER@dom0 ~]$ xl list | awk '{print $3}' | paste -s -d+ -
which will create:
4061+297+1424+1023+4095+44+3999
4) passing this to bc should give me the total RAM:
[USER@dom0 ~]$ xl list | awk '{print $3}' | paste -s -d+ - | bc
If someone is interested in additional tweaks to i3status:
I've added some changes to this file to format date and time and more important
to get better battery metrics as I like to keep an eye on the current discharge
rate to learn how system load is impacting battery runtime.
This is also usefull to learn how optimizations like tlp will influence battery
runtime etc.
[...]
status_bat() {
local my_bat=/sys/class/power_supply/BAT0
local bat_rate=$(bc <<< "scale=1;`cat $my_bat/current_now`*`cat
$my_bat/voltage_now`/10^12")"W"
local bat=$((100*`cat $my_bat/charge_now`/`cat $my_bat/charge_full_design`))
local ac=''
local color=''
if [[ $(cat /sys/class/power_supply/AC/online) == '1' ]]; then
ac=' AC'
elif ((bat < 25)); then
color='#ff0000' # red
elif ((bat < 50)); then
color='#ff6600' #was #ffff00 = yellow before
fi
json bat "Bat: $bat_rate $bat%$ac" "$color"
}
[799]
--
You received this message because you are subscribed to the Google Groups
"qubes-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/qubes-users/W3biJfnI57zpgFICAeyZ3MFjveXf4FvnmTmRYTQ4t9xRcMFAJ6zoLdeFpLpSQWqh3yyU5aejwKz_81TzHMMuLo2qkfO57p7oh74uzTh_i6A%3D%40protonmail.com.
For more options, visit https://groups.google.com/d/optout.