2021-11-09 23:17:36 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.xsession.windowManager.herbstluftwm;
|
|
|
|
|
|
|
|
renderValue = val:
|
|
|
|
if lib.isBool val then
|
|
|
|
if val then "true" else "false"
|
|
|
|
else
|
|
|
|
lib.escapeShellArg val;
|
|
|
|
|
|
|
|
renderSettings = settings:
|
|
|
|
lib.concatStringsSep "\n" (lib.mapAttrsToList
|
|
|
|
(name: value: "herbstclient set ${name} ${renderValue value}") settings);
|
|
|
|
|
|
|
|
renderKeybinds = keybinds:
|
|
|
|
lib.concatStringsSep "\n"
|
|
|
|
(lib.mapAttrsToList (key: cmd: "herbstclient keybind ${key} ${cmd}")
|
|
|
|
keybinds);
|
|
|
|
|
|
|
|
renderMousebinds = mousebinds:
|
|
|
|
lib.concatStringsSep "\n"
|
|
|
|
(lib.mapAttrsToList (btn: cmd: "herbstclient mousebind ${btn} ${cmd}")
|
|
|
|
mousebinds);
|
|
|
|
|
|
|
|
renderRules = rules:
|
|
|
|
lib.concatStringsSep "\n" (map (rule: "herbstclient rule ${rule}") rules);
|
|
|
|
|
|
|
|
settingType = lib.types.oneOf [ lib.types.bool lib.types.int lib.types.str ];
|
|
|
|
|
2023-01-20 20:17:55 +01:00
|
|
|
escapedTags = map lib.escapeShellArg cfg.tags;
|
|
|
|
|
2021-11-09 23:17:36 +01:00
|
|
|
in {
|
|
|
|
meta.maintainers = [ lib.hm.maintainers.olmokramer ];
|
|
|
|
|
|
|
|
options.xsession.windowManager.herbstluftwm = {
|
2023-07-02 01:45:18 +02:00
|
|
|
enable = lib.mkEnableOption "herbstluftwm window manager";
|
2021-11-09 23:17:36 +01:00
|
|
|
|
|
|
|
package = lib.mkOption {
|
|
|
|
type = lib.types.package;
|
|
|
|
default = pkgs.herbstluftwm;
|
|
|
|
defaultText = lib.literalExpression "pkgs.herbstluftwm";
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2023-07-01 01:30:13 +02:00
|
|
|
Package providing the {command}`herbstluftwm` and
|
|
|
|
{command}`herbstclient` commands.
|
2021-11-09 23:17:36 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
settings = lib.mkOption {
|
|
|
|
type = lib.types.attrsOf settingType;
|
|
|
|
default = { };
|
|
|
|
example = lib.literalExpression ''
|
|
|
|
{
|
|
|
|
gapless_grid = false;
|
|
|
|
window_border_width = 1;
|
|
|
|
window_border_active_color = "#FF0000";
|
|
|
|
}
|
|
|
|
'';
|
2023-07-02 01:45:18 +02:00
|
|
|
description = "Herbstluftwm settings.";
|
2021-11-09 23:17:36 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
keybinds = lib.mkOption {
|
|
|
|
type = lib.types.attrsOf lib.types.str;
|
|
|
|
default = { };
|
|
|
|
example = lib.literalExpression ''
|
|
|
|
{
|
|
|
|
Mod4-o = "split right";
|
|
|
|
Mod4-u = "split bottom";
|
|
|
|
}
|
|
|
|
'';
|
2023-07-02 01:45:18 +02:00
|
|
|
description = "Herbstluftwm keybinds.";
|
2021-11-09 23:17:36 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
mousebinds = lib.mkOption {
|
|
|
|
type = lib.types.attrsOf lib.types.str;
|
|
|
|
default = { };
|
|
|
|
example = lib.literalExpression ''
|
|
|
|
{
|
|
|
|
Mod4-B1 = "move";
|
|
|
|
Mod4-B3 = "resize";
|
|
|
|
}
|
|
|
|
'';
|
2023-07-02 01:45:18 +02:00
|
|
|
description = "Herbstluftwm mousebinds.";
|
2021-11-09 23:17:36 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
rules = lib.mkOption {
|
|
|
|
type = lib.types.listOf lib.types.str;
|
|
|
|
default = [ ];
|
|
|
|
example = lib.literalExpression ''
|
|
|
|
[
|
|
|
|
"windowtype~'_NET_WM_WINDOW_TYPE_(DIALOG|UTILITY|SPLASH)' focus=on pseudotile=on"
|
|
|
|
"windowtype~'_NET_WM_WINDOW_TYPE_(NOTIFICATION|DOCK|DESKTOP)' manage=off"
|
|
|
|
]
|
|
|
|
'';
|
2023-07-02 01:45:18 +02:00
|
|
|
description = "Herbstluftwm rules.";
|
2021-11-09 23:17:36 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
tags = lib.mkOption {
|
|
|
|
type = lib.types.listOf lib.types.str;
|
|
|
|
default = [ ];
|
|
|
|
example = lib.literalExpression ''
|
|
|
|
[ "work" "browser" "music" "gaming" ]
|
|
|
|
'';
|
2023-07-02 01:45:18 +02:00
|
|
|
description = "Tags to create on startup.";
|
2021-11-09 23:17:36 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
extraConfig = lib.mkOption {
|
|
|
|
type = lib.types.lines;
|
|
|
|
default = "";
|
|
|
|
example = ''
|
|
|
|
herbstclient set_layout max
|
|
|
|
herbstclient detect_monitors
|
|
|
|
'';
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2021-11-09 23:17:36 +01:00
|
|
|
Extra configuration lines to add verbatim to
|
2023-07-01 01:30:13 +02:00
|
|
|
{file}`$XDG_CONFIG_HOME/herbstluftwm/autostart`.
|
2021-11-09 23:17:36 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
|
|
assertions = [
|
|
|
|
(lib.hm.assertions.assertPlatform "xsession.windowManager.herbstluftwm"
|
|
|
|
pkgs lib.platforms.linux)
|
|
|
|
];
|
|
|
|
|
|
|
|
home.packages = [ cfg.package ];
|
|
|
|
|
|
|
|
xsession.windowManager.command = "${cfg.package}/bin/herbstluftwm --locked";
|
|
|
|
|
|
|
|
xdg.configFile."herbstluftwm/autostart".source =
|
|
|
|
pkgs.writeShellScript "herbstluftwm-autostart" ''
|
|
|
|
shopt -s expand_aliases
|
|
|
|
|
|
|
|
# shellcheck disable=SC2142
|
|
|
|
alias herbstclient='set -- "$@" ";"'
|
|
|
|
set --
|
|
|
|
|
|
|
|
herbstclient emit_hook reload
|
|
|
|
|
|
|
|
# Reset everything.
|
|
|
|
herbstclient attr theme.tiling.reset 1
|
|
|
|
herbstclient attr theme.floating.reset 1
|
|
|
|
herbstclient keyunbind --all
|
2022-12-19 22:12:34 +01:00
|
|
|
herbstclient mouseunbind --all
|
2021-11-09 23:17:36 +01:00
|
|
|
herbstclient unrule --all
|
|
|
|
|
|
|
|
${renderSettings cfg.settings}
|
|
|
|
|
2022-12-19 22:08:33 +01:00
|
|
|
${lib.optionalString (cfg.tags != [ ]) ''
|
2023-01-20 20:17:55 +01:00
|
|
|
for tag in ${lib.concatStringsSep " " escapedTags}; do
|
2022-12-19 22:08:33 +01:00
|
|
|
herbstclient add "$tag"
|
|
|
|
done
|
2023-01-20 20:17:55 +01:00
|
|
|
|
|
|
|
if ${cfg.package}/bin/herbstclient object_tree tags.by-name.default &>/dev/null; then
|
|
|
|
herbstclient use ${lib.head escapedTags}
|
|
|
|
herbstclient merge_tag default ${lib.head escapedTags}
|
|
|
|
fi
|
2022-12-19 22:08:33 +01:00
|
|
|
''}
|
2021-11-09 23:17:36 +01:00
|
|
|
|
|
|
|
${renderKeybinds cfg.keybinds}
|
|
|
|
|
|
|
|
${renderMousebinds cfg.mousebinds}
|
|
|
|
|
|
|
|
${renderRules cfg.rules}
|
|
|
|
|
|
|
|
${cfg.extraConfig}
|
|
|
|
|
|
|
|
herbstclient unlock
|
|
|
|
|
|
|
|
${cfg.package}/bin/herbstclient chain ";" "$@"
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
}
|