Initial version of a shell script that uses the json mode to show system info

This commit is contained in:
Simon Hausmann 2021-10-01 17:29:27 +02:00
parent 8150bb027b
commit e464b473d6
2 changed files with 91 additions and 0 deletions

67
examples/bash/sysinfo.60 Normal file
View file

@ -0,0 +1,67 @@
/* LICENSE BEGIN
This file is part of the SixtyFPS Project -- https://sixtyfps.io
Copyright (c) 2021 Olivier Goffart <olivier.goffart@sixtyfps.io>
Copyright (c) 2021 Simon Hausmann <simon.hausmann@sixtyfps.io>
SPDX-License-Identifier: GPL-3.0-only
This file is also available under commercial licensing terms.
Please contact info@sixtyfps.io for more information.
LICENSE END */
import { TabWidget, StandardButton, GridBox } from "sixtyfps_widgets.60";
SysInfo := Dialog {
property cpu_count <=> cpu-count.text;
property cpu_model <=> cpu-model.text;
property cpu_vendor <=> cpu-vendor.text;
property<int> mem_size_kb;
StandardButton { kind: ok; }
preferred-width: 300px;
TabWidget {
Tab {
title: "CPU";
GridBox {
Row {
Text {
text: "Product:";
max-width: min-width;
}
cpu-model := Text {
}
}
Row {
Text {
text: "Vendor:";
max-width: min-width;
}
cpu-vendor := Text {
}
}
Row {
Text {
text: "Number of logical cores:";
max-width: min-width;
}
cpu-count := Text {
}
}
}
}
Tab {
title: "Memory";
GridBox {
Row {
Text {
text: "Size:";
max-width: min-width;
}
Text {
text: "\{floor(mem_size_kb / 1024)} GB";
}
}
}
}
}
}

24
examples/bash/sysinfo_linux.sh Executable file
View file

@ -0,0 +1,24 @@
#!/bin/bash -e
# LICENSE BEGIN
# This file is part of the SixtyFPS Project -- https://sixtyfps.io
# Copyright (c) 2021 Olivier Goffart <olivier.goffart@sixtyfps.io>
# Copyright (c) 2021 Simon Hausmann <simon.hausmann@sixtyfps.io>
#
# SPDX-License-Identifier: GPL-3.0-only
# This file is also available under commercial licensing terms.
# Please contact info@sixtyfps.io for more information.
# LICENSE END
cpu_count=`grep processor /proc/cpuinfo | wc -l`
cpu_vendor=`awk -F ": " '/vendor_id/{ print $2; exit}' < /proc/cpuinfo`
cpu_model=`awk -F ": " '/model name/{ print $2; exit}' < /proc/cpuinfo`
mem_size_kb=`sed -n -e "s,MemTotal:\s\+\(.*\)\s\+.\+,\1,p"< /proc/meminfo`
sixtyfps-viewer `dirname $0`/sysinfo.60 --load-data - <<EOT
{
"cpu_count": "$cpu_count",
"cpu_vendor": "$cpu_vendor",
"cpu_model": "$cpu_model",
"mem_size_kb": $mem_size_kb
}
EOT