Skip to content

Conversation

@pullclone
Copy link

This commit fixes an import-time crash in bluetooth.py and makes the agent robust when DBus/GLib bindings or the BlueZ daemon are missing.

  • Pass human-readable message as the first arg and DBus error name via name= (e.g., org.bluez.Error.Rejected, org.bluez.Error.Canceled).
  • Switch Agent capability to KeyboardDisplay so both PIN and passkey flows are supported.

Robust behavior when Bluetooth is unavailable

  • Introduce HYPERPANEL_BT_KEEP_ALIVE env flag (default: off).
    • When deps or BlueZ are missing, either exit(0) or idle (GLib loop/sleep) based on the flag.
  • Add helpers:
    • idle_or_exit to centralize graceful shutdown/idle behavior.
    • is_bluez_running to check org.bluez on the system bus before attempting registration.
  • Improve user interaction and notifications:
    • request_input_sync uses zenity when available, otherwise falls back to TTY input; handles cancellations cleanly.
    • send_notification_with_actions returns a Callable[[], None] disconnect and safely unregisters signal handlers; logs and no-ops if notifications aren’t available.

Other additions

  • More informative logging around agent registration and user prompts.
  • Defensive handling when removing signal receivers.
  • Typing polish for send_notification_with_actions.

Behavioral notes

  • No behavioral change when BlueZ and deps are present: the agent registers and runs the GLib main loop as before.
  • When BlueZ or deps are missing, hyprpanel no longer aborts due to a parse error; the script exits 0 by default unless keep-alive is requested.

Testing tips

  • Catch syntax errors early: python3 -m compileall -q /usr/share/hyprpanel/scripts/bluetooth.py
  • Simulate missing BlueZ: systemctl stop bluetooth; run the script and verify exit code 0 (or idle when HYPERPANEL_BT_KEEP_ALIVE=1).
  • Start hyprpanel and confirm it no longer aborts on bluetooth.py

This commit fixes an import-time crash in bluetooth.py and makes the agent robust when DBus/GLib bindings or the BlueZ daemon are missing.

  - Pass human-readable message as the first arg and DBus error name via name= (e.g., org.bluez.Error.Rejected, org.bluez.Error.Canceled).
- Switch Agent capability to KeyboardDisplay so both PIN and passkey flows are supported.

Robust behavior when Bluetooth is unavailable
- Introduce HYPERPANEL_BT_KEEP_ALIVE env flag (default: off).
  - When deps or BlueZ are missing, either exit(0) or idle (GLib loop/sleep) based on the flag.
- Add helpers:
  - idle_or_exit to centralize graceful shutdown/idle behavior.
  - is_bluez_running to check org.bluez on the system bus before attempting registration.
- Improve user interaction and notifications:
  - request_input_sync uses zenity when available, otherwise falls back to TTY input; handles cancellations cleanly.
  - send_notification_with_actions returns a Callable[[], None] disconnect and safely unregisters signal handlers; logs and no-ops if notifications aren’t available.

Other additions
- More informative logging around agent registration and user prompts.
- Defensive handling when removing signal receivers.
- Typing polish for send_notification_with_actions.

Behavioral notes
- No behavioral change when BlueZ and deps are present: the agent registers and runs the GLib main loop as before.
- When BlueZ or deps are missing, hyprpanel no longer aborts due to a parse error; the script exits 0 by default unless keep-alive is requested.

Testing tips
- Catch syntax errors early: python3 -m compileall -q /usr/share/hyprpanel/scripts/bluetooth.py
- Simulate missing BlueZ: systemctl stop bluetooth; run the script and verify exit code 0 (or idle when HYPERPANEL_BT_KEEP_ALIVE=1).
- Start hyprpanel and confirm it no longer aborts on bluetooth.py
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.

1 participant