Skip to content

Comments

Closes issue #322 | Add option to check if headset is connected#323

Merged
Sapd merged 1 commit intoSapd:masterfrom
theaino:master
Feb 1, 2024
Merged

Closes issue #322 | Add option to check if headset is connected#323
Sapd merged 1 commit intoSapd:masterfrom
theaino:master

Conversation

@theaino
Copy link
Contributor

@theaino theaino commented Jan 28, 2024

This closes issue #322. It adds the command line flag --connected alias -t (standing for test)
to check if there is a headset connected.

It works by first checking if a headset is detected.
If it does, there are 2 cases:

  • a headset is connected and turned on
  • a wireless headset's usb is connected but it is turned off

These 2 cases are differentiated by first checking if the
model has the battery status capability.

If it doesn't, it is wired connected.

If it does, the battery status is checked. If an error is returned, the headset
is turned off.

For example, this option can be integrated in bash scripts using
if headsetcontrol -t ; then ; <do something> ; fi

@theaino
Copy link
Contributor Author

theaino commented Jan 28, 2024

There is also true being returned when a headset
is connected making it compatible with the
test command.

@Sapd
Copy link
Owner

Sapd commented Feb 1, 2024

Thank you! However I would remove the -t short option and keep it for other purposes (given --connected is just used for scripting). To do so you basically set it to NULL and handle it in case 0:

I can also update the code in your branch but will not get to do so before next week

@theaino
Copy link
Contributor Author

theaino commented Feb 1, 2024

That makes sense. I just implemented and pushed it.

@Sapd Sapd merged commit a33a486 into Sapd:master Feb 1, 2024
rpbaptist pushed a commit to rpbaptist/HeadsetControl that referenced this pull request May 31, 2024
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.

2 participants