From 0c4da4809f9bfc1ec0542404800fef4f93a66a12 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Thu, 7 Oct 2021 14:54:07 +0200 Subject: [PATCH] Split out the memory into a separate tab and add some more information about memory and swap --- examples/bash/sysinfo.60 | 68 +++++++++++++++++++++++++++++----- examples/bash/sysinfo_linux.sh | 8 ++++ examples/bash/sysinfo_macos.sh | 16 +++++++- 3 files changed, 81 insertions(+), 11 deletions(-) diff --git a/examples/bash/sysinfo.60 b/examples/bash/sysinfo.60 index 27ff8b6b4ee..32743199ee1 100644 --- a/examples/bash/sysinfo.60 +++ b/examples/bash/sysinfo.60 @@ -8,7 +8,7 @@ Please contact info@sixtyfps.io for more information. LICENSE END */ -import { TabWidget, StandardButton, GridBox, ListView } from "sixtyfps_widgets.60"; +import { TabWidget, StandardButton, GridBox, VerticalBox, ListView } from "sixtyfps_widgets.60"; SysInfo := Dialog { @@ -18,6 +18,10 @@ SysInfo := Dialog { property cpu_model <=> cpu-model.text; property cpu_vendor <=> cpu-vendor.text; property mem_size_kb; + property buffer_mem_size_kb; + property swap_total_kb; + property swap_used_kb; + property swap_free_kb; property <[{dev: string, mnt: string, total: int, free: int}]> partitions; title: "System information"; @@ -77,30 +81,74 @@ SysInfo := Dialog { cpu-count := Text {} } Row { - Text { + Text{ col: 1; - text: "Memory Size:"; + text: "Uptime:"; max-width: min-width; } + uptime := Text {} + } + Rectangle {} + } + } + + Tab { + title: "Memory"; + GridBox { + Row { Text { - text: "\{floor(mem_size_kb / (1000*1000))} GB"; + text: "Installed Memory:"; + max-width: min-width; + } + Text { + text: "\{floor(mem_size_kb / (1024*1024))} GiB"; } } Row { - Text{ - col: 1; - text: "Uptime:"; + Text { + text: "Buffer/Cache Memory:"; max-width: min-width; } - uptime := Text {} + Text { + text: "\{floor(buffer_mem_size_kb / (1024*1024))} GiB"; + } + } + Row { + Text { + text: "Swap Total:"; + max-width: min-width; + } + Text { + text: "\{floor(swap_total_kb / (1024*1024))} GiB"; + } + } + Row { + Text { + text: "Swap Used:"; + max-width: min-width; + } + Text { + text: "\{floor(swap_used_kb / (1024*1024))} GiB"; + } + } + Row { + Text { + text: "Swap Free:"; + max-width: min-width; + } + Text { + text: "\{floor(swap_free_kb / (1024*1024))} GiB"; + } + } + Row { + Rectangle {} } - Rectangle {} } } Tab { title: "Partitions"; - VerticalLayout { + VerticalBox { padding: 5px; HorizontalLayout { diff --git a/examples/bash/sysinfo_linux.sh b/examples/bash/sysinfo_linux.sh index 8eaa73e6b3a..0cb25611845 100755 --- a/examples/bash/sysinfo_linux.sh +++ b/examples/bash/sysinfo_linux.sh @@ -21,6 +21,10 @@ cpu_vendor=`awk -F ": " '/vendor_id/{ print $2; exit}' < /proc/cpuinfo | tr -d ' cpu_model=`awk -F ": " '/model name/{ print $2; exit}' < /proc/cpuinfo | tr -d '"\\\\'` mem_size_kb=`sed -n -e "s,MemTotal:\s\+\(.*\)\s\+.\+,\1,p"< /proc/meminfo` partitions=`df -T --block-size=1 | tail -n+2 | awk 'NR > 1 { printf(", ") } {printf "{ \"dev\": \"%s\", \"mnt\": \"%s\", \"total\": %s, \"free\": %s }", $1,$7, $3, $5}'` +buffer_mem_size_kb=`sed -n -e "s,Buffers:\s\+\(.*\)\s\+.\+,\1,p"< /proc/meminfo` +swap_total_kb=`sed -n -e "s,SwapTotal:\s\+\(.*\)\s\+.\+,\1,p"< /proc/meminfo` +swap_free_kb=`sed -n -e "s,SwapFree:\s\+\(.*\)\s\+.\+,\1,p"< /proc/meminfo` +swap_used_kb=$(swap_total_kb - swap_free_kb)) sixtyfps-viewer `dirname $0`/sysinfo.60 --load-data - <