From 1750031d4227b38a73e0a12660bb3f97d5fdd45a Mon Sep 17 00:00:00 2001 From: Lorenz Leitner Date: Thu, 21 Jan 2021 18:56:25 +0100 Subject: [PATCH] Add changes from #44 --- README.md | 24 +++++++++++++++--------- razer_cli/razer_cli.py | 28 +++++++++++++++++++--------- setup.py | 2 +- 3 files changed, 35 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 827dca4..1d264cb 100644 --- a/README.md +++ b/README.md @@ -18,28 +18,34 @@ information. ## Usage ``` -$ razer-cli -h -usage: razer-cli [-h] [-e EFFECT] [-v] [-c COLOR [COLOR ...]] [-l] [-ll] [-a] - [-d DEVICE [DEVICE ...]] [--dpi DPI] [-b BRIGHTNESS] +$ razer-cli -h <<< +usage: razer-cli [-h] [-e EFFECT [EFFECT ...]] [-v] [-c COLOR [COLOR ...]] + [-l] [-ll] [-llh] [-a] [-d DEVICE [DEVICE ...]] [--dpi DPI] + [--poll POLL] [-b BRIGHTNESS] [--sync] optional arguments: -h, --help show this help message and exit - -e EFFECT, --effect EFFECT + -e EFFECT [EFFECT ...], --effect EFFECT [EFFECT ...] set effect -v, --verbose increase output verbosity -c COLOR [COLOR ...], --color COLOR [COLOR ...] - choose color (default: X color1), use one argument for - hex, or three for base10 rgb + choose color (default: X color1), use one argument + for hex, or three for base10 rgb -l, --list_devices list available devices and their supported effects -ll, --list_devices_long list available devices and all their capabilities - -a, --automatic try to find colors and set them to all devices without - user arguments, uses X or pywal colors + -llh, --list_devices_long_human + list devices and capabilities human readable + -a, --automatic try to find colors and set them to all devices + without user arguments, uses X or pywal colors -d DEVICE [DEVICE ...], --device DEVICE [DEVICE ...] only affect these devices, same name as output of -l - --dpi DPI set DPI of device + --dpi DPI set DPI of device (use print as a value to show it) + --poll POLL set polling rate of device (use print as a value to + show it) -b BRIGHTNESS, --brightness BRIGHTNESS set brightness of device + --sync sync lighting effects to all supported Razer products ``` This might be out of date, just run it with `-h` yourself to see the newest options. diff --git a/razer_cli/razer_cli.py b/razer_cli/razer_cli.py index db80b8d..a5f70b7 100755 --- a/razer_cli/razer_cli.py +++ b/razer_cli/razer_cli.py @@ -4,7 +4,7 @@ """ __author__ = "Lorenz Leitner" -__version__ = "1.5.0" +__version__ = "1.5.1" __license__ = "GPL-3.0" # Libraries @@ -131,11 +131,17 @@ def set_dpi(device_manager): if args.verbose: print("Device {} is not a mouse".format(device.name)) elif args.dpi == "print": - args.dpi = str(device.dpi)[1:-1].split(', ') - if args.dpi[0] == args.dpi[1]: - print(args.dpi[0]) + dpi = str(device.dpi)[1:-1].split(', ') + if args.poll == "print": + if dpi[0] == dpi[1]: + print('dpi:', dpi[0]) + else: + print('dpi:', dpi[0], dpi[1]) else: - print(args.dpi[0], args.dpi[1]) + if dpi[0] == dpi[1]: + print(dpi[0]) + else: + print(dpi[0], dpi[1]) else: if args.verbose: print("Setting DPI of device {} to {}".format(device.name, @@ -158,7 +164,10 @@ def set_poll_rate(device_manager): if (args.device and device.name in args.device) or (not args.device): if device.has("poll_rate"): if args.poll == "print": - print(device.poll_rate) + if args.dpi == "print": + print('poll_rate:', device.poll_rate) + else: + print(device.poll_rate) else: if args.verbose: print( @@ -358,12 +367,13 @@ def read_args(): help="only affect these devices, same name as output " "of -l") - parser.add_argument("--dpi", - help="set DPI of device", + parser.add_argument("--dpi", help="set DPI of device" + " (use print as a value to show it)", action="store") parser.add_argument("--poll", - help="set polling rate of device", + help="set polling rate of device" + " (use print as a value to show it)", action="store") parser.add_argument("-b", "--brightness", diff --git a/setup.py b/setup.py index a61d1df..4e30e08 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name="razer-cli", - version="1.5.0", + version="1.5.1", author="Lorenz Leitner", author_email="lrnz.ltnr@gmail.com", description="Control Razer devices from the command line",