LoLei / razer-cli

CLI for configuring Razer devices
GNU General Public License v3.0
93 stars 11 forks source link

[Request w/ Patch] Support for different X/Y DPI #34

Closed GM-Script-Writer-62850 closed 3 years ago

GM-Script-Writer-62850 commented 3 years ago

Proposed change to this part of the script: https://github.com/LoLei/razer-cli/blob/master/razer_cli/razer_cli.py#L140-L142

                # Actually set DPI
                args.dpi = args.dpi.split(',')
                if len(args.dpi) == 1:
                    args.dpi.append(int(args.dpi[0]))
                device.dpi = (int(args.dpi[0]), int(args.dpi[1]))

Example usage:

It is a niche feature, but adding support is easy so why not?

LoLei commented 3 years ago

You can open a pull request with these changes and I'll gladly accept it.

GM-Script-Writer-62850 commented 3 years ago

not sure how to make those, never bothered to figure it out, if you are like me you mat want to change some of the code formatting don't even need this feature, but i was just curious if it was supported and saw it made a error so i looked at that part of the code and was well i am here may as well add it

LoLei commented 3 years ago

Well if you want to try it:

  1. Make a fork of this project (top right)
  2. Add your changes to the code of the fork (directly on GitHub or locally and push again with git)
  3. Open a pull request (next to issues) in this project and select the fork as the source

Otherwise I can add the changes myself and credit you as the source.

GM-Script-Writer-62850 commented 3 years ago

you can do that, still need to be noted in help documentation you can do that now

also added another feature for the sake of scripting

$ .local/bin/razer-cli --dpi print
1000 128
$ .local/bin/razer-cli --dpi print
1200

see lines 9 - 14 here, may change the output format when i make my script to watch for accidental dpi button presses only reason accidents happen is my finger hits the desk and then my finger goes into the dpi button and 4500+DPI is well beyond usable (changing the DPI via the GUI sucks when the DPI is too high or too low)

def set_dpi(device_manager):
    # Iterate over each device and set DPI
    for device in device_manager.devices:
        # If -d argument is set, only set those devices
        if (args.device and device.name in args.device) or (not args.device):
            if (device.type != "mouse"):
                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])
                else:
                    print(args.dpi[0],args.dpi[1])
            else:
                if args.verbose:
                    print("Setting DPI of device {} to {}".format(device.name,
                                                                  args.dpi))

                # Save used settings for this device to a file
                util.write_settings_to_file(device, dpi=args.dpi)

                # Actually set DPI
                args.dpi = args.dpi.split(',')
                if len(args.dpi) == 1:
                    args.dpi.append(int(args.dpi[0]))
                device.dpi = (int(args.dpi[0]), int(args.dpi[1]))

EDIT: There is one thing i would like to complain about: please use tabs not spaces TabError: inconsistent use of tabs and spaces in indentation every single time i make a edit i get that annoying error

LoLei commented 3 years ago

Done in #37