Skip to content

Add Bluetooth file receiving to the Bluetooth panel - #12766

Closed
krsna1729 wants to merge 5 commits into
omacom:quattrofrom
krsna1729:bluetooth-file-receive
Closed

krsna1729 wants to merge 5 commits into
omacom:quattrofrom
krsna1729:bluetooth-file-receive

Conversation

@krsna1729

@krsna1729 krsna1729 commented Sep 21, 2026 •

Copy link
Copy Markdown

What: the Bluetooth panel gains an Accept files switch, and omarchy-bluetooth-files <on|off|toggle|is-on> moves the user unit behind it. With it on, a file shared from a paired phone (Android's share sheet → Bluetooth) lands in your downloads directory.

Why Object Push: it is the one file transfer every phone already speaks, so it needs no app on the phone, no Wi-Fi, no mDNS and no vendor protocol. Quick Share is not an option on Linux today (rquickshare can advertise over mDNS, but current Android drops off Wi-Fi while the share sheet is open and looks for BLE receivers), and LocalSend requires installing its app on the phone.

How it works

  • omarchy-bluetooth-files only moves the unit: on is enable --now, so the receiver also comes back at the next login; off is disable --now; is-on is the exit code a caller reads instead of parsing systemd output.
  • omarchy-bluetooth-files.service runs omarchy-bluetooth-files-agent, an Object Push agent for obexd (bluez-obex). The agent starts obexd itself with the downloads directory as its root (obexd --root …), because obexd refuses to store outside its root folder (filesystem_open → verify_path → -EPERM) and the directory is the agent's to resolve: XDG_DOWNLOAD_DIR, then user-dirs.dirs, then ~/Downloads.
  • obexd asks the agent before it stores a push (AuthorizePush), which is where the policy lives: the sender is read off the transfer's session and must be a BlueZ device with Paired: true; anything else is answered with org.bluez.obex.Error.Rejected, and the check fails closed when bluetoothd cannot be reached. A session rooted anywhere but the agent's directory is rejected as well, so an obexd the agent did not start cannot be talked into storing a download.
  • The agent names the destination itself: the incoming name, or the next free name (1) variant, claimed with O_EXCL before the transfer starts. obexd opens the claimed path, so there is no rename afterwards and a push can never land on an existing download.
  • ConditionPathIsDirectory and ExecCondition follow bt-agent.service, so a machine without Bluetooth hardware, or with bluetoothd down, skips cleanly instead of restarting in a loop.
  • The panel row sits under the radio switch, ahead of the device sections: cursor-reachable with j/k, Return flips it, and it re-reads the unit on open, right after a switch, and every few seconds while the popup is up, so it cannot drift from systemd.
  • Receiving stays opt-in: nothing enables the unit at first run, and only a device the user has paired can push. Turning Bluetooth off (the rfkill block) stops it too.
  • bluez-obex joins the base package set, and a migration installs it on machines that predate it.

Files

  • bin/omarchy-bluetooth-files — the helper
  • bin/omarchy-bluetooth-files-agent — the Object Push agent: paired-only policy and the claimed destination
  • default/systemd/user/omarchy-bluetooth-files.service — the receiver unit
  • shell/plugins/panels/bluetooth/Panel.qml — the row, the files cursor section, toggleFiles over IPC
  • shell/plugins/panels/bluetooth/manifest.json — description
  • manual/05-the-top-bar.md — the panel bullet
  • install/omarchy-base.packages, migrations/1789987125.sh — packaging for new and existing installs
  • test/shell.d/bluetooth-test.sh, test/shell.d/config-test.sh — coverage

Tests

  • bash test/shell.d/bluetooth-test.sh — 83 assertions pass. The new ones cover the agent: the unit runs it, unpaired and unknown senders are refused with no file created, a session rooted elsewhere is refused, the incoming name is claimed and a duplicate gets the next free name (1), a name carrying a path cannot leave the directory, and the download directory resolves from XDG_DOWNLOAD_DIR, user-dirs.dirs and the ~/Downloads fallback.
  • bash test/shell.d/config-test.sh with OMARCHY_PKGS_PATH — passes; it caught the missing PKGBUILD install line, which is the companion PR below.
  • ./test/cli — passes.
  • ./test/all here: 246 of 248 test files pass. screenshot-sanity-test.sh and snapper-test.sh fail identically on a pristine quattro checkout in this environment (no omasnap, no omarchy-iso checkout), so they are unrelated to this change.
  • Real transfers over obexd 5.87 and bluetoothd 5.87 across two virtual BR/EDR controllers: a paired sender's push lands as report.pdf, a second push of the same name as report (1).pdf with the first file untouched, and the deployed unit writes into ~/Downloads.

Visual verification — captured from this branch running in a live session, driven by keyboard only, with the unit state checked after each flip:

  • switch on → PUSH → ~/DOWNLOADS, unit active/enabled
  • switch off → PUSH · OFF, unit inactive/disabled

Accept files on

Accept files off

Companion packaging PR: omacom/omarchy-pkgs#576
Suggestion discussion: #12765

@llstrk

llstrk commented Sep 23, 2026

Copy link
Copy Markdown

Two source-backed issues affect the new unattended receiver at 43aff5ce.

Verified by source inspection: the helper wires explicit on/off commands to the user unit, the panel queries its active state, and the migration adds bluez-obex. Real transfers and UI behavior were not tested.

The receiver does not enforce the advertised paired-only restriction

The new unit uses bt-obex --auto-accept. BlueZ 5.87's Object Push defaults use BT_IO_SEC_LOW and disable service authorization; obexd's profile registration does not override those settings. The packaged bt-obex agent auto-accepts without checking the sender's pairing state.

Inspected acceptance path, not an on-air reproduction:
OPP connection -> no service-authorization gate
               -> bt-obex auto-accept -> incoming file
                  (no paired-device check)

Impact: opting in can permit an unpaired nearby sender that can reach the adapter to submit files. Android's bonded-device picker constrains that client, not other OBEX senders. Discoverability and knowledge of the adapter address affect reachability; no hardware exploit was reproduced. Enabling the unit also preserves this opt-in across later logins.

Suggested change: enforce the paired-only policy using verified sender identity at the receiver's authorization decision, or choose a receiver that provides that protection. Remove the paired-only guarantee from the comments and UI/documentation until it is enforced.

Receiving a duplicate filename can overwrite an existing download

The selected bt-obex implementation retains the incoming name, then calls g_rename on completion without a no-replace check or checking its result.

Source-derived example, same filesystem:
incoming report.pdf -> rename into Downloads/report.pdf
                       existing report.pdf is replaced

Impact: even a legitimately paired sender can silently replace an existing download. Enforcing pairing alone would not fix this.

Suggested change: use a collision-safe destination handoff, such as unique names with atomic no-replace semantics, and check the final move result. Avoid unattended delivery through the unmodified clobbering path.


Review information

Test scope: source inspection of this head, BlueZ 5.87 and Arch's pinned bluez-tools source. No runtime tests, Bluetooth transfers or UI validation; the companion packaging PR was not independently reviewed.

Community review: Independent automated community review, unaffiliated with the Omarchy team, intended to help prepare PRs for their review.

Automated AI review: Astra Medium coordinated source inspection and synthesis of independent Opus 5.5 High and GPT 6 Sol Xhigh technical assessments, with claims checked against source evidence.

@krsna1729

Copy link
Copy Markdown
Author

Both findings hold up in the sources, and e90879d2 addresses them.

Paired-only is now enforced at the authorization decision. bt-obex is gone: the unit runs bin/omarchy-bluetooth-files-agent, which registers org.bluez.obex.Agent1 with obexd. AuthorizePush reads the sender from Transfer1.Session → Session1.Destination, requires an org.bluez.Device1 with that Address and Paired: true, and otherwise replies org.bluez.obex.Error.Rejected. The check fails closed: an unknown device, an unreadable BlueZ object tree, or a session whose Session1.Root is not the directory the agent started obexd with all reject. (The root check covers an obexd the agent did not start — the agent refuses to run through one at startup too.)

Nothing is renamed, so nothing can clobber. The agent names the destination itself and claims it with O_EXCL (0600) before the transfer starts; obexd opens the claimed path, so report.pdf and then report (1).pdf, with no g_rename and no look-then-rename gap. obexd's root is set to the download directory by the agent (obexd --root <dir>) — that is also why the agent, not the unit, starts obexd: filesystem_open → verify_path refuses anything outside its root folder with -EPERM. The claim resolves the directory from XDG_DOWNLOAD_DIR/user-dirs.dirs, which drops the ~/Downloads hardcode.

Evidence

  • Real transfers, obexd 5.87 + bluetoothd 5.87 across two virtual BR/EDR controllers (btvirt): a paired sender's push lands as report.pdf (22 B); a second push of the same name lands as report (1).pdf (20 B) with the first file byte-identical to before; the deployed unit writes into ~/Downloads and stops cleanly, with obexd terminating with it.
  • test/shell.d/bluetooth-test.sh (83 assertions, exit 0) covers the agent's decisions against fake D-Bus objects: unpaired and unknown senders refused with no file created, a session rooted elsewhere refused, claim/O_EXCL collision naming, and XDG_DOWNLOAD_DIR/user-dirs.dirs resolution. config-test.sh and ./test/cli pass.

Not reproduced on the air: the unpaired push itself. On the emulated radios an unauthenticated link is refused (with Omarchy's bt-agent stopped the ACL is refused before any PUT reaches obexd, and Adapter1.RemoveDevice tears the session down), so the rejection path rests on the agent-level test above plus the source reading rather than an on-air reproduction. One related note: Omarchy's bt-agent auto-accepts pairings while the adapter is pairable, so Paired is a weaker gate than Trusted; tightening to Trusted is a one-line change in the agent if you would rather have that.

@omarchybot omarchybot added the enhancement New feature or request label Sep 27, 2026
@llstrk

llstrk commented Sep 27, 2026

Copy link
Copy Markdown

Automated AI review

Community review: Independent automated community review, unaffiliated with the Omarchy team, intended to help prepare PRs for their review.

Follow-up at e90879d2 to the earlier review and the author's reply. Both earlier findings are resolved for the Object Push path. One new issue: the obexd the agent starts also serves OBEX File Transfer on the downloads directory, and that path bypasses the agent.

Earlier finding At e90879d2
Paired-only restriction not enforced Resolved for Object Push
Duplicate filename can overwrite a download Resolved for Object Push

Verified: obexd's Object Push handler calls the agent's AuthorizePush for every push, and the agent rejects senders that BlueZ does not list as Paired. It also rejects sessions whose root is not the agent's directory and fails closed when BlueZ cannot be read; with no agent registered, obexd rejects the push itself. The agent claims the destination with O_EXCL, and obexd opens exactly that path, with no rename. In an isolated D-Bus harness against a stand-in obexd, unpaired and unknown pushes, and a push while BlueZ was unreachable, created no file, and the agent refused to start next to an obexd it had not started. A second report.pdf landed as report (1).pdf, and the first file stayed byte-identical. bluetooth-test.sh passes at this head (83 assertions, including a foreign-root rejection), and the updated test fails against the earlier head 43aff5ce.

Paired versus Trusted (author's note): the note is accurate. With Omarchy's bt-agent accepting pairings, Paired is only as strong as whoever can bond, and Trusted would limit acceptance to devices the user paired or connected from the panel (Omarchy's pair and connect actions mark the device trusted), which excludes devices that bonded on their own through bt-agent. That is a maintainer choice. It does not change the File Transfer issue below, because that path does not go through this agent.

The receiver also exposes OBEX File Transfer on the downloads directory

The agent starts /usr/lib/bluetooth/obexd --nodetach --root <downloads> with no plugin restriction (agent). obexd then loads all of its built-in services, and File Transfer (also reused by PC Suite) works directly on that root. Only Object Push asks the agent (opp.c). The File Transfer write path, ftp_chkput, goes straight to obex_put_stream_start, which opens the target with O_WRONLY|O_CREAT|O_TRUNC. File Transfer also supports listing, reading and deleting files in the root.

Source-derived, not reproduced over a real radio:
Object Push   -> agent AuthorizePush (Paired check, O_EXCL claim) -> new file
File Transfer -> bluetoothd service authorization (Trusted: allowed; else bt-agent: any Paired)
              -> O_TRUNC open, no agent call -> existing download overwritten

File Transfer is registered with authorize = true (profile.c), bluetoothd admits trusted devices without asking an agent (adapter.c), and Omarchy's bt-agent approves service authorization for any other paired device (bluez-tools agent-helper.c). So pairing still gates this path, but switching the agent's check to Trusted would not change it.

Impact: while the receiver is on, a paired peer that uses File Transfer (another computer, or a misbehaving paired device) can overwrite, read or delete files in the downloads directory. That contradicts the stated guarantee that "a push can never land on an existing download" and goes beyond "accept files". Android's share sheet uses Object Push, so the ordinary phone flow is unaffected.

Suggested change: start obexd with only the plugins Object Push needs, for example --plugin opp,filesystem,bluetooth (obexd accepts a comma-separated list), and add a test that pins the spawned command line.

Packaging note: the unit file ships only through the companion omarchy-pkgs#576. Without it, config-test.sh fails ("PKGBUILD does not explicitly install …omarchy-bluetooth-files.service"), and package installs get the helper and agent without the unit.

Optional test improvement: the new tests call Receiver.authorize against fakes, so some agent regressions still pass all 83 assertions. For example, a mutant that accepts pushes when the BlueZ query fails, or one that starts obexd without --root. One test that checks the spawned obexd argv and the BlueZ-error branch would catch these.


Review information

Test scope: source inspection of this head, the earlier head 43aff5ce, BlueZ 5.87 and Arch's pinned bluez-tools. Repository tests and an isolated D-Bus harness with a stand-in obexd and bluetoothd were run in a sandbox. No real Bluetooth transfers, File Transfer sessions or UI validation.

AI process: Opus 5.5 Medium coordination and synthesis, Opus 5.5 Xhigh technical review (its final report write-up ran on Opus 4.8 after an automatic model fallback) and final fact check, GPT 6 Sol Xhigh search for related issues, Opus 5.5 Medium editorial check.

Opt out: To stop receiving these reviews, reply to this comment saying so.

@jandrusk

jandrusk commented Oct 8, 2026

Copy link
Copy Markdown

Thanks for the rework to a real AuthorizePush agent. That covers Object Push. Two things are still open at e90879d:

  1. Blocking: the File Transfer finding from the last review is still unaddressed. The agent starts /usr/lib/bluetooth/obexd --nodetach --root <downloads> with no plugin restriction, so obexd also serves FTP/PC Suite on that root. Those profiles never call the agent, so any paired device could list, read, overwrite, or delete files in ~/Downloads while "Accept files" is on. Please limit obexd to what Object Push needs, for example:

    obexd = subprocess.Popen([OBEXD, "--nodetach", "--root", directory, "--plugin", "filesystem,bluetooth,opp"])

    Please also add a test that pins the spawned command line (and maybe check Trusted rather than Paired, given that bt-agent auto-accepts bonding).

  2. Needs a rebase. shell/plugins/panels/bluetooth/Panel.qml no longer applies on current quattro after Fix shell palette collision with Qt 6.12 #14553 (the Qt 6.12 palette fix). Any new color references in the panel need to use Commons.Color, not a bare Color..

Object Push is the one file transfer every phone already speaks: Android's
share sheet offers a Bluetooth target next to Quick Share, and it needs no
app, no Wi-Fi and no mDNS on either side — only a paired device and an
agent here accepting the push. bt-obex is that agent and writes into the
download directory.

The unit is the state: omarchy-bluetooth-files enables or disables
omarchy-bluetooth-files.service, so once switched on the receiver also
comes back at the next login, and `is-on` is the exit code a caller reads
back instead of parsing systemd output.

Only the panel switch and the CLI enable it, which keeps auto-accept
opt-in; the exposure is otherwise bounded by pairing, since a phone only
pushes to a bonded device, and pairing runs through the Bluetooth panel.

obexd carries the profile and joins the base package set; a migration
installs it on machines that predate it.
The row sits under the hero switch, ahead of the device sections, so j/k
reaches it and Return flips it like the radio switch above it. It asks the
helper for a direction rather than toggling, and reads the unit back on
open, right after a switch, and every few seconds while the popup is up,
so the switch can never disagree with systemd about whether pushes are
being accepted.
…iver

Both review findings hold up in the sources: BlueZ registers Object Push
with authorize=false and BT_IO_SEC_LOW, so bt-obex --auto-accept stores a
push from any sender that can reach the adapter, and its g_rename into the
destination directory has no no-replace check, so a duplicate filename
replaces an existing download.

The receiver is now obexd plus our own Object Push agent. obexd asks the
agent before it stores anything, which is where the policy lives:

- AuthorizePush reads the sender off the transfer's session, requires a
  BlueZ Device1 with that address and Paired: true, and rejects with
  org.bluez.obex.Error.Rejected otherwise. A session rooted anywhere but
  the directory the agent started obexd with is rejected too, so an obexd
  the agent did not start cannot be talked into storing a download.
- The agent names the destination itself: the incoming name, or the next
  free "name (1)" variant, claimed with O_EXCL before the transfer starts.
  obexd opens the claimed path, so nothing is renamed afterwards and a
  push cannot land on an existing download. The claim resolves the
  directory from XDG_DOWNLOAD_DIR and user-dirs.dirs, which drops the
  ~/Downloads hardcode.
- The agent starts obexd with that directory as its root, because obexd
  refuses to store outside it (filesystem_open -> verify_path -> -EPERM).

Tests: bluetooth-test.sh covers the agent's decisions (unpaired and unknown
senders, foreign root, claim and collision naming, XDG resolution) and
asserts the unit runs the agent. Verified with real transfers over obexd
5.87 and bluetoothd 5.87 across two virtual BR/EDR controllers: a paired
push lands as report.pdf, a second push of the same name as report (1).pdf
with the first file untouched, and the deployed unit writes into
~/Downloads.
@krsna1729

Copy link
Copy Markdown
Author

Pushed: rebased on current quattro (clean; Panel.qml applies, its color refs already use Commons.Color) and limited obexd to --plugin bluetooth,filesystem,opp via obexd_command(), so File Transfer / PC Suite are no longer served on the downloads directory. The test pins the root and plugin list; bluetooth-test.sh passes (85 ok). Left Paired as the gate rather than Trusted: devices bonded through bluetoothctl without trust would silently stop working; one-line change if the maintainers prefer it.

@krsna1729
krsna1729 force-pushed the bluetooth-file-receive branch from e90879d to c0bdfda Compare October 12, 2026 04:32
@krsna1729

Copy link
Copy Markdown
Author

Verified c0bdfda6 against a real obexd 5.87 (bluez-obex installed), agent run in an isolated D-Bus session: obexd's log shows Ignoring pcsuite, ftp, irmc, pbap, mas and mns, so only bluetooth, filesystem and opp load. The spawned command line was obexd --nodetach --root <downloads> --plugin bluetooth,filesystem,opp, the agent registered with obexd, and obexd terminated with it. Not exercised: a real push from a phone, and the installed unit (it ships through omarchy-pkgs#576).

@greptile-apps

greptile-apps Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge, with a non-blocking request to restore unrelated panel tests.

Findings

  1. P2 Existing panel checks disappear ▶

Summary

Adds opt-in Bluetooth file receiving for paired devices, controlled by the Bluetooth panel and a user service.

  • Paired phones can send Bluetooth files into your downloads folder.
  • The Bluetooth panel now has an Accept files switch.

Diagram

sequenceDiagram
  participant Panel as Bluetooth panel
  participant Helper as Receiver helper
  participant Unit as User service
  participant Agent as File agent
  participant Phone as Paired phone
  participant Obex as obexd
  Panel->>Helper: Read current state
  Panel->>Helper: Turn receiving on or off
  Helper->>Unit: Enable/start or disable/stop
  Unit->>Agent: Start receiver
  Agent->>Obex: Start with downloads root
  Phone->>Obex: Push file
  Obex->>Agent: AuthorizePush
  Agent->>Agent: Check pairing and claim free name
  Agent-->>Obex: Destination or rejection
  Panel->>Helper: Read resulting state
Loading

Reviews (2) · Last reviewed commit: "fix: address Bluetooth receiver review f..." · Reviewed by Greptile

Comment thread bin/omarchy-bluetooth-files-agent Resolved
@jandrusk

Copy link
Copy Markdown

Thanks, --plugin bluetooth,filesystem,opp with a test pinning the command line fixes the blocking point. The obexd log showing ftp/pcsuite ignored is good confirmation. The rebase is done too. Paired vs Trusted is fine to leave to the maintainers, given the bluetoothctl bonding case you describe. Greptile's "IPC toggle leaves receiving on" looks worth checking before merge, since that would leave the receiver running after the switch says it's off.

Comment on lines 196 to 197
run_node_test <<'JS'
const fs = require('fs')
const bluetooth = requireFromRoot('shell/plugins/panels/bluetooth/Model.js')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Existing panel checks disappear

This removes the existing checks for radio IPC and discovery cleanup, including handing an active scan between monitors. Those parts of Panel.qml are unchanged, and no replacement tests cover them. Future changes could break the radio shortcut or leave scans running without a test catching it.

Restore these checks; only the receiver checks tied to the old detached command need rewriting.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@krsna1729

Copy link
Copy Markdown
Author

Closing this. The local deployment was rolled back in September: the phone-with-no-app case is narrow, LocalSend covers the common one, and the feature would ask Omarchy to own a 393-line authorization agent plus its paired/trusted policy. The branch has also drifted from quattro after two months without a maintainer decision. The security reviews from @jandrusk and @llstrk drove real fixes and are preserved in the local record and patches. Reopen or re-propose if the maintainers decide they want the feature.

@krsna1729 krsna1729 closed this Nov 26, 2026
@krsna1729
krsna1729 deleted the bluetooth-file-receive branch November 26, 2026 06:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants