nixos/system/home/hyprland.nix

424 lines
16 KiB
Nix
Raw Normal View History

{
config,
lib,
pkgs,
osConfig,
...
}:
{
imports = [
./udiskie.nix
./waybar.nix
./fuzzel.nix
./mako.nix
./avizo.nix
./wlogout.nix
];
home.packages = [
(pkgs.writeShellScriptBin "protonmail-setup-bridge" ''
pkill -9 -f protonmail-bridge
PASSWORD_STORE_DIR=/dev/null ${pkgs.protonmail-bridge}/bin/protonmail-bridge -c
${config.wayland.windowManager.hyprland.finalPackage}/bin/hyprctl dispatch exec "PASSWORD_STORE_DIR=/dev/null ${pkgs.protonmail-bridge}/bin/protonmail-bridge -n"
'')
];
services = {
hyprpaper.enable = true;
kanshi.systemdTarget = "hyprland-session.target";
gpg-agent.pinentryPackage = pkgs.pinentry-gnome3;
hypridle = {
enable = true;
settings =
let
hyprctl = "${config.wayland.windowManager.hyprland.finalPackage}/bin/hyprctl";
2024-10-25 13:40:24 +01:00
hyprlock = "${config.programs.hyprlock.package}/bin/hyprlock";
in
{
general = {
after_sleep_cmd = "${hyprctl} dispatch dpms on";
ignore_dbus_inhibit = false;
2024-10-25 13:40:24 +01:00
lock_cmd = "${hyprlock}";
};
listener = [
{
timeout = 900;
2024-10-25 13:40:24 +01:00
on-timeout = "${hyprlock}";
}
{
timeout = 1200;
on-timeout = "${hyprctl} dispatch dpms off";
on-resume = "${hyprctl} dispatch dpms on";
}
];
};
};
};
programs = {
waybar.systemd.target = "hyprland-session.target";
hyprlock =
let
font = config.stylix.fonts.sansSerif.name;
scheme = config.lib.stylix.scheme;
2024-12-05 09:03:59 +00:00
accent = scheme.base0C;
in
{
enable = true;
settings = {
general = {
hide_cursor = true;
grace = 5;
ignore_emptry_input = true;
};
background = [
{
monitor = "";
path = "screenshot";
blur_passes = 3;
blur_size = 8;
}
];
label = [
{
monitor = "";
text = "cmd[update:30000] echo \"$(date +\"%R\")\"";
color = "0xff${scheme.base00}";
font_size = 90;
font_family = font;
position = "-30, 0";
halign = "right";
valign = "top";
}
{
monitor = "";
text = "cmd[update:43200000] echo \"$(date +\"%A,%e %B %Y\")\"";
color = "0xff${scheme.base00}";
font_size = 25;
font_family = font;
position = "-30, -150";
halign = "right";
valign = "top";
}
];
image = [
{
monitor = "";
path = "${./pfp/personal.png}";
size = 100;
border_color = "0xff${accent}";
position = "0, 75";
halign = "center";
valign = "center";
}
];
input-field = [
{
monitor = "";
size = "300, 60";
outline_thickness = 2;
dots_size = 0.2; # Scale of input-field height, 0.2 - 0.8
dots_spacing = 0.2; # Scale of dots' absolute size, 0.0 - 1.0
dots_center = true;
outer_color = "0xff${accent}";
inner_color = "0xff${scheme.base00}";
font_color = "0xff${scheme.base05}";
fade_on_empty = false;
placeholder_text = "󰌾 Logged in as <span foreground=\"##${accent}\">$USER</span>";
check_color = "0xff${scheme.blue}";
fail_color = "0xff${scheme.red}";
fail_text = "<i>$FAIL <b>($ATTEMPTS)</b></i>";
hide_input = false;
position = "0, -50";
halign = "center";
valign = "center";
}
];
};
};
};
wayland.windowManager.hyprland = {
enable = true;
package = osConfig.programs.hyprland.package;
xwayland.enable = true;
systemd.enable = true;
settings = {
monitor = [ ",preferred,auto,auto" ];
exec-once = [
"systemctl --user import-environment WAYLAND_DISPLAY QT_QPA_PLATFORMTHEME"
"${config.wayland.windowManager.hyprland.finalPackage}/bin/hyprctl setcursor ${config.gtk.cursorTheme.name} ${toString config.gtk.cursorTheme.size}"
"${pkgs.libsForQt5.polkit-kde-agent}/libexec/polkit-kde-authentication-agent-1"
"PASSWORD_STORE_DIR=/dev/null ${pkgs.protonmail-bridge}/bin/protonmail-bridge -n"
"sleep 5; ${pkgs.dex}/bin/dex -a"
];
gestures.workspace_swipe = true;
2024-11-14 13:20:46 +00:00
general = {
2024-12-04 11:42:40 +00:00
layout = "master";
2024-11-14 13:20:46 +00:00
gaps_in = 2.5;
gaps_out = 5;
2024-12-05 09:03:59 +00:00
"col.active_border" = lib.mkForce "rgb(${config.lib.stylix.scheme.base0C})";
};
2024-12-04 11:42:40 +00:00
master = {
allow_small_split = true;
special_scale_factor = 0.95;
2024-12-04 11:42:40 +00:00
mfact = 0.5;
new_on_top = false;
no_gaps_when_only = 0;
orientation = "left";
inherit_fullscreen = false;
smart_resizing = false;
drop_at_cursor = true;
};
2024-11-14 13:20:46 +00:00
input = {
kb_layout = osConfig.services.xserver.xkb.layout;
follow_mouse = 1;
touchpad.natural_scroll = "yes";
};
decoration = {
rounding = 5;
"col.shadow" = lib.mkForce "rgba(${config.lib.stylix.scheme.base00}0d)";
drop_shadow = "yes";
shadow_ignore_window = true;
shadow_range = 4;
shadow_render_power = 3;
blur = {
enabled = true;
size = 5;
passes = 3;
new_optimizations = true;
brightness = 1.0;
noise = 2.0e-2;
};
};
animations = {
enabled = true;
bezier = "myBezier, 0.05, 0.9, 0.1, 1.05";
animation = [
"windows, 1, 7, myBezier"
"windowsOut, 1, 7, default, popin 80%"
"border, 1, 10, default"
"borderangle, 1, 8, default"
"fade, 1, 7, default"
"workspaces, 1, 6, default"
];
};
misc = {
disable_splash_rendering = true;
disable_autoreload = true;
mouse_move_enables_dpms = true;
key_press_enables_dpms = true;
};
xwayland.force_zero_scaling = true;
layerrule =
let
blur = x: "blur, ^(${x})$";
ignorealpha = x: "ignorealpha 0.3, ^(${x})$";
layers = [
"system-menu"
"gtk-layer-shell"
"notifications"
"launcher"
"logout_dialog"
"waybar"
"avizo"
];
in
(lib.lists.forEach layers blur) ++ (lib.lists.forEach layers ignorealpha);
windowrule = [
# Float + move system windows
# Password prompts
"float, org.kde.polkit-kde-authentication-agent-1|Pinentry|pinentry-qt|gcr-prompter"
"center, org.kde.polkit-kde-authentication-agent-1|Pinentry|pinentry-qt|gcr-prompter"
"pin, org.kde.polkit-kde-authentication-agent-1|Pinentry|pinentry-qt|gcr-prompter"
"dimaround, org.kde.polkit-kde-authentication-agent-1|Pinentry|pinentry-qt|gcr-prompter"
"stayfocused, org.kde.polkit-kde-authentication-agent-1|Pinentry|pinentry-qt|gcr-prompter"
# Network and Bluetooth control panels
"float, pavucontrol|nm-connection-editor|overskride|io.github.kaii_lb.Overskride"
"size 800 600, pavucontrol|nm-connection-editor|overskride|io.github.kaii_lb.Overskride"
"move onscreen 100%-820 50,pavucontrol|nm-connection-editor|overskride|io.github.kaii_lb.Overskride"
# File browser and picker dialog
"float, org.gnome.Nautilus|xdg-desktop-portal-gtk"
2024-12-05 13:14:25 +00:00
"size 1200 900, org.gnome.Nautilus|xdg-desktop-portal-gtk"
"center, org.gnome.Nautilus|xdg-desktop-portal-gtk"
# Workspace rules
"workspace 2, (firefox|nyxt|org.qutebrowser.qutebrowser)" # Browser
"workspace 3, (signal|whatsapp-for-linux|WebCord|teams-for-linux|twinkle)" # Messaging
2024-12-03 15:53:05 +00:00
"workspace 4, (libreoffice|soffice)(.*)" # Documents
"workspace 5, (org.remmina.Remmina|Nxplayer.bin)" # Remote Desktop
"workspace 6, (PrusaSlicer)" # 3D Printing
"workspace 7, (lutris|page.kramo.Cartridges|org.prismlauncher.PrismLauncher)" # Gaming
"workspace 7 silent, (steam|steam_app)" # Gaming (Silent)
# PrismLauncher / Minecraft
"float, org.prismlauncher.PrismLauncher"
"center, org.prismlauncher.PrismLauncher"
"size 800 600, org.prismlauncher.PrismLauncher"
];
windowrulev2 = [
# Firefox PIP
"float, title:Picture-in-Picture|Library,class:firefox"
"size 750 400, title:Picture-in-Picture,class:firefox"
"size 800 800, title:Library,class:firefox"
"move onscreen 100%-775 100%-425, title:Picture-in-Picture,class:firefox"
"center, title:Library,class:firefox"
"pin, title:Picture-in-Picture,class:firefox"
# NautilusPreviewer (Sushi)
"float, class:org.gnome.NautilusPreviewer"
"center, class:org.gnome.NautilusPreviewer"
# Electron file picker dialog
"float, title:Open Files,class:electron"
"size 800 600, title:Open Files,class:electron"
"center, title:Open Files,class:electron"
# Inhibit idle when watching videos
"idleinhibit fullscreen, class:firefox|com.github.rafostar.Clapper"
# Inhibit idle when playing games
"idleinhibit always, class:(steam_app|Minecraft).*"
# LibreOffice
"suppressevent fullscreen maximize, class:(libreoffice|soffice)(.*)"
"float, title:Open,class:(libreoffice|soffice)(.*)"
# Steam
"float, title:Friends List,class:steam"
"size 400 600, title:Friends List,class:steam"
"float, title:(.*)(Chat),class:steam"
"size 800 600, title:(.*)(Chat),class:steam"
"float, title:Steam Settings,class:steam"
"size 800 600, title:Steam Settings,class:steam"
"float, title:(.*)(Controller Layout),class:steam"
"size 1200 800, title:(.*)(Controller Layout),class:steam"
# Remmina / NoMachine
"suppressevent fullscreen maximize, class:org.remmina.Remmina|Nxplayer.bin"
"float, title:Remmina Remote Desktop Client, class:org.remmina.Remmina"
"center, title:Remmina Remote Desktop Client, class:org.remmina.Remmina"
];
bind =
let
withTerm =
{
term ? "alacritty",
package ? config.programs.${term}.package,
progname,
args ? "",
}:
"${package}/bin/${term} -T ${progname} -e ${progname} ${args}";
workspace = w: [
"SUPER, ${toString w}, moveworkspacetomonitor, ${toString w} current"
"SUPER, ${toString w}, workspace, ${toString w}"
"SUPER SHIFT, ${toString w}, movetoworkspace, ${toString w}"
];
in
lib.lists.flatten (lib.lists.forEach (lib.lists.range 1 9) workspace)
++ (
let
btm_args = "--autohide_time --battery --celsius --enable_cache_memory --enable_gpu_memory --group --hide_avg_cpu --hide_table_gap --retention=3m --show_table_scroll_position";
in
[
# See https://wiki.hyprland.org/Configuring/Keywords/ for more
# Open Hyprland wiki at correct version number
"CTRL_SHIFT, H, exec, xdg-open \"https://wiki.hyprland.org/$(${config.wayland.windowManager.hyprland.finalPackage}/bin/hyprctl version -j | ${pkgs.jq}/bin/jq $args.tag | ${pkgs.gnused}/bin/sed s/v// | ${pkgs.gnused}/bin/sed s/\\\"//g)\""
"SUPER, F1, exec, ${config.programs.hyprlock.package}/bin/hyprlock"
# "SUPER, F1, exec, ${config.programs.swaylock.package}/bin/swaylock --screenshots --clock --indicator --grace-no-mouse"
"SUPER, Q, killactive,"
"SUPER, V, togglefloating"
# "SUPER SHIFT, V, setfloating" ## TODO setfloating exists
# in newer version of Hyprland than mine
"SUPER SHIFT, V, moveactive, exact 1% 4%"
"SUPER SHIFT, V, resizeactive, exact 800 600"
"SUPER SHIFT, V, pin"
"SUPER, M, fullscreen, 1" # Maximise window
"SUPER SHIFT, M, fullscreen, 0" # Actual fullscreen
"SUPER, Z, exec, ${config.services.mako.package}/bin/makoctl restore"
"SUPER SHIFT, Z, exec, exec ${config.services.mako.package}/bin/makoctl dismiss -a"
# Common program shortcuts
"SUPER, Space, exec, ${config.programs.fuzzel.package}/bin/fuzzel"
"SUPER, Return, exec, ${config.programs.alacritty.package}/bin/alacritty"
"SUPER SHIFT, Return, exec, ${config.programs.emacs.finalPackage}/bin/emacsclient -c"
"SUPER, W, exec, ${config.programs.firefox.finalPackage}/bin/firefox"
"SUPER, F, exec, ${pkgs.gnome.nautilus}/bin/nautilus"
# Terminal utilities
"SUPER, S, exec, ${
withTerm {
progname = "${config.programs.bottom.package}/bin/btm";
args = btm_args;
}
}"
"SUPER SHIFT, S, exec, ${
withTerm {
progname = "${config.programs.bottom.package}/bin/btm";
args = btm_args + " --basic";
}
}"
"SUPER, C, exec, ${withTerm { progname = "${config.programs.cava.package}/bin/cava"; }}"
# Misc useful binds
",Print,exec,${pkgs.grim}/bin/grim -g \"$(${pkgs.slurp}/bin/slurp)\" - | ${pkgs.swappy}/bin/swappy -f -"
# ",XF86Calculator,exec,pkill rofi || ${config.programs.rofi.finalPackage}/bin/rofi -show calc"
# Movement binds
"SUPER, H, movefocus, l"
"SUPER, L, movefocus, r"
"SUPER, K, movefocus, u"
"SUPER, J, movefocus, d"
"SUPER SHIFT, H, movewindow, l"
"SUPER SHIFT, L, movewindow, r"
"SUPER SHIFT, K, movewindow, u"
"SUPER SHIFT, J, movewindow, d"
# Special workspaces
"SUPER, comma, workspace, m-1"
"SUPER SHIFT, comma, movetoworkspace, r-1"
"SUPER, period, workspace, m+1"
"SUPER SHIFT, period, movetoworkspace, r+1"
"SUPER, N, workspace, empty"
"SUPER SHIFT, N, movetoworkspace, empty"
"SUPER, minus, togglespecialworkspace"
"SUPER SHIFT, minus, movetoworkspace, special"
"SUPER, bracketright, focusmonitor, +1"
"SUPER SHIFT, bracketright, movecurrentworkspacetomonitor, +1"
"SUPER, bracketleft, focusmonitor, -1"
"SUPER SHIFT, bracketleft, movecurrentworkspacetomonitor, -1"
"SUPER, O, focusurgentorlast"
]
);
bindl = [
# Sound
",XF86AudioMute,exec,${config.services.avizo.package}/bin/volumectl %"
",XF86AudioMicMute,exec,${config.services.avizo.package}/bin/volumectl -m %"
# Playback
",XF86AudioPlay,exec,${pkgs.playerctl}/bin/playerctl play-pause"
",XF86AudioStop,exec,${pkgs.playerctl}/bin/playerctl play-pause"
",XF86AudioPrev,exec,${pkgs.playerctl}/bin/playerctl previous"
",XF86AudioNext,exec,${pkgs.playerctl}/bin/playerctl next"
];
bindle = [
# Sound
",XF86AudioRaiseVolume,exec,${config.services.avizo.package}/bin/volumectl -u + 5"
",XF86AudioLowerVolume,exec,${config.services.avizo.package}/bin/volumectl -u - 5"
# Brightness
",XF86MonBrightnessUp,exec,${config.services.avizo.package}/bin/lightctl + 5"
",XF86MonBrightnessDown,exec,${config.services.avizo.package}/bin/lightctl - 5"
];
bindm = [
# Move/resize windows with mainMod + LMB/RMB and dragging
"SUPER, mouse:272, movewindow"
"SUPER, mouse:273, resizewindow"
];
};
};
xdg.configFile."hypr/hyprpaper.conf".text = ''
preload = ${config.stylix.image}
wallpaper = ,${config.stylix.image}
'';
}