From 8b9a61339e604c0e962d39c220095dbfee24aa0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geoffrey=20=E2=80=9CFrogeye=E2=80=9D=20Preud=27homme?= Date: Thu, 29 May 2025 19:21:19 +0200 Subject: [PATCH] Smol wayland fixes --- hm/desktop/frobar/frobar/__init__.py | 3 +- hm/desktop/sway/default.nix | 341 ++++++++++++++------------- 2 files changed, 175 insertions(+), 169 deletions(-) diff --git a/hm/desktop/frobar/frobar/__init__.py b/hm/desktop/frobar/frobar/__init__.py index 0b7e2e0..abde50a 100644 --- a/hm/desktop/frobar/frobar/__init__.py +++ b/hm/desktop/frobar/frobar/__init__.py @@ -36,7 +36,7 @@ def main() -> None: theme = rich.terminal_theme.TerminalTheme( base16_color(0x0), - base16_color(0x7), + base16_color(0x0), # TODO Should be 0x7 but otherwise spacer is white [ base16_color(0x0), # black base16_color(0x8), # red @@ -80,6 +80,7 @@ def main() -> None: alignment=Alignment.LEFT, ) + if dual_screen: bar.add_provider( frobar.providers.I3WindowTitleProvider(color=color("white")), diff --git a/hm/desktop/sway/default.nix b/hm/desktop/sway/default.nix index d0d5dc2..d2f91a3 100644 --- a/hm/desktop/sway/default.nix +++ b/hm/desktop/sway/default.nix @@ -87,177 +87,182 @@ in }; wayland = { systemd.target = "sway-session.target"; - windowManager.sway.checkConfig = false; # us_qwerty-fr is not in the testing environment - }; - # https://github.com/nix-community/home-manager/issues/5311 - # Setting a compiled file is not desirable as it depends on the keyboard's, uuuh, key placement - wayland.windowManager.sway.config = { - input."*".xkb_layout = "us_qwerty-fr"; - modifier = lib.mkDefault "Mod4"; - fonts = { - names = [ config.stylix.fonts.sansSerif.name ]; - size = lib.mkForce 8.0; - }; - terminal = "alacritty"; - colors = - let - ignore = "#ff00ff"; - in - with config.lib.stylix.colors.withHashtag; - lib.mkForce { - focused = { - border = base0B; - background = base0B; - text = base00; - indicator = base00; - childBorder = base0B; + windowManager.sway = { + checkConfig = false; # us_qwerty-fr is not in the testing environment + config = { + # https://github.com/nix-community/home-manager/issues/5311 + # Setting a compiled file is not desirable as it depends on the keyboard's, uuuh, key placement + input."*".xkb_layout = "us_qwerty-fr"; + modifier = lib.mkDefault "Mod4"; + fonts = { + names = [ config.stylix.fonts.sansSerif.name ]; + size = lib.mkForce 8.0; }; - focusedInactive = { - border = base02; - background = base02; - text = base05; - indicator = base02; - childBorder = base02; - }; - unfocused = { - border = base05; - background = base04; - text = base00; - indicator = base04; - childBorder = base00; - }; - urgent = { - border = base0F; - background = base08; - text = base00; - indicator = base08; - childBorder = base0F; - }; - placeholder = { - border = ignore; - background = base00; - text = base05; - indicator = ignore; - childBorder = base00; - }; - background = base07; - # I set the color of the active tab as the the background color of the terminal so they merge together. - }; - focus = { - followMouse = false; - mouseWarping = "container"; - }; - keybindings = lib.mkOptionDefault ( - { - # Compatibility layer for people coming from other backgrounds - "Mod1+Tab" = "${rofi} -modi window -show window"; - "Mod1+F2" = "${rofi} -modi drun -show drun"; - "Mod1+F4" = "kill"; - # kill focused window - "${mod}+z" = "kill"; - button2 = "kill"; - # Rofi - "${mod}+i" = "exec --no-startup-id ${pkgs.rofimoji}/bin/rofimoji"; - # start program launcher - "${mod}+d" = "${rofi} -modi run -show run"; - "${mod}+Shift+d" = "${rofi} -modi drun -show drun"; - # Start Applications - "${mod}+p" = "exec ${pkgs.xfce.thunar}/bin/thunar"; - # workspace back and forth (with/without active container) - "${mod}+b" = "workspace back_and_forth"; - "${mod}+Shift+b" = "move container to workspace back_and_forth; workspace back_and_forth"; - # Split horizontally (rebound from ${mod}+b because used above) - "${mod}+g" = "splith"; - # Change container layout - "${mod}+q" = "focus child"; - # i3 control - "${mod}+Shift+r" = "restart"; - # Warp around (ex-keynav) - "Mod4+Mod1+x" = "exec ${lib.getExe pkgs.warpd} --hint"; - "Mod4+Mod1+c" = "exec ${lib.getExe pkgs.warpd} --normal"; - "Mod4+Mod1+g" = "exec ${lib.getExe pkgs.warpd} --grid"; - } - // lib.mapAttrs' (k: v: lib.nameValuePair v.enter ''mode "${v.name}"'') ( - lib.filterAttrs (k: v: v.enter != null) modes - ) - // lib.attrsets.mergeAttrsList ( - forEachCardinal (c: { - #navigate workspaces next / previous - "${mod}+Ctrl+${c.vi}" = "workspace ${c.workspace}"; - # Move to workspace next / previous with focused container - "${mod}+Ctrl+Shift+${c.vi}" = - "move container to workspace ${c.workspace}; workspace ${c.workspace}"; - # move workspaces to screen (arrow keys) - "${mod}+Ctrl+Shift+${c.arrow}" = "move workspace to output ${c.output}"; - }) - ) - // lib.attrsets.mergeAttrsList ( - forEachWorkspace (w: { - # move container to workspace, do not follow (normally bound to ${mod}+Shift+${w.key} - "${mod}+Ctrl+${w.key}" = "move container to workspace number ${w.name}"; - # move container to workspace, follow it - "${mod}+Shift+${w.key}" = - "move container to workspace number ${w.name}; workspace number ${w.name}"; - }) - ) - ); - modes = lib.mkOptionDefault ( - lib.mapAttrs' ( - k: v: - lib.nameValuePair v.name ( - v.bindings - // lib.optionalAttrs v.return_bindings { - "Return" = "mode default"; - "Escape" = "mode default"; - } - ) - ) modes - ); - window = { - hideEdgeBorders = "both"; - titlebar = false; # So that single-container screens are basically almost fullscreen - commands = [ - # switch to workspace with urgent window automatically - { - criteria = { - urgent = "latest"; + terminal = "alacritty"; + colors = + let + ignore = "#ff00ff"; + in + with config.lib.stylix.colors.withHashtag; + lib.mkForce { + focused = { + border = base0B; + background = base0B; + text = base00; + indicator = base00; + childBorder = base0B; + }; + focusedInactive = { + border = base02; + background = base02; + text = base05; + indicator = base02; + childBorder = base02; + }; + unfocused = { + border = base05; + background = base04; + text = base00; + indicator = base04; + childBorder = base00; + }; + urgent = { + border = base0F; + background = base08; + text = base00; + indicator = base08; + childBorder = base0F; + }; + placeholder = { + border = ignore; + background = base00; + text = base05; + indicator = ignore; + childBorder = base00; + }; + background = base07; + # I set the color of the active tab as the the background color of the terminal so they merge together. }; - command = "focus"; - } - ]; - }; - floating = { - criteria = [ - { window_role = "pop-up"; } - { window_role = "task_dialog"; } - ]; - }; - seat."*".hide_cursor = "5000"; - startup = [ - { - command = "${ - pkgs.writeShellApplication { - name = "batteryNotify"; - runtimeInputs = with pkgs; [ - coreutils - libnotify - ]; - text = builtins.readFile ./batteryNotify.sh; - # TODO Use batsignal instead? - # TODO Only on computers with battery + focus = { + followMouse = false; + mouseWarping = "container"; + }; + keybindings = lib.mkOptionDefault ( + { + # Compatibility layer for people coming from other backgrounds + "Mod1+Tab" = "${rofi} -modi window -show window"; + "Mod1+F2" = "${rofi} -modi drun -show drun"; + "Mod1+F4" = "kill"; + # kill focused window + "${mod}+z" = "kill"; + button2 = "kill"; + # Rofi + "${mod}+i" = "exec --no-startup-id ${pkgs.rofimoji}/bin/rofimoji"; + # start program launcher + "${mod}+d" = "${rofi} -modi run -show run"; + "${mod}+Shift+d" = "${rofi} -modi drun -show drun"; + # Start Applications + "${mod}+p" = "exec ${pkgs.xfce.thunar}/bin/thunar"; + # workspace back and forth (with/without active container) + "${mod}+b" = "workspace back_and_forth"; + "${mod}+Shift+b" = "move container to workspace back_and_forth; workspace back_and_forth"; + # Split horizontally (rebound from ${mod}+b because used above) + "${mod}+g" = "splith"; + # Change container layout + "${mod}+q" = "focus child"; + # i3 control + "${mod}+Shift+r" = "restart"; + # Warp around (ex-keynav) + "Mod4+Mod1+x" = "exec ${lib.getExe pkgs.warpd} --hint"; + "Mod4+Mod1+c" = "exec ${lib.getExe pkgs.warpd} --normal"; + "Mod4+Mod1+g" = "exec ${lib.getExe pkgs.warpd} --grid"; } - }/bin/batteryNotify"; - } - ]; - workspaceLayout = "tabbed"; - workspaceOutputAssign = lib.mkIf (builtins.length screenCombinations > 0) ( - forEachWorkspace (w: { - output = builtins.map ( - combination: builtins.elemAt combination (lib.mod w.id (builtins.length combination)) - ) screenCombinations; - workspace = w.name; - }) - ); + // lib.mapAttrs' (k: v: lib.nameValuePair v.enter ''mode "${v.name}"'') ( + lib.filterAttrs (k: v: v.enter != null) modes + ) + // lib.attrsets.mergeAttrsList ( + forEachCardinal (c: { + #navigate workspaces next / previous + "${mod}+Ctrl+${c.vi}" = "workspace ${c.workspace}"; + # Move to workspace next / previous with focused container + "${mod}+Ctrl+Shift+${c.vi}" = + "move container to workspace ${c.workspace}; workspace ${c.workspace}"; + # move workspaces to screen (arrow keys) + "${mod}+Ctrl+Shift+${c.arrow}" = "move workspace to output ${c.output}"; + }) + ) + // lib.attrsets.mergeAttrsList ( + forEachWorkspace (w: { + # move container to workspace, do not follow (normally bound to ${mod}+Shift+${w.key} + "${mod}+Ctrl+${w.key}" = "move container to workspace number ${w.name}"; + # move container to workspace, follow it + "${mod}+Shift+${w.key}" = + "move container to workspace number ${w.name}; workspace number ${w.name}"; + }) + ) + ); + modes = lib.mkOptionDefault ( + lib.mapAttrs' ( + k: v: + lib.nameValuePair v.name ( + v.bindings + // lib.optionalAttrs v.return_bindings { + "Return" = "mode default"; + "Escape" = "mode default"; + } + ) + ) modes + ); + window = { + hideEdgeBorders = "both"; + titlebar = false; # So that single-container screens are basically almost fullscreen + commands = [ + # switch to workspace with urgent window automatically + { + criteria = { + urgent = "latest"; + }; + command = "focus"; + } + ]; + }; + floating = { + criteria = [ + { window_role = "pop-up"; } + { window_role = "task_dialog"; } + ]; + }; + seat."*".hide_cursor = "5000"; + startup = [ + { + command = "${ + pkgs.writeShellApplication { + name = "batteryNotify"; + runtimeInputs = with pkgs; [ + coreutils + libnotify + ]; + text = builtins.readFile ./batteryNotify.sh; + # TODO Use batsignal instead? + # TODO Only on computers with battery + } + }/bin/batteryNotify"; + } + ]; + workspaceLayout = "tabbed"; + workspaceOutputAssign = lib.mkIf (builtins.length screenCombinations > 0) ( + forEachWorkspace (w: { + output = builtins.map ( + combination: builtins.elemAt combination (lib.mod w.id (builtins.length combination)) + ) screenCombinations; + workspace = w.name; + }) + ); + }; + extraConfig = '' + titlebar_padding 3 + ''; + }; }; frogeye.desktop.i3.bindmodes = { "[L] Vérouillage [E] Déconnexion [S] Veille [H] Hibernation [R] Redémarrage [P] Extinction" = {