Skip to content

Commit

Permalink
Merge pull request #45 from LoLei/feature/print-dpi-poll
Browse files Browse the repository at this point in the history
Add changes from #44
  • Loading branch information
LoLei authored Jan 23, 2021
2 parents 783f3f7 + 1750031 commit 7b6bf00
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 19 deletions.
24 changes: 15 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
<sup>This might be out of date, just run it with `-h` yourself to see the newest
options.</sup>
Expand Down
28 changes: 19 additions & 9 deletions razer_cli/razer_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""

__author__ = "Lorenz Leitner"
__version__ = "1.5.0"
__version__ = "1.5.1"
__license__ = "GPL-3.0"

# Libraries
Expand Down Expand Up @@ -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,
Expand All @@ -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(
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="razer-cli",
version="1.5.0",
version="1.5.1",
author="Lorenz Leitner",
author_email="[email protected]",
description="Control Razer devices from the command line",
Expand Down

0 comments on commit 7b6bf00

Please sign in to comment.