From 177b60befa15ff7f0d73fee6cdb48c55bc4d4bba Mon Sep 17 00:00:00 2001 From: Nathan McCarty Date: Thu, 20 Apr 2023 02:20:23 -0400 Subject: [PATCH] Setup layman --- home-manager/linux/programs/sway.nix | 76 ++++++++++++++++++++++++---- 1 file changed, 66 insertions(+), 10 deletions(-) diff --git a/home-manager/linux/programs/sway.nix b/home-manager/linux/programs/sway.nix index 84ed5f3..b0ce328 100644 --- a/home-manager/linux/programs/sway.nix +++ b/home-manager/linux/programs/sway.nix @@ -4,6 +4,7 @@ in with lib; { config = mkIf nathan.programs.swaywm.enable (let swaylock-command = '' ${pkgs.swaylock-effects}/bin/swaylock --screenshots --grace 30 --indicator --clock --timestr "%-I:%M:%S %p" --datestr "%A %Y-%M-%d" --effect-blur 20x3''; + layman-package = inputs.self.packages.${pkgs.system}.layman; in { home.packages = with pkgs; [ # Locking and display management @@ -45,11 +46,13 @@ in with lib; { # sworkstyle - Automatic workspace renaming swayest-workstyle font-awesome + layman-package ]; ######################### ## Sway ######################### - wayland.windowManager.sway = { + wayland.windowManager.sway = let modifier = "Mod4"; + in { enable = true; systemdIntegration = true; wrapperFeatures = { @@ -145,19 +148,18 @@ in with lib; { }; }; # Setup keybindings - keybindings = let modifer = "Mod4"; - in lib.mkOptionDefault { - "${modifer}+q" = "kill"; - "${modifer}+z" = "exec ${swaylock-command}"; + keybindings = lib.mkOptionDefault { + "${modifier}+q" = "kill"; + "${modifier}+z" = "exec ${swaylock-command}"; ## Sreenshot keybinds # Copy area to clipboard - "${modifer}+x" = + "${modifier}+x" = "exec ${pkgs.sway-contrib.grimshot}/bin/grimshot copy area"; # Copy window to clipboard - "${modifer}+Ctrl+x" = + "${modifier}+Ctrl+x" = "exec ${pkgs.sway-contrib.grimshot}/bin/grimshot copy window"; # Clpy entire output to clipboard - "${modifer}+Alt+x" = + "${modifier}+Alt+x" = "exec ${pkgs.sway-contrib.grimshot}/bin/grimshot copy output"; # Make the mute key work "XF86AudioMute" = "exec pactl set-sink-mute @DEFAULT_SINK@ toggle"; @@ -170,11 +172,29 @@ in with lib; { "XF86AudioPlay" = "exec mpc toggle"; "XF86AudioNext" = "exec mpc next"; # Setup scratchpads - "${modifer}+n" = + "${modifier}+n" = "exec sh -c 'swaymsg [app_id=\"emacs\"] scratchpad show'"; - "${modifer}+m" = + "${modifier}+m" = "exec sh -c 'swaymsg [app_id=\"Alacritty\"] scratchpad show'"; + # Rebind movement keys to use layman + "${modifier}+Shift+h" = "nop layman move left"; + "${modifier}+Shift+j" = "nop layman move down"; + "${modifier}+Shift+k" = "nop layman move up"; + "${modifier}+Shift+l" = "nop layman move right"; + # Switch to layman mode + "${modifier}+g" = "mode layout"; }; + modes = lib.mkOptionDefault { + layout = { + h = "nop layman none"; + j = "nop layman Autotiling"; + k = "nop layman Grid"; + l = "nop layman MasterStack"; + Escape = "mode default"; + Return = "mode default"; + }; + }; + # Setup a custom mode for layman operations # Turn on numlock by default input = { "*" = { xkb_numlock = "enable"; }; @@ -216,6 +236,42 @@ in with lib; { 'org.jellyfin.' = '' ''; }; + ## layman + # First setup the service + systemd.user.services.layman = { + Unit = { + Description = "layman - sway layout manager"; + After = [ "graphical-session.target" ]; + }; + Service = { + Type = "simple"; + ExecStart = '' + ${layman-package}/bin/layman + ''; + Restart = "always"; + }; + Install = { WantedBy = [ "graphical-session.target" ]; }; + }; + # then setup the configuration + xdg.configFile."layman" = { + target = "layman/config.toml"; + text = '' + # The `layman` section configures options that apply to the layman daemon, and any fallback + # values for options not set in a [workspace] or [output] section. + [layman] + defaultLayout = "none" # The default WLM to assign to a workspace + excludedWorkspaces = [] # Numbers of workspaces to be excuded + excludedOutputs = [] # Names of outputs to be excuded + debug = true # Enable logging debug messages globaly + depthLimit = 0 # Autotiling: Default depth limit (disabled) for all workspaces + stackLayout = "splitv" # MasterStack: Default stack layout for all workspaces + stackSidet = "left" # MasterStack: Default stack position for all workspaces + masterWidth = 65 # MasterStack: Default master width for all workspaces + ''; + onChange = '' + ${layman-package}/bin/layman || true + ''; + }; ######################### ## Mako (notifications) #########################