Files
dotfiles/homes/julian/features/hyprland/default.nix

406 lines
12 KiB
Nix

{
pkgs,
inputs,
config,
lib,
...
}: let
inherit
(inputs.nix-colors.colorschemes.${builtins.toString config.colorscheme.name})
palette
;
in {
imports = [
# inputs.hyprland.homeManagerModules.default
./waybar
./wofi
./mako
# ./hyprlock
./wlogout
../gammastep
./swayidle.nix
./swaylock.nix
./zathura.nix
./waypipe.nix
./hyprbars.nix
];
xdg.portal = {
extraPortals = [pkgs.xdg-desktop-portal-wlr];
config.hyprland = {
default = [
"wlr"
"gtk"
];
};
};
programs.imv.enable = true; # TODO: what is that
home.packages = with pkgs; [
hyprpicker
brightnessctl
frajul.hyprshot-gui
frajul.wl-ocr
wf-recorder
wl-clipboard
(pkgs.writeShellScriptBin "toggle-screen-mirroring" (
builtins.readFile ./toggle-screen-mirroring.sh
))
(pkgs.writeShellScriptBin "correct-workspace-locations" (
lib.concatStringsSep "\n" (
builtins.concatLists (
map (
monitor:
map (ws: "hyprctl dispatch moveworkspacetomonitor ${ws} ${monitor.name}") monitor.workspaces
)
config.monitors
)
)
))
];
services.cliphist = {
enable = true;
};
home.sessionVariables = {
MOZ_ENABLE_WAYLAND = 1;
QT_QPA_PLATFORM = "wayland";
LIBSEAT_BACKEND = "logind";
};
# services.hypridle = {
# enable = true;
# settings = {
# general = {
# after_sleep_cmd = "hyprctl dispatch dpms on";
# ignore_dbus_inhibit = false;
# lock_cmd = "hyprlock";
# };
# listener = [
# {
# timeout = 300; # 5min
# on-timeout = "brightnessctl -s set 10"; # set monitor backlight to minimum, avoid 0 on OLED monitor.
# on-resume = "brightnessctl -r"; # monitor backlight restore.
# }
# {
# timeout = 360; # 6min
# on-timeout = "hyprlock"; # lock screen when timeout has passed
# }
# {
# timeout = 600; # 10min
# on-timeout = "hyprctl dispatch dpms off"; # screen off when timeout has passed
# on-resume = "hyprctl dispatch dpms on"; # screen on when activity is detected after timeout has fired.
# }
# ];
# };
# };
# services.hypridle.enable = true; # can be configured
services.network-manager-applet.enable = true;
wayland.windowManager.hyprland = {
# Whether to enable Hyprland wayland compositor
enable = true;
# package = config.lib.nixGL.wrap (
# pkgs.hyprland.override {
# # nixgl needed?
# wrapRuntimeDeps = false;
# }
# );
systemd = {
enable = true;
# Same as default, but stop graphical-session too
extraCommands = lib.mkBefore [
"systemctl --user stop graphical-session.target"
"systemctl --user start hyprland-session.target"
];
variables = [
"DISPLAY"
"HYPRLAND_INSTANCE_SIGNATURE"
"WAYLAND_DISPLAY"
"XDG_CURRENT_DESKTOP"
];
};
# package = inputs.hyprland.packages."${pkgs.system}".hyprland; # does only work with nixos-unstable
# The hyprland package to use (simplifies use of plugins)
# package = inputs.hyprland.packages.${pkgs.system}.hyprland;
# Whether to enable XWayland
xwayland.enable = true;
# Optional
# Whether to enable hyprland-session.target on hyprland startup
# systemd.enable = true;
# Make PATH available to systemd services
# systemd.variables = [ "--all" ];
plugins = [
# inputs.hyprland-plugins.packages.${pkgs.system}.hyprbars # does only work with nixos-unstable
# hyprlandPlugins.hyprbars
];
settings = {
"$mod" = "SUPER";
# Environment variables programs like emacs have access to
env = "TERMINAL,${config.terminal}";
# Monitors
monitor = ",preferred,auto,1";
# Autostart
exec-once = ["firefox"];
# Look and Feel
general = {
gaps_in = 5;
gaps_out = 5;
layout = "dwindle";
# "col.active_border" = "0xff${palette.base0C} 0xff${palette.base0D} 270deg";
# "col.inactive_border" = "0xff${palette.base00}";
};
decoration = {
# power saving
blur.enabled = false;
# power saving
shadow.enabled = false;
};
# Dwindle layout
dwindle = {
pseudotile = true; # Master switch for pseudotiling. Enabling is bound to mainMod + P in the keybinds section below
preserve_split = true; # You probably want this
smart_split = false;
smart_resizing = false;
force_split = 2;
# no_gaps_when_only = 2; # with border
};
# Master layout
master = {
new_status = "slave";
# no_gaps_when_only = 2; # with border
mfact = 0.5; # Do not make master bigger
};
animations = {
enabled = true;
animation = [
"windows,1,3,default,slide"
"fade,1,3,default"
"layers,1,3,default,slide"
"border,1,3,default"
"workspaces,1,3,default,slide"
];
};
exec = [
"hyprctl setcursor ${config.gtk.cursorTheme.name} ${toString config.gtk.cursorTheme.size}"
"correct-workspace-locations"
];
misc = {
# disable auto polling for config file changes
disable_autoreload = true;
force_default_wallpaper = 0;
vfr = true; # power saving
};
render = {
# we do, in fact, want direct scanout
direct_scanout = true;
};
# Input
input = {
kb_layout = "de";
natural_scroll = false;
follow_mouse = 1;
};
# Window rules
windowrulev2 = [
"suppressevent maximize, class:.*"
"workspace 1, class:firefox"
"workspace 9, class:nheko"
"workspace 9, class:org.telegram.desktop"
"workspace 10, class:thunderbird"
"float, class:qalculate-gtk"
"tile, class:MATLAB, title:MATLAB"
];
# Workspace rules
workspace =
[
# smart gaps (none when only one window in workspace)
"w[t1], gapsin:0, gapsout:0, border:1"
"w[tg1], gapsin:0, gapsout:0, border:1"
"f[1], gapsin:0, gapsout:0, border:1"
]
# builds like "1, e-DP1" "2, HDMI-1" etc.
++ builtins.concatLists (
map (monitor: map (ws: "${ws}, monitor:${monitor.name}") monitor.workspaces) config.monitors
);
# Mouse binds
bindm = [
"$mod, mouse:272, movewindow" # leftclick
"$mod, mouse:273, resizewindow" # rightclick
];
# binds
bind =
[
# compositor commands
"$mod, Space, focuswindow, floating"
"$mod SHIFT, Space, togglefloating,"
"$mod, F, fullscreen,"
"$mod, X, killactive,"
"$mod, O, togglesplit," # dwindle
# opening applications
"$mod, D, exec, wofi --show drun,run"
"$mod, E, exec, pcmanfm"
"$mod, Return, exec, ${config.terminal}"
"$mod, B, exec, firefox"
"$mod, C, exec, qalculate-gtk"
# other commands
"$mod SHIFT, E, exec, wlogout -p layer-shell"
"$mod, Escape, exec, wlogout -p layer-shell"
"$mod SHIFT, R, exec, hyprctl reload"
"$mod, Print, exec, hyprshot-gui"
", Print, exec, hyprshot-gui"
"$mod, P, exec, toggle-screen-mirroring; correct-workspace-locations"
# "$mod SHIFT, E, exec, pkill Hyprland"
# "$mod, G, togglegroup,"
# "$mod SHIFT, N, changegroupactive, f"
# "$mod SHIFT, P, changegroupactive, b"
# "$mod ALT, ,resizeactive,"
# media keys
", XF86AudioRaiseVolume, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+"
", XF86AudioLowerVolume, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-"
", XF86AudioPlay, exec, playerctl play-pause"
", XF86AudioPause, exec, playerctl pause"
", XF86AudioStop, exec, playerctl stop"
", XF86AudioNext, exec, playerctl next"
", XF86AudioPrev, exec, playerctl previous"
", XF86AudioMute, exec, wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle"
", XF86MonBrightnessUp, exec, brightnessctl --class backlight set 5%+"
", XF86MonBrightnessDown, exec, brightnessctl --class backlight set 5%-"
# move focus
"$mod, left, movefocus, l"
"$mod, H, movefocus, l"
"$mod, right, movefocus, r"
"$mod, L, movefocus, r"
"$mod, up, movefocus, u"
"$mod, K, movefocus, u"
"$mod, down, movefocus, d"
"$mod, J, movefocus, d"
# move window
"$mod SHIFT, left, movewindow, l"
"$mod SHIFT, H, movewindow, l"
"$mod SHIFT, right, movewindow, r"
"$mod SHIFT, L, movewindow, r"
"$mod SHIFT, up, movewindow, u"
"$mod SHIFT, K, movewindow, u"
"$mod SHIFT, down, movewindow, d"
"$mod SHIFT, J, movewindow, d"
# 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"
# Move active window to a workspace without following with mainMod + CTRL + [0-9]
"$mod CTRL, 1, movetoworkspacesilent, 1"
"$mod CTRL, 2, movetoworkspacesilent, 2"
"$mod CTRL, 3, movetoworkspacesilent, 3"
"$mod CTRL, 4, movetoworkspacesilent, 4"
"$mod CTRL, 5, movetoworkspacesilent, 5"
"$mod CTRL, 6, movetoworkspacesilent, 6"
"$mod CTRL, 7, movetoworkspacesilent, 7"
"$mod CTRL, 8, movetoworkspacesilent, 8"
"$mod CTRL, 9, movetoworkspacesilent, 9"
"$mod CTRL, 0, movetoworkspacesilent, 10"
]
++
# Screen lock
(
let
swaylock = lib.getExe config.programs.swaylock.package;
in
lib.optionals config.programs.swaylock.enable [
"$mod,TAB,exec,${swaylock} --daemonize"
]
)
++
# Notification manager
(
let
makoctl = lib.getExe' config.services.mako.package "makoctl";
in
lib.optionals config.services.mako.enable [
"$mod,w,exec,${makoctl} dismiss"
"$mod SHIFT,W,exec,${makoctl} restore"
]
);
# plugin = {
# hyprbars = {
# bar_text_size = 10;
# bar_height = 16;
# bar_text_font = "Ubuntu Nerd Font";
# bar_precedence_over_border = true;
# bar_color = "rgb(${palette.base01})";
# hyprbars-button = [ "rgb(${palette.base03}), 14, 󰖭, hyprctl dispatch killactive" ];
# };
# };
};
};
}