{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; { programs.cosmic = { enable = true; defaultKeybindings = false; keybindings = [ # 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) # 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")) ]; background = { displays = { all = { source = ../../../images/nier2.jpg; }; }; }; 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; active_hint = true; focus_follows_cursor = true; focus_follows_cursor_delay = 0; cursor_follows_focus = true; }; }; }; }