Skip to content

Instantly share code, notes, and snippets.

@solson
Last active June 3, 2023 17:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save solson/615d89c78b26a431eaf3ef5ed1edc058 to your computer and use it in GitHub Desktop.
Save solson/615d89c78b26a431eaf3ef5ed1edc058 to your computer and use it in GitHub Desktop.
const auth = new TextEncoder().encode("\x00AUTH EXTERNAL 31303030\r\nBEGIN\r\n");
/*
‣ Type=method_call Endian=l Flags=0 Version=1 Cookie=1
Sender=:1.1180 Destination=org.freedesktop.DBus Path=/org/freedesktop/DBus Interface=org.freedesktop.DBus Member=Hello
UniqueName=:1.1180
MESSAGE "" {
};
*/
const hello = new Uint8Array([
0x6c, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x6e,
0x00, 0x00, 0x00, 0x01, 0x01, 0x6f, 0x00, 0x15, 0x00, 0x00, 0x00, 0x2f, 0x6f,
0x72, 0x67, 0x2f, 0x66, 0x72, 0x65, 0x65, 0x64, 0x65, 0x73, 0x6b, 0x74, 0x6f,
0x70, 0x2f, 0x44, 0x42, 0x75, 0x73, 0x00, 0x00, 0x00, 0x06, 0x01, 0x73, 0x00,
0x14, 0x00, 0x00, 0x00, 0x6f, 0x72, 0x67, 0x2e, 0x66, 0x72, 0x65, 0x65, 0x64,
0x65, 0x73, 0x6b, 0x74, 0x6f, 0x70, 0x2e, 0x44, 0x42, 0x75, 0x73, 0x00, 0x00,
0x00, 0x00, 0x02, 0x01, 0x73, 0x00, 0x14, 0x00, 0x00, 0x00, 0x6f, 0x72, 0x67,
0x2e, 0x66, 0x72, 0x65, 0x65, 0x64, 0x65, 0x73, 0x6b, 0x74, 0x6f, 0x70, 0x2e,
0x44, 0x42, 0x75, 0x73, 0x00, 0x00, 0x00, 0x00, 0x03, 0x01, 0x73, 0x00, 0x05,
0x00, 0x00, 0x00, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x00, 0x00, 0x00
]);
/*
‣ Type=method_call Endian=l Flags=4 Version=1 Cookie=2
Sender=:1.1180 Destination=org.freedesktop.Notifications Path=/org/freedesktop/Notifications Interface=org.freedesktop.Notifications Member=Notify
UniqueName=:1.1180
MESSAGE "susssasa{sv}i" {
STRING "Deno";
UINT32 0;
STRING "";
STRING "";
STRING "Hello from Deno";
ARRAY "s" {
};
ARRAY "{sv}" {
};
INT32 5000;
};
*/
const notify = new Uint8Array([
0x6c, 0x01, 0x04, 0x01, 0x44, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xaf,
0x00, 0x00, 0x00, 0x01, 0x01, 0x6f, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x2f, 0x6f,
0x72, 0x67, 0x2f, 0x66, 0x72, 0x65, 0x65, 0x64, 0x65, 0x73, 0x6b, 0x74, 0x6f,
0x70, 0x2f, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f,
0x6e, 0x73, 0x00, 0x00, 0x03, 0x01, 0x73, 0x00, 0x06, 0x00, 0x00, 0x00, 0x4e,
0x6f, 0x74, 0x69, 0x66, 0x79, 0x00, 0x00, 0x02, 0x01, 0x73, 0x00, 0x1d, 0x00,
0x00, 0x00, 0x6f, 0x72, 0x67, 0x2e, 0x66, 0x72, 0x65, 0x65, 0x64, 0x65, 0x73,
0x6b, 0x74, 0x6f, 0x70, 0x2e, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61,
0x74, 0x69, 0x6f, 0x6e, 0x73, 0x00, 0x00, 0x00, 0x06, 0x01, 0x73, 0x00, 0x1d,
0x00, 0x00, 0x00, 0x6f, 0x72, 0x67, 0x2e, 0x66, 0x72, 0x65, 0x65, 0x64, 0x65,
0x73, 0x6b, 0x74, 0x6f, 0x70, 0x2e, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63,
0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x00, 0x00, 0x00, 0x08, 0x01, 0x67, 0x00,
0x0d, 0x73, 0x75, 0x73, 0x73, 0x73, 0x61, 0x73, 0x61, 0x7b, 0x73, 0x76, 0x7d,
0x69, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0x73, 0x00, 0x06, 0x00,
0x00, 0x00, 0x3a, 0x31, 0x2e, 0x38, 0x35, 0x39, 0x00, 0x00, 0x04, 0x00, 0x00,
0x00, 0x44, 0x65, 0x6e, 0x6f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20,
0x66, 0x72, 0x6f, 0x6d, 0x20, 0x44, 0x65, 0x6e, 0x6f, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x13, 0x00, 0x00
]);
const conn = await Deno.connect({
transport: "unix",
path: "/run/user/1000/bus",
});
await Deno.writeAll(conn, auth);
await Deno.writeAll(conn, hello);
await Deno.writeAll(conn, notify);
await new Promise((resolve) => setTimeout(resolve, 1000));
conn.close();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment