some refactor

This commit is contained in:
cnst
2024-11-01 17:19:21 +01:00
parent 7608e0f934
commit 81a45ac062
9 changed files with 251 additions and 251 deletions

View File

@@ -4,12 +4,12 @@
...
}: let
inherit (lib) mkIf mkEnableOption;
cfg = config.home.programs.hyprland.appearance;
cfg = config.home.programs.hyprland;
in {
options = {
home.programs.hyprland.appearance.enable = mkEnableOption "Enables appearance settings in Hyprland";
};
config = mkIf cfg.enable {
config = mkIf cfg.appearance.enable {
wayland.windowManager.hyprland.settings = {
general = {
gaps_in = 2;

View File

@@ -2,14 +2,11 @@
config,
lib,
pkgs,
umodPath,
osConfig,
...
}: let
inherit (lib) mkIf mkEnableOption mkOption types mkDefault;
cfg = config.home.programs.hyprland;
hyprlandPkg = pkgs.hyprland;
isCnst = osConfig.networking.hostName == "cnix";
in {
imports = [
./appearance.nix
@@ -22,6 +19,7 @@ in {
options = {
home.programs.hyprland = {
enable = mkEnableOption "Enable Hyprland";
user = mkOption {type = types.enum ["cnst" "toothpick"];};
};
};

View File

@@ -4,100 +4,112 @@
osConfig,
...
}: let
inherit (lib) mkIf mkEnableOption;
toothpc = osConfig.networking.hostName == "toothpc";
inherit (lib) mkIf mkEnableOption mkMerge;
kbOption =
if osConfig.networking.hostName == "cnixpad"
then "ctrl:swapcaps"
else "";
cfg = config.home.programs.hyprland.inputs;
renderSettings =
if toothpc
then {
explicit_sync = 0;
explicit_sync_kms = 0;
direct_scanout = false;
}
else {
explicit_sync = 2;
explicit_sync_kms = 2;
direct_scanout = false;
};
cursorSettings =
if toothpc
then {
no_hardware_cursors = true;
}
else {
no_hardware_cursors = 2;
};
cfg = config.home.programs.hyprland;
in {
options = {
home.programs.hyprland.inputs.enable = mkEnableOption "Enables input settings in Hyprland";
};
config = mkIf cfg.enable {
wayland.windowManager.hyprland.settings = {
monitor = map (
m: "${m.name},${
if m.enabled
then "${toString m.width}x${toString m.height}@${toString m.refreshRate},${m.position},1${
if m.bitDepth != null
then ",bitdepth,${toString m.bitDepth}"
else ""
}"
else "disable"
}"
) (config.monitors);
config = mkIf cfg.inputs.enable (mkMerge [
{
wayland.windowManager.hyprland.settings = {
monitor =
map (
m: "${m.name},${
if m.enabled
then "${toString m.width}x${toString m.height}@${toString m.refreshRate},${m.position},1${
if m.bitDepth != null
then ",bitdepth,${toString m.bitDepth}"
else ""
}"
else "disable"
}"
)
config.monitors;
workspace = map (
m: "name:${m.workspace},monitor:${m.name}"
) (lib.filter (m: m.enabled && m.workspace != null) config.monitors);
workspace = map (
m: "name:${m.workspace},monitor:${m.name}"
) (lib.filter (m: m.enabled && m.workspace != null) config.monitors);
env = [
"QT_WAYLAND_DISABLE_WINDOWDECORATION,1"
];
env = [
"QT_WAYLAND_DISABLE_WINDOWDECORATION,1"
];
input = {
kb_layout = "se";
kb_variant = "nodeadkeys";
kb_options = kbOption;
follow_mouse = 1;
accel_profile = "flat";
sensitivity = 0; # -1.0 - 1.0, 0 means no modification.
input = {
kb_layout = "se";
kb_variant = "nodeadkeys";
kb_options = kbOption;
follow_mouse = 1;
accel_profile = "flat";
sensitivity = 0; # -1.0 - 1.0, 0 means no modification.
touchpad = {
natural_scroll = true;
disable_while_typing = true;
clickfinger_behavior = true;
scroll_factor = 0.5;
touchpad = {
natural_scroll = true;
disable_while_typing = true;
clickfinger_behavior = true;
scroll_factor = 0.5;
};
};
gestures = {
workspace_swipe = true;
workspace_swipe_distance = 400;
workspace_swipe_fingers = 3;
workspace_swipe_cancel_ratio = 0.2;
workspace_swipe_min_speed_to_force = 5;
workspace_swipe_direction_lock = true;
workspace_swipe_direction_lock_threshold = 10;
workspace_swipe_create_new = true;
};
misc = {
vrr = 0;
mouse_move_enables_dpms = 1;
key_press_enables_dpms = 0;
force_default_wallpaper = 0;
disable_hyprland_logo = true;
disable_splash_rendering = true;
disable_autoreload = true;
};
xwayland = {
force_zero_scaling = false;
};
};
gestures = {
workspace_swipe = true;
workspace_swipe_distance = 400;
workspace_swipe_fingers = 3;
workspace_swipe_cancel_ratio = 0.2;
workspace_swipe_min_speed_to_force = 5;
workspace_swipe_direction_lock = true;
workspace_swipe_direction_lock_threshold = 10;
workspace_swipe_create_new = true;
}
(mkIf (cfg.user == "toothpick") {
wayland.windowManager.hyprland.settings.render = {
explicit_sync = 0;
explicit_sync_kms = 0;
direct_scanout = false;
};
misc = {
vrr = 0;
mouse_move_enables_dpms = 1;
key_press_enables_dpms = 0;
force_default_wallpaper = 0;
disable_hyprland_logo = true;
disable_splash_rendering = true;
disable_autoreload = true;
})
(mkIf (cfg.user != "toothpick") {
wayland.windowManager.hyprland.settings.render = {
explicit_sync = 2;
explicit_sync_kms = 2;
direct_scanout = false;
};
xwayland = {
force_zero_scaling = false;
})
(mkIf (cfg.user == "toothpick") {
wayland.windowManager.hyprland.settings.cursor = {
no_hardware_cursors = true;
};
render = renderSettings;
cursor = cursorSettings;
};
};
})
(mkIf (cfg.user != "toothpick") {
wayland.windowManager.hyprland.settings.cursor = {
no_hardware_cursors = 2;
};
})
]);
}

View File

@@ -5,130 +5,115 @@
osConfig,
...
}: let
inherit (lib) mkIf mkEnableOption;
cfg = config.home.programs.hyprland.keybinds;
inherit (lib) mkIf mkEnableOption mkMerge;
cfg = config.home.programs.hyprland;
in {
options = {
home.programs.hyprland.keybinds.enable = mkEnableOption "Enables keybind settings in Hyprland";
};
config = mkIf cfg.enable {
wayland.windowManager.hyprland.settings = let
cnixpad = osConfig.networking.hostName == "cnixpad";
toothpc = osConfig.networking.hostName == "toothpc";
modKey =
if (cnixpad || toothpc)
then "ALT_L"
else "SUPER";
term =
if (cnixpad || toothpc)
then "foot"
else "alacritty";
browser =
if toothpc
then "firefox"
else "zen";
in {
"$terminal" = term;
"$fileManager" = "thunar";
"$passwordManager" = "keepassxc";
"$menu" = "pkill anyrun || anyrun | xargs hyprctl dispatch exec --";
"$menuw" = "pkill anyrun || anyrun | xargs hyprctl dispatch exec --";
"$browser" = browser;
"$browserinc" = "${browser} --private-window";
"$yazi" = "alacritty -e yazi";
"$tuirun" = "tuirun-toggle.sh";
# See https://wiki.hyprland.org/Configuring/Keywords/ for more
"$mod" = modKey;
config = mkIf cfg.keybinds.enable (mkMerge [
{
wayland.windowManager.hyprland.settings = {
# Common Keybind Variables
"$fileManager" = "thunar";
"$passwordManager" = "keepassxc";
"$menu" = "pkill anyrun || anyrun | xargs hyprctl dispatch exec --";
"$menuw" = "pkill anyrun || anyrun | xargs hyprctl dispatch exec --";
"$yazi" = "alacritty -e yazi";
"$tuirun" = "tuirun-toggle.sh";
bind = let
grimblast = lib.getExe pkgs.grimblast;
tesseract = lib.getExe pkgs.tesseract;
notify-send = lib.getExe' pkgs.libnotify "notify-send";
in [
# Custom binds
"$mod SHIFT, B, exec, pkill -SIGUSR2 waybar" # Reload waybar
bind = [
"$mod SHIFT, B, exec, pkill -SIGUSR2 waybar"
"$mod, A, exec, pkill -SIGUSR1 waybar"
"$mod, T, exec, $terminal"
"$mod, W, exec, $browser"
"$mod, K, exec, $passwordManager"
"$mod SHIFT, W, exec, $browserinc"
"$mod, Q, killactive,"
"$mod, E, exec, $fileManager"
"$mod, R, exec, $tuirun"
"$mod SHIFT, E, exec, $yazi"
"$mod, F, fullscreen,"
"$mod SHIFT, F, togglefloating,"
"$mod, SPACE, exec, $tuirun"
"$mod, P, pseudo,"
"$mod, J, togglesplit,"
"$mod, C, exec, hyprctl dispatch exec copyq toggle"
"$mod, left, movefocus, l"
"$mod, right, movefocus, r"
"$mod, up, movefocus, u"
"$mod, down, movefocus, d"
"$mod, 1, workspace, 1"
"$mod, 2, workspace, 2"
"$mod, 3, workspace, 3"
"$mod, 4, workspace, 4"
"$mod, 5, workspace, 5"
"$mod, 6, workspace, 6"
"$mod, 7, workspace, 7"
"$mod, 8, workspace, 8"
"$mod, 9, workspace, 9"
"$mod, 0, workspace, 10"
"$mod SHIFT, 1, movetoworkspace, 1"
"$mod SHIFT, 2, movetoworkspace, 2"
"$mod SHIFT, 3, movetoworkspace, 3"
"$mod SHIFT, 4, movetoworkspace, 4"
"$mod SHIFT, 5, movetoworkspace, 5"
"$mod SHIFT, 6, movetoworkspace, 6"
"$mod SHIFT, 7, movetoworkspace, 7"
"$mod SHIFT, 8, movetoworkspace, 8"
"$mod SHIFT, 9, movetoworkspace, 9"
"$mod SHIFT, 0, movetoworkspace, 10"
",XF86AudioLowerVolume, exec, pamixer -d 5"
",XF86AudioRaiseVolume, exec, pamixer -i 5"
",XF86AudioMute, exec, pamixer -t"
",XF86AudioMicMute, exec, pactl -- set-source-mute 0 toggle"
",XF86MonBrightnessDown, exec, brightnessctl s 5%-"
",XF86MonBrightnessUp, exec, brightnessctl s +5%"
"$mod, XF86MonBrightnessUp, exec, hyprctl dispatch dpms on"
"$mod, XF86MonBrightnessDown, exec, hyprctl dispatch dpms off"
",Insert,exec,${lib.getExe pkgs.grimblast} --notify --freeze copysave area"
"SHIFT,Insert,exec,${lib.getExe pkgs.grimblast} --notify --freeze copysave output"
"ALT,Insert,exec,${lib.getExe pkgs.grimblast} --freeze save area - | ${lib.getExe pkgs.tesseract} - - | wl-copy && ${lib.getExe pkgs.libnotify}/bin/notify-send -t 3000 'OCR result copied to buffer'"
"$mod, S, togglespecialworkspace, magic"
"$mod SHIFT, S, movetoworkspace, special:magic"
];
# Example binds, see https://wiki.hyprland.org/Configuring/Binds/ for more
"$mod, A, exec, pkill -SIGUSR1 waybar"
"$mod, T, exec, $terminal"
"$mod, W, exec, $browser"
"$mod, K, exec, $passwordManager"
"$mod SHIFT, W, exec, $browserinc"
"$mod, Q, killactive,"
#bind = $mod, M, exec, hyprctl dispatch exit
#bind = $mod, E, exec, $fileManager
"$mod, E, exec, $fileManager"
"$mod, R, exec, $tuirun"
"$mod SHIFT, E, exec, $yazi"
"$mod, F, fullscreen,"
"$mod SHIFT, F, togglefloating,"
"$mod, SPACE, exec, $tuirun"
"$mod, P, pseudo," # dwindle
"$mod, J, togglesplit," # dwindle
"$mod, C, exec, hyprctl dispatch exec copyq toggle"
# "$mod, TAB, exec, $menuw"
bindm = [
"$mod, mouse:272, movewindow"
"$mod, mouse:273, resizewindow"
];
};
}
# Move focus with mainMod + arrow keys
"$mod, left, movefocus, l"
"$mod, right, movefocus, r"
"$mod, up, movefocus, u"
"$mod, down, movefocus, d"
(mkIf (cfg.user == "cnst") {
wayland.windowManager.hyprland.settings = let
cnixpad = osConfig.networking.hostName == "cnixpad";
modKey =
if cnixpad
then "ALT_L"
else "SUPER";
in {
"$terminal" = "alacritty";
"$browser" = "zen";
"$browserinc" = "zen --private-window";
"$mod" = modKey;
bind = [
# Add more host-specific binds as needed
];
};
})
# Switch workspaces with mainMod + [0-9]
"$mod, 1, workspace, 1"
"$mod, 2, workspace, 2"
"$mod, 3, workspace, 3"
"$mod, 4, workspace, 4"
"$mod, 5, workspace, 5"
"$mod, 6, workspace, 6"
"$mod, 7, workspace, 7"
"$mod, 8, workspace, 8"
"$mod, 9, workspace, 9"
"$mod, 0, workspace, 10"
# Move active window to a workspace with mainMod + SHIFT + [0-9]
"$mod SHIFT, 1, movetoworkspace, 1"
"$mod SHIFT, 2, movetoworkspace, 2"
"$mod SHIFT, 3, movetoworkspace, 3"
"$mod SHIFT, 4, movetoworkspace, 4"
"$mod SHIFT, 5, movetoworkspace, 5"
"$mod SHIFT, 6, movetoworkspace, 6"
"$mod SHIFT, 7, movetoworkspace, 7"
"$mod SHIFT, 8, movetoworkspace, 8"
"$mod SHIFT, 9, movetoworkspace, 9"
"$mod SHIFT, 0, movetoworkspace, 10"
# Laptop controls
",XF86AudioLowerVolume, exec, pamixer -d 5"
",XF86AudioRaiseVolume, exec, pamixer -i 5"
",XF86AudioMute, exec, pamixer -t"
",XF86AudioMicMute, exec, pactl -- set-source-mute 0 toggle"
",XF86MonBrightnessDown, exec, brightnessctl s 5%-"
",XF86MonBrightnessUp, exec, brightnessctl s +5%"
"$mod, XF86MonBrightnessUp, exec, hyprctl dispatch dpms on"
"$mod, XF86MonBrightnessDown, exec, hyprctl dispatch dpms off"
# Screenshotting
",Insert,exec,${grimblast} --notify --freeze copysave area"
"SHIFT,Insert,exec,${grimblast} --notify --freeze copysave output"
# To OCR
"ALT,Insert,exec,${grimblast} --freeze save area - | ${tesseract} - - | wl-copy && ${notify-send} -t 3000 'OCR result copied to buffer'"
# Example special workspace (scratchpad)
"$mod, S, togglespecialworkspace, magic"
"$mod SHIFT, S, movetoworkspace, special:magic"
# Scroll through existing workspaces with mainMod + scroll
# bind = $mod, mouse_down, workspace, e+1
# bind = $mod, mouse_up, workspace, e-1
];
# Move/resize windows with mainMod + LMB/RMB and dragging
bindm = [
"$mod, mouse:272, movewindow"
"$mod, mouse:273, resizewindow"
];
};
};
(mkIf (cfg.user == "toothpick") {
wayland.windowManager.hyprland.settings = {
"$terminal" = "foot";
"$browser" = "firefox";
"$browserinc" = "firefox --private-window";
"$mod" = "ALT_L";
bind = [
# Add more toothpc-specific binds as needed
];
};
})
]);
}

View File

@@ -1,40 +1,41 @@
{
lib,
config,
osConfig,
...
}: let
inherit (lib) mkIf mkEnableOption;
cfg = config.home.programs.hyprland.startup;
isCnix = osConfig.networking.hostName == "cnix";
isCnixpad = osConfig.networking.hostName == "cnixpad";
isToothpc = osConfig.networking.hostName == "toothpc";
inherit (lib) mkIf mkEnableOption mkMerge;
cfg = config.home.programs.hyprland;
in {
options = {
home.programs.hyprland.startup.enable = mkEnableOption "Enables startup settings in Hyprland";
};
config = mkIf cfg.enable {
wayland.windowManager.hyprland.settings = {
exec-once =
[
config = mkIf cfg.startup.enable (mkMerge [
{
wayland.windowManager.hyprland.settings = {
exec-once = [
"systemctl --user start polkit-gnome-authentication-agent-1"
"udiskie -Nt"
"wl-clip-persist --clipboard regular --all-mime-type-regex '^(?!x-kde-passwordManagerHint).+'"
"hyprctl dispatch exec 'sleep 5s && keepassxc'"
]
++ lib.optionals isCnix [
"mullvad-vpn"
"blueman-applet"
"pamixer --set-volume 50"
"hyprctl dispatch exec 'sleep 3s && solaar -w hide'"
]
++ lib.optionals isCnixpad [
"blueman-applet"
]
++ lib.optionals isToothpc [
"mullvad-vpn"
"hyprctl dispatch exec 'sleep 3s && solaar -w hide'"
];
};
};
};
}
(mkIf (cfg.user == "cnix") {
wayland.windowManager.hyprland.settings.exec-once = [
"mullvad-vpn"
"blueman-applet"
"pamixer --set-volume 50"
"hyprctl dispatch exec 'sleep 3s && solaar -w hide'"
];
})
(mkIf (cfg.user == "toothpc") {
wayland.windowManager.hyprland.settings.exec-once = [
"mullvad-vpn"
"hyprctl dispatch exec 'sleep 3s && solaar -w hide'"
];
})
]);
}

View File

@@ -10,7 +10,9 @@
# hyprsysteminfoFlake = inputs.hyprsysteminfo.packages.${pkgs.system}.default;
in {
options = {
nixos.programs.hyprland.enable = mkEnableOption "Enables hyprland";
nixos.programs.hyprland = {
enable = mkEnableOption "Enables hyprland";
};
};
config = mkIf cfg.enable {
security.pam.services.hyprlock.text = "auth include login";