Skip to content

Commit

Permalink
i3, sway: extract border functionality to common function (#1947)
Browse files Browse the repository at this point in the history
* i3, sway: extract border functionality to common function

Converted the i3 module to use default_border and
default_floating_border and extracted that functionality out to be
shared between the i3 and sway modules.

* i3: add sumnerevans as maintainer
  • Loading branch information
sumnerevans authored Apr 28, 2021
1 parent a759143 commit 19ebab9
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 18 deletions.
6 changes: 6 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,13 @@

/modules/services/unison.nix @pacien

/modules/services/window-managers/i3-sway/i3.nix @sumnerevans
/tests/modules/services/window-managers/i3 @sumnerevans

/modules/services/window-managers/i3-sway/lib @sumnerevans

/modules/services/window-managers/i3-sway/sway.nix @alexarice @sumnerevans
/tests/modules/services/window-managers/sway @sumnerevans

/modules/services/wlsunset.nix @matrss
/tests/modules/services/wlsunset @matrss
Expand Down
11 changes: 4 additions & 7 deletions modules/services/window-managers/i3-sway/i3.nix
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ let

inherit (commonFunctions)
keybindingsStr keycodebindingsStr modeStr assignStr barStr gapsStr
floatingCriteriaStr windowCommandsStr colorSetStr;
floatingCriteriaStr windowCommandsStr colorSetStr windowBorderString;

startupEntryStr = { command, always, notification, workspace, ... }: ''
${if always then "exec_always" else "exec"} ${
Expand All @@ -157,12 +157,7 @@ let
with cfg.config; ''
font pango:${concatStringsSep ", " fonts}
floating_modifier ${floating.modifier}
new_window ${if window.titlebar then "normal" else "pixel"} ${
toString window.border
}
new_float ${if floating.titlebar then "normal" else "pixel"} ${
toString floating.border
}
${windowBorderString window floating}
hide_edge_borders ${window.hideEdgeBorders}
force_focus_wrapping ${if focus.forceWrapping then "yes" else "no"}
focus_follows_mouse ${if focus.followMouse then "yes" else "no"}
Expand Down Expand Up @@ -209,6 +204,8 @@ let
'';

in {
meta.maintainers = with maintainers; [ sumnerevans ];

options = {
xsession.windowManager.i3 = {
enable = mkEnableOption "i3 window manager.";
Expand Down
9 changes: 9 additions & 0 deletions modules/services/window-managers/i3-sway/lib/functions.nix
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,15 @@ rec {
${optionalString (smartBorders != "off") "smart_borders ${smartBorders}"}
'';

windowBorderString = window: floating:
let
titlebarString = { titlebar, border, ... }:
"${if titlebar then "normal" else "pixel"} ${toString border}";
in concatStringsSep "\n" [
"default_border ${titlebarString window}"
"default_floating_border ${titlebarString floating}"
];

floatingCriteriaStr = criteria:
"for_window ${criteriaStr criteria} floating enable";
windowCommandsStr = { command, criteria, ... }:
Expand Down
9 changes: 2 additions & 7 deletions modules/services/window-managers/i3-sway/sway.nix
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ let

inherit (commonFunctions)
keybindingsStr keycodebindingsStr modeStr assignStr barStr gapsStr
floatingCriteriaStr windowCommandsStr colorSetStr;
floatingCriteriaStr windowCommandsStr colorSetStr windowBorderString;

startupEntryStr = { command, always, ... }: ''
${if always then "exec_always" else "exec"} ${command}
Expand All @@ -265,12 +265,7 @@ let
with cfg.config; ''
font pango:${concatStringsSep ", " fonts}
floating_modifier ${floating.modifier}
default_border ${if window.titlebar then "normal" else "pixel"} ${
toString window.border
}
default_floating_border ${
if floating.titlebar then "normal" else "pixel"
} ${toString floating.border}
${windowBorderString window floating}
hide_edge_borders ${window.hideEdgeBorders}
focus_wrapping ${if focus.forceWrapping then "yes" else "no"}
focus_follows_mouse ${focus.followMouse}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
font pango:monospace 8
floating_modifier Mod1
new_window normal 2
new_float normal 2
default_border normal 2
default_floating_border normal 2
hide_edge_borders none
force_focus_wrapping no
focus_follows_mouse no
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
font pango:monospace 8
floating_modifier Mod1
new_window normal 2
new_float normal 2
default_border normal 2
default_floating_border normal 2
hide_edge_borders none
force_focus_wrapping no
focus_follows_mouse yes
Expand Down

0 comments on commit 19ebab9

Please sign in to comment.