Help finetuning i3status in Qubes dom0

41 views
Skip to first unread message

One7two99

unread,
Oct 3, 2017, 5:06:08 PM10/3/17
to qubes-users
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:
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]

Ilpo Järvinen

unread,
Oct 3, 2017, 5:12:39 PM10/3/17
to One7two99, qubes-users
On Tue, 3 Oct 2017, 'One7two99' via qubes-users wrote:

> Hello,
>
> [ ...snip...]
>
> 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?
> **************

| tail -n +2


--
i.
Reply all
Reply to author
Forward
0 new messages