feat: add window manager options

This commit is contained in:
danny 2026-02-04 18:21:40 +08:00
parent b4b7997ac5
commit 601dfb9217
31 changed files with 2006 additions and 821 deletions

View file

@ -1,118 +1,123 @@
{
osConfig,
config,
lib,
pkgs,
inputs,
...
}:
let
inherit (lib) mkIf;
inherit (pkgs.stdenv.hostPlatform) system;
terminal = "ghostty";
execOnceScript = pkgs.writeShellScript "hyprlandExecOnce" ''
# Fix nemo open in terminal
dconf write /org/cinnamon/desktop/applications/terminal/exec "''\'${terminal}''\'" &
dconf write /org/cinnamon/desktop/applications/terminal/exec-arg "''\'''\'" &
systemctl --user import-environment WAYLAND_DISPLAY XDG_CURRENT_DESKTOP QT_QPA_PLATFORMTHEME &
dbus-update-activation-environment --systemd HYPRLAND_INSTANCE_SIGNATURE
# Hint dark theme
gsettings set org.gnome.desktop.interface color-scheme "prefer-dark"
'';
mainMod = "SUPER";
wmCfg = config.wm;
bindCfg = wmCfg.keybinds;
mainMod = bindCfg.mod;
in
{
home.packages = with pkgs; [
hyprcursor
];
imports = [
(import ./hypr/bind.nix { inherit mainMod; })
./hypr/workspace.nix
./hypr/window.nix
./hypr/windowrule.nix
./hypr/input.nix
];
wayland.windowManager.hyprland = {
enable = true;
xwayland.enable = true;
systemd = {
enable = true;
variables = [ "--all" ];
};
package = null;
portalPackage = null;
plugins = (
with inputs.hyprland-plugins.packages.${system};
[
hyprwinwrap
]
);
settings = {
"$mainMod" = mainMod;
debug = {
disable_logs = true;
config = mkIf osConfig.programs.hyprland.enable {
wm = {
exec-once = /* bash */ ''
dbus-update-activation-environment --systemd HYPRLAND_INSTANCE_SIGNATURE
'';
keybinds = {
mod = "SUPER";
separator = ",";
hypr-type = true;
};
};
ecosystem.no_update_news = true;
home.packages = with pkgs; [
hyprcursor
];
bindm = [
# Move/resize windows with mainMod + LMB/RMB and dragging
''${mainMod}, mouse:272, movewindow''
''${mainMod}, mouse:273, resizewindow''
];
imports = [
(import ./hypr/bind.nix { inherit mainMod; })
./hypr/workspace.nix
./hypr/window.nix
./hypr/windowrule.nix
./hypr/input.nix
];
binde =
let
resizeStep = builtins.toString 20;
brightnessStep = builtins.toString 10;
volumeStep = builtins.toString 4;
in
wayland.windowManager.hyprland = {
enable = true;
xwayland.enable = true;
systemd = {
enable = true;
variables = [ "--all" ];
};
package = null;
portalPackage = null;
plugins = (
with inputs.hyprland-plugins.packages.${system};
[
'',XF86AudioRaiseVolume, exec, wpctl set-mute @DEFAULT_SINK@ 0 && wpctl set-volume @DEFAULT_SINK@ ${volumeStep}%+''
'',XF86AudioLowerVolume, exec, wpctl set-mute @DEFAULT_SINK@ 0 && wpctl set-volume @DEFAULT_SINK@ ${volumeStep}%-''
'',XF86MonBrightnessDown, exec, brightnessctl set ${brightnessStep}%-''
'',XF86MonBrightnessUp, exec, brightnessctl set ${brightnessStep}%+''
''${mainMod} CTRL, l, resizeactive, ${resizeStep} 0''
''${mainMod} CTRL, h, resizeactive, -${resizeStep} 0''
''${mainMod} CTRL, k, resizeactive, 0 -${resizeStep}''
''${mainMod} CTRL, j, resizeactive, 0 ${resizeStep}''
hyprwinwrap
]
);
settings = {
"$mainMod" = mainMod;
debug = {
disable_logs = true;
};
ecosystem.no_update_news = true;
bindm = [
# Move/resize windows with mainMod + LMB/RMB and dragging
"${mainMod}, mouse:272, movewindow"
"${mainMod}, mouse:273, resizewindow"
];
plugin = {
hyprwinrap = {
class = "kitty-bg";
binde =
let
resizeStep = toString 20;
brightnessStep = toString 10;
volumeStep = toString 4;
in
[
",XF86AudioRaiseVolume, exec, wpctl set-mute @DEFAULT_SINK@ 0 && wpctl set-volume @DEFAULT_SINK@ ${volumeStep}%+"
",XF86AudioLowerVolume, exec, wpctl set-mute @DEFAULT_SINK@ 0 && wpctl set-volume @DEFAULT_SINK@ ${volumeStep}%-"
",XF86MonBrightnessDown, exec, brightnessctl set ${brightnessStep}%-"
",XF86MonBrightnessUp, exec, brightnessctl set ${brightnessStep}%+"
"${mainMod} CTRL, l, resizeactive, ${resizeStep} 0"
"${mainMod} CTRL, h, resizeactive, -${resizeStep} 0"
"${mainMod} CTRL, k, resizeactive, 0 -${resizeStep}"
"${mainMod} CTRL, j, resizeactive, 0 ${resizeStep}"
];
plugin = {
hyprwinrap = {
class = "kitty-bg";
};
touch_gestures = {
sensitivity = 4.0;
workspace_swipe_fingers = 3;
workspace_swipe_edge = "d";
long_press_delay = 400;
resize_on_border_long_press = true;
edge_margin = 10;
emulate_touchpad_swipe = false;
};
};
touch_gestures = {
sensitivity = 4.0;
workspace_swipe_fingers = 3;
workspace_swipe_edge = "d";
long_press_delay = 400;
resize_on_border_long_press = true;
edge_margin = 10;
emulate_touchpad_swipe = false;
exec-once = [ "${wmCfg.exec-once}" ];
env = [
"XDG_CURRENT_DESKTOP, Hyprland"
"XDG_SESSION_DESKTOP, Hyprland"
"GDK_PIXBUF_MODULE_FILE, ${pkgs.librsvg}/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache"
];
misc = {
disable_hyprland_logo = true;
force_default_wallpaper = 0;
disable_splash_rendering = true;
};
};
exec-once = [ "${execOnceScript}" ];
env = [
''XDG_CURRENT_DESKTOP, Hyprland''
''XDG_SESSION_DESKTOP, Hyprland''
''GDK_PIXBUF_MODULE_FILE, ${pkgs.librsvg}/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache''
];
misc = {
disable_hyprland_logo = true;
force_default_wallpaper = 0;
disable_splash_rendering = true;
};
};
};
}

93
home/user/wm.nix Normal file
View file

@ -0,0 +1,93 @@
{
pkgs,
lib,
config,
...
}:
let
inherit (lib) getExe getExe';
# ==== binary ==== #
rofi = getExe pkgs.rofi;
playerctl = getExe pkgs.playerctl;
wpctl = getExe' pkgs.wireplumber "wpctl";
brightnessctl = getExe pkgs.brightnessctl;
brightnessStep = toString 10;
volumeStep = toString 4;
rofiWall = import ../../home/scripts/rofiwall.nix { inherit config pkgs; };
rbwSelector = import ../../home/scripts/rbwSelector.nix { inherit pkgs; };
toggleWlogout = pkgs.writeShellScript "toggleWlogout" ''
if ${pkgs.busybox}/bin/pgrep wlogout > /dev/null; then
${pkgs.busybox}/bin/pkill wlogout
else
${getExe config.programs.wlogout.package} --protocol layer-shell
fi
'';
cfg = config.wm;
mod = cfg.keybinds.mod;
sep = cfg.keybinds.separator;
in
{
wm = {
exec-once = /* bash */ ''
# Fix nemo open in terminal
dconf write /org/cinnamon/desktop/applications/terminal/exec "''\'${cfg.app.terminal.name}''\'" &
dconf write /org/cinnamon/desktop/applications/terminal/exec-arg "''\'''\'" &
# Hint dark theme
dconf write /org/gnome/desktop/interface/color-scheme '"prefer-dark"' &
systemctl --user import-environment WAYLAND_DISPLAY XDG_CURRENT_DESKTOP QT_QPA_PLATFORMTHEME &
'';
app = {
terminal = {
package = config.programs.ghostty.package;
name = "ghostty";
run = "ghostty -e";
};
browser = {
package = config.programs.zen-browser.package;
name = "zen-twilight";
};
file-browser = {
package = config.programs.yazi.pacakge;
name = "yazi";
};
};
keybinds = {
spawn-repeat = {
# ==== Media ==== #
"XF86AudioPrev" = "${playerctl} previous";
"XF86AudioNext" = "${playerctl} next";
"${mod}${sep}CTRL${sep}COMMA" = "${playerctl} previous";
"${mod}${sep}CTRL${sep}PERIOD" = "${playerctl} next";
"XF86AudioPlay" = "${playerctl} play-pause";
"XF86AudioStop" = "${playerctl} stop";
"XF86AudioMute" = "${wpctl} set-mute @DEFAULT_SINK@ toggle";
"XF86AudioRaiseVolume" =
"${wpctl} set-mute @DEFAULT_SINK@ 0 && ${wpctl} set-volume @DEFAULT_SINK@ ${volumeStep}%+";
"XF86AudioLowerVolume" =
"${wpctl} set-mute @DEFAULT_SINK@ 0 && ${wpctl} set-volume @DEFAULT_SINK@ ${volumeStep}%-";
"XF86MonBrightnessDown" = "${brightnessctl} set ${brightnessStep}%-";
"XF86MonBrightnessUp" = "${brightnessctl} set ${brightnessStep}%+";
};
spawn = {
"${mod}${sep}Return" = "${getExe cfg.app.terminal.package}";
"${mod}${sep}F" = "${getExe cfg.app.browser.package}";
"${mod}${sep}E" = "${cfg.app.terminal.run} ${cfg.app.file-browser.name}";
"${mod}${sep}CTRL${sep}P" = "${rbwSelector}";
"${mod}${sep}CTRL${sep}M" = "${toggleWlogout}";
# Launcher
"${mod}${sep}CTRL${sep}W" = "${rofiWall}";
"ALT${sep}SPACE" = "${rofi} -config config/rofi/apps.rasi -show drun";
"${mod}${sep}PERIOD" = "${rofi} -modi emoji -show emoji";
"${mod}${sep}CTRL${sep}C" = "${rofi} -modi calc -show calc -no-show-match -no-sort";
};
};
};
}

View file

@ -3,10 +3,12 @@
config,
helper,
pkgs,
lib,
...
}:
let
inherit (osConfig.systemConf) username;
inherit (lib) mkForce;
inherit (helper) capitalize;
inherit (pkgs) runCommand;
@ -14,7 +16,7 @@ let
owner = "JustAdumbPrsn";
repo = "zen-nebula";
rev = "main";
sha256 = "sha256-wtntRAkOGm6fr396kqzqk+GyPk+ytifXTqqOp0YIvlw=";
sha256 = "sha256-Eg9HsN+yDA8OdVcE9clS+FyUhVBH3ooN/odkZIVR/p4=";
};
patchedNebula =
@ -143,6 +145,8 @@ in
recursive = true;
};
home.file.".zen/${profileName}/search.json.mozlz4".force = mkForce true;
xdg.mimeApps =
let
value =