aboutsummaryrefslogtreecommitdiff
path: root/modules/services/kdeconnect.nix
blob: 82de1f0eb7cba86b1e0337d2d64fcde8b94790ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
{ config, lib, pkgs, ... }:

with lib;

let

  cfg = config.services.kdeconnect;
  package = pkgs.kdeconnect;

in {
  meta.maintainers = [ maintainers.adisbladis ];

  options = {
    services.kdeconnect = {
      enable = mkEnableOption "KDE connect";

      indicator = mkOption {
        type = types.bool;
        default = false;
        description = "Whether to enable kdeconnect-indicator service.";
      };

    };
  };

  config = mkMerge [
    (mkIf cfg.enable {
      home.packages = [ package ];

      systemd.user.services.kdeconnect = {
        Unit = {
          Description =
            "Adds communication between your desktop and your smartphone";
          After = [ "graphical-session-pre.target" ];
          PartOf = [ "graphical-session.target" ];
        };

        Install = { WantedBy = [ "graphical-session.target" ]; };

        Service = {
          Environment = "PATH=${config.home.profileDirectory}/bin";
          ExecStart = "${package}/libexec/kdeconnectd";
          Restart = "on-abort";
        };
      };
    })

    (mkIf cfg.indicator {
      systemd.user.services.kdeconnect-indicator = {
        Unit = {
          Description = "kdeconnect-indicator";
          After = [
            "graphical-session-pre.target"
            "polybar.service"
            "taffybar.service"
            "stalonetray.service"
          ];
          PartOf = [ "graphical-session.target" ];
        };

        Install = { WantedBy = [ "graphical-session.target" ]; };

        Service = {
          Environment = "PATH=${config.home.profileDirectory}/bin";
          ExecStart = "${package}/bin/kdeconnect-indicator";
          Restart = "on-abort";
        };
      };
    })

  ];
}