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

6
flake.lock generated
View file

@ -304,11 +304,11 @@
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs"
}, },
"locked": { "locked": {
"lastModified": 1727725142, "lastModified": 1728079598,
"narHash": "sha256-VHM8iZb1y/y0gOGD6Q/4Yey0OHczLrBNp6BLBiDwWFU=", "narHash": "sha256-RUOZKSntxbTN7seIzq9oGNgh3LP00CDtspEDVyuD1hM=",
"owner": "tristanbeedell", "owner": "tristanbeedell",
"repo": "home-manager", "repo": "home-manager",
"rev": "ed1eed53419d49d7de94e34678e3261dbdd07dfd", "rev": "faf69fb8d9690429cc1d55ae39c5c40cdded71ff",
"type": "github" "type": "github"
}, },
"original": { "original": {

View file

@ -6,9 +6,7 @@
url = "github:nix-community/home-manager/master"; url = "github:nix-community/home-manager/master";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
home-manager-cosmic = { home-manager-cosmic.url = "github:tristanbeedell/home-manager/cosmic";
url = "github:tristanbeedell/home-manager/cosmic";
};
stylix.url = "github:danth/stylix"; stylix.url = "github:danth/stylix";
sops-nix.url = "github:Mic92/sops-nix"; sops-nix.url = "github:Mic92/sops-nix";
nixos-cosmic = { nixos-cosmic = {

View file

@ -1,178 +1,41 @@
{pkgs, config, ...}: let {pkgs, config, ...}: let
bind = mods: key: action: { inherit (config.lib.cosmic) Actions;
modifiers = ["Super"] ++ mods; in {
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 = { programs.cosmic = {
enable = true; enable = true;
defaultKeybindings = false; input.defaultKeybindings = false;
keybindings = [ input.binds = {
# Navigation # Navigation
(bind [Super] "h" (Actions.Focus "Left")) Super. "h" = (Actions.Focus "Left");
(bind [Super] "l" (Actions.Focus "Right")) Super. "l" = (Actions.Focus "Right");
(bind [Super] "j" (Actions.Focus "Down")) Super. "j" = (Actions.Focus "Down");
(bind [Super] "k" (Actions.Focus "Up")) Super. "k" = (Actions.Focus "Up");
(bind [Super Shift] "h" (Actions.Move "Left")) Super.Shift. "h" = (Actions.Move "Left");
(bind [Super Shift] "l" (Actions.Move "Right")) Super.Shift. "l" = (Actions.Move "Right");
(bind [Super Shift] "j" (Actions.Move "Down")) Super.Shift. "j" = (Actions.Move "Down");
(bind [Super Shift] "k" (Actions.Move "Up")) Super.Shift. "k" = (Actions.Move "Up");
Super. "1" = (Actions.Workspace 1);
(bind [Super] "1" (Actions.Workspace 1)) Super. "2" = (Actions.Workspace 2);
(bind [Super] "2" (Actions.Workspace 2)) Super. "3" = (Actions.Workspace 3);
(bind [Super] "3" (Actions.Workspace 3)) Super. "4" = (Actions.Workspace 4);
(bind [Super] "4" (Actions.Workspace 4)) Super. "5" = (Actions.Workspace 5);
(bind [Super] "5" (Actions.Workspace 5)) Super.Shift. "1" = (Actions.MoveToWorkspace 1);
(bind [Super Shift] "1" (Actions.MoveToWorkspace 1)) Super.Shift. "2" = (Actions.MoveToWorkspace 2);
(bind [Super Shift] "2" (Actions.MoveToWorkspace 2)) Super.Shift. "3" = (Actions.MoveToWorkspace 3);
(bind [Super Shift] "3" (Actions.MoveToWorkspace 3)) Super.Shift. "4" = (Actions.MoveToWorkspace 4);
(bind [Super Shift] "4" (Actions.MoveToWorkspace 4)) Super.Shift. "5" = (Actions.MoveToWorkspace 5);
(bind [Super Shift] "5" (Actions.MoveToWorkspace 5)) Super. "Space" = Actions.ToggleWindowFloating;
Super. "f" = Actions.Maximize;
(bind [Super] "Space" Actions.ToggleWindowFloating) Super. "m" = Actions.Minimize;
(bind [Super] "f" Actions.Maximize) Super.Shift. "x" = Actions.Close;
(bind [Super] "m" Actions.Minimize) Super.Shift. "v" = Actions.ToggleStacking;
(bind [Super Shift] "x" Actions.Close) Super.Shift. "y" = Actions.ToggleSticky;
(bind [Super Shift] "v" Actions.ToggleStacking)
(bind [Super Shift] "y" Actions.ToggleSticky)
# System # System
(bind [Super] "d" (Actions.Spawn config.programs.menu.drunCommand)) Super. "d" = (Actions.Spawn config.programs.menu.drunCommand);
(bind [Super] "Return" (Actions.Spawn "${pkgs.alacritty}/bin/alacritty")) Super. "Return" = (Actions.Spawn pkgs.alacritty);
(bind [Super] "o" (Actions.System "HomeFolder")) Super. "o" = (Actions.System "HomeFolder");
(bind [Super Shift] "s" (Actions.Spawn "cosmic-screenshot")) Super.Shift. "s" = (Actions.Spawn "cosmic-screenshot");
]; };
background = { background = {
displays = { displays = {
all = { all = {
@ -180,21 +43,21 @@ in with Modifiers; {
}; };
}; };
}; };
panels = { # panels = {
Panel = { # Panel = {
applets = { # applets = {
start = [ "com.system76.CosmicAppletWorkspaces" ]; # start = [ "com.system76.CosmicAppletWorkspaces" ];
center = [ "com.system76.CosmicAppList" ]; # center = [ "com.system76.CosmicAppList" ];
end = [ # end = [
"com.system76.CosmicAppletTime" # "com.system76.CosmicAppletTime"
"com.system76.CosmicAppletAudio" # "com.system76.CosmicAppletAudio"
"com.system76.CosmicAppletNotifications" # "com.system76.CosmicAppletNotifications"
"com.system76.CosmicAppletMinimize" # "com.system76.CosmicAppletMinimize"
"com.system76.CosmicAppletPower" # "com.system76.CosmicAppletPower"
]; # ];
}; # };
}; # };
}; # };
settings = { settings = {
"com.system76.CosmicComp".options = { "com.system76.CosmicComp".options = {
autotile = true; autotile = true;