sway: add settings option
This commit is contained in:
parent
74acd4d937
commit
fd6c12bfd7
|
@ -272,63 +272,73 @@ let
|
||||||
${pkgs.xvfb-run}/bin/xvfb-run ${swayPackage}/bin/sway --config "$target" --validate --unsupported-gpu
|
${pkgs.xvfb-run}/bin/xvfb-run ${swayPackage}/bin/sway --config "$target" --validate --unsupported-gpu
|
||||||
'';
|
'';
|
||||||
|
|
||||||
text = concatStringsSep "\n"
|
text = let
|
||||||
((optional (cfg.extraConfigEarly != "") cfg.extraConfigEarly)
|
# include and set should be at the top of the configuration
|
||||||
++ (if cfg.config != null then
|
setSettings = lib.filterAttrs (key: _: key == "set") cfg.settings;
|
||||||
with cfg.config;
|
includeSettings = lib.filterAttrs (key: _: key == "include") cfg.settings;
|
||||||
([
|
otherSettings =
|
||||||
(fontConfigStr fonts)
|
lib.filterAttrs (key: _: key != "set" && key != "include") cfg.settings;
|
||||||
"floating_modifier ${floating.modifier}"
|
in lib.optionalString (setSettings != { })
|
||||||
(windowBorderString window floating)
|
(lib.hm.generators.toSwayConf { } setSettings)
|
||||||
"hide_edge_borders ${window.hideEdgeBorders}"
|
+ lib.optionalString (includeSettings != { })
|
||||||
"focus_wrapping ${focus.wrapping}"
|
(lib.hm.generators.toSwayConf { } includeSettings)
|
||||||
"focus_follows_mouse ${focus.followMouse}"
|
+ lib.optionalString (otherSettings != { })
|
||||||
"focus_on_window_activation ${focus.newWindow}"
|
(lib.hm.generators.toSwayConf { } otherSettings) + concatStringsSep "\n"
|
||||||
"mouse_warping ${
|
((optional (cfg.extraConfigEarly != "") cfg.extraConfigEarly)
|
||||||
if builtins.isString (focus.mouseWarping) then
|
++ (if cfg.config != null then
|
||||||
focus.mouseWarping
|
with cfg.config;
|
||||||
else if focus.mouseWarping then
|
([
|
||||||
"output"
|
(fontConfigStr fonts)
|
||||||
else
|
"floating_modifier ${floating.modifier}"
|
||||||
"none"
|
(windowBorderString window floating)
|
||||||
}"
|
"hide_edge_borders ${window.hideEdgeBorders}"
|
||||||
"workspace_layout ${workspaceLayout}"
|
"focus_wrapping ${focus.wrapping}"
|
||||||
"workspace_auto_back_and_forth ${
|
"focus_follows_mouse ${focus.followMouse}"
|
||||||
lib.hm.booleans.yesNo workspaceAutoBackAndForth
|
"focus_on_window_activation ${focus.newWindow}"
|
||||||
}"
|
"mouse_warping ${
|
||||||
"client.focused ${colorSetStr colors.focused}"
|
if builtins.isString (focus.mouseWarping) then
|
||||||
"client.focused_inactive ${colorSetStr colors.focusedInactive}"
|
focus.mouseWarping
|
||||||
"client.unfocused ${colorSetStr colors.unfocused}"
|
else if focus.mouseWarping then
|
||||||
"client.urgent ${colorSetStr colors.urgent}"
|
"output"
|
||||||
"client.placeholder ${colorSetStr colors.placeholder}"
|
else
|
||||||
"client.background ${colors.background}"
|
"none"
|
||||||
(keybindingsStr {
|
}"
|
||||||
keybindings = keybindingDefaultWorkspace;
|
"workspace_layout ${workspaceLayout}"
|
||||||
bindsymArgs =
|
"workspace_auto_back_and_forth ${
|
||||||
lib.optionalString (cfg.config.bindkeysToCode) "--to-code";
|
lib.hm.booleans.yesNo workspaceAutoBackAndForth
|
||||||
})
|
}"
|
||||||
(keybindingsStr {
|
"client.focused ${colorSetStr colors.focused}"
|
||||||
keybindings = keybindingsRest;
|
"client.focused_inactive ${colorSetStr colors.focusedInactive}"
|
||||||
bindsymArgs =
|
"client.unfocused ${colorSetStr colors.unfocused}"
|
||||||
lib.optionalString (cfg.config.bindkeysToCode) "--to-code";
|
"client.urgent ${colorSetStr colors.urgent}"
|
||||||
})
|
"client.placeholder ${colorSetStr colors.placeholder}"
|
||||||
(keycodebindingsStr keycodebindings)
|
"client.background ${colors.background}"
|
||||||
] ++ mapAttrsToList inputStr input
|
(keybindingsStr {
|
||||||
++ mapAttrsToList outputStr output # outputs
|
keybindings = keybindingDefaultWorkspace;
|
||||||
++ mapAttrsToList seatStr seat # seats
|
bindsymArgs =
|
||||||
++ mapAttrsToList (modeStr cfg.config.bindkeysToCode) modes # modes
|
lib.optionalString (cfg.config.bindkeysToCode) "--to-code";
|
||||||
++ mapAttrsToList assignStr assigns # assigns
|
})
|
||||||
++ map barStr bars # bars
|
(keybindingsStr {
|
||||||
++ optional (gaps != null) gapsStr # gaps
|
keybindings = keybindingsRest;
|
||||||
++ map floatingCriteriaStr floating.criteria # floating
|
bindsymArgs =
|
||||||
++ map windowCommandsStr window.commands # window commands
|
lib.optionalString (cfg.config.bindkeysToCode) "--to-code";
|
||||||
++ map startupEntryStr startup # startup
|
})
|
||||||
++ map workspaceOutputStr workspaceOutputAssign # custom mapping
|
(keycodebindingsStr keycodebindings)
|
||||||
)
|
] ++ mapAttrsToList inputStr input
|
||||||
else
|
++ mapAttrsToList outputStr output # outputs
|
||||||
[ ]) ++ (optional cfg.systemd.enable systemdActivation)
|
++ mapAttrsToList seatStr seat # seats
|
||||||
++ (optional (!cfg.xwayland) "xwayland disable")
|
++ mapAttrsToList (modeStr cfg.config.bindkeysToCode) modes # modes
|
||||||
++ [ cfg.extraConfig ]);
|
++ mapAttrsToList assignStr assigns # assigns
|
||||||
|
++ map barStr bars # bars
|
||||||
|
++ optional (gaps != null) gapsStr # gaps
|
||||||
|
++ map floatingCriteriaStr floating.criteria # floating
|
||||||
|
++ map windowCommandsStr window.commands # window commands
|
||||||
|
++ map startupEntryStr startup # startup
|
||||||
|
++ map workspaceOutputStr workspaceOutputAssign # custom mapping
|
||||||
|
)
|
||||||
|
else
|
||||||
|
[ ]) ++ (optional cfg.systemd.enable systemdActivation)
|
||||||
|
++ (optional (!cfg.xwayland) "xwayland disable") ++ [ cfg.extraConfig ]);
|
||||||
};
|
};
|
||||||
|
|
||||||
defaultSwayPackage = pkgs.sway.override {
|
defaultSwayPackage = pkgs.sway.override {
|
||||||
|
@ -473,6 +483,20 @@ in {
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
settings = lib.mkOption {
|
||||||
|
type = with lib.types;
|
||||||
|
let
|
||||||
|
valueType =
|
||||||
|
oneOf [ int float str path (listOf str) (attrsOf valueType) ] // {
|
||||||
|
description = "Sway configuration value";
|
||||||
|
};
|
||||||
|
in valueType;
|
||||||
|
default = { };
|
||||||
|
description = ''
|
||||||
|
Configuration for `sway`. See `sway(5)` for supported values.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
config = mkOption {
|
config = mkOption {
|
||||||
type = types.nullOr configModule;
|
type = types.nullOr configModule;
|
||||||
default = { };
|
default = { };
|
||||||
|
@ -518,6 +542,14 @@ in {
|
||||||
assertions = [
|
assertions = [
|
||||||
(hm.assertions.assertPlatform "wayland.windowManager.sway" pkgs
|
(hm.assertions.assertPlatform "wayland.windowManager.sway" pkgs
|
||||||
platforms.linux)
|
platforms.linux)
|
||||||
|
{
|
||||||
|
assertion = cfg.settings != { } -> cfg.extraConfigEarly == "";
|
||||||
|
message = ''
|
||||||
|
`wayland.windowManager.sway.extraConfigEarly` is not needed when
|
||||||
|
using `wayland.windowManager.sway.settings`, it'll properly handle
|
||||||
|
`set` and `include` configuration.
|
||||||
|
'';
|
||||||
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
home.packages = optional (cfg.package != null) cfg.package
|
home.packages = optional (cfg.package != null) cfg.package
|
||||||
|
|
Loading…
Reference in a new issue