From: Xing Guo Date: Fri, 26 Dec 2025 12:25:54 +0000 (+0800) Subject: rfkill: Output in JSON format if -J is provided. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8832034dea26268359de8f405f34ff004ea598e0;p=thirdparty%2Futil-linux.git rfkill: Output in JSON format if -J is provided. This patch teaches rfkill output in JSON format if -J is provided. E.g., ``` $ ./rfkill -J list { "rfkilldevices": [ { "id": 0, "type": "bluetooth", "device": "tpacpi_bluetooth_sw", "soft": "unblocked", "hard": "unblocked" },{ "id": 1, "type": "wwan", "device": "tpacpi_wwan_sw", "soft": "unblocked", "hard": "unblocked" },{ "id": 3, "type": "wlan", "device": "phy0", "soft": "unblocked", "hard": "unblocked" },{ "id": 4, "type": "bluetooth", "device": "hci0", "soft": "unblocked", "hard": "unblocked" } ] } $ ./rfkill -J list bluetooth { "rfkilldevices": [ { "id": 0, "type": "bluetooth", "device": "tpacpi_bluetooth_sw", "soft": "unblocked", "hard": "unblocked" },{ "id": 4, "type": "bluetooth", "device": "hci0", "soft": "unblocked", "hard": "unblocked" } ] } ``` --- diff --git a/sys-utils/rfkill.c b/sys-utils/rfkill.c index d1c38b0c0..88a8a9d4c 100644 --- a/sys-utils/rfkill.c +++ b/sys-utils/rfkill.c @@ -740,7 +740,7 @@ int main(int argc, char **argv) * For backward compatibility we use old output format if * "list" explicitly specified and --output not defined. */ - if (!outarg && act == ACT_LIST) + if (!outarg && !ctrl.json && act == ACT_LIST) act = ACT_LIST_OLD; }