fork/home-manager
git clone https://git.julia.blue/fork/home-manager
75790441
master
1{ config , lib , pkgs , ...} : 2 3with lib ; 4 5let 6 7cfg = config . services . mako ; 8 9in { 10meta . maintainers = [ maintainers . onny ]; 11 12imports = 13[ ( mkRenamedOptionModule [ "programs" "mako" ] [ "services" "mako" ]) ]; 14 15options = { 16services . mako = { 17enable = mkEnableOption '' 18Mako, lightweight notification daemon for Wayland 19'' ; 20 21package = mkOption { 22type = types . package ; 23default = pkgs . mako ; 24defaultText = literalExpression "pkgs.mako" ; 25description = "The mako package to use." ; 26}; 27 28maxVisible = mkOption { 29default = 5 ; 30type = types . nullOr types . int ; 31description = '' 32Set maximum number of visible notifications. Set -1 to show all. 33'' ; 34}; 35 36sort = mkOption { 37default = "-time" ; 38type = 39types . nullOr ( types . enum [ "+time" "-time" "+priority" "-priority" ]); 40description = '' 41Sorts incoming notifications by time and/or priority in ascending(+) 42or descending(-) order. 43'' ; 44}; 45 46output = mkOption { 47default = null ; 48type = types . nullOr types . str ; 49description = '' 50Show notifications on the specified output. If empty, notifications 51will appear on the focused output. Requires the compositor to support 52the Wayland protocol xdg-output-unstable-v1 version 2. 53'' ; 54}; 55 56layer = mkOption { 57default = "top" ; 58type = 59types . nullOr ( types . enum [ "background" "bottom" "top" "overlay" ]); 60description = '' 61Arrange mako at the specified layer, relative to normal windows. 62Supported values are background, bottom, top, and overlay. Using 63overlay will cause notifications to be displayed above fullscreen 64windows, though this may also occur at top depending on your 65compositor. 66'' ; 67}; 68 69anchor = mkOption { 70default = "top-right" ; 71type = types . nullOr ( types . enum [ 72"top-right" 73"top-center" 74"top-left" 75"bottom-right" 76"bottom-center" 77"bottom-left" 78"center" 79]); 80description = '' 81Show notifications at the specified position on the output. 82Supported values are top-right, top-center, top-left, bottom-right, 83bottom-center, bottom-left, and center. 84'' ; 85}; 86 87font = mkOption { 88default = "monospace 10" ; 89type = types . nullOr types . str ; 90description = '' 91Font to use, in Pango format. 92'' ; 93}; 94 95backgroundColor = mkOption { 96default = "#285577FF" ; 97type = types . nullOr types . str ; 98description = '' 99Set popup background color to a specific color, represented in hex 100color code. 101'' ; 102}; 103 104textColor = mkOption { 105default = "#FFFFFFFF" ; 106type = types . nullOr types . str ; 107description = '' 108Set popup text color to a specific color, represented in hex color 109code. 110'' ; 111}; 112 113width = mkOption { 114default = 300 ; 115type = types . nullOr types . int ; 116description = '' 117Set width of notification popups in specified number of pixels. 118'' ; 119}; 120 121height = mkOption { 122default = 100 ; 123type = types . nullOr types . int ; 124description = '' 125Set maximum height of notification popups. Notifications whose text 126takes up less space are shrunk to fit. 127'' ; 128}; 129 130margin = mkOption { 131default = "10" ; 132type = types . nullOr types . str ; 133description = '' 134Set margin of each edge specified in pixels. Specify single value to 135apply margin on all sides. Two comma-separated values will set 136vertical and horizontal edges separately. Four comma-separated will 137give each edge a separate value. 138For example: 10,20,5 will set top margin to 10, left and right to 20 139and bottom to five. 140'' ; 141}; 142 143padding = mkOption { 144default = "5" ; 145type = types . nullOr types . str ; 146description = '' 147Set padding of each edge specified in pixels. Specify single value to 148apply margin on all sides. Two comma-separated values will set 149vertical and horizontal edges separately. Four comma-separated will 150give each edge a separate value. 151For example: 10,20,5 will set top margin to 10, left and right to 20 152and bottom to five. 153'' ; 154}; 155 156borderSize = mkOption { 157default = 1 ; 158type = types . nullOr types . int ; 159description = '' 160Set popup border size to the specified number of pixels. 161'' ; 162}; 163 164borderColor = mkOption { 165default = "#4C7899FF" ; 166type = types . nullOr types . str ; 167description = '' 168Set popup border color to a specific color, represented in hex color 169code. 170'' ; 171}; 172 173borderRadius = mkOption { 174default = 0 ; 175type = types . nullOr types . int ; 176description = '' 177Set popup corner radius to the specified number of pixels. 178'' ; 179}; 180 181progressColor = mkOption { 182default = "over #5588AAFF" ; 183type = types . nullOr types . str ; 184description = '' 185Set popup progress indicator color to a specific color, 186represented in hex color code. To draw the progress 187indicator on top of the background color, use the 188`over` attribute. To replace the background 189color, use the `source` attribute (this can 190be useful when the notification is semi-transparent). 191'' ; 192}; 193 194icons = mkOption { 195default = true ; 196type = types . nullOr types . bool ; 197description = '' 198Whether or not to show icons in notifications. 199'' ; 200}; 201 202maxIconSize = mkOption { 203default = 64 ; 204type = types . nullOr types . int ; 205description = '' 206Set maximum icon size to the specified number of pixels. 207'' ; 208}; 209 210iconPath = mkOption { 211default = null ; 212type = types . nullOr types . str ; 213description = '' 214Paths to search for icons when a notification specifies a name 215instead of a full path. Colon-delimited. This approximates the search 216algorithm used by the XDG Icon Theme Specification, but does not 217support any of the theme metadata. Therefore, if you want to search 218parent themes, you'll need to add them to the path manually. 219 220The {file}`/usr/share/icons/hicolor` and 221{file}`/usr/share/pixmaps` directories are 222always searched. 223'' ; 224}; 225 226markup = mkOption { 227default = true ; 228type = types . nullOr types . bool ; 229description = '' 230If 1, enable Pango markup. If 0, disable Pango markup. If enabled, 231Pango markup will be interpreted in your format specifier and in the 232body of notifications. 233'' ; 234}; 235 236actions = mkOption { 237default = true ; 238type = types . nullOr types . bool ; 239description = '' 240Applications may request an action to be associated with activating a 241notification. Disabling this will cause mako to ignore these requests. 242'' ; 243}; 244 245format = mkOption { 246default = "<b>%s</b>\\n%b" ; 247type = types . nullOr types . str ; 248description = '' 249Set notification format string to format. See FORMAT SPECIFIERS for 250more information. To change this for grouped notifications, set it 251within a grouped criteria. 252'' ; 253}; 254 255defaultTimeout = mkOption { 256default = 0 ; 257type = types . nullOr types . int ; 258description = '' 259Set the default timeout to timeout in milliseconds. To disable the 260timeout, set it to zero. 261'' ; 262}; 263 264ignoreTimeout = mkOption { 265default = false ; 266type = types . nullOr types . bool ; 267description = '' 268If set, mako will ignore the expire timeout sent by notifications 269and use the one provided by default-timeout instead. 270'' ; 271}; 272 273groupBy = mkOption { 274default = null ; 275type = types . nullOr types . str ; 276description = '' 277A comma-separated list of criteria fields that will be compared to 278other visible notifications to determine if this one should form a 279group with them. All listed criteria must be exactly equal for two 280notifications to group. 281'' ; 282}; 283 284extraConfig = mkOption { 285default = "" ; 286type = types . lines ; 287example = literalExpression '' 288[urgency=low] 289border-color=#b8bb26 290'' ; 291description = "Additional configuration." ; 292}; 293}; 294}; 295 296config = let 297boolToString = v :if v then "true" else "false" ; 298optionalBoolean = name :val : 299lib . optionalString ( val != null ) " ${ name } = ${ boolToString val } " ; 300optionalInteger = name :val : 301lib . optionalString ( val != null ) " ${ name } = ${ toString val } " ; 302optionalString = name :val : 303lib . optionalString ( val != null ) " ${ name } = ${ val } " ; 304in mkIf cfg . enable { 305assertions = 306[ ( hm . assertions . assertPlatform "services.mako" pkgs platforms . linux ) ]; 307 308home . packages = [ cfg . package ]; 309 310xdg . configFile . "mako/config" = { 311onChange = '' 312${ cfg . package } /bin/makoctl reload || true 313'' ; 314text = '' 315${ optionalInteger "max-visible" cfg . maxVisible } 316${ optionalString "sort" cfg . sort } 317${ optionalString "output" cfg . output } 318${ optionalString "layer" cfg . layer } 319${ optionalString "anchor" cfg . anchor } 320 321${ optionalString "font" cfg . font } 322${ optionalString "background-color" cfg . backgroundColor } 323${ optionalString "text-color" cfg . textColor } 324${ optionalInteger "width" cfg . width } 325${ optionalInteger "height" cfg . height } 326${ optionalString "margin" cfg . margin } 327${ optionalString "padding" cfg . padding } 328${ optionalInteger "border-size" cfg . borderSize } 329${ optionalString "border-color" cfg . borderColor } 330${ optionalInteger "border-radius" cfg . borderRadius } 331${ optionalString "progress-color" cfg . progressColor } 332${ optionalBoolean "icons" cfg . icons } 333${ optionalInteger "max-icon-size" cfg . maxIconSize } 334${ optionalString "icon-path" cfg . iconPath } 335${ optionalBoolean "markup" cfg . markup } 336${ optionalBoolean "actions" cfg . actions } 337${ optionalString "format" cfg . format } 338${ optionalInteger "default-timeout" cfg . defaultTimeout } 339${ optionalBoolean "ignore-timeout" cfg . ignoreTimeout } 340${ optionalString "group-by" cfg . groupBy } 341 342${ cfg . extraConfig } 343'' ; 344}; 345}; 346}