{
  "$type": "site.standard.document",
  "bskyPostRef": {
    "cid": "bafyreibjko2cs3f5lpnvhbxjpa73yhjziqds2gpdovxovzs5mcenv6eae4",
    "uri": "at://did:plc:yrn4rbgwenb6lfhhzjegbtnc/app.bsky.feed.post/3mkzzxrugqnp2"
  },
  "path": "/t/write-access-to-sys/12088#post_2",
  "publishedAt": "2026-05-04T02:44:42.000Z",
  "site": "https://discourse.flathub.org",
  "textContent": "I found one method, which is to use flatpak-spawn and pkexec to open the file in a child process:\n\n\n            let mut child = Command::new(\"flatpak-spawn\")\n                .args([\"--host\", \"pkexec\", \"sh\", \"-c\", &format!(\"echo ready && cat > /sys/class/leds/{led}/brightness\")])\n                .stdin(Stdio::piped())\n                .stdout(Stdio::piped())\n                .spawn()?;\n\n            let mut stdout = child.stdout.take().ok_or_else(|| anyhow!(\"no stdout\"))?;\n            let stdin = child.stdin.take().ok_or_else(|| anyhow!(\"no stdin\"))?;\n\n            // block until pkexec authenticates and sh prints \"ready\"\n            let mut buf = [0u8; 6];\n            stdout.read(&mut buf)?;\n",
  "title": "Write-access to /sys"
}