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
libusb
to download the Latest Windows Binaries - In the
.7z
file downloaded, extract\VS2019\MS64\dll\libusb-1.0.dll
toC:\Windows\System32
and\VS2019\MS32\dll\libusb-1.0.dll
toC:\Windows\SysWOW64
- If you can run PowerShell script on your system, run
. .\mamba.ps1
in 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.txt
inside the directory - Go to
Task Scheduler
by searching in the start menu - In the
Actions
menu on the right hand side, clickCreate Task...
- Enter a name and a description as you like
- Go to
Actions
and 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
Triggers
and 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.c
in the cloned repository - Search for
battery
in the.c
file 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_RECEIVER
inside the switch statement, so thetransaction_id.id
for my mouse is0x3f
- If you do not see your mouse name inside, then the
transaction_id.id
is0xff
- Open
mamba.pyw
and change the values ofWIRELESS_RECEIVER
,WIRELESS_WIRED
andTRAN_ID
according 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