2023-09-05 23:01:07 +02:00
|
|
|
{
|
2023-09-18 17:27:54 +02:00
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}: let
|
|
|
|
inherit
|
|
|
|
(lib)
|
|
|
|
types
|
|
|
|
mkEnableOption
|
|
|
|
mkPackageOption
|
|
|
|
mkOption
|
|
|
|
mkIf
|
|
|
|
;
|
|
|
|
settingsFormat = pkgs.formats.json {};
|
|
|
|
in {
|
|
|
|
home-manager.sharedModules = [
|
2024-03-12 18:19:52 +01:00
|
|
|
({config, ...}: let
|
|
|
|
cfg = settingsFormat.generate "config.json" {
|
|
|
|
streamdeck_ui_version = 1;
|
|
|
|
state = config.programs.streamdeck-ui.settings;
|
|
|
|
};
|
|
|
|
preStart = pkgs.writeShellScript "streamdeck-setup-config" ''
|
|
|
|
cp "${cfg}" "$XDG_RUNTIME_DIR/streamdeck/config.json"
|
|
|
|
'';
|
|
|
|
in {
|
2023-09-18 17:27:54 +02:00
|
|
|
options.programs.streamdeck-ui = {
|
|
|
|
enable = mkEnableOption "streamdeck-ui";
|
|
|
|
package = mkPackageOption pkgs "streamdeck-ui" {};
|
|
|
|
settings = mkOption {
|
|
|
|
default = {};
|
|
|
|
type = types.submodule {freeformType = settingsFormat.type;};
|
|
|
|
description = "Configuration per streamdeck";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
config = mkIf config.programs.streamdeck-ui.enable {
|
2023-10-11 20:54:56 +02:00
|
|
|
systemd.user = {
|
|
|
|
services = {
|
|
|
|
streamdeck = {
|
|
|
|
Unit = {
|
|
|
|
Description = "start streamdeck-ui";
|
2023-10-12 02:30:03 +02:00
|
|
|
# For some reason this depends on X or wayland running
|
2023-10-13 15:43:24 +02:00
|
|
|
ConditionEnvironment = ["DISPLAY"];
|
2023-10-11 20:54:56 +02:00
|
|
|
};
|
|
|
|
Service = {
|
|
|
|
Type = "exec";
|
2023-10-13 15:43:24 +02:00
|
|
|
ExecStart = "${pkgs.streamdeck-ui}/bin/streamdeck --no-ui";
|
2024-03-12 18:19:52 +01:00
|
|
|
ExecStartPre = preStart;
|
|
|
|
Environment = ''STREAMDECK_UI_CONFIG=%t/streamdeck/config.json'';
|
|
|
|
RuntimeDirectory = "streamdeck";
|
2023-10-11 20:54:56 +02:00
|
|
|
};
|
|
|
|
Install.WantedBy = ["graphical-session.target"];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2023-09-18 17:27:54 +02:00
|
|
|
};
|
|
|
|
})
|
|
|
|
];
|
2023-09-05 23:01:07 +02:00
|
|
|
}
|