Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i3, sway: extract border functionality to common function #1947

Merged
merged 2 commits into from
Apr 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,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