Comments (3)
You guys may want to look into what I made: https://github.com/yurtemre7/mouse-battery
:)
from rivalcfg.
Rivalcfg is currently only a CLI and a Python library, so it will not implement any GUI nor tray icon (at least not as a direct part of it, it can be a separated program).
Someone seems to be working on a GNOME Shell extension to display the battery level (see #198), and it should not be too difficult to implement a simple Python script that display a tray icon using TKinter
from rivalcfg.
Hum... It seems there is nothing in tk for handling systray... But I found a way to do it with pystray and Pillow:
pip install rivalcfg pystray pillow
import os
os.environ["PYSTRAY_BACKEND"] = "xorg"
import threading
import time
from PIL import Image, ImageDraw
import pystray
import rivalcfg
def create_image(
percent,
width=16,
height=16,
color_bg="black",
color_high="lime",
color_low="red",
):
image = Image.new("RGB", (width, height), color_bg)
dc = ImageDraw.Draw(image)
bar_height = max(min(int(height * percent / 100), height), 1)
dc.rectangle(
(0, height - bar_height, width, height),
fill=color_high if percent > 25 else color_low,
)
return image
mouse = rivalcfg.get_first_mouse()
icon = pystray.Icon(
"test name",
icon=create_image(0),
)
threading.Thread(target=icon.run).start()
while True:
battery_info = mouse.battery
level = 0
if battery_info["level"]:
level = battery_info["level"]
icon.icon = create_image(level)
time.sleep(60)
This code can be improved but it works :)
from rivalcfg.
Related Issues (20)
- "OSError: open failed" on macOS Ventura HOT 1
- New Aerox 5 edition: Aerox 5 Wireless Destiny 2 Editon
- New Aerox 5 edition: Aerox Wireless 5 Diablo IV Edition
- Request for SteelSeries Prime Mini Wireless HOT 6
- Support for Rival 5 HOT 1
- Unrecognized arguments error when no device is found. HOT 1
- command to list current settings? HOT 1
- Steelseries Rival 3 Wireless - Turning off RGB and setting sleep timer HOT 1
- Cannot change LED colour on Prime HOT 2
- Only one device manageable at a time? HOT 4
- SteelSeries Rival 3 mapped-value (button6) not working HOT 2
- SteamDeck issue HOT 3
- Prime mini support HOT 4
- Problem solved HOT 1
- Aerox 3 Wireless never seems to persist my color settings (#000000 for everything. Max power savings.) HOT 5
- Problem with color settings on Rival 500 HOT 4
- Could you do a standalone version for Windows in your releases (without need to install python) ? HOT 1
- Question: I have the Rival 500 with the CPI error. I would like to reset it. HOT 1
- Set macros on the mouse persist even after a factory reset HOT 5
- Keyboard Support HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rivalcfg.