// SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie // SPDX-License-Identifier: MIT //! Print the udev rules for every device this library knows. //! //! The rules come out of the device table rather than out of somebody's //! memory, so a model added to `StreamDeck.Type` appears here without //! anyone having to remember. `nix/module.nix` carries what this prints //! and a test checks that it still does. //! //! With no arguments the rules use `uaccess`, which hands the device to //! whoever is logged in at the seat. `--group NAME` writes the older //! shape instead, for a machine with no seat. const std = @import("std"); const streamdeck = @import("streamdeck"); pub fn main(init: std.process.Init) !void { var owner: streamdeck.udev.Owner = .uaccess; var args = init.minimal.args.iterate(); _ = args.next(); while (args.next()) |arg| { if (std.mem.eql(u8, arg, "--group")) { owner = .{ .group = args.next() orelse return error.MissingGroupName }; } else if (std.mem.startsWith(u8, arg, "--group=")) { owner = .{ .group = arg["--group=".len..] }; } } var buf: [4096]u8 = undefined; const locked = std.debug.lockStderr(&buf); defer std.debug.unlockStderr(); try streamdeck.udev.writeRules(&locked.file_writer.interface, owner); } test { std.testing.refAllDecls(@This()); }