From 6aec3fbb50b3c44af0899858d35fcafeb443ffb9 Mon Sep 17 00:00:00 2001 From: pjan vandaele Date: Thu, 28 Dec 2017 09:55:31 +0900 Subject: [PATCH 1/3] Adds attrs type for defaults. Adds additional Dock settings. --- .gitignore | 1 + modules/system/defaults-write.nix | 1 + modules/system/defaults/dock.nix | 118 +++++++++++++++++++++++++++--- 3 files changed, 111 insertions(+), 9 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..1377554e --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.swp diff --git a/modules/system/defaults-write.nix b/modules/system/defaults-write.nix index 7a5eba49..cf0a10a3 100644 --- a/modules/system/defaults-write.nix +++ b/modules/system/defaults-write.nix @@ -12,6 +12,7 @@ let if isBool value then "-bool ${boolValue value}" else if isInt value then "-int ${toString value}" else if isString value then "-string '${value}'" else + if isAttrs value then "-${value.type} '${value.value}'" else throw "invalid value type"; writeDefault = domain: key: value: diff --git a/modules/system/defaults/dock.nix b/modules/system/defaults/dock.nix index 5795bcd2..1fd97c3d 100644 --- a/modules/system/defaults/dock.nix +++ b/modules/system/defaults/dock.nix @@ -13,27 +13,79 @@ with lib; ''; }; - system.defaults.dock.orientation = mkOption { - type = types.nullOr (types.enum [ "bottom" "left" "right" ]); + system.defaults.dock.autohide-delay = mkOption { + type = types.nullOr types.attrs; default = null; + example = { + type = "float"; + value = "0.24"; + }; description = '' - Position of the dock on screen. The default is "bottom". + Sets the speed of the autohide delay. The default is given in the example. ''; }; - system.defaults.dock.showhidden = mkOption { + system.defaults.dock.autohide-time-modifier = mkOption { + type = types.nullOr types.attrs; + default = null; + example = { + type = "float"; + value = "1.0"; + }; + description = '' + Sets the speed of the animation when hiding/showing the Dock. The default is given in the example. + ''; + }; + + system.defaults.dock.dashboard-in-overlay = mkOption { type = types.nullOr types.bool; default = null; description = '' - Whether to make icons of hidden applications tranclucent. The default is false. + Whether to hide Dashboard as a Space. The default is false; ''; }; - system.defaults.dock.tilesize = mkOption { - type = types.nullOr types.int; + system.defaults.dock.enable-spring-load-actions-on-all-items = mkOption { + type = types.nullOr types.bool; default = null; description = '' - Size of the icons in the dock. The default is 64. + Enable spring loading for all Dock items. The default is false; + ''; + }; + + system.defaults.dock.expose-animation-duration = mkOption { + type = types.nullOr types.attrs; + default = null; + example = { + type = "float"; + value = "1.0"; + }; + description = '' + Sets the speed of the Mission Control animations. The default is given in the example. + ''; + }; + + system.defaults.dock.expose-group-by-app = mkOption { + type = types.nullOr types.bool; + default = null; + description = '' + Whether to group windows by application in Mission Control's Exposé. The default is true. + ''; + }; + + system.defaults.dock.launchanim = mkOption { + type = types.nullOr types.bool; + default = null; + description = '' + Animate opening applications from the Dock. The default is true. + ''; + }; + + system.defaults.dock.mineffect = mkOption { + type = types.nullOr (types.enum [ "genie" "suck" "scale" ]); + default = null; + description = '' + Set the minimize/maximize window effect. The default is genie. ''; }; @@ -45,6 +97,14 @@ with lib; ''; }; + system.defaults.dock.mouse-over-hilite-stack = mkOption { + type = types.nullOr types.bool; + default = null; + description = '' + Enable highlight hover effect for the grid view of a stack in the Dock. + ''; + }; + system.defaults.dock.mru-spaces = mkOption { type = types.nullOr types.bool; default = null; @@ -53,5 +113,45 @@ with lib; ''; }; - }; + system.defaults.dock.orientation = mkOption { + type = types.nullOr (types.enum [ "bottom" "left" "right" ]); + default = null; + description = '' + Position of the dock on screen. The default is "bottom". + ''; + }; + + system.defaults.dock.show-process-indicators = mkOption { + type = types.nullOr types.bool; + default = null; + description = '' + Show indicator lights for open applications in the Dock. The default is true. + ''; + }; + + system.defaults.dock.showhidden = mkOption { + type = types.nullOr types.bool; + default = null; + description = '' + Whether to make icons of hidden applications tranclucent. The default is false. + ''; + }; + + system.defaults.dock.static-only = mkOption { + type = types.nullOr types.bool; + default = null; + description = '' + Show only open applications in the Dock. The default is false. + ''; + }; + + system.defaults.dock.tilesize = mkOption { + type = types.nullOr types.int; + default = null; + description = '' + Size of the icons in the dock. The default is 64. + ''; + }; + + }; } From d7e67ce030e6b7ec41f5f3beb011992c698984e2 Mon Sep 17 00:00:00 2001 From: pjan vandaele Date: Sun, 31 Dec 2017 11:44:02 +0900 Subject: [PATCH 2/3] float type --- modules/system/defaults-write.nix | 4 +++- modules/system/defaults/dock.nix | 33 ++++++++++++++++--------------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/modules/system/defaults-write.nix b/modules/system/defaults-write.nix index cf0a10a3..d69a2c3c 100644 --- a/modules/system/defaults-write.nix +++ b/modules/system/defaults-write.nix @@ -6,13 +6,15 @@ let cfg = config.system.defaults; + isFloat = x: isString x && builtins.match "^[+-]?([1-9]*[.])?[0-9]+$" x != null; + boolValue = x: if x then "YES" else "NO"; writeValue = value: if isBool value then "-bool ${boolValue value}" else if isInt value then "-int ${toString value}" else + if isFloat value then "-float ${toString value}" else if isString value then "-string '${value}'" else - if isAttrs value then "-${value.type} '${value.value}'" else throw "invalid value type"; writeDefault = domain: key: value: diff --git a/modules/system/defaults/dock.nix b/modules/system/defaults/dock.nix index 1fd97c3d..378d703f 100644 --- a/modules/system/defaults/dock.nix +++ b/modules/system/defaults/dock.nix @@ -2,7 +2,17 @@ with lib; -{ +let + isFloat = x: isString x && builtins.match "^[+-]?([0-9]*[.])?[0-9]+$" x != null; + + float = mkOptionType { + name = "float"; + description = "float"; + check = isFloat; + merge = options.mergeOneOption; + }; + +in { options = { system.defaults.dock.autohide = mkOption { @@ -14,24 +24,18 @@ with lib; }; system.defaults.dock.autohide-delay = mkOption { - type = types.nullOr types.attrs; + type = types.nullOr float; default = null; - example = { - type = "float"; - value = "0.24"; - }; + example = "0.24"; description = '' Sets the speed of the autohide delay. The default is given in the example. ''; }; system.defaults.dock.autohide-time-modifier = mkOption { - type = types.nullOr types.attrs; + type = types.nullOr float; default = null; - example = { - type = "float"; - value = "1.0"; - }; + example = "1.0"; description = '' Sets the speed of the animation when hiding/showing the Dock. The default is given in the example. ''; @@ -54,12 +58,9 @@ with lib; }; system.defaults.dock.expose-animation-duration = mkOption { - type = types.nullOr types.attrs; + type = types.nullOr float; default = null; - example = { - type = "float"; - value = "1.0"; - }; + example = "1.0"; description = '' Sets the speed of the Mission Control animations. The default is given in the example. ''; From 1d8c5d9b79dba8ec20806701b711f49b0b07a6fe Mon Sep 17 00:00:00 2001 From: pjan vandaele Date: Mon, 1 Jan 2018 09:20:27 +0900 Subject: [PATCH 3/3] fix + tests --- modules/system/defaults-write.nix | 2 +- tests/system-defaults-write.nix | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/system/defaults-write.nix b/modules/system/defaults-write.nix index d69a2c3c..e5c2cddb 100644 --- a/modules/system/defaults-write.nix +++ b/modules/system/defaults-write.nix @@ -6,7 +6,7 @@ let cfg = config.system.defaults; - isFloat = x: isString x && builtins.match "^[+-]?([1-9]*[.])?[0-9]+$" x != null; + isFloat = x: isString x && builtins.match "^[+-]?([0-9]*[.])?[0-9]+$" x != null; boolValue = x: if x then "YES" else "NO"; diff --git a/tests/system-defaults-write.nix b/tests/system-defaults-write.nix index 3ba3ef5a..0a41a045 100644 --- a/tests/system-defaults-write.nix +++ b/tests/system-defaults-write.nix @@ -2,11 +2,13 @@ { system.defaults.NSGlobalDomain.KeyRepeat = 1; + system.defaults.dock.autohide-delay = "0.24"; system.defaults.dock.orientation = "left"; test = '' echo checking defaults write in /activate-user >&2 grep "defaults write -g 'KeyRepeat' -int 1" ${config.out}/activate-user grep "defaults write com.apple.dock 'orientation' -string 'left'" ${config.out}/activate-user + grep "defaults write com.apple.dock 'autohide-delay' -float 0.24" ${config.out}/activate-user ''; }