nixos/system/home/desktop/hyprland.nix
Evie Litherland-Smith 048d44ce6d Switch Thunar+Xarchiver for GNOME Nautilus and File-Roller
Add Sushi (NautilusPreviewer) for quick file previews

Add zathura back as PDF viewer

Update mimeapps for swayimg, mpv, zathura, etc...
2024-10-25 12:19:00 +01:00

439 lines
16 KiB
Nix

{
config,
lib,
pkgs,
...
}:
{
imports = [
./waybar.nix
./fuzzel.nix
./mako.nix
];
stylix.targets.hyprland.enable = false; # Use my own theme config
home.packages = [
pkgs.libreoffice-fresh
pkgs.ffmpeg
pkgs.swayimg
(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-qt;
avizo = {
enable = true;
settings.default.image-opacity = lib.mkForce "1.0";
};
kdeconnect = {
enable = true;
indicator = true;
};
hypridle = {
enable = true;
settings =
let
hyprctl = "${config.wayland.windowManager.hyprland.finalPackage}/bin/hyprctl";
in
{
general = {
after_sleep_cmd = "${hyprctl} dispatch dpms on";
ignore_dbus_inhibit = false;
lock_cmd = "hyprlock";
};
listener = [
{
timeout = 900;
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;
foreground = config.lib.stylix.scheme.base05;
background = config.lib.stylix.scheme.base00;
accent = config.lib.stylix.scheme.base0E;
in
{
enable = true;
settings = {
general = {
disable_loading_bar = true;
grace = 5;
hide_cursor = true;
no_fade_in = false;
};
background = [
{
monitor = "";
path = "screenshot";
blur_passes = 3;
blur_size = 8;
}
];
label = [
{
monitor = "";
text = "cmd[update:30000] echo \"$(date +\"%R\")\"";
color = "0xff${background}";
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${background}";
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${background}";
font_color = "0xff${foreground}";
fade_on_empty = false;
placeholder_text = "<span foreground=\"##${foreground}\">󰌾 Logged in as <span foreground=\"##${accent}\">$USER</span></span>";
hide_input = false;
position = "0, -50";
halign = "center";
valign = "center";
}
];
};
};
};
wayland.windowManager.hyprland = {
enable = true;
xwayland.enable = true;
systemd.enable = true;
settings = {
monitor = [ ",preferred,auto,auto" ];
env = [
"XDG_CURRENT_DESKTOP=Hyprland"
"XDG_SESSION_DESKTOP=Hyprland"
"GDK_BACKEND=wayland,x11"
"QT_AUTO_SCREEN_SCALE_FACTOR,1"
"QT_WAYLAND_DISABLE_WINDOWDECORATION,1"
"GRIM_DEFAULT_DIR,${config.xdg.userDirs.pictures}/Screenshots"
];
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"
"${pkgs.dex}/bin/dex -a"
# "systemctl --user start hyprland-session.target"
# "systemctl --user start hyprpaper.service"
];
gestures.workspace_swipe = true;
input = {
kb_layout = "gb";
kb_options = "ctrl:nocaps";
follow_mouse = 1;
touchpad.natural_scroll = "yes";
};
dwindle = {
force_split = 2;
preserve_split = false;
smart_split = false;
smart_resizing = false;
special_scale_factor = 0.95;
no_gaps_when_only = 0;
use_active_for_splits = true;
default_split_ratio = 1.0;
};
master = {
allow_small_split = true;
special_scale_factor = 0.95;
mfact = 0.5;
# new_is_master = false;
new_on_top = false;
no_gaps_when_only = 0;
orientation = "left";
inherit_fullscreen = false;
smart_resizing = false;
drop_at_cursor = true;
};
general = with config.lib.stylix.scheme; {
"col.active_border" = "rgb(${base0E})";
"col.inactive_border" = "rgb(${base04})";
gaps_in = 2.5;
gaps_out = 5;
border_size = 1;
# cursor_inactive_timeout = 0;
layout = "master";
};
decoration = {
rounding = 5;
"col.shadow" = "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
"float, org.kde.polkit-kde-authentication-agent-1|Pinentry"
"center, org.kde.polkit-kde-authentication-agent-1|Pinentry"
"pin, org.kde.polkit-kde-authentication-agent-1|Pinentry"
"dimaround, org.kde.polkit-kde-authentication-agent-1|Pinentry"
"stayfocused, org.kde.polkit-kde-authentication-agent-1|Pinentry"
"float, pavucontrol|.blueman-manager-wrapped|nm-connection-editor"
"size 800 600, pavucontrol|.blueman-manager-wrapped|nm-connection-editor"
"move onscreen 100%-820 60,pavucontrol|.blueman-manager-wrapped|nm-connection-editor"
# 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"
# LibreOffice
# "nofullscreenrequest, class:(libreoffice|soffice)(.*)"
# "nomaximizerequest, 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"
# Remmina / NoMachine
# "nofullscreenrequest, class:org.remmina.Remmina|Nxplayer.bin"
# "nomaximizerequest, 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 SHIFT, Q, exec, pkill rofi || ${config.programs.rofi.finalPackage}/bin/rofi -show powermenu -modi powermenu:${pkgs.rofi-power-menu}/bin/rofi-power-menu"
"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, 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.package}/bin/firefox"
"SUPER, F, exec, ${pkgs.gnome.nautilus}/bin/nautilus"
# fuzzel binds
"SUPER, Space, exec, ${config.programs.fuzzel.package}/bin/fuzzel"
# "SUPER, Space, exec, pkill rofi || ${config.programs.rofi.finalPackage}/bin/rofi -show drun"
# "SUPER, tab, exec, pkill rofi || ${config.programs.rofi.finalPackage}/bin/rofi -show window"
# "SUPER, A, exec, pkill rofi || ${config.programs.rofi.finalPackage}/bin/rofi -show emoji"
# rofi-pass binds
"SUPER, P, exec, pkill rofi || ${config.programs.rofi.pass.package}/bin/rofi-pass"
"SUPER SHIFT, P, exec, pkill rofi || ${config.programs.rofi.pass.package}/bin/rofi-pass --last-used"
"SUPER ALT, P, exec, pkill rofi || ${config.programs.rofi.pass.package}/bin/rofi-pass --insert"
# Terminal utilities
"SUPER, S, exec, ${
withTerm {
progname = "btm";
args = btm_args;
}
}"
"SUPER SHIFT, S, exec, ${
withTerm {
progname = "btm";
args = btm_args + " --basic";
}
}"
"SUPER, C, exec, ${withTerm { progname = "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}
'';
}