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

50
flake.lock generated
View File

@@ -28,11 +28,11 @@
"systems": "systems_2" "systems": "systems_2"
}, },
"locked": { "locked": {
"lastModified": 1728852607, "lastModified": 1730444665,
"narHash": "sha256-PhJdr8b4nZVHts5KMEsf7vCDXVpFIFCa7VlCt+oYpL4=", "narHash": "sha256-i3FxeHjsHw4AePx3AWVVywy92EEobx/ZER4ignWxNrE=",
"owner": "anyrun-org", "owner": "anyrun-org",
"repo": "anyrun", "repo": "anyrun",
"rev": "6e0385f6945d701545edc5bccfc5f544e1e12663", "rev": "b3b4f2253d43af3311b3d3fc86973fc3e9559c33",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -154,11 +154,11 @@
"rust-analyzer-src": "rust-analyzer-src" "rust-analyzer-src": "rust-analyzer-src"
}, },
"locked": { "locked": {
"lastModified": 1730356297, "lastModified": 1730442928,
"narHash": "sha256-pMW/yx6urzUimYdMHLGKRWxu2wmWMd7Dqz9oiGHBi8o=", "narHash": "sha256-U1DWb5c3EfkA7pqx5V1H4AWRA+EaE6UJ0lIRvK1RxgM=",
"owner": "nix-community", "owner": "nix-community",
"repo": "fenix", "repo": "fenix",
"rev": "3a35e2c06a31ff4420639a454eeca4ccdfe69f13", "rev": "87b4d20f896c99018dde4702a9c6157b516f2a76",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -436,11 +436,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1730016908, "lastModified": 1730450782,
"narHash": "sha256-bFCxJco7d8IgmjfNExNz9knP8wvwbXU4s/d53KOK6U0=", "narHash": "sha256-0AfApF8aexgB6o34qqLW2cCX4LaWJajBVdU6ddiWZBM=",
"owner": "nix-community", "owner": "nix-community",
"repo": "home-manager", "repo": "home-manager",
"rev": "e83414058edd339148dc142a8437edb9450574c8", "rev": "8ca921e5a806b5b6171add542defe7bdac79d189",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -567,11 +567,11 @@
"xdph": "xdph" "xdph": "xdph"
}, },
"locked": { "locked": {
"lastModified": 1730373668, "lastModified": 1730466192,
"narHash": "sha256-UNBRvBacwYSFmM5TvWx4ASGMWs42tGP0AhUW/adWE/k=", "narHash": "sha256-7O1TwW5neOpfeGRp4SSsbMJinupmBGFGo7yxQD9yk+A=",
"owner": "hyprwm", "owner": "hyprwm",
"repo": "hyprland", "repo": "hyprland",
"rev": "93b4478e70af6ffb08a4a66a6d0364c3296db296", "rev": "3852418d2446555509738bf1486940042107afe7",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -900,11 +900,11 @@
"umu": "umu" "umu": "umu"
}, },
"locked": { "locked": {
"lastModified": 1730339322, "lastModified": 1730425644,
"narHash": "sha256-n3519T7sH4KYMO4jYbhDZsGUjM5mf8cr1KCrQj09vrM=", "narHash": "sha256-dfxO6mkn1KkotGQXV93m/2MoS9ayLUwaIIbR3mReLd0=",
"owner": "fufexan", "owner": "fufexan",
"repo": "nix-gaming", "repo": "nix-gaming",
"rev": "6c55bedcc36bc0c62aa6072c21c3456fe81d9cad", "rev": "bcc7c896b56ccd644ca2daea74dac05c1731f59d",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -986,11 +986,11 @@
}, },
"nixpkgs_2": { "nixpkgs_2": {
"locked": { "locked": {
"lastModified": 1728492678, "lastModified": 1730200266,
"narHash": "sha256-9UTxR8eukdg+XZeHgxW5hQA9fIKHsKCdOIUycTryeVw=", "narHash": "sha256-l253w0XMT8nWHGXuXqyiIC/bMvh1VRszGXgdpQlfhvU=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "5633bcff0c6162b9e4b5f1264264611e950c8ec7", "rev": "807e9154dcb16384b1b765ebe9cd2bba2ac287fd",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -1192,11 +1192,11 @@
"rust-analyzer-src": { "rust-analyzer-src": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1730315096, "lastModified": 1730386175,
"narHash": "sha256-Kvve0NSLliNl1cv7qLSPdVWqLUEeAq0aZGsMeV632Cg=", "narHash": "sha256-0Uq+/B8eu7pw8B8pxuGdFYKjcVLwNMcHfDxU9sXh7rg=",
"owner": "rust-lang", "owner": "rust-lang",
"repo": "rust-analyzer", "repo": "rust-analyzer",
"rev": "8244f30eff828355f5ec92b2307c216d10caa25b", "rev": "0ba893e1a00d92557ac91efb771d72eee36ca687",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -1431,11 +1431,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1730395634, "lastModified": 1730441165,
"narHash": "sha256-/aY1ugI/JjY4EZfrT2s75g7vQptalCrJeuX3n0H8dTU=", "narHash": "sha256-lXLgi09KvDfxuu2eyCFh8J/pjENoF6LKQWlJD5WKm3k=",
"ref": "refs/heads/main", "ref": "refs/heads/main",
"rev": "3db77d973f30714f3ebf44dd214ac40c78f07511", "rev": "c31396e77f54b2d9f5bbcd5aab4b15245068e51c",
"revCount": 52, "revCount": 53,
"type": "git", "type": "git",
"url": "https://git.sr.ht/~canasta/zen-browser-flake" "url": "https://git.sr.ht/~canasta/zen-browser-flake"
}, },

View File

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

View File

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

View File

@@ -4,42 +4,23 @@
osConfig, osConfig,
... ...
}: let }: let
inherit (lib) mkIf mkEnableOption; inherit (lib) mkIf mkEnableOption mkMerge;
toothpc = osConfig.networking.hostName == "toothpc";
kbOption = kbOption =
if osConfig.networking.hostName == "cnixpad" if osConfig.networking.hostName == "cnixpad"
then "ctrl:swapcaps" then "ctrl:swapcaps"
else ""; else "";
cfg = config.home.programs.hyprland.inputs;
renderSettings = cfg = config.home.programs.hyprland;
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;
};
in { in {
options = { options = {
home.programs.hyprland.inputs.enable = mkEnableOption "Enables input settings in Hyprland"; home.programs.hyprland.inputs.enable = mkEnableOption "Enables input settings in Hyprland";
}; };
config = mkIf cfg.enable { config = mkIf cfg.inputs.enable (mkMerge [
{
wayland.windowManager.hyprland.settings = { wayland.windowManager.hyprland.settings = {
monitor = map ( monitor =
map (
m: "${m.name},${ m: "${m.name},${
if m.enabled if m.enabled
then "${toString m.width}x${toString m.height}@${toString m.refreshRate},${m.position},1${ then "${toString m.width}x${toString m.height}@${toString m.refreshRate},${m.position},1${
@@ -49,7 +30,8 @@ in {
}" }"
else "disable" else "disable"
}" }"
) (config.monitors); )
config.monitors;
workspace = map ( workspace = map (
m: "name:${m.workspace},monitor:${m.name}" m: "name:${m.workspace},monitor:${m.name}"
@@ -74,6 +56,7 @@ in {
scroll_factor = 0.5; scroll_factor = 0.5;
}; };
}; };
gestures = { gestures = {
workspace_swipe = true; workspace_swipe = true;
workspace_swipe_distance = 400; workspace_swipe_distance = 400;
@@ -84,6 +67,7 @@ in {
workspace_swipe_direction_lock_threshold = 10; workspace_swipe_direction_lock_threshold = 10;
workspace_swipe_create_new = true; workspace_swipe_create_new = true;
}; };
misc = { misc = {
vrr = 0; vrr = 0;
mouse_move_enables_dpms = 1; mouse_move_enables_dpms = 1;
@@ -93,11 +77,39 @@ in {
disable_splash_rendering = true; disable_splash_rendering = true;
disable_autoreload = true; disable_autoreload = true;
}; };
xwayland = { xwayland = {
force_zero_scaling = false; force_zero_scaling = false;
}; };
render = renderSettings;
cursor = cursorSettings;
}; };
}
(mkIf (cfg.user == "toothpick") {
wayland.windowManager.hyprland.settings.render = {
explicit_sync = 0;
explicit_sync_kms = 0;
direct_scanout = false;
}; };
})
(mkIf (cfg.user != "toothpick") {
wayland.windowManager.hyprland.settings.render = {
explicit_sync = 2;
explicit_sync_kms = 2;
direct_scanout = false;
};
})
(mkIf (cfg.user == "toothpick") {
wayland.windowManager.hyprland.settings.cursor = {
no_hardware_cursors = true;
};
})
(mkIf (cfg.user != "toothpick") {
wayland.windowManager.hyprland.settings.cursor = {
no_hardware_cursors = 2;
};
})
]);
} }

View File

@@ -5,77 +5,45 @@
osConfig, osConfig,
... ...
}: let }: let
inherit (lib) mkIf mkEnableOption; inherit (lib) mkIf mkEnableOption mkMerge;
cfg = config.home.programs.hyprland.keybinds; cfg = config.home.programs.hyprland;
in { in {
options = { options = {
home.programs.hyprland.keybinds.enable = mkEnableOption "Enables keybind settings in Hyprland"; home.programs.hyprland.keybinds.enable = mkEnableOption "Enables keybind settings in Hyprland";
}; };
config = mkIf cfg.enable {
wayland.windowManager.hyprland.settings = let config = mkIf cfg.keybinds.enable (mkMerge [
cnixpad = osConfig.networking.hostName == "cnixpad"; {
toothpc = osConfig.networking.hostName == "toothpc"; wayland.windowManager.hyprland.settings = {
modKey = # Common Keybind Variables
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"; "$fileManager" = "thunar";
"$passwordManager" = "keepassxc"; "$passwordManager" = "keepassxc";
"$menu" = "pkill anyrun || anyrun | xargs hyprctl dispatch exec --"; "$menu" = "pkill anyrun || anyrun | xargs hyprctl dispatch exec --";
"$menuw" = "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"; "$yazi" = "alacritty -e yazi";
"$tuirun" = "tuirun-toggle.sh"; "$tuirun" = "tuirun-toggle.sh";
# See https://wiki.hyprland.org/Configuring/Keywords/ for more bind = [
"$mod" = modKey; "$mod SHIFT, B, exec, pkill -SIGUSR2 waybar"
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
# Example binds, see https://wiki.hyprland.org/Configuring/Binds/ for more
"$mod, A, exec, pkill -SIGUSR1 waybar" "$mod, A, exec, pkill -SIGUSR1 waybar"
"$mod, T, exec, $terminal" "$mod, T, exec, $terminal"
"$mod, W, exec, $browser" "$mod, W, exec, $browser"
"$mod, K, exec, $passwordManager" "$mod, K, exec, $passwordManager"
"$mod SHIFT, W, exec, $browserinc" "$mod SHIFT, W, exec, $browserinc"
"$mod, Q, killactive," "$mod, Q, killactive,"
#bind = $mod, M, exec, hyprctl dispatch exit
#bind = $mod, E, exec, $fileManager
"$mod, E, exec, $fileManager" "$mod, E, exec, $fileManager"
"$mod, R, exec, $tuirun" "$mod, R, exec, $tuirun"
"$mod SHIFT, E, exec, $yazi" "$mod SHIFT, E, exec, $yazi"
"$mod, F, fullscreen," "$mod, F, fullscreen,"
"$mod SHIFT, F, togglefloating," "$mod SHIFT, F, togglefloating,"
"$mod, SPACE, exec, $tuirun" "$mod, SPACE, exec, $tuirun"
"$mod, P, pseudo," # dwindle "$mod, P, pseudo,"
"$mod, J, togglesplit," # dwindle "$mod, J, togglesplit,"
"$mod, C, exec, hyprctl dispatch exec copyq toggle" "$mod, C, exec, hyprctl dispatch exec copyq toggle"
# "$mod, TAB, exec, $menuw"
# Move focus with mainMod + arrow keys
"$mod, left, movefocus, l" "$mod, left, movefocus, l"
"$mod, right, movefocus, r" "$mod, right, movefocus, r"
"$mod, up, movefocus, u" "$mod, up, movefocus, u"
"$mod, down, movefocus, d" "$mod, down, movefocus, d"
# Switch workspaces with mainMod + [0-9]
"$mod, 1, workspace, 1" "$mod, 1, workspace, 1"
"$mod, 2, workspace, 2" "$mod, 2, workspace, 2"
"$mod, 3, workspace, 3" "$mod, 3, workspace, 3"
@@ -86,8 +54,6 @@ in {
"$mod, 8, workspace, 8" "$mod, 8, workspace, 8"
"$mod, 9, workspace, 9" "$mod, 9, workspace, 9"
"$mod, 0, workspace, 10" "$mod, 0, workspace, 10"
# Move active window to a workspace with mainMod + SHIFT + [0-9]
"$mod SHIFT, 1, movetoworkspace, 1" "$mod SHIFT, 1, movetoworkspace, 1"
"$mod SHIFT, 2, movetoworkspace, 2" "$mod SHIFT, 2, movetoworkspace, 2"
"$mod SHIFT, 3, movetoworkspace, 3" "$mod SHIFT, 3, movetoworkspace, 3"
@@ -98,37 +64,56 @@ in {
"$mod SHIFT, 8, movetoworkspace, 8" "$mod SHIFT, 8, movetoworkspace, 8"
"$mod SHIFT, 9, movetoworkspace, 9" "$mod SHIFT, 9, movetoworkspace, 9"
"$mod SHIFT, 0, movetoworkspace, 10" "$mod SHIFT, 0, movetoworkspace, 10"
# Laptop controls
",XF86AudioLowerVolume, exec, pamixer -d 5" ",XF86AudioLowerVolume, exec, pamixer -d 5"
",XF86AudioRaiseVolume, exec, pamixer -i 5" ",XF86AudioRaiseVolume, exec, pamixer -i 5"
",XF86AudioMute, exec, pamixer -t" ",XF86AudioMute, exec, pamixer -t"
",XF86AudioMicMute, exec, pactl -- set-source-mute 0 toggle" ",XF86AudioMicMute, exec, pactl -- set-source-mute 0 toggle"
",XF86MonBrightnessDown, exec, brightnessctl s 5%-" ",XF86MonBrightnessDown, exec, brightnessctl s 5%-"
",XF86MonBrightnessUp, exec, brightnessctl s +5%" ",XF86MonBrightnessUp, exec, brightnessctl s +5%"
"$mod, XF86MonBrightnessUp, exec, hyprctl dispatch dpms on" "$mod, XF86MonBrightnessUp, exec, hyprctl dispatch dpms on"
"$mod, XF86MonBrightnessDown, exec, hyprctl dispatch dpms off" "$mod, XF86MonBrightnessDown, exec, hyprctl dispatch dpms off"
",Insert,exec,${lib.getExe pkgs.grimblast} --notify --freeze copysave area"
# Screenshotting "SHIFT,Insert,exec,${lib.getExe pkgs.grimblast} --notify --freeze copysave output"
",Insert,exec,${grimblast} --notify --freeze copysave area" "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'"
"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, S, togglespecialworkspace, magic"
"$mod SHIFT, S, movetoworkspace, special: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 = [ bindm = [
"$mod, mouse:272, movewindow" "$mod, mouse:272, movewindow"
"$mod, mouse:273, resizewindow" "$mod, mouse:273, resizewindow"
]; ];
}; };
}
(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
];
}; };
})
(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, lib,
config, config,
osConfig,
... ...
}: let }: let
inherit (lib) mkIf mkEnableOption; inherit (lib) mkIf mkEnableOption mkMerge;
cfg = config.home.programs.hyprland.startup; cfg = config.home.programs.hyprland;
isCnix = osConfig.networking.hostName == "cnix";
isCnixpad = osConfig.networking.hostName == "cnixpad";
isToothpc = osConfig.networking.hostName == "toothpc";
in { in {
options = { options = {
home.programs.hyprland.startup.enable = mkEnableOption "Enables startup settings in Hyprland"; home.programs.hyprland.startup.enable = mkEnableOption "Enables startup settings in Hyprland";
}; };
config = mkIf cfg.enable {
config = mkIf cfg.startup.enable (mkMerge [
{
wayland.windowManager.hyprland.settings = { wayland.windowManager.hyprland.settings = {
exec-once = exec-once = [
[
"systemctl --user start polkit-gnome-authentication-agent-1" "systemctl --user start polkit-gnome-authentication-agent-1"
"udiskie -Nt" "udiskie -Nt"
"wl-clip-persist --clipboard regular --all-mime-type-regex '^(?!x-kde-passwordManagerHint).+'" "wl-clip-persist --clipboard regular --all-mime-type-regex '^(?!x-kde-passwordManagerHint).+'"
"hyprctl dispatch exec 'sleep 5s && keepassxc'" "hyprctl dispatch exec 'sleep 5s && keepassxc'"
] ];
++ lib.optionals isCnix [ };
}
(mkIf (cfg.user == "cnix") {
wayland.windowManager.hyprland.settings.exec-once = [
"mullvad-vpn" "mullvad-vpn"
"blueman-applet" "blueman-applet"
"pamixer --set-volume 50" "pamixer --set-volume 50"
"hyprctl dispatch exec 'sleep 3s && solaar -w hide'" "hyprctl dispatch exec 'sleep 3s && solaar -w hide'"
] ];
++ lib.optionals isCnixpad [ })
"blueman-applet"
] (mkIf (cfg.user == "toothpc") {
++ lib.optionals isToothpc [ wayland.windowManager.hyprland.settings.exec-once = [
"mullvad-vpn" "mullvad-vpn"
"hyprctl dispatch exec 'sleep 3s && solaar -w hide'" "hyprctl dispatch exec 'sleep 3s && solaar -w hide'"
]; ];
}; })
}; ]);
} }

View File

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

View File

@@ -49,6 +49,7 @@
}; };
hyprland = { hyprland = {
enable = true; enable = true;
user = "cnst";
}; };
hyprlock = { hyprlock = {
enable = true; enable = true;

View File

@@ -40,6 +40,7 @@
}; };
hyprland = { hyprland = {
enable = true; enable = true;
user = "toothpick";
}; };
hyprlock = { hyprlock = {
enable = true; enable = true;