2024-04-27 15:03:11 +00:00
{ pkgs , lib , config , . . . }:
let
cfg = config . services . swaync ;
jsonFormat = pkgs . formats . json { } ;
in {
meta . maintainers = [ lib . hm . maintainers . abayomi185 ] ;
options . services . swaync = {
enable = lib . mkEnableOption " S w a y n c n o t i f i c a t i o n d a e m o n " ;
package = lib . mkPackageOption pkgs " s w a y n o t i f i c a t i o n c e n t e r " { } ;
style = lib . mkOption {
type = lib . types . nullOr ( lib . types . either lib . types . path lib . types . lines ) ;
default = null ;
example = ''
. notification-row {
outline : none ;
}
. notification-row:focus,
. notification-row:hover {
background : @ noti-bg-focus ;
}
. notification {
border-radius : 1 2 px ;
margin : 6 px 1 2 px ;
box-shadow : 0 0 0 1 px rgba ( 0 , 0 , 0 , 0 .3 ) , 0 1 px 3 px 1 px rgba ( 0 , 0 , 0 , 0 .7 ) ,
0 2 px 6 px 2 px rgba ( 0 , 0 , 0 , 0 .3 ) ;
padding : 0 ;
}
'' ;
description = ''
CSS style of the bar . See
< https://github.com/ErikReider/SwayNotificationCenter/blob/main/src/style.css >
for the documentation .
If the value is set to a path literal , then the path will be used as the CSS file .
'' ;
} ;
settings = lib . mkOption {
type = jsonFormat . type ;
default = { } ;
example = lib . literalExpression ''
{
positionX = " r i g h t " ;
positionY = " t o p " ;
layer = " o v e r l a y " ;
control-center-layer = " t o p " ;
layer-shell = true ;
cssPriority = " a p p l i c a t i o n " ;
control-center-margin-top = 0 ;
control-center-margin-bottom = 0 ;
control-center-margin-right = 0 ;
control-center-margin-left = 0 ;
notification-2fa-action = true ;
notification-inline-replies = false ;
notification-icon-size = 64 ;
notification-body-image-height = 100 ;
2024-09-12 16:58:01 +00:00
notification-body-image-width = 200 ;
2024-04-27 15:03:11 +00:00
} ;
'' ;
description = ''
Configuration written to { file } ` $ XDG_CONFIG_HOME/swaync/config.json ` .
See
< https://github.com/ErikReider/SwayNotificationCenter/blob/main/src/configSchema.json >
for the documentation .
'' ;
} ;
} ;
config = lib . mkIf cfg . enable {
# 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"
home . packages = [ cfg . package pkgs . at-spi2-core ] ;
xdg . configFile = {
" s w a y n c / c o n f i g . j s o n " . source =
jsonFormat . generate " c o n f i g . j s o n " cfg . settings ;
" s w a y n c / s t y l e . c s s " = lib . mkIf ( cfg . style != null ) {
2024-05-04 23:28:16 +00:00
source = if builtins . isPath cfg . style || lib . isStorePath cfg . style then
2024-04-27 15:03:11 +00:00
cfg . style
else
pkgs . writeText " s w a y n c / s t y l e . c s s " cfg . style ;
} ;
} ;
systemd . user . services . swaync = {
Unit = {
Description = " S w a y n c n o t i f i c a t i o n d a e m o n " ;
Documentation = " h t t p s : / / g i t h u b . c o m / E r i k R e i d e r / S w a y N o t i f i c a t i o n C e n t e r " ;
PartOf = [ " g r a p h i c a l - s e s s i o n . t a r g e t " ] ;
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 " ] ;
ConditionEnvironment = " W A Y L A N D _ D I S P L A Y " ;
} ;
Service = {
Type = " d b u s " ;
BusName = " o r g . f r e e d e s k t o p . N o t i f i c a t i o n s " ;
ExecStart = " ${ cfg . package } / b i n / s w a y n c " ;
Restart = " o n - f a i l u r e " ;
} ;
Install . WantedBy = [ " g r a p h i c a l - s e s s i o n . t a r g e t " ] ;
} ;
} ;
}