1

Refine hyprland autostart option

This commit is contained in:
2024-06-03 20:36:18 +02:00
parent dbc84a1d97
commit fc62ee87ae
2 changed files with 195 additions and 174 deletions

View File

@ -26,36 +26,6 @@ in {
iconTheme.name = "Papirus"; iconTheme.name = "Papirus";
}; };
# TODO: catppuccin-cursors
home.pointerCursor = {
gtk.enable = true;
x11.enable = true;
package = pkgs.bibata-cursors;
name = "Bibata-Modern-Classic";
# package = pkgs.catppuccin-cursors.latteMauve;
# name = "Catppuccin-Latte-Mauve-Cursors";
size = 16;
};
home.packages = with pkgs; [
hyprpaper # Wallpaper setter
hyprpicker # Color picker
wl-clipboard
clipman # Clipboard manager (wl-paste)
libnotify
inotifyTools # inotifywait etc.
moc # Audio player
ncpamixer # ncurses pavucontrol
slurp # Region selector for screensharing
grim # Grab images from compositor
# xfce.thunar
# xfce.tumbler # Thunar thumbnails
libsForQt5.polkit-kde-agent
];
programs = { programs = {
imv = { imv = {
enable = true; enable = true;
@ -104,20 +74,52 @@ in {
}; };
}; };
home.sessionVariables = { home = {
# TODO: catppuccin-cursors
pointerCursor = {
gtk.enable = true;
x11.enable = true;
package = pkgs.bibata-cursors;
name = "Bibata-Modern-Classic";
# package = pkgs.catppuccin-cursors.latteMauve;
# name = "Catppuccin-Latte-Mauve-Cursors";
size = 16;
};
packages = with pkgs; [
hyprpaper # Wallpaper setter
hyprpicker # Color picker
wl-clipboard
clipman # Clipboard manager (wl-paste)
libnotify
inotifyTools # inotifywait etc.
moc # Audio player
ncpamixer # ncurses pavucontrol
slurp # Region selector for screensharing
grim # Grab images from compositor
# xfce.thunar
# xfce.tumbler # Thunar thumbnails
libsForQt5.polkit-kde-agent
];
sessionVariables = {
}; };
# #
# Generate many individual config files from the options # Generate many individual config files from the options
# #
file = {
# Polkit # Polkit
home.file.".config/hypr/polkit.conf".text = '' ".config/hypr/polkit.conf".text = ''
exec-once = ${pkgs.libsForQt5.polkit-kde-agent}/libexec/polkit-kde-authentication-agent-1 exec-once = ${pkgs.libsForQt5.polkit-kde-agent}/libexec/polkit-kde-authentication-agent-1
''; '';
# Monitors for different systems # Monitors for different systems
home.file.".config/hypr/monitors.conf".text = let ".config/hypr/monitors.conf".text = let
mkMonitor = name: conf: "monitor = ${name}, ${toString conf.width}x${toString conf.height}@${toString conf.rate}, ${toString conf.x}x${toString conf.y}, ${toString conf.scale}"; mkMonitor = name: conf: "monitor = ${name}, ${toString conf.width}x${toString conf.height}@${toString conf.rate}, ${toString conf.x}x${toString conf.y}, ${toString conf.scale}";
in in
lib.pipe cfg.monitors [ lib.pipe cfg.monitors [
@ -127,7 +129,7 @@ in {
]; ];
# Bind workspaces to monitors # Bind workspaces to monitors
home.file.".config/hypr/workspaces.conf".text = let ".config/hypr/workspaces.conf".text = let
mkWorkspace = monitor: workspace: "workspace = ${toString workspace}, monitor:${toString monitor}"; mkWorkspace = monitor: workspace: "workspace = ${toString workspace}, monitor:${toString monitor}";
mkWorkspaces = monitor: workspace-list: map (mkWorkspace monitor) workspace-list; mkWorkspaces = monitor: workspace-list: map (mkWorkspace monitor) workspace-list;
in in
@ -139,7 +141,7 @@ in {
]; ];
# Keybindings # Keybindings
home.file.".config/hypr/keybindings.conf".text = let ".config/hypr/keybindings.conf".text = let
always-bind = { always-bind = {
# Hyprland control # Hyprland control
"$mainMod, Q" = ["killactive"]; "$mainMod, Q" = ["killactive"];
@ -164,7 +166,7 @@ in {
''; '';
# Autostart applications # Autostart applications
home.file.".config/hypr/autostart.conf".text = let ".config/hypr/autostart.conf".text = let
# Stuff that is not negotiable # Stuff that is not negotiable
always-exec = [ always-exec = [
"dunst" # Notifications "dunst" # Notifications
@ -174,17 +176,22 @@ in {
"hyprctl setcursor Bibata-Modern-Classic 16" "hyprctl setcursor Bibata-Modern-Classic 16"
]; ];
# NOTE: The sleep is a hack for tray icons, they need to be launched after waybar
sleepTime = 5;
mkDelayedStart = str: "hyprctl dispatch exec \"sleep ${builtins.toString sleepTime}s && ${str}\"";
delayed-exec = builtins.map mkDelayedStart cfg.autostart.delayed;
mkExec = prog: "exec-once = ${prog}"; mkExec = prog: "exec-once = ${prog}";
in in
lib.pipe (cfg.autostart ++ always-exec) [ lib.pipe (always-exec ++ cfg.autostart.immediate ++ delayed-exec) [
(builtins.map mkExec) (builtins.map mkExec)
(builtins.concatStringsSep "\n") (builtins.concatStringsSep "\n")
]; ];
# Assign windows to workspaces # Assign windows to workspaces
home.file.".config/hypr/workspacerules.conf".text = let ".config/hypr/workspacerules.conf".text = let
mkWorkspaceRule = workspace: class: "windowrulev2 = workspace ${workspace}, class:^(${class})$"; mkWorkspaceRule = workspace: class: "windowrulev2 = workspace ${workspace}, class:^(${class})$";
mkWorkspaceRules = workspace: class-list: map (mkWorkspaceRule workspace) class-list; mkWorkspaceRules = workspace: class-list: builtins.map (mkWorkspaceRule workspace) class-list;
in in
lib.pipe cfg.workspacerules [ lib.pipe cfg.workspacerules [
(builtins.mapAttrs mkWorkspaceRules) (builtins.mapAttrs mkWorkspaceRules)
@ -194,7 +201,7 @@ in {
]; ];
# Make windows float # Make windows float
home.file.".config/hypr/floatingrules.conf".text = let ".config/hypr/floatingrules.conf".text = let
mkFloatingRule = attrs: mkFloatingRule = attrs:
"windowrulev2 = float" "windowrulev2 = float"
+ (lib.optionalString (builtins.hasAttr "class" attrs) ", class:^(${attrs.class})$") + (lib.optionalString (builtins.hasAttr "class" attrs) ", class:^(${attrs.class})$")
@ -206,7 +213,7 @@ in {
]; ];
# Make windows translucent # Make windows translucent
home.file.".config/hypr/translucentrules.conf".text = let ".config/hypr/translucentrules.conf".text = let
opacity = 0.8; opacity = 0.8;
mkTranslucentRule = class: "windowrulev2 = opacity ${toString opacity} ${toString opacity}, class:^(${class})$"; mkTranslucentRule = class: "windowrulev2 = opacity ${toString opacity} ${toString opacity}, class:^(${class})$";
in in
@ -216,7 +223,7 @@ in {
]; ];
# Set wallpaper for each configured monitor # Set wallpaper for each configured monitor
home.file.".config/hypr/hyprpaper.conf".text = let ".config/hypr/hyprpaper.conf".text = let
mkWallpaper = monitor: "wallpaper = ${monitor}, ${config.home.homeDirectory}/NixFlake/wallpapers/${cfg.theme}.png"; mkWallpaper = monitor: "wallpaper = ${monitor}, ${config.home.homeDirectory}/NixFlake/wallpapers/${cfg.theme}.png";
wallpapers = lib.pipe cfg.monitors [ wallpapers = lib.pipe cfg.monitors [
builtins.attrNames builtins.attrNames
@ -229,7 +236,7 @@ in {
''; '';
# Keyboard layout # Keyboard layout
home.file.".config/hypr/input.conf".text = '' ".config/hypr/input.conf".text = ''
input { input {
kb_layout = ${cfg.kb-layout} kb_layout = ${cfg.kb-layout}
kb_variant = ${cfg.kb-variant} kb_variant = ${cfg.kb-variant}
@ -246,13 +253,15 @@ in {
sensitivity = 0 # -1.0 - 1.0, 0 means no modification. sensitivity = 0 # -1.0 - 1.0, 0 means no modification.
} }
''; '';
};
home.activation = { activation = {
# NOTE: Keep the hyprland config symlinked, to allow easy changes with hotreload
# TODO: Don't symlink at all, why not just tell Hyprland where the config is? Much easier # TODO: Don't symlink at all, why not just tell Hyprland where the config is? Much easier
# NOTE: Keep the hyprland config symlinked, to allow easy changes with hotreload
linkHyprlandConfig = linkHyprlandConfig =
lib.hm.dag.entryAfter ["writeBoundary"] lib.hm.dag.entryAfter ["writeBoundary"]
(mylib.modules.mkLink "~/NixFlake/config/hyprland/hyprland.conf" "~/.config/hypr/hyprland.conf"); (mylib.modules.mkLink "~/NixFlake/config/hyprland/hyprland.conf" "~/.config/hypr/hyprland.conf");
}; };
}; };
};
} }

View File

@ -53,9 +53,20 @@ with mylib.modules; {
''; '';
}; };
autostart = mkOption { autostart = {
immediate = mkOption {
type = types.listOf types.str; type = types.listOf types.str;
description = "Programs to launch when Hyprland starts"; description = "Programs to launch when Hyprland starts";
example = ''
[
"kitty"
]
'';
};
delayed = mkOption {
type = types.listOf types.str;
description = "Programs to launch with a delay when Hyprland starts (e.g. to wait for the waybar tray)";
example = '' example = ''
[ [
"keepassxc" "keepassxc"
@ -63,6 +74,7 @@ with mylib.modules; {
] ]
''; '';
}; };
};
workspacerules = mkOption { workspacerules = mkOption {
type = types.attrs; type = types.attrs;