Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to view the battery charge of connected Bluetooth devices #74

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SfyMantissa
Copy link

Hello!

I have added new base functionality to view the battery charge of a connected Bluetooth device.

E.g.
~/repos/polybar-pulseaudio-control/pulseaudio-control.bash --color-muted "D75F87" --icons-volume ",奔,墳," --icon-muted "ﱝ" --node-nickname "alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp__sink:ﰝ" --node-nickname "bluez_sink.68_D6_ED_8D_E9_D2.a2dp_sink:" **--icons-bluetooth-battery "ﴆ,ﴇ,ﴈ,ﴉ,ﴊ,ﴋ,ﴌ,ﴍ,ﴎ,ﴅ" --hide-bluetooth-battery-level listen**

Produces the following output in my Polybar (I can now see the battery charge of my headphones).

image

This PR is pretty raw (needs additional refactoring and updates to tests).
I will make the adjustments, however I want to know whether such functionality would be welcome in this repo.

Thank you very much in advance for your feedback!

@marioortizmanero
Copy link
Owner

Sounds like a great idea, thanks for the contribution! I would only say that we shouldn't modify the default value for FORMAT, let's add it as opt-in. Let me know when it's ready for a full review.

@SfyMantissa
Copy link
Author

Hello!

Ready for review

I have:

  • Updated the README.
  • Updated the code.
  • Added a unit test for new functionality.

Sample polybar module config

...
[module/volume]
type = custom/script

; Temporary path until I finish my pull request and it gets merged.
exec = ~/repos/polybar-pulseaudio-control/pulseaudio-control.bash --color-muted "ffb86c" --icons-volume ",奔,墳," --icon-muted "ﱝ" --node-nickname "alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp__sink:ﰝ" --node-nickname "bluez_sink.04_CB_88_29_72_66.a2dp_sink:" --icons-bluetooth-battery "ﴆ,ﴇ,ﴈ,ﴉ,ﴊ,ﴋ,ﴌ,ﴍ,ﴎ,ﴅ" --hide-bluetooth-battery-level listen
label-margin = 2
label-foreground = ${colors.dracula-orange}
label-underline = ${colors.dracula-orange}
tail = true
...

How it looks in my bar with these settings and headphones connected:

image

Tests

Case 1: Docker image (as suggested).

sfy@neonblaze: ~/repos/polybar-pulseaudio-control ❱❱ docker run -it pulseaudio-control-tests
root@78db65502259:/# bats tests.bats 
 ✓ nextNode() 
 ✓ volUp() 
 ✓ volDown() 
 ✓ volMute() 
 ✓ getNickname() 
 ✓ getCurCharge()

6 tests, 0 failures

Case 2: local machine, headphones disconnected.

sfy@neonblaze: ~/repos/polybar-pulseaudio-control ❱❱ bluetoothctl info '04:CB:88:29:72:66' | grep Connected && bats tests.bats 
	Connected: no
tests.bats
 - nextNode() (skipped)
 ✓ volUp()
 ✓ volDown()
 ✓ volMute()
 ✓ getNickname()
 ✓ getCurCharge()

6 tests, 0 failures, 1 skipped

Case 3: local machine, headphones connected.

sfy@neonblaze: ~/repos/polybar-pulseaudio-control ❱❱ bluetoothctl info '04:CB:88:29:72:66' | grep Connected && bats tests.bats 
	Connected: yes
tests.bats
 - nextNode() (skipped)
 ✓ volUp()
 ✓ volDown()
 ✓ volMute()
 ✓ getNickname()
 ✓ getCurCharge()

6 tests, 0 failures, 1 skipped

Please, let me know if you need anything else and have a happy New Year!

…evice.

* Updated new Bluetooth battery info functionality.
* Added unit test for new Bluetooth battery info functionality.
* Updated README.
* Removed trailing whitespace from files.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants