the script can be rewriten using JSON/QMP utilizing `jq` for better pasrsing, instead of relying on `grep`, `cut` and bashisms etc.