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

fix: Issue #1289 ds4|5 disconnect #1484

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

thekk1
Copy link

@thekk1 thekk1 commented Aug 10, 2024

Add script to monitor and disconnect Bluetooth gamepads and corresponding Systemd service.
This is a workaround for #1289 and should be removed if there comes a native solution from
ValveSoftware/steam-for-linux#8678

…ding Systemd service

This is a workaround for ublue-os#1289 and should be removed if there comes a native solution from ValveSoftware/steam-for-linux#8678

- Added `bazzite-bluetooth-ds4-ds5-workaround` script to monitor PS4 and PS5 controllers
  - Script checks for connected gamepads, extracts their MAC addresses, and starts a monitoring process
  - The monitoring process listens for specific button combinations (Home + Triangle) to disconnect the gamepad
  - Includes cleanup functionality to stop monitoring processes for disconnected gamepads

- Created Systemd service `bazzite-bluetooth-ds4-ds5-workaround.service`
  - Service description and dependencies defined in `[Unit]` section
  - `[Service]` section specifies script execution, restart policy, user, and group
  - `[Install]` section enables the service to start on boot

- Added instructions to load, start, and enable the service
  - Included commands for reloading Systemd, starting the service, and enabling it on boot
  - Provided guidance on checking the service status and logs for troubleshooting

Author: thekk1
Version: 1.0
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. bug Something isn't working labels Aug 10, 2024
@thekk1
Copy link
Author

thekk1 commented Aug 10, 2024

Because I messed up the original PR (#1416), I created a new clean one.

@thekk1 thekk1 changed the title fix/issue #1289 ds4|5 disconnect fix: Issue #1289 ds4|5 disconnect Aug 10, 2024
@Zeglius
Copy link
Contributor

Zeglius commented Aug 10, 2024

Would suggest checking #1476 to see if is better suited. Not saying that this wouldn't work, but in my opinion is far easier to maintain a python script than an AWK one.

@thekk1
Copy link
Author

thekk1 commented Aug 11, 2024

Would suggest checking #1476 to see if is better suited. Not saying that this wouldn't work, but in my opinion is far easier to maintain a python script than an AWK one.

I choosed this way because of the performance not because of the maintainability. The task to check for the key combo will run all the time in backgroup while a DS4|5 Controller is connected so this is a very important point.
I am not familiar enough with python but I see some points in #1476 which could cause a higher cpu load. I will check other day on this.

udev could might be a good point but I remember that starting an infinite prozess with udev should be a nono!?

@Zeglius
Copy link
Contributor

Zeglius commented Aug 11, 2024

I choosed this way because of the performance not because of the maintainability. The task to check for the key combo will run all the time in backgroup while a DS4|5 Controller is connected so this is a very important point

Same here with the python version, the udev rule will will start the service using @ systemd unit parameters, so the script will be running all the time for that mac address, but only start when the device is connected.

udev could might be a good point but I remember that starting an infinite prozess with udev should be a nono!?

It starts a systemd service with --no-block, so it will run at background and the lifespan of the script wont rely entirely in the udev rule, only to start the service.

Also must ask for the reason of your version running as a user service (systemctl enable --global) instead of a system one.
Under my perspective, it would lead to have duplicate services running simultaneously, potentially including root user (which I saw being an headache with Handheld Daemon case).

If user service is a must by your rationale, might suggest moving the service to /usr/lib/systemd/user/ and add a check for system users like this:

# /usr/lib/systemd/user/bazzite-bluetooth-ds4-ds5-workaround.service
[Unit]
Description=Disconnect DS4 and DS5 controller on shortcut HOME + triangle
After=bluetooth.target
ConditionFileIsExecutable=/usr/libexec/bazzite-bluetooth-ds4-ds5-workaround
ConditionUser=!@system

And change the WantedBy to default.target:

[Install]
WantedBy=default.target

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants