From f3df391d7160491d75ec7a5c884e1547cf55fba3 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 26 Feb 2019 11:20:46 +1000 Subject: [PATCH] tools: do a simple name match if we can't find the device If the specific name isn't the list (e.g. howling-woodrat) do a basic string search on all the device names. For the normal case where users have only one or maybe two devices and they have unique model names, they can do ratbagctl "Logitech G303" info Which is something we can easily support forever as sensible API. Signed-off-by: Peter Hutterer --- tools/ratbagctl.in | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/ratbagctl.in b/tools/ratbagctl.in index 62369dd6..b168531d 100755 --- a/tools/ratbagctl.in +++ b/tools/ratbagctl.in @@ -67,6 +67,9 @@ def list_devices(r, args): def find_device(r, args): dev = r[args.device] if dev is None: + for d in r.devices: + if args.device in d.name: + return d print("Unable to find device {}".format(args.device)) sys.exit(1) return dev