nixos/legacy_modules/desktop/hyprland/default.nix

311 lines
10 KiB
Nix
Raw Normal View History

2025-01-31 15:13:22 +01:00
{
lib,
config,
2025-02-19 23:42:24 +01:00
pkgs,
pkgsUnstable,
2025-01-31 15:13:22 +01:00
...
}:
2025-02-18 20:17:57 +01:00
with lib; let
cfg = config.fireproof;
2025-02-25 22:58:44 +01:00
primaryMonitorName = (builtins.head config.monitors).name or "";
2025-02-19 23:42:24 +01:00
2025-02-24 22:52:19 +01:00
color = {
bg = "rgb(1C1B1A)";
2025-02-24 23:46:48 +01:00
ui = "rgb(343331)";
2025-02-24 22:52:19 +01:00
fg = "rgb(DAD8CE)";
accent = "rgb(CF6A4C)";
black = "rgb(100F0F)";
transparent = "rgba(00000000)";
};
2025-02-24 07:55:57 +01:00
record_script = pkgs.writeShellScriptBin "record_script" ''
DIR="$HOME/recordings"
FILE="$DIR/$(date '+%Y-%m-%d_%H.%M.%S').mp4"
mkdir -p $DIR
if pgrep -f ${lib.getExe pkgs.wf-recorder} > /dev/null; then
pkill ${lib.getExe pkgs.wf-recorder}
${pkgs.libnotify}/bin/notify-send "Recording Stopped" "Recording saved to $FILE"
else
# Stolen from grimblast
FULLSCREEN_WORKSPACES="$(hyprctl workspaces -j | jq -r 'map(select(.hasfullscreen) | .id)')"
WORKSPACES="$(hyprctl monitors -j | jq -r '[(foreach .[] as $monitor (0; if $monitor.specialWorkspace.name == "" then $monitor.activeWorkspace else $monitor.specialWorkspace end)).id]')"
WINDOWS="$(hyprctl clients -j | jq -r --argjson workspaces "$WORKSPACES" --argjson fullscreenWorkspaces "$FULLSCREEN_WORKSPACES" 'map((select(([.workspace.id] | inside($workspaces)) and ([.workspace.id] | inside($fullscreenWorkspaces) | not) or .fullscreen > 0)))')"
GEOMETRY=$(echo "$WINDOWS" | jq -r '.[] | "\(.at[0]),\(.at[1]) \(.size[0])x\(.size[1])"' | ${lib.getExe pkgs.slurp})
# ${pkgs.libnotify}/bin/notify-send "Starting recording" "Recording in 3 seconds" -a "record_script" -t 1000
# sleep 1
# ${pkgs.libnotify}/bin/notify-send "Starting recording" "Recording in 2 seconds" -a "record_script" -t 1000
# sleep 1
# ${pkgs.libnotify}/bin/notify-send "Starting recording" "Recording in 1 second" -t 1000
# sleep 1
${pkgs.wf-recorder}/bin/wf-recorder --pixel-format yuv420p -f "$FILE" -t --geometry "$GEOMETRY" & disown
${pkgs.wl-clipboard}/bin/wl-copy < "$FILE"
fi
'';
2025-02-18 20:17:57 +01:00
mkKeyboard = name: {
inherit name;
kb_layout = "eu";
};
2025-02-21 14:27:55 +01:00
mkMouse = name: sensitivity: {
inherit name;
2025-02-21 15:25:56 +01:00
inherit sensitivity;
2025-02-21 14:27:55 +01:00
};
2025-02-18 20:17:57 +01:00
in {
2025-02-19 23:42:24 +01:00
imports = [
./hyprpolkitagent.nix
2025-02-20 22:50:06 +01:00
./hyprpaper.nix
2025-04-15 23:48:15 +02:00
./hyprlock.nix
./hypridle.nix
2025-02-19 23:42:24 +01:00
];
2025-01-31 15:13:22 +01:00
config = {
programs.uwsm.enable = true;
programs.hyprland = {
package = pkgsUnstable.hyprland;
portalPackage = pkgsUnstable.xdg-desktop-portal-hyprland;
2025-01-31 15:13:22 +01:00
enable = true;
withUWSM = true;
xwayland.enable = true;
};
security.polkit.enable = true;
services.dbus.enable = true;
2025-02-24 07:55:57 +01:00
services.systembus-notify.enable = true;
2025-01-31 15:13:22 +01:00
environment.sessionVariables.NIXOS_OZONE_WL = "1";
2025-02-19 23:42:24 +01:00
environment.systemPackages = with pkgs; [
hyprcursor
];
2025-01-31 15:13:22 +01:00
2025-02-18 20:17:57 +01:00
fireproof.home-manager = {
2025-01-31 15:13:22 +01:00
wayland.windowManager.hyprland = {
enable = true;
xwayland.enable = true;
systemd.enable = false; # Conficts with UWSM
settings = {
2025-02-19 23:42:24 +01:00
env = [
"HYPRCURSOR_THEME,Adwaita"
"HYPRCURSOR_SIZE,24"
];
2025-02-18 20:17:57 +01:00
monitor =
map (
m: let
name =
if m.name != null
then m.name
else "";
resolution =
if m.resolution != null
then m.resolution
else "preferred";
refreshRate =
if m.refreshRate != null
then "@${builtins.toString m.refreshRate}"
else "";
position =
if m.position != null
then m.position
else "auto";
2025-02-21 14:27:55 +01:00
transform =
if m.transform != null
then ", transform, ${builtins.toString m.transform}"
else "";
in "${name}, ${resolution}${refreshRate}, ${position}, 1${transform}"
2025-02-18 20:17:57 +01:00
)
config.monitors;
2025-04-15 23:48:15 +02:00
exec = [
"systemctl --user start hyprpaper"
"systemctl --user start hypridle"
];
2025-02-20 22:50:06 +01:00
2025-02-18 20:17:57 +01:00
input = {
# Most unknown keyboards will be of the DK layout, we set known keyboards to eu in `devices`
kb_layout = "dk";
kb_options = "caps:backspace";
# Cursor focus will be detached from keyboard focus. Clicking on a window will move keyboard focus to that window.
follow_mouse = 2;
touchpad = {
natural_scroll = false;
};
2025-02-19 23:42:24 +01:00
sensitivity = 0;
accel_profile = "flat";
2025-02-18 20:17:57 +01:00
};
2025-02-19 23:42:24 +01:00
workspace =
if primaryMonitorName != ""
then [
"1, monitor:${primaryMonitorName}, persistent:true, default:true"
"2, monitor:${primaryMonitorName}, persistent:true"
"3, monitor:${primaryMonitorName}, persistent:true"
"4, monitor:${primaryMonitorName}, persistent:true"
"5, monitor:${primaryMonitorName}, persistent:true"
]
else [
"1, persistent:true, default:true"
"2, persistent:true"
"3, persistent:true"
"4, persistent:true"
"5, persistent:true"
];
2025-02-18 20:17:57 +01:00
# Names can be found with:
# $ hyprctl devices -j | jq '.["keyboards"].[].name' -r | grep -vE "(system|consumer)-control"
2025-02-21 15:25:56 +01:00
device =
[
# $ hyprctl devices -j | jq '.["mice"].[].name' -r
(mkMouse "logitech-usb-ps/2-optical-mouse" 0.2)
]
++ map mkKeyboard [
"splitkb-kyria-rev1"
"zsa-technology-labs-inc-ergodox-ez-shine"
"mattia-dal-ben-redox_wireless"
"zsa-technology-labs-inc-ergodox-ez-shine-keyboard"
];
2025-01-31 15:13:22 +01:00
general = {
gaps_in = 5;
gaps_out = 10;
border_size = 2;
2025-02-24 22:52:19 +01:00
"col.active_border" = color.accent;
2025-02-24 23:46:48 +01:00
"col.inactive_border" = color.ui;
2025-01-31 15:13:22 +01:00
layout = "dwindle";
};
cursor = {
no_warps = true;
};
misc = {
focus_on_activate = true;
disable_hyprland_logo = true;
2025-02-24 23:46:48 +01:00
background_color = color.bg;
2025-01-31 15:13:22 +01:00
force_default_wallpaper = 0;
middle_click_paste = false;
font_family = "Hack Nerd Font";
};
decoration = {
2025-02-24 22:52:19 +01:00
rounding = 8;
rounding_power = 4;
2025-01-31 15:13:22 +01:00
shadow = {
enabled = true;
2025-02-24 23:46:48 +01:00
color = "rgba(1a1a1aee)";
2025-01-31 15:13:22 +01:00
};
};
animations = {
enabled = true;
animation = [
"windows, 1, 4, default"
"windowsOut, 1, 4, default, popin 80%"
"border, 1, 10, default"
"borderangle, 1, 8, default"
"fade, 1, 7, default"
"workspaces, 1, 3, default"
];
};
dwindle = {
pseudotile = true;
preserve_split = true;
force_split = 2;
use_active_for_splits = true;
};
2025-02-24 22:52:19 +01:00
group = {
2025-02-24 23:46:48 +01:00
auto_group = false;
2025-02-24 22:52:19 +01:00
"col.border_inactive" = color.bg;
"col.border_active" = color.accent;
groupbar = {
enabled = true;
font_size = 12;
gradients = false;
height = 16;
indicator_height = 2;
2025-02-24 23:46:48 +01:00
"col.inactive" = color.ui;
2025-02-24 22:52:19 +01:00
"col.active" = color.accent;
"text_color" = color.fg;
};
};
2025-01-31 15:13:22 +01:00
bind = [
"SUPER, RETURN, exec, ${getExe config.programs.uwsm.package} app -- ${cfg.base.defaults.terminal}"
2025-01-31 15:13:22 +01:00
"SUPER, BACKSPACE, killactive"
"SUPER, SPACE, exec, astal launcher"
2025-03-06 22:21:43 +01:00
"SUPER, semicolon, exec, astal launcher .e"
2025-04-15 23:48:15 +02:00
"SUPER, p, exec, ${getExe config.programs.uwsm.package} app -- ${pkgs.systemd}/bin/loginctl lock-session"
2025-02-24 07:55:57 +01:00
", Print, exec, ${lib.getExe pkgs.grimblast} save area - | ${lib.getExe pkgs.satty} -f -"
"SHIFT, Print, exec, ${lib.getExe pkgs.grimblast} --freeze save area - | ${lib.getExe pkgs.satty} -f -"
"CTRL, Print, exec, ${lib.getExe record_script}"
2025-01-31 15:13:22 +01:00
"SUPER, S, togglefloating"
"SUPER, A, pseudo"
"SUPER, D, fullscreen"
"SUPER, BACKSLASH, togglesplit"
2025-02-24 07:55:57 +01:00
2025-01-31 15:13:22 +01:00
"SUPER, left, movefocus, l"
"SUPER, right, movefocus, r"
"SUPER, up, movefocus, u"
"SUPER, down, movefocus, d"
2025-02-24 07:55:57 +01:00
2025-01-31 15:13:22 +01:00
"SUPER, h, movefocus, l"
"SUPER, l, movefocus, r"
"SUPER, k, movefocus, u"
"SUPER, j, movefocus, d"
"SUPER, p, submap, preselect"
2025-02-24 07:55:57 +01:00
2025-01-31 15:13:22 +01:00
"SUPER, q, workspace, 1"
"SUPER, w, workspace, 2"
"SUPER, e, workspace, 3"
"SUPER, r, workspace, 4"
"SUPER, t, workspace, 5"
"SUPER SHIFT, q, movetoworkspace, 1"
"SUPER SHIFT, w, movetoworkspace, 2"
"SUPER SHIFT, e, movetoworkspace, 3"
"SUPER SHIFT, r, movetoworkspace, 4"
"SUPER SHIFT, t, movetoworkspace, 5"
2025-02-24 07:55:57 +01:00
2025-01-31 15:13:22 +01:00
"SUPER SHIFT, h, workspace, r-1"
"SUPER SHIFT, l, workspace, r+1"
2025-02-24 07:55:57 +01:00
"SUPER, M, togglegroup"
2025-01-31 15:13:22 +01:00
"SUPER, tab, changegroupactive, f"
"SUPER SHIFT, tab, changegroupactive, b"
];
2025-02-19 20:32:36 +00:00
bindm = [
"SUPER, mouse:272, movewindow"
"SUPER, mouse:273, resizewindow"
];
2025-01-31 15:13:22 +01:00
layerrule = [
"noanim, gtk4-layer-shell"
];
2025-02-24 07:55:57 +01:00
windowrulev2 = [
2025-02-24 15:36:30 +01:00
# Screenshots
2025-02-24 07:55:57 +01:00
"float,class:^(com.gabm.satty)$"
"dimaround,class:^(com.gabm.satty)$"
2025-02-24 15:36:30 +01:00
# Firefox
2025-02-24 07:55:57 +01:00
"float,class:^(firefox)$,title:^(Picture-in-Picture)$"
"float,class:^(firefox)$,title:^(Library)$"
2025-02-26 15:26:31 +01:00
"float,class:^(firefox)$,title:^(Bitwarden Password Manager)$"
2025-02-24 15:36:30 +01:00
# JetBrains
"center,class:^(jetbrains-.*)$,title:^$,floating:1"
"noinitialfocus,class:^(jetbrains-.*)$,title:^$,floating:1"
"noanim,class:^(jetbrains-.*)$,title:^$,floating:1"
2025-02-24 22:52:19 +01:00
2025-02-24 15:36:30 +01:00
"center,class:^(jetbrains-.*)$,title:^(splash)$,floating:1"
"nofocus,class:^(jetbrains-.*)$,title:^(splash)$,floating:1"
"noborder,class:^(jetbrains-.*)$,title:^(splash)$,floating:1"
2025-02-24 07:55:57 +01:00
];
2025-01-31 15:13:22 +01:00
};
};
};
};
}