From ab83a2ed2597c95147deb778f3e54c59a49f9c24 Mon Sep 17 00:00:00 2001 From: tristan Date: Sun, 6 Oct 2024 18:05:22 +0100 Subject: [PATCH] cosmic: update module --- flake.lock | 6 +- flake.nix | 4 +- home/desktop/cosmic/default.nix | 233 +++++++------------------------- 3 files changed, 52 insertions(+), 191 deletions(-) diff --git a/flake.lock b/flake.lock index f03dd3b..03dee71 100644 --- a/flake.lock +++ b/flake.lock @@ -304,11 +304,11 @@ "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1727725142, - "narHash": "sha256-VHM8iZb1y/y0gOGD6Q/4Yey0OHczLrBNp6BLBiDwWFU=", + "lastModified": 1728079598, + "narHash": "sha256-RUOZKSntxbTN7seIzq9oGNgh3LP00CDtspEDVyuD1hM=", "owner": "tristanbeedell", "repo": "home-manager", - "rev": "ed1eed53419d49d7de94e34678e3261dbdd07dfd", + "rev": "faf69fb8d9690429cc1d55ae39c5c40cdded71ff", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 060f1ce..b81f9ac 100644 --- a/flake.nix +++ b/flake.nix @@ -6,9 +6,7 @@ url = "github:nix-community/home-manager/master"; inputs.nixpkgs.follows = "nixpkgs"; }; - home-manager-cosmic = { - url = "github:tristanbeedell/home-manager/cosmic"; - }; + home-manager-cosmic.url = "github:tristanbeedell/home-manager/cosmic"; stylix.url = "github:danth/stylix"; sops-nix.url = "github:Mic92/sops-nix"; nixos-cosmic = { diff --git a/home/desktop/cosmic/default.nix b/home/desktop/cosmic/default.nix index d87403b..6116d5c 100644 --- a/home/desktop/cosmic/default.nix +++ b/home/desktop/cosmic/default.nix @@ -1,178 +1,41 @@ {pkgs, config, ...}: let - bind = mods: key: action: { - modifiers = ["Super"] ++ mods; - inherit key action; - }; - _action = type: value: { - inherit type value; - }; - Actions = (enum [ - # Close the active window - "Close" - - # Show a debug overlay if enabled in the compositor build - "Debug" - - # Disable a default shortcut binding - "Disable" - - # Change focus to the last workspace - "LastWorkspace" - - # Maximize the active window - "Maximize" - - # Migrate the active workspace to the next output - "MigrateWorkspaceToNextOutput" - - # Migrate the active workspace to the previous output - "MigrateWorkspaceToPreviousOutput" - - # Minimize the active window - "Minimize" - - # Move a window to the last workspace - "MoveToLastWorkspace" - - # Move a window to the next output - "MoveToNextOutput" - - # Move a window to the next workspace - "MoveToNextWorkspace" - - # Move a window to the previous output - "MoveToPreviousOutput" - - # Move a window to the previous workspace - "MoveToPreviousWorkspace" - - # Change focus to the next output - "NextOutput" - - # Change focus to the next workspace - "NextWorkspace" - - # Change focus to the previous output - "PreviousOutput" - - # Change focus to the previous workspace - "PreviousWorkspace" - - # Move a window to the last workspace - "SendToLastWorkspace" - - # Move a window to the next output - "SendToNextOutput" - - # Move a window to the next workspace - "SendToNextWorkspace" - - # Move a window to the previous output - "SendToPreviousOutput" - - # Move a window to the previous workspace - "SendToPreviousWorkspace" - - # Swap positions of the active window with another - "SwapWindow" - - # Stop the compositor - "Terminate" - - # Toggle the orientation of a tiling group - "ToggleOrientation" - - # Toggle window stacking for the active window - "ToggleStacking" - - # Toggle the sticky state of the active window - "ToggleSticky" - - # Toggle tiling mode of the active workspace - "ToggleTiling" - - # Toggle between tiling and floating window states for the active window - "ToggleWindowFloating" - - ]) // { - - # Change focus to the window or workspace in the given direction - "Focus" = FocusDirection: _action "Focus" FocusDirection; - # Migrate the active workspace to the output in the given direction - "MigrateWorkspaceToOutput" = Direction: _action "MigrateWorkspaceToOutput" Direction; - # Move a window in the given direction - Move = Direction: _action "Move" Direction; - # Move a window to the given output - MoveToOutput = Direction: _action "MoveToOutput" Direction; - # Move a window to the given workspace - MoveToWorkspace = u8: _action "MoveToWorkspace" u8; - # Change the orientation of a tiling group - Orientation = Orientation: _action "Orientation" Orientation; - # Resize the active window in a given direction - Resizing = ResizeDirection: _action "Resizing" ResizeDirection; - # Move a window to the output in the given direction - SendToOutput = Direction: _action "SendToOutput" Direction; - # Move a window to the given workspace - SendToWorkspace = u8: _action "SendToWorkspace" u8; - # Move to an output in the given direction - SwitchOutput = Direction: _action "SwitchOutput" Direction; - # Perform a common system operation - System = System: _action "System" System; - # Execute a command with any given arguments - Spawn = String: _action "Spawn" String; - # Change focus to the given workspace ID - Workspace = u8: _action "Workspace" u8; - - }; - - Modifiers = enum [ - "Super" - "Ctrl" - "Alt" - "Shift" - ]; - - enum = builtins.foldl' (acc: el: {${el}=el;} // acc) {}; - -in with Modifiers; { + inherit (config.lib.cosmic) Actions; +in { programs.cosmic = { enable = true; - defaultKeybindings = false; - keybindings = [ + input.defaultKeybindings = false; + input.binds = { # Navigation - (bind [Super] "h" (Actions.Focus "Left")) - (bind [Super] "l" (Actions.Focus "Right")) - (bind [Super] "j" (Actions.Focus "Down")) - (bind [Super] "k" (Actions.Focus "Up")) - (bind [Super Shift] "h" (Actions.Move "Left")) - (bind [Super Shift] "l" (Actions.Move "Right")) - (bind [Super Shift] "j" (Actions.Move "Down")) - (bind [Super Shift] "k" (Actions.Move "Up")) - - (bind [Super] "1" (Actions.Workspace 1)) - (bind [Super] "2" (Actions.Workspace 2)) - (bind [Super] "3" (Actions.Workspace 3)) - (bind [Super] "4" (Actions.Workspace 4)) - (bind [Super] "5" (Actions.Workspace 5)) - (bind [Super Shift] "1" (Actions.MoveToWorkspace 1)) - (bind [Super Shift] "2" (Actions.MoveToWorkspace 2)) - (bind [Super Shift] "3" (Actions.MoveToWorkspace 3)) - (bind [Super Shift] "4" (Actions.MoveToWorkspace 4)) - (bind [Super Shift] "5" (Actions.MoveToWorkspace 5)) - - (bind [Super] "Space" Actions.ToggleWindowFloating) - (bind [Super] "f" Actions.Maximize) - (bind [Super] "m" Actions.Minimize) - (bind [Super Shift] "x" Actions.Close) - - (bind [Super Shift] "v" Actions.ToggleStacking) - (bind [Super Shift] "y" Actions.ToggleSticky) + Super. "h" = (Actions.Focus "Left"); + Super. "l" = (Actions.Focus "Right"); + Super. "j" = (Actions.Focus "Down"); + Super. "k" = (Actions.Focus "Up"); + Super.Shift. "h" = (Actions.Move "Left"); + Super.Shift. "l" = (Actions.Move "Right"); + Super.Shift. "j" = (Actions.Move "Down"); + Super.Shift. "k" = (Actions.Move "Up"); + Super. "1" = (Actions.Workspace 1); + Super. "2" = (Actions.Workspace 2); + Super. "3" = (Actions.Workspace 3); + Super. "4" = (Actions.Workspace 4); + Super. "5" = (Actions.Workspace 5); + Super.Shift. "1" = (Actions.MoveToWorkspace 1); + Super.Shift. "2" = (Actions.MoveToWorkspace 2); + Super.Shift. "3" = (Actions.MoveToWorkspace 3); + Super.Shift. "4" = (Actions.MoveToWorkspace 4); + Super.Shift. "5" = (Actions.MoveToWorkspace 5); + Super. "Space" = Actions.ToggleWindowFloating; + Super. "f" = Actions.Maximize; + Super. "m" = Actions.Minimize; + Super.Shift. "x" = Actions.Close; + Super.Shift. "v" = Actions.ToggleStacking; + Super.Shift. "y" = Actions.ToggleSticky; # System - (bind [Super] "d" (Actions.Spawn config.programs.menu.drunCommand)) - (bind [Super] "Return" (Actions.Spawn "${pkgs.alacritty}/bin/alacritty")) - (bind [Super] "o" (Actions.System "HomeFolder")) - (bind [Super Shift] "s" (Actions.Spawn "cosmic-screenshot")) - ]; + Super. "d" = (Actions.Spawn config.programs.menu.drunCommand); + Super. "Return" = (Actions.Spawn pkgs.alacritty); + Super. "o" = (Actions.System "HomeFolder"); + Super.Shift. "s" = (Actions.Spawn "cosmic-screenshot"); + }; background = { displays = { all = { @@ -180,21 +43,21 @@ in with Modifiers; { }; }; }; - panels = { - Panel = { - applets = { - start = [ "com.system76.CosmicAppletWorkspaces" ]; - center = [ "com.system76.CosmicAppList" ]; - end = [ - "com.system76.CosmicAppletTime" - "com.system76.CosmicAppletAudio" - "com.system76.CosmicAppletNotifications" - "com.system76.CosmicAppletMinimize" - "com.system76.CosmicAppletPower" - ]; - }; - }; - }; + # panels = { + # Panel = { + # applets = { + # start = [ "com.system76.CosmicAppletWorkspaces" ]; + # center = [ "com.system76.CosmicAppList" ]; + # end = [ + # "com.system76.CosmicAppletTime" + # "com.system76.CosmicAppletAudio" + # "com.system76.CosmicAppletNotifications" + # "com.system76.CosmicAppletMinimize" + # "com.system76.CosmicAppletPower" + # ]; + # }; + # }; + # }; settings = { "com.system76.CosmicComp".options = { autotile = true;