andyvorld / LGSTrayBattery

A tray app used to track battery levels of wireless Logitech mouse.
GNU General Public License v3.0
369 stars 30 forks source link

LGS Tray Battery

A rewrite/combination of my two programs LGSTrayBattery and LGSTrayBattery_GHUB, which should allow for interaction via both the native HID and Logitech GaminG Hub websockets.

How to install

GitHub Release

Please, visit the latest release page and download the release zip files from assets. Builds with the -standalone suffix are pre-bundled with .Net 8 and does not require any further dependencies, the non-standalone version requires .Net 8 to be pre-installed (https://dotnet.microsoft.com/en-us/download/dotnet/8.0).

Changes from V2

When migrating from earlier versions, device ids may have changed.

Features

Tray Indicator

image

Battery percentage and voltage (if supported) in a tray tooltip with notification icon.

Right-click for more options.

Multiple Icons

image

Depending on the number of devices selected in the context menu, multiple devices can be seen simultatniously

Numerical Icons

image

Display the current battery percentage as a number.

In numerical display mode, charging status will not be displayed

Reactive Icons

image

Icon changes to match devices type (Current supported: mouse, keyboard and headsets)

image

Icon changes to match light/dark system theme

image

Icon changes to reflect current charging status

Http/Web "server" api

By default the running of the http server is enabled. The IP address and port used for bindings are under addr and port respectively with the defaults being localhost and 12321.

addr accepts either a hostname (DESKTOP-1234) or an IP address (127.0.0.1) to bind to, if you are not sure use localhost or if you have admin permission 0.0.0.0 to bind to all interfaces.

IPv6 can also be disabled with useIpv6 in the event that dual stack networking is causing issues.

If any issues arise from running the server, it can be turned off by the enable value in appsettings.toml under [HTTPServer].

image

Visit http://{addr}:{port}/ on your browser to view the list of devices available.

image

With the deviceID, a HTTP/GET request to {addr}:{port}/device/{deviceID}, will result in an xml document of the name and battery status of the device. Devices that do not support battery_voltage will report 0.00.

Device ids starting with dev originates from tapping into Logitech GHUB's own drivers, while random numbers are from the natively implement HID++ code. Thus, there are some fields that different between the two,

GHUB* Native
device_id ✔️ ✔️
device_name ✔️ ✔️
device_type ✔️ ✔️
battery_percent ✔️ ✔️
battery_voltage ✔️**
mileage*** ✔️
charging ✔️ ✔️

* - Requires Logitech G Hub Installed

** - Depends on the device

*** - Logitech G Hub's metric of estimated life left on the battery

HID++ Device Sources

As of v3.0.0, there are 2 sources in which the program will pull battery status,

These sources can be individually disabled/enabled before runtime via appsettings.toml, in the their respective sections,

[GHub]
enabled = true

[Native]
enabled = true

GHub is Logitech G Hub, Native is hidapi

appsettings.toml

Refer to https://toml.io/en/ for a guide on toml syntax.

Note the " around strings

In the event of an invalid settings, at launch the app will prompt you for a reset to the default settings.

[Native] settings

Known Issues

Common

Native HID (hidapi)

GHUB

Working with

Community Tested

HID Backend has changed, would need restesting of devices, please raise a PR to add to this list

How to Build project

TBA

Acknowledgements

This project began as a task with me messing around with my mouse for battery tracking.