hm.nix: add descriptions and examples
Browse files
+333 −121 hm.nix
| @@ -1,5 +1,9 @@ | ||
| 1 | -{ self }: { config, lib, pkgs, ... }: | |
| 2 | -let | |
| 1 | +{self}: { | |
| 2 | + config, | |
| 3 | + lib, | |
| 4 | + pkgs, | |
| 5 | + ... | |
| 6 | +}: let | |
| 3 | 7 | inherit (lib) mkEnableOption mkOption mkIf types getExe; |
| 4 | 8 | cfg = config.programs.oxwm; |
| 5 | 9 | |
| @@ -9,42 +13,54 @@ let | ||
| 9 | 13 | interval = ${toString block.interval}, |
| 10 | 14 | color = "#${block.color}", |
| 11 | 15 | underline = ${lib.boolToString block.underline},''; |
| 12 | - in "oxwm.bar.block.${block.kind}({\n" + | |
| 13 | - (if block.kind == "static" then '' | |
| 14 | - text = "${block.text}", | |
| 15 | - ${common} | |
| 16 | - '' else if block.kind == "shell" then '' | |
| 17 | - format = "${block.format}", | |
| 18 | - command = "${block.command}", | |
| 19 | - ${common} | |
| 20 | - '' else if block.kind == "datetime" then '' | |
| 21 | - format = "${block.format}", | |
| 22 | - date_format = "${block.date_format}", | |
| 23 | - ${common} | |
| 24 | - '' else if block.kind == "battery" then '' | |
| 25 | - format = "${block.format}", | |
| 26 | - charging = "${block.charging}", | |
| 27 | - discharging = "${block.discharging}", | |
| 28 | - full = "${block.full}", | |
| 29 | - ${common} | |
| 30 | - '' else '' | |
| 31 | - format = "${block.format}", | |
| 32 | - ${common} | |
| 33 | - '') + "})"; | |
| 16 | + in | |
| 17 | + "oxwm.bar.block.${block.kind}({\n" | |
| 18 | + + ( | |
| 19 | + if block.kind == "static" | |
| 20 | + then '' | |
| 21 | + text = "${block.text}", | |
| 22 | + ${common} | |
| 23 | + '' | |
| 24 | + else if block.kind == "shell" | |
| 25 | + then '' | |
| 26 | + format = "${block.format}", | |
| 27 | + command = "${block.command}", | |
| 28 | + ${common} | |
| 29 | + '' | |
| 30 | + else if block.kind == "datetime" | |
| 31 | + then '' | |
| 32 | + format = "${block.format}", | |
| 33 | + date_format = "${block.date_format}", | |
| 34 | + ${common} | |
| 35 | + '' | |
| 36 | + else if block.kind == "battery" | |
| 37 | + then '' | |
| 38 | + format = "${block.format}", | |
| 39 | + charging = "${block.charging}", | |
| 40 | + discharging = "${block.discharging}", | |
| 41 | + full = "${block.full}", | |
| 42 | + ${common} | |
| 43 | + '' | |
| 44 | + else '' | |
| 45 | + format = "${block.format}", | |
| 46 | + ${common} | |
| 47 | + '' | |
| 48 | + ) | |
| 49 | + + "})"; | |
| 34 | 50 | |
| 35 | - ruleToLua = rule: let | |
| 36 | - fields = lib.concatStringsSep ", " ( | |
| 37 | - lib.optional (rule.match.class != null) ''class = "${rule.match.class}"'' ++ | |
| 38 | - lib.optional (rule.match.instance != null) ''instance = "${rule.match.instance}"'' ++ | |
| 39 | - lib.optional (rule.match.title != null) ''title = "${rule.match.title}"'' ++ | |
| 40 | - lib.optional (rule.match.role != null) ''role = "${rule.match.role}"'' ++ | |
| 41 | - lib.optional (rule.floating != null) ''floating = ${lib.boolToString rule.floating}'' ++ | |
| 42 | - lib.optional (rule.tag != null) ''tag = ${toString rule.tag}'' ++ | |
| 43 | - lib.optional (rule.fullscreen != null) ''fullscreen = ${lib.boolToString rule.fullscreen}'' | |
| 44 | - ); | |
| 45 | - in "oxwm.rule.add({ ${fields} })"; | |
| 46 | -in | |
| 47 | -{ | |
| 51 | + ruleToLua = rule: let | |
| 52 | + fields = lib.concatStringsSep ", " ( | |
| 53 | + lib.optional (rule.match.class != null) ''class = "${rule.match.class}"'' | |
| 54 | + ++ lib.optional (rule.match.instance != null) ''instance = "${rule.match.instance}"'' | |
| 55 | + ++ lib.optional (rule.match.title != null) ''title = "${rule.match.title}"'' | |
| 56 | + ++ lib.optional (rule.match.role != null) ''role = "${rule.match.role}"'' | |
| 57 | + ++ lib.optional (rule.floating != null) ''floating = ${lib.boolToString rule.floating}'' | |
| 58 | + ++ lib.optional (rule.tag != null) ''tag = ${toString rule.tag}'' | |
| 59 | + ++ lib.optional (rule.fullscreen != null) ''fullscreen = ${lib.boolToString rule.fullscreen}'' | |
| 60 | + ++ lib.optional (rule.focus != null) ''focus = ${lib.boolToString rule.fullscreen}'' | |
| 61 | + ); | |
| 62 | + in "oxwm.rule.add({ ${fields} })"; | |
| 63 | +in { | |
| 48 | 64 | options.programs.oxwm = { |
| 49 | 65 | enable = mkEnableOption "oxwm window manager"; |
| 50 | 66 | package = mkOption { |
| @@ -57,96 +73,289 @@ in | ||
| 57 | 73 | default = ""; |
| 58 | 74 | description = "Shell commands executed just before oxwm is started"; |
| 59 | 75 | }; |
| 60 | - terminal = mkOption { type = types.str; default = "alacritty"; }; | |
| 61 | - modkey = mkOption { type = types.str; default = "Mod4"; }; | |
| 62 | - tags = mkOption { type = types.listOf types.str; | |
| 63 | - default = [ "1" "2" "3" "4" "5" "6" "7" "8" "9" ]; | |
| 64 | - }; | |
| 65 | - layoutSymbol = { | |
| 66 | - tiling = mkOption { type = types.str; default = "[T]"; }; | |
| 67 | - normie = mkOption { type = types.str; default = "[F]"; }; | |
| 68 | - tabbed = mkOption { type = types.str; default = "[=]"; }; | |
| 69 | - }; | |
| 70 | - autostart = mkOption { | |
| 71 | - type = types.listOf types.str; | |
| 72 | - default = []; | |
| 73 | - }; | |
| 74 | - binds = mkOption { | |
| 75 | - type = types.listOf (types.submodule { | |
| 76 | - options = { | |
| 77 | - mods = mkOption { type = types.listOf types.str; default = [ "${cfg.modkey}" ]; }; | |
| 78 | - key = mkOption { type = types.str; }; | |
| 79 | - action = mkOption { type = types.str; }; | |
| 80 | - }; | |
| 81 | - }); | |
| 82 | - default = []; | |
| 83 | - }; | |
| 84 | - border = { | |
| 85 | - width = mkOption { type = types.int; default = 2; }; | |
| 86 | - focusedColor = mkOption { type = types.str; default = "6dade3"; }; | |
| 87 | - unfocusedColor = mkOption { type = types.str; default = "bbbbbb"; }; | |
| 88 | - }; | |
| 89 | - gaps = { | |
| 90 | - smart = mkOption { type = types.enum [ "enabled" "disabled" ]; default = "enabled"; }; | |
| 91 | - inner = mkOption { type = types.listOf types.int; default = [ 5 5 ];}; | |
| 92 | - outer = mkOption { type = types.listOf types.int; default = [ 5 5 ];}; | |
| 93 | - }; | |
| 94 | - bar = { | |
| 95 | - font = mkOption { type = types.str; default = "monospace 10"; }; | |
| 96 | - hideVacantTags = mkOption { type = types.bool; default = false; }; | |
| 97 | - unoccupiedScheme = mkOption { | |
| 98 | - type = types.listOf types.str; | |
| 99 | - default = [ "bbbbbb" "1a1b26" "444444" ]; | |
| 76 | + settings = { | |
| 77 | + terminal = mkOption { | |
| 78 | + type = types.str; | |
| 79 | + default = "alacritty"; | |
| 80 | + description = "Terminal used"; | |
| 100 | 81 | }; |
| 101 | - occupiedScheme = mkOption { | |
| 102 | - type = types.listOf types.str; | |
| 103 | - default = [ "0db9d7" "1a1b26" "0db9d7" ]; | |
| 82 | + modkey = mkOption { | |
| 83 | + type = types.str; | |
| 84 | + default = "Mod4"; | |
| 85 | + description = "Modifier key. Used for mouse dragging"; | |
| 104 | 86 | }; |
| 105 | - selectedScheme = mkOption { | |
| 87 | + tags = mkOption { | |
| 106 | 88 | type = types.listOf types.str; |
| 107 | - default = [ "0db9d7" "1a1b26" "ad8ee6" ]; | |
| 89 | + default = ["1" "2" "3" "4" "5" "6" "7" "8" "9"]; | |
| 90 | + description = "Workspace tags"; | |
| 91 | + example = ["" "" "" "" "" "" "" "" ""]; | |
| 108 | 92 | }; |
| 109 | - urgentScheme = mkOption { | |
| 93 | + layoutSymbol = { | |
| 94 | + tiling = mkOption { | |
| 95 | + type = types.str; | |
| 96 | + default = "[T]"; | |
| 97 | + description = "Symbol in tiling mode"; | |
| 98 | + }; | |
| 99 | + normie = mkOption { | |
| 100 | + type = types.str; | |
| 101 | + default = "[F]"; | |
| 102 | + description = "Symbol in normie mode"; | |
| 103 | + }; | |
| 104 | + tabbed = mkOption { | |
| 105 | + type = types.str; | |
| 106 | + default = "[=]"; | |
| 107 | + description = "Symbol in tabbed mode"; | |
| 108 | + }; | |
| 109 | + }; | |
| 110 | + autostart = mkOption { | |
| 110 | 111 | type = types.listOf types.str; |
| 111 | - default = [ "f7768e" "1a1b26" "f7768e" ]; | |
| 112 | + default = []; | |
| 113 | + description = "A list of commands to run when oxwm starts"; | |
| 112 | 114 | }; |
| 113 | - blocks = mkOption { type = types.listOf (types.submodule { | |
| 114 | - options = { | |
| 115 | - kind = mkOption { | |
| 116 | - type = types.enum [ "ram" "static" "shell" "datetime" "battery" ]; | |
| 117 | - default = "static"; | |
| 115 | + binds = mkOption { | |
| 116 | + type = types.listOf (types.submodule { | |
| 117 | + options = { | |
| 118 | + mods = mkOption { | |
| 119 | + type = types.listOf types.str; | |
| 120 | + default = ["${cfg.modkey}"]; | |
| 121 | + description = "The modifier keys to invoke the command"; | |
| 122 | + }; | |
| 123 | + key = mkOption { | |
| 124 | + type = types.str; | |
| 125 | + description = "The keystroke to invoke the command"; | |
| 126 | + }; | |
| 127 | + action = mkOption { | |
| 128 | + type = types.str; | |
| 129 | + description = "The command to invoke"; | |
| 130 | + }; | |
| 118 | 131 | }; |
| 119 | - interval = mkOption { type = types.int; default = 5; }; | |
| 120 | - color = mkOption { type = types.str; default = ""; }; | |
| 121 | - underline = mkOption { type = types.bool; default = true; }; | |
| 122 | - text = mkOption { type = types.str; default = "|"; }; | |
| 123 | - format = mkOption { type = types.str; default = "{}"; }; | |
| 124 | - command = mkOption { type = types.str; default = "uname -r"; }; | |
| 125 | - date_format = mkOption { type = types.str; default = "%a, %b %d - %-I:%M %P"; }; | |
| 126 | - charging = mkOption { type = types.str; default = "⚡ Bat: {}%"; }; | |
| 127 | - discharging = mkOption { type = types.str; default = "- Bat: {}%"; }; | |
| 128 | - full = mkOption { type = types.str; default = "✓ Bat: {}%"; }; | |
| 129 | - }; | |
| 130 | - }); }; | |
| 131 | - }; | |
| 132 | - rules = mkOption { type = types.listOf (types.submodule { | |
| 133 | - options = { | |
| 134 | - match = { | |
| 135 | - class = mkOption { type = types.nullOr types.str; default = null; }; | |
| 136 | - instance = mkOption { type = types.nullOr types.str; default = null; }; | |
| 137 | - title = mkOption { type = types.nullOr types.str; default = null; }; | |
| 138 | - role = mkOption { type = types.nullOr types.str; default = null; }; | |
| 139 | - }; | |
| 140 | - floating = mkOption { type = types.nullOr types.bool; default = null; }; | |
| 141 | - tag = mkOption { type = types.nullOr types.int; default = null; }; | |
| 142 | - fullscreen = mkOption { type = types.nullOr types.bool; default = null; }; | |
| 132 | + }); | |
| 133 | + default = []; | |
| 134 | + description = "The list of keybinds"; | |
| 135 | + example = ''[ | |
| 136 | + { | |
| 137 | + mods = [ "Mod4" "Shift" ]; | |
| 138 | + key = "Slash"; | |
| 139 | + action = "oxwm.show_keybinds()"; | |
| 140 | + } | |
| 141 | + { | |
| 142 | + mods = [ "Mod4" ]; | |
| 143 | + key = "D"; | |
| 144 | + action = "oxwm.spawn({ "sh", "-c", "dmenu_run -l 10" })"; | |
| 145 | + } | |
| 146 | + ];''; | |
| 147 | + }; | |
| 148 | + border = { | |
| 149 | + width = mkOption { | |
| 150 | + type = types.int; | |
| 151 | + default = 2; | |
| 152 | + description = "Width of the window borders"; | |
| 153 | + }; | |
| 154 | + focusedColor = mkOption { | |
| 155 | + type = types.str; | |
| 156 | + default = "6dade3"; | |
| 157 | + description = "Color of the focused window"; | |
| 158 | + }; | |
| 159 | + unfocusedColor = mkOption { | |
| 160 | + type = types.str; | |
| 161 | + default = "bbbbbb"; | |
| 162 | + description = "Color of the unfocused window"; | |
| 163 | + }; | |
| 143 | 164 | }; |
| 144 | - }); }; | |
| 145 | - extraConfig = mkOption { type = types.lines; default = ""; }; | |
| 165 | + gaps = { | |
| 166 | + smart = mkOption { | |
| 167 | + type = types.enum ["enabled" "disabled"]; | |
| 168 | + default = "enabled"; | |
| 169 | + description = "If enabled, removes border if single window in tag"; | |
| 170 | + }; | |
| 171 | + inner = mkOption { | |
| 172 | + type = types.listOf types.int; | |
| 173 | + default = [5 5]; | |
| 174 | + description = "Inner gaps [ horizontal vertical ] in pixels"; | |
| 175 | + }; | |
| 176 | + outer = mkOption { | |
| 177 | + type = types.listOf types.int; | |
| 178 | + default = [5 5]; | |
| 179 | + description = "Outer gaps [ horizontal vertical ] in pixels"; | |
| 180 | + }; | |
| 181 | + }; | |
| 182 | + bar = { | |
| 183 | + font = mkOption { | |
| 184 | + type = types.str; | |
| 185 | + default = "monospace 10"; | |
| 186 | + description = "The font displayed on the bar"; | |
| 187 | + }; | |
| 188 | + hideVacantTags = mkOption { | |
| 189 | + type = types.bool; | |
| 190 | + default = false; | |
| 191 | + description = "Whether to hide tags with no windows from the bar"; | |
| 192 | + }; | |
| 193 | + unoccupiedScheme = mkOption { | |
| 194 | + type = types.listOf types.str; | |
| 195 | + default = ["bbbbbb" "1a1b26" "444444"]; | |
| 196 | + description = "The colorscheme to use for unoccupied tags as hex colors. Do not put a `#` before each color."; | |
| 197 | + }; | |
| 198 | + occupiedScheme = mkOption { | |
| 199 | + type = types.listOf types.str; | |
| 200 | + default = ["0db9d7" "1a1b26" "0db9d7"]; | |
| 201 | + description = "The colorscheme to use for occupied tags as hex colors. Do not put a `#` before each color."; | |
| 202 | + }; | |
| 203 | + selectedScheme = mkOption { | |
| 204 | + type = types.listOf types.str; | |
| 205 | + default = ["0db9d7" "1a1b26" "ad8ee6"]; | |
| 206 | + description = "The colorscheme to use for selected tags as hex colors. Do not put a `#` before each color."; | |
| 207 | + }; | |
| 208 | + urgentScheme = mkOption { | |
| 209 | + type = types.listOf types.str; | |
| 210 | + default = ["f7768e" "1a1b26" "f7768e"]; | |
| 211 | + description = "The colorscheme to use for tags with a window requesting attention as hex colors. Do not put a `#` before each color."; | |
| 212 | + }; | |
| 213 | + blocks = mkOption { | |
| 214 | + type = types.listOf (types.submodule { | |
| 215 | + options = { | |
| 216 | + kind = mkOption { | |
| 217 | + type = types.enum ["ram" "static" "shell" "datetime" "battery"]; | |
| 218 | + default = "static"; | |
| 219 | + description = "The kind of block to be used"; | |
| 220 | + }; | |
| 221 | + interval = mkOption { | |
| 222 | + type = types.int; | |
| 223 | + default = 5; | |
| 224 | + }; | |
| 225 | + color = mkOption { | |
| 226 | + type = types.str; | |
| 227 | + default = ""; | |
| 228 | + }; | |
| 229 | + underline = mkOption { | |
| 230 | + type = types.bool; | |
| 231 | + default = true; | |
| 232 | + }; | |
| 233 | + text = mkOption { | |
| 234 | + type = types.str; | |
| 235 | + default = "|"; | |
| 236 | + }; | |
| 237 | + format = mkOption { | |
| 238 | + type = types.str; | |
| 239 | + default = "{}"; | |
| 240 | + }; | |
| 241 | + command = mkOption { | |
| 242 | + type = types.str; | |
| 243 | + default = "uname -r"; | |
| 244 | + }; | |
| 245 | + date_format = mkOption { | |
| 246 | + type = types.str; | |
| 247 | + default = "%a, %b %d - %-I:%M %P"; | |
| 248 | + }; | |
| 249 | + charging = mkOption { | |
| 250 | + type = types.str; | |
| 251 | + default = "⚡ Bat: {}%"; | |
| 252 | + }; | |
| 253 | + discharging = mkOption { | |
| 254 | + type = types.str; | |
| 255 | + default = "- Bat: {}%"; | |
| 256 | + }; | |
| 257 | + full = mkOption { | |
| 258 | + type = types.str; | |
| 259 | + default = "✓ Bat: {}%"; | |
| 260 | + }; | |
| 261 | + }; | |
| 262 | + }); | |
| 263 | + description = "The modules to put on the bar"; | |
| 264 | + example = ''[ | |
| 265 | + { | |
| 266 | + kind = "ram"; | |
| 267 | + interval = 5; | |
| 268 | + format = "Ram: {used}/{total} GB"; | |
| 269 | + color = "9ece6a"; | |
| 270 | + } | |
| 271 | + { | |
| 272 | + kind = "static"; | |
| 273 | + text = "|"; | |
| 274 | + interval = 99999999; | |
| 275 | + color = "6dade3"; | |
| 276 | + } | |
| 277 | + { | |
| 278 | + kind = "shell"; | |
| 279 | + format = "{}"; | |
| 280 | + command = "uname -r"; | |
| 281 | + interval = 9999999; | |
| 282 | + color = "f7768e"; | |
| 283 | + underline = true; | |
| 284 | + } | |
| 285 | + ];''; | |
| 286 | + }; | |
| 287 | + }; | |
| 288 | + rules = mkOption { | |
| 289 | + type = types.listOf (types.submodule { | |
| 290 | + options = { | |
| 291 | + match = { | |
| 292 | + class = mkOption { | |
| 293 | + type = types.nullOr types.str; | |
| 294 | + default = null; | |
| 295 | + description = "The class to match windows with"; | |
| 296 | + }; | |
| 297 | + instance = mkOption { | |
| 298 | + type = types.nullOr types.str; | |
| 299 | + default = null; | |
| 300 | + description = "The instance to match windows with"; | |
| 301 | + }; | |
| 302 | + title = mkOption { | |
| 303 | + type = types.nullOr types.str; | |
| 304 | + default = null; | |
| 305 | + description = "The title to match windows with"; | |
| 306 | + }; | |
| 307 | + role = mkOption { | |
| 308 | + type = types.nullOr types.str; | |
| 309 | + default = null; | |
| 310 | + description = "The role to match windows with"; | |
| 311 | + }; | |
| 312 | + }; | |
| 313 | + floating = mkOption { | |
| 314 | + type = types.nullOr types.bool; | |
| 315 | + default = null; | |
| 316 | + description = "Whether to apply floating to the matched window"; | |
| 317 | + }; | |
| 318 | + tag = mkOption { | |
| 319 | + type = types.nullOr types.int; | |
| 320 | + default = null; | |
| 321 | + description = "What tag the matched window should be opened on"; | |
| 322 | + }; | |
| 323 | + fullscreen = mkOption { | |
| 324 | + type = types.nullOr types.bool; | |
| 325 | + default = null; | |
| 326 | + description = "Whether to apply fullscreen to the matched window"; | |
| 327 | + }; | |
| 328 | + focus = mkOption { | |
| 329 | + type = types.nullOr types.bool; | |
| 330 | + default = null; | |
| 331 | + description = "Whether to apply focus to the matched window"; | |
| 332 | + }; | |
| 333 | + }; | |
| 334 | + }); | |
| 335 | + description = "A list of window rules for the window manager to follow"; | |
| 336 | + example = ''[ | |
| 337 | + { | |
| 338 | + match.class = "gimp"; | |
| 339 | + floating = true; | |
| 340 | + } | |
| 341 | + { | |
| 342 | + match.class = "firefox"; | |
| 343 | + match.title = "Library"; | |
| 344 | + tag = 9; | |
| 345 | + focus = true; | |
| 346 | + } | |
| 347 | + ];''; | |
| 348 | + }; | |
| 349 | + extraConfig = mkOption { | |
| 350 | + type = types.lines; | |
| 351 | + default = ""; | |
| 352 | + description = "Extra lua confguration that gets inserted at the bottom of the file"; | |
| 353 | + }; | |
| 354 | + }; | |
| 146 | 355 | }; |
| 147 | 356 | |
| 148 | 357 | config = mkIf cfg.enable { |
| 149 | - home.packages = [ cfg.package ]; | |
| 358 | + home.packages = [cfg.package]; | |
| 150 | 359 | |
| 151 | 360 | xsession.windowManager.command = '' |
| 152 | 361 | ${cfg.extraSessionCommands} |
| @@ -187,14 +396,17 @@ in | ||
| 187 | 396 | |
| 188 | 397 | ${lib.concatMapStrings (cmd: '' |
| 189 | 398 | oxwm.autostart("${cmd}") |
| 190 | - '') cfg.autostart} | |
| 399 | + '') | |
| 400 | + cfg.autostart} | |
| 191 | 401 | ${lib.concatMapStrings (bind: '' |
| 192 | - oxwm.key.bind({ ${lib.concatMapStringsSep ", " (m: ''"${m}"'') bind.mods} }, "${bind.key}", ${bind.action}) | |
| 193 | - '') cfg.binds} | |
| 402 | + oxwm.key.bind({ ${lib.concatMapStringsSep ", " (m: ''"${m}"'') bind.mods} }, "${bind.key}", ${bind.action}) | |
| 403 | + '') | |
| 404 | + cfg.binds} | |
| 194 | 405 | ${cfg.extraConfig} |
| 195 | 406 | ${lib.concatMapStrings (rule: '' |
| 196 | - ${ruleToLua rule} | |
| 197 | - '') cfg.rules} | |
| 407 | + ${ruleToLua rule} | |
| 408 | + '') | |
| 409 | + cfg.rules} | |
| 198 | 410 | ''; |
| 199 | 411 | }; |
| 200 | 412 | } |