1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2025-01-23 09:29:50 +01:00
home-manager/modules/services/amberol.nix
Sefa Eyeoglu 6a9f87b3aa
treewide: use graphical-session.target for GUI services
As per systemd.special(7)[0] graphical-session-pre.target is strictly
for units that set up things for a graphical session. Most notably,
these are usually started *before* the compositor/session is actually
ready.

While Home Manager's current implementation of graphical-session.target
allows these units to work regardless of what systemd.special(7)
specifies, other setups like ones with uwsm[1] do not allow these units
to start properly.

[0]: https://www.freedesktop.org/software/systemd/man/latest/systemd.special.html#graphical-session-pre.target
[1]: https://github.com/Vladimir-csp/uwsm

Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
2024-10-29 12:54:22 +01:00

70 lines
1.7 KiB
Nix

{ config, lib, pkgs, ... }:
let
cfg = config.services.amberol;
in {
meta.maintainers = with lib.maintainers; [ surfaceflinger ];
options.services.amberol = {
enable = lib.mkEnableOption "" // {
description = ''
Whether to enable Amberol music player as a daemon.
Note, it is necessary to add
```nix
programs.dconf.enable = true;
```
to your system configuration for the daemon to work correctly.
'';
};
package = lib.mkPackageOption pkgs "amberol" { };
enableRecoloring = lib.mkOption {
type = lib.types.bool;
default = true;
description = "UI recoloring using the album art.";
};
replaygain = lib.mkOption {
type = lib.types.enum [ "album" "track" "off" ];
default = "track";
description = "ReplayGain mode.";
};
};
config = lib.mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.amberol" pkgs
lib.platforms.linux)
];
# Running amberol will just attach itself to gapplication service.
home.packages = [ cfg.package ];
dconf.settings."io/bassi/Amberol" = {
background-play = true;
enable-recoloring = cfg.enableRecoloring;
replay-gain = cfg.replaygain;
};
systemd.user.services.amberol = {
Unit = {
Description = "Amberol music player daemon";
Requires = [ "dbus.service" ];
After = [ "graphical-session.target" ];
PartOf = [ "graphical-session.target" ];
};
Install.WantedBy = [ "graphical-session.target" ];
Service = {
ExecStart = "${lib.getExe cfg.package} --gapplication-service";
Restart = "on-failure";
RestartSec = 5;
};
};
};
}