Re: New keychron Q5 pro keyboard. Looking for a way to query the battery level.
Reply #3 –
I'm using a wireless mouse, so I'm not sure if it'll work the same for both of you.
Notes:
The <number> could be any number assigned by the system. Usually starting with 0
I've used this to query the mouse battery percentage.
First see if you can go to:
/sys/class/power_supply/hidpp_battery_<number>/
From there check the files named with model_name and capacity.
The model_name verifies that this device in this directory/folder is indeed for the keyboard.
capacity for the battery percentage.
If you can't find anything (such as the directory) then try these commands: (I don't recommend these for a status script(such as for status bars) it's gonna be slow/bloated.)
for finding the keyboard: (The first line reported should be the name of the device, second line being the directory it is at.)
find /sys -type f -iname 'model_name' -exec cat {} \; -execdir pwd \; 2> /dev/null
if the output does say that it's from Keychron Q5/wireless keyboard
then:
Go to the directory: (If you have more than 1 wireless device this command may not work. You will have to go to it manually.)
cd $(find /sys -type f -iname 'model_name' -execdir pwd \; 2> /dev/null)
From there there should be a file named model_name and capacity.