I have a json file which provides options for a 'whiptail' checkbox or radiolist. I grab them, make some redactions and wanna use them to show as options:
defaults.json
file:
{"displays":
[
{"id": "320x240", "default":"on", "description":"320x240 (native resolution of 3.2 TFT-Display)", "hdmi_group":"2", "hdmi_mode":"87","hdmi_cvt":"320 240 60 1 0 0 0"},
{"id": "640x480", "default":"off", "description":"640x480", "hdmi_group":"2","hdmi_mode":"87", "hdmi_cvt":"3240 240 60 1 0 0 0"},
{"id": "720x540", "default":"off", "description":"720x540", "hdmi_group":"2","hdmi_mode":"87", "hdmi_cvt":"3240 240 60 1 0 0 0"},
{"id": "800x600", "default":"off", "description":"800x600", "hdmi_group":"2","hdmi_mode":"87", "hdmi_cvt":"3240 240 60 1 0 0 0"},
{"id": "1024x768", "default":"off", "description":"1024x768", "hdmi_group":"2","hdmi_mode":"87", "hdmi_cvt":"3240 240 60 1 0 0 0"},
{"id": "1280x720", "default":"off", "description":"1280x720 (16:9)", "hdmi_group":"2","hdmi_mode":"87", "hdmi_cvt":"3240 240 60 1 0 0 0"},
{"id": "1600x900", "default":"off", "description":"1600x900 (16:9)", "hdmi_group":"2","hdmi_mode":"87", "hdmi_cvt":"3240 240 60 1 0 0 0"},
{"id": "1920x1080", "default":"off", "description":"1920x1080 (16:9)", "hdmi_group":"2","hdmi_mode":"87", "hdmi_cvt":"3240 240 60 1 0 0 0"}
]
}
The jq
script
displays=$(cat defaults.json | jq -r -j '.displays[] | "\(.id) \"\(.description)\" \(.default) "')
which gives me the following output (which works when I paste it directly into the [tag item status]
position:
320x240 "320x240 (native resolution of 3.2 TFT-Display)" on 640x480 "640x480" off 720x540 "720x540" off 800x600 "800x600" off 1024x768 "1024x768" off 1280x720 "1280x720 (16:9)" off 1600x900 "1600x900 (16:9)" off 1920x1080 "1920x1080 (16:9)" off
This one works perfectly:
whiptail --title "Display setup" --radiolist "Choose your display" 20 78 8 320x240 "320x240 (native resolution of 3.2 TFT-Display)" on 640x480 "640x480" off 720x540 "720x540" off 800x600 "800x600" off 1024x768 "1024x768" off 1280x720 "1280x720 (16:9)" off 1600x900 "1600x900 (16:9)" off 1920x1080 "1920x1080 (16:9)" off 3>&1 1>&2 2>&3
**BUT** when I try to add them through the variable $displays
, whiptail
only spits out the "help" file.
**This is not working**
whiptail --title "Display setup" --radiolist "Choose your display" 20 78 8 $displays 3>&1 1>&2 2>&3
**What I am doing wrong, why is this not working?**
Asked by Jan
(175 rep)
Nov 3, 2018, 10:20 AM
Last activity: Nov 3, 2018, 11:27 PM
Last activity: Nov 3, 2018, 11:27 PM