2020-04-21 22:12:45 +02:00
{ config , lib , pkgs , . . . }:
with lib ;
let
cfg = config . services . pulseeffects ;
presetOpts = optionalString ( cfg . preset != " " ) " - - l o a d - p r e s e t ${ cfg . preset } " ;
in {
2024-06-29 17:20:18 +02:00
meta . maintainers = [ hm . maintainers . jonringer ] ;
2020-04-21 22:12:45 +02:00
options . services . pulseeffects = {
2023-07-02 01:45:18 +02:00
enable = mkEnableOption ''
2021-09-23 22:28:53 +02:00
Pulseeffects daemon
Note , it is necessary to add
2023-07-01 01:30:13 +02:00
` ` ` nix
2021-09-23 22:28:53 +02:00
programs . dconf . enable = true ;
2023-07-01 01:30:13 +02:00
` ` `
2023-07-02 01:45:18 +02:00
to your system configuration for the daemon to work correctly'' ;
2020-04-21 22:12:45 +02:00
2021-02-23 20:37:38 +01:00
package = mkOption {
type = types . package ;
2021-08-11 17:21:43 +02:00
default = pkgs . pulseeffects-legacy ;
2021-10-09 11:14:08 +02:00
defaultText = literalExpression " p k g s . p u l s e e f f e c t s - l e g a c y " ;
2023-07-02 01:45:18 +02:00
description = " P u l s e e f f e c t s p a c k a g e t o u s e . " ;
2021-02-23 20:37:38 +01:00
} ;
2020-04-21 22:12:45 +02:00
preset = mkOption {
type = types . str ;
default = " " ;
2023-07-02 01:45:18 +02:00
description = ''
2020-04-21 22:12:45 +02:00
Which preset to use when starting pulseeffects .
Will likely need to launch pulseeffects to initially create preset .
'' ;
} ;
} ;
config = mkIf cfg . enable {
2021-07-07 23:24:27 +02:00
assertions = [
( lib . hm . assertions . assertPlatform " s e r v i c e s . p u l s e e f f e c t s " pkgs
lib . platforms . linux )
] ;
2020-04-21 22:12:45 +02:00
# running pulseeffects will just attach itself to gapplication service
# at-spi2-core is to minimize journalctl noise of:
# "AT-SPI: Error retrieving accessibility bus address: org.freedesktop.DBus.Error.ServiceUnknown: The name org.a11y.Bus was not provided by any .service files"
2021-02-23 20:37:38 +01:00
home . packages = [ cfg . package pkgs . at-spi2-core ] ;
2020-04-21 22:12:45 +02:00
systemd . user . services . pulseeffects = {
Unit = {
Description = " P u l s e e f f e c t s d a e m o n " ;
2020-08-13 21:34:25 +02:00
Requires = [ " d b u s . s e r v i c e " ] ;
After = [ " g r a p h i c a l - s e s s i o n - p r e . t a r g e t " ] ;
PartOf = [ " g r a p h i c a l - s e s s i o n . t a r g e t " " p u l s e a u d i o . s e r v i c e " ] ;
2020-04-21 22:12:45 +02:00
} ;
2020-08-13 21:34:25 +02:00
Install = { WantedBy = [ " g r a p h i c a l - s e s s i o n . t a r g e t " ] ; } ;
2020-04-21 22:12:45 +02:00
Service = {
ExecStart =
2021-02-23 20:37:38 +01:00
" ${ cfg . package } / b i n / p u l s e e f f e c t s - - g a p p l i c a t i o n - s e r v i c e ${ presetOpts } " ;
ExecStop = " ${ cfg . package } / b i n / p u l s e e f f e c t s - - q u i t " ;
2020-04-21 22:12:45 +02:00
Restart = " o n - f a i l u r e " ;
RestartSec = 5 ;
} ;
} ;
} ;
}