cosmic: update module

This commit is contained in:
tristan 2024-10-06 18:05:22 +01:00
parent ee902d57c8
commit ab83a2ed25
3 changed files with 52 additions and 191 deletions

View file

@ -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;