
This is a script for Windows written in Python 3.10 that gets the battery level of a Razer Mamba Wireless and shows a tray notification.
Combining with the Task Scheduler, the notification can be regularly shown with self-defined interval (the default is a notification every 15 minutes).
- Clone this repository
- Go to the website of
libusbto download the Latest Windows Binaries - In the
.7zfile downloaded, extract\VS2019\MS64\dll\libusb-1.0.dlltoC:\Windows\System32and\VS2019\MS32\dll\libusb-1.0.dlltoC:\Windows\SysWOW64 - If you can run PowerShell script on your system, run
. .\mamba.ps1in a PowerShell inside the directory - Input a time interval in minutes, or press Enter for the default of 15 minutes when prompted
- The script installs the needed Python packages and sets up the scheduled tasks with a 15-minute time interval
- Run the PowerShell script, then run
python -m pip install -r requirements.txtinside the directory - Go to
Task Schedulerby searching in the start menu - In the
Actionsmenu on the right hand side, clickCreate Task... - Enter a name and a description as you like
- Go to
Actionsand clickNew... - Enter the details in the dialog box that appears:
| Field | To Enter | Example |
|---|---|---|
| Program/script: | \path\to\pythonw.exe |
C:\Python310\pythonw.exe |
| Add arguments (optional): | mamba.pyw |
mamba.pyw |
| Start in (optional): | the path that you put mamba.pyw |
the directory that you cloned this repo |
- Go to
Triggersand clickNew... - Enter the details in the dialog box that appears:
| Field | To Enter | Example |
|---|---|---|
| Repeat task every: | enable; the notification would appear every x minutes |
15 minutes = 1 notification every 15 minutes |
| for a duration of: | Indefinitely |
- Click
OK, done! Now the notification would appear every 15 minutes (or the time interval that you choose)
This script is written by looking into OpenRazer, a GNU/Linux driver for controlling razer devices.
Also, I have referenced the blog post and the script by Roland Smith in the process of writing this script.
Warning: This process may brick your device (although my mouse did not). TRY AT YOUR OWN RISK!
To adapt the script for your Razer mouse, follow the steps below:
- Get the PIDs of your mouse in both the wireless and wired mode
Go to Device Manager -> Find your mouse -> Right click -> Properties -> Details -> Hardware Ids -> Repeat in the other state
- e.g., in wireless state, the entries of Hardware Ids contain
VID_1532&PID_0072, then 0x0072 is the PID of my mouse in the wireless state - In wired state, the entries contain
VID_1532&PID_0073, then 0x0073 is the PID of my mouse in the wired state
git clone https://github.com/openrazer/openrazer.git- Look at
openrazer/driver/razermouse_driver.cin the cloned repository - Search for
batteryin the.cfile to find the functionrazer_attr_read_charge_level - If the name of your mouse appears inside the switch statement, write down the
transaction_id.id
- e.g., I see
USB_DEVICE_ID_RAZER_MAMBA_WIRELESS_RECEIVERinside the switch statement, so thetransaction_id.idfor my mouse is0x3f - If you do not see your mouse name inside, then the
transaction_id.idis0xff
- Open
mamba.pywand change the values ofWIRELESS_RECEIVER,WIRELESS_WIREDandTRAN_IDaccording to your findings above - Done!
If the script is not working, you could try the following steps:
- Turn off Focus Assist in the action center, accessed by the dialog button on the bottom right corner of the taskbar
- Try a different USB port
- Uninstall any WinUSB driver (upper filter) that you have installed
- Try closing Razer Synapse
- Try uninstalling the driver of your mouse in Device Manager, and then replug the USB receiver
- If the mouse is not responsive after executing the script, replug usb receiver should solve the problem
GNU General Public License v2.0