BIG refactoring

This commit is contained in:
Charlie Root 2024-05-20 23:55:11 +02:00
commit 325f16a9d5
12 changed files with 343 additions and 28 deletions

View file

@ -0,0 +1,6 @@
{ config, pkgs, inputs, ... }: {
imports =
[ inputs.niri.nixosModules.niri ];
;
programs.niri.enable = true;
}

View file

View file

View file

@ -0,0 +1,297 @@
{ config, pkgs, lib, inputs, ... }:
with lib;
let
cfg = config.modules.programs.hyprland;
username = config.modules.other.system.username;
inherit (inputs.hyprland.packages.${pkgs.system}) hyprland;
inherit (inputs.anyrun.packages.${pkgs.system}) anyrun;
inherit (inputs.nixpkgs-wayland.packages.${pkgs.system})
wl-clipboard swww wlsunset;
inherit (inputs.waybar.packages.${pkgs.system}) waybar;
inherit (inputs.split-monitor-workspaces.packages.${pkgs.system})
split-monitor-workspaces;
in {
options.modules.programs.hyprland.enable = mkEnableOption "hyprland";
config = mkIf cfg.enable {
# xdg Portal
xdg.portal = {
enable = true;
extraPortals = [
pkgs.xdg-desktop-portal-gtk
inputs.hyprland.packages.${pkgs.system}.xdg-desktop-portal-hyprland
];
config.common.default = "*";
};
home-manager.users.${username} = {
wayland.windowManager.hyprland = {
enable = true;
package = hyprland;
# Split-monitor-workspaces provides awesome-like workspace behaviour
plugins = [ split-monitor-workspaces ];
# Xwayland for X applications
xwayland.enable = true;
# No idea why I set this
systemd = {
enable = true;
variables = [ "--all" ];
};
# Hyprland settings
settings = {
"$mainMod" = "SUPER";
# Monitor config
monitor = [
"DP-2,1920x1080,0x0,1"
"HDMI-A-2,1920x1080,1920x0,1"
"HDMI-A-1,1920x1080,3840x0,1"
# Had the shadow monitor bug, so had to disable all unknown monitors.
# "Unknown-1,disable"
];
# Workspace config
workspace = [
"1, monitor:HDMI-A-1, default:true"
"2, monitor:HDMI-A-1"
"3, monitor:HDMI-A-1"
"4, monitor:HDMI-A-1"
"5, monitor:HDMI-A-1"
"6, monitor:HDMI-A-1"
"7, monitor:HDMI-A-1"
"8, monitor:HDMI-A-1"
"9, monitor:HDMI-A-1"
"10, monitor:HDMI-A-1"
"11, monitor:HDMI-A-2, default:true"
"12, monitor:HDMI-A-2"
"13, monitor:HDMI-A-2"
"14, monitor:HDMI-A-2"
"15, monitor:HDMI-A-2"
"16, monitor:HDMI-A-2"
"17, monitor:HDMI-A-2"
"18, monitor:HDMI-A-2"
"19, monitor:HDMI-A-2"
"20, monitor:HDMI-A-2"
"21, monitor:DP-2, default:true"
"22, monitor:DP-2"
"23, monitor:DP-2"
"24, monitor:DP-2"
"25, monitor:DP-2"
"26, monitor:DP-2"
"27, monitor:DP-2"
"28, monitor:DP-2"
"29, monitor:DP-2"
"30, monitor:DP-2"
# scratchpads
"special:btop, decorate:false"
"special:pipewire, decorate:false"
"special:nixos, decorate:false"
"special:keepassxc, decorate:false"
];
# Input settings
input = {
kb_layout = "de";
kb_variant = "";
kb_model = "";
kb_options = "";
kb_rules = "";
follow_mouse = true;
repeat_rate = 50;
repeat_delay = 250;
tablet = { output = "HDMI-A-2"; };
};
general = {
sensitivity = 1.0;
gaps_in = 4;
gaps_out = 10;
border_size = 2;
};
#Decoration settings
decoration = {
rounding = 0;
blur = {
enabled = true;
size = 3;
passes = 2;
};
drop_shadow = 1;
shadow_range = 15;
shadow_render_power = 2;
shadow_ignore_window = 1;
shadow_offset = "2 4";
shadow_scale = 1;
};
# Bezier curves for aninmations.
# Generate your own at https://www.cssportal.com/css-cubic-bezier-generator/
bezier = [
"dupa, 0.1, 0.9, 0.1, 1.05"
"apf,0.76,0,0.24,1"
"fast,0.34,1.56,0.64,1"
];
# Hyprland anomations, using the above bezier curves
animations = {
enabled = true;
animation = [
"windows, 1, 4, dupa, popin"
"windowsOut, 1, 4, dupa, slide"
"border, 1, 15, default"
"fade, 1, 10, default"
"workspaces, 1, 5, dupa, slidevert"
];
};
dwindle = { no_gaps_when_only = true; };
debug.disable_logs = false;
misc = {
enable_swallow = true;
swallow_regex = "kitty";
focus_on_activate = true;
vrr = 1;
vfr = true;
animate_manual_resizes = false;
animate_mouse_windowdragging = false;
force_default_wallpaper = 0;
};
# Window rules for some programs.
windowrulev2 = [
"float, class:^(Tor Browser)$"
"float, class:^(mpv)$"
"float, class:^(imv)$"
"float, title:^(Picture-in-Picture)$"
"float, title:^(.*)(Choose User Profile)(.*)$"
"float, title:^(blob:null/)(.*)$"
"float, class:^(xdg-desktop-portal-gtk)$"
"float, class:^(code), title: ^(Open*)"
"size 70% 70%, class:^(code), title: ^(Open*)"
"center, class: ^(code), title: ^(Open*)"
"float, class:^(org.keepassxc.KeePassXC)$"
];
# Keybinds
bind = [
"$mainMod, RETURN, exec, ${pkgs.kitty}/bin/kitty -d ~"
"$mainMod, Q, killactive"
"$mainMod, F, fullscreen, 0"
"$mainMod, D, exec, ${pkgs.procps}/bin/pkill anyrun || ${anyrun}/bin/anyrun"
"$mainMod, SPACE, togglefloating, active"
"$mainMod, O, exec, obsidian --ozone-platform=wayland --enable-features=UseOzonePlatform --enable-features=WaylandWindowDecorations --enable-features=WebRTCPipeWireCpaturer --disable-gpu"
# workspaces
# split-workspace is because of the split-workspace plugin
"$mainMod, 1, split-workspace, 1"
"$mainMod, 2, split-workspace, 2"
"$mainMod, 3, split-workspace, 3"
"$mainMod, 4, split-workspace, 4"
"$mainMod, 5, split-workspace, 5"
"$mainMod, 6, split-workspace, 6"
"$mainMod, 7, split-workspace, 7"
"$mainMod, 8, split-workspace, 8"
"$mainMod, 9, split-workspace, 9"
"$mainMod, 0, split-workspace, 10"
"$mainMod SHIFT, 1, split-movetoworkspacesilent, 1"
"$mainMod SHIFT, 2, split-movetoworkspacesilent, 2"
"$mainMod SHIFT, 3, split-movetoworkspacesilent, 3"
"$mainMod SHIFT, 4, split-movetoworkspacesilent, 4"
"$mainMod SHIFT, 5, split-movetoworkspacesilent, 5"
"$mainMod SHIFT, 6, split-movetoworkspacesilent, 6"
"$mainMod SHIFT, 7, split-movetoworkspacesilent, 7"
"$mainMod SHIFT, 8, split-movetoworkspacesilent, 8"
"$mainMod SHIFT, 9, split-movetoworkspacesilent, 9"
"$mainMod SHIFT, 0, split-movetoworkspacesilent, 10"
# Screenshotting
"$mainMod, S, exec, ${pkgs.grimblast}/bin/grimblast copy area"
# File manager
"$mainMod, E, exec, ${pkgs.gnome.nautilus}/bin/nautilus"
# Toggle the four different special workspaces.
"$mainMod, B, togglespecialworkspace, btop"
"$mainMod, V, togglespecialworkspace, pipewire"
"$mainMod, N, togglespecialworkspace, nixos"
"$mainMod, X, togglespecialworkspace, keepassxc"
# Reload hyprland
"$mainMod, R, exec, ${hyprland}/bin/hyprctl reload"
# Restart waybar
"$mainMod CONTROL, B, exec, ${pkgs.procps}/bin/pkill waybar || ${waybar}/bin/waybar"
];
binde = [
# window focus
"$mainMod, H, movefocus, l"
"$mainMod, J, movefocus, d"
"$mainMod, K, movefocus, u"
"$mainMod, L, movefocus, r"
];
# Media controls
bindl = let
play-pause = "${pkgs.playerctl}/bin/playerctl play-pause";
stop = "${pkgs.playerctl}/bin/playerctl stop";
prev = "${pkgs.playerctl}/bin/playerctl previous";
next = "${pkgs.playerctl}/bin/playerctl next";
toggle-mute = "${pkgs.pamixer}/bin/pamixer --toggle-mute";
in [
", XF86AudioMedia, exec, ${play-pause}"
", XF86AudioPlay, exec, ${play-pause}"
", XF86AudioStop, exec, ${stop}"
", XF86AudioPrev, exec, ${prev}"
", XF86AudioNext, exec, ${next}"
", XF86AudioMute, exec, ${toggle-mute}"
];
# locked + repeat
bindle = let
volume_up = "${pkgs.pamixer}/bin/pamixer -ui 5";
volume_down = "${pkgs.pamixer}/bin/pamixer -ud 5";
in [
", XF86AudioRaiseVolume, exec, ${volume_up}"
", XF86AudioLowerVolume, exec, ${volume_down}"
];
# Mouse settings
bindm = [
"$mainMod, mouse:272, movewindow"
"$mainMod, mouse:273, resizewindow"
];
# Some more movement-related settings
binds = {
pass_mouse_when_bound = false;
movefocus_cycles_fullscreen = false;
};
# Programs which get executed at Hyprland start.
exec-once = [
#start waybar
# "${waybar}/bin/waybar"
# run persistent special workspace windows
"[workspace special:nixos; silent;tile] ${pkgs.bash}/bin/bash cd ~/repos/nichts && emacsclient -c"
"[workspace special:keepassxc; silent;tile] ${pkgs.keepassxc}/bin/keepassxc"
"${swww}/bin/swww-daemon"
"${wlsunset}/bin/wlsunset -S 06:00 -s 20:00"
];
exec = [
# kill (almost) everything on special workspaces
"${pkgs.procps}/bin/pkill btop"
"${pkgs.procps}/bin/pkill pavucontrol"
# and run it all again
"[workspace special:btop;silent;tile] ${pkgs.kitty}/bin/kitty -e ${pkgs.btop}/bin/btop"
# "[workspace special:pipewire silent;tile] ${pkgs.helvum}/bin/helvum"
"[workspace special:pipewire;silent;tile] ${pkgs.pavucontrol}/bin/pavucontrol"
# "${pkgs.networkmanagerapplet}/bin/nm-applet --indicator"
];
plugin = {
split-monitor-workspaces = {
count = 10;
keep_focused = true;
};
};
};
};
};
environment.systemPackages = with pkgs; [ mako libnotify ];
};
}

View file

View file

View file

@ -0,0 +1,170 @@
{
pkgs,
theme,
config,
...
}:
with theme.colors; {
programs.niri.settings = {
outputs."eDP-1".position = {
x = 0;
y = 0;
};
outputs."DP-2" = {
mode = {
width = 1920;
height = 1080;
refresh = 144.001;
};
position = {
x = 0;
y = -1080;
};
};
input = {
keyboard.xkb = {
layout = "pl";
options = "caps:escape";
};
touchpad = {
# disable when typing /trackpointing
dwt = true;
dwtp = true;
natural-scroll = true;
click-method = "clickfinger";
};
focus-follows-mouse = true;
warp-mouse-to-focus = true;
trackpoint.accel-speed = 0.001;
};
layout = {
gaps = 16;
center-focused-column = "never";
preset-column-widths = [
{proportion = 0.333;}
{proportion = 0.5;}
{proportion = 0.666;}
];
default-column-width = {proportion = 0.5;};
focus-ring = {
enable = true;
width = 2;
active.color = "#${accent}";
inactive.color = "#${overlay0}";
};
};
animations = let
butter = {
spring = {
damping-ratio = 0.75;
epsilon = 0.00010;
stiffness = 400;
};
};
smooth = {
spring = {
damping-ratio = 0.58;
epsilon = 0.00010;
stiffness = 735;
};
};
in {
slowdown = 1.3;
horizontal-view-movement = butter;
window-movement = butter;
workspace-switch = butter;
window-open = smooth;
window-close = smooth;
};
window-rules = [
{
geometry-corner-radius = let radius =8.0; in{
bottom-left = radius;
bottom-right = radius;
top-left = radius;
top-right = radius;
};
clip-to-geometry= true;
}
];
binds = with config.lib.niri.actions; let
sh = spawn "sh" "-c";
in {
"Mod+Return" = {
action = spawn "${pkgs.foot}/bin/foot";
cooldown-ms = 500;
};
"Mod+Space".action = spawn "${pkgs.fuzzel}/bin/fuzzel";
"Mod+V".action = sh "${pkgs.cliphist}/bin/cliphist list | fuzzel --dmenu | cliphist decode | wl-copy";
"Mod+Shift+Period".action = spawn "emoji";
"XF86AudioRaiseVolume".action = spawn "pamixer" "-i" "5";
"XF86AudioLowerVolume".action = spawn "pamixer" "-d" "5";
"XF86AudioMute".action = spawn "pamixer" "-t";
"XF86AudioMicMute".action = spawn "micmute";
"XF86MonBrightnessUp".action = spawn "brightnessctl" "set" "+5%";
"XF86MonBrightnessDown".action = spawn "brightnessctl" "set" "5%-";
"Super+WheelScrollDown".action = focus-workspace-down;
"Super+WheelScrollDown".cooldown-ms = 500;
"Super+WheelScrollUp".action = focus-workspace-up;
"Super+WheelScrollUp".cooldown-ms = 500;
"Super+WheelScrollRight".action = focus-column-right;
"Super+WheelScrollLeft".action = focus-column-left;
"Super+H".action = focus-column-left;
"Super+L".action = focus-column-right;
"Super+J".action = focus-workspace-down;
"Super+K".action = focus-workspace-up;
"Super+Left".action = focus-column-left;
"Super+Right".action = focus-column-right;
"Super+Down".action = focus-window-down;
"Super+Up".action = focus-window-up;
"Super+Print".action = screenshot-window;
"Super+Shift+Print".action = screenshot-screen;
"Super+Shift+S".action = screenshot;
"Super+Ctrl+H".action = move-column-left;
"Super+Ctrl+J".action = move-window-down;
"Super+Ctrl+K".action = move-window-up;
"Super+Ctrl+L".action = move-column-right;
"Super+U".action = move-workspace-down;
"Super+I".action = move-workspace-up;
"Super+Minus".action = set-column-width "-10%";
"Super+Equal".action = set-column-width "+10%";
"Super+Shift+Minus".action = set-window-height "-10%";
"Super+Shift+Equal".action = set-window-height "+10%";
"Super+Shift+H".action = focus-monitor-left;
"Super+Shift+J".action = focus-monitor-down;
"Super+Shift+K".action = focus-monitor-up;
"Super+Shift+L".action = focus-monitor-right;
"Super+Shift+Ctrl+H".action = move-column-to-monitor-left;
"Super+Shift+Ctrl+J".action = move-column-to-monitor-down;
"Super+Shift+Ctrl+K".action = move-column-to-monitor-up;
"Super+Shift+Ctrl+L".action = move-column-to-monitor-right;
"Super+R".action = switch-preset-column-width;
"Super+F".action = maximize-column;
"Super+Shift+F".action = fullscreen-window;
"Super+C".action = center-column;
"Mod+Q".action = close-window;
};
prefer-no-csd = true;
hotkey-overlay.skip-at-startup = true;
screenshot-path = "~/pics/ss/ss%Y-%m-%d %H-%M-%S.png";
};
}

View file

@ -0,0 +1,52 @@
{
pkgs,
lib,
theme,
...
}: let
mkService = lib.recursiveUpdate {
Unit.PartOf = ["graphical-session.target"];
Unit.After = ["graphical-session.target"];
Install.WantedBy = ["graphical-session.target"];
};
in {
imports = [./config.nix];
home.packages = with pkgs; [pamixer];
services = {
wlsunset = {
# TODO: fix opaque red screen issue
enable = true;
latitude = "52.0";
longitude = "21.0";
temperature = {
day = 6200;
night = 3750;
};
systemdTarget = "niri.service";
};
cliphist.enable = true;
};
systemd.user.targets = {
# fake a tray to let apps start
# https://github.com/nix-community/home-manager/issues/2064
tray = {
Unit = {
Description = "Home Manager System Tray";
Requires = ["graphical-session-pre.target"];
};
};
};
systemd.user.services = {
swaybg = mkService {
Unit = {
Description = "Wallpaper chooser";
After = "niri.service";
};
Service = {
ExecStart = "${lib.getExe pkgs.swaybg} -i ${theme.wallpaper}";
Restart = "always";
};
};
};
}

View file

@ -0,0 +1,28 @@
{ pkgs, inputs, config, ... }: {
programs.niri = {
enable = true;
package = inputs.niri.packages.${pkgs.system}.niri-unstable;
};
services = {
greetd = {
enable = true;
settings = rec {
initial_session = {
command = "${config.programs.niri.package}/bin/niri-session";
user = "vali";
};
default_session = initial_session;
};
};
gnome = {
# glib-networking.enable = true;
};
# lorri.enable = true;
# udisks2.enable = true;
# printing.enable = true;
# fstrim.enable = true;
};
}

View file

@ -0,0 +1,53 @@
{config, lib, ... }:
with lib;
let
cfg = config.modules.wms.wayland;
hyprland = config.modules.wms.wayland.hyprland;
in {
options.modules.wms.wayland.enable = mkEnableOption "wayland";
options.modules.wms.wayland.hyprland.enable = mkEnableOption "hyprland";
config = mkIf cfg.enable {
environment = {
variables = {
NIXOS_OZONE_WL = "1";
__GL_GSYNC_ALLOWED = "0";
__GL_VRR_ALLOWED = "0";
_JAVA_AWT_WM_NONEREPARENTING = "1";
SSH_AUTH_SOCK = "/run/user/1000/keyring/ssh";
DISABLE_QT5_COMPAT = "0";
GDK_BACKEND = "wayland,x11";
ANKI_WAYLAND = "1";
DIRENV_LOG_FORMAT = "";
WLR_DRM_NO_ATOMIC = "1";
QT_AUTO_SCREEN_SCALE_FACTOR = "1";
QT_QPA_PLATFORM = "wayland;xcb";
DISABLE_QT_COMPAT = "0";
QT_WAYLAND_DISABLE_WINDOWDECORATION = "1";
MOZ_ENABLE_WAYLAND = "1";
WLR_BACKEND = "vulkan";
WLR_RENDERER = "vulkan";
XDG_SESSION_TYPE = "wayland";
SDL_VIDEODRIVER = "wayland";
CLUTTER_BACKEND = "wayland";
WLR_DRM_DEVICES = "/dev/dri/card1:/dev/dri/card0";
# Session variables for Hyprland
(mkIf hyprland.enable LIBVA_DRIVER_NAME = "nvidia");
GTK_USE_PORTAL = "1";
NIXOS_XDG_OPEN_USE_PORTAL = "1";
XDG_CURRENT_DESKTOP = "Hyprland";
XDG_SESSION_TYPE = "wayland";
XDG_SESSION_DESKTOP = "Hyprland";
SDL_VIDEODRIVER = "wayland";
CLUTTER_BACKEND = "wayland";
GDK_BACKEND = "wayland";
WLR_RENDERER_ALLOW_SOFTWARE = "1";
QT_QPA_PLATFORM = "wayland";
# Needed anymore?
LIBSEAT_BACKEND = "logind";
# WLR_NO_HARDWARE_CURSORS = "1";
NIXOS_OZONE_WL = "1";
};
}
}