nix-config/modules/optional/streamdeck.nix

57 lines
1.5 KiB
Nix
Raw Normal View History

2023-09-05 23:01:07 +02:00
{
lib,
pkgs,
...
}: let
inherit
(lib)
types
mkEnableOption
mkPackageOption
mkOption
mkIf
;
settingsFormat = pkgs.formats.json {};
in {
home-manager.sharedModules = [
({config, ...}: {
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 {
systemd.user = {
services = {
streamdeck = {
Unit = {
Description = "start streamdeck-ui";
# For some reason this depends on X or wayland running
2023-10-13 15:43:24 +02:00
ConditionEnvironment = ["DISPLAY"];
};
Service = {
Type = "exec";
2023-10-13 15:43:24 +02:00
ExecStart = "${pkgs.streamdeck-ui}/bin/streamdeck --no-ui";
Environment = "STREAMDECK_UI_CONFIG=${config.xdg.configHome}/streamdeck-ui/config.json";
};
Install.WantedBy = ["graphical-session.target"];
};
};
};
xdg.configFile.streamdeck-ui = {
target = "streamdeck-ui/config.json";
source = settingsFormat.generate "config.json" {
streamdeck_ui_version = 1;
state = config.programs.streamdeck-ui.settings;
};
};
};
})
];
2023-09-05 23:01:07 +02:00
}