1

Further modularize hyprland config

This commit is contained in:
2023-05-24 23:02:37 +02:00
parent 5d3a1a5ec2
commit 26b95e5f10
6 changed files with 291 additions and 151 deletions

View File

@ -1,49 +1,16 @@
# Source a file (multi-file configs)
# source = ~/.config/hypr/myColors.conf
source = ~/.config/hypr/polkit.conf # NOTE: This needs to be sourced, because NixOS fills in the polkit executable path
source = ~/.config/hypr/waybar-reload.conf
source = ~/.config/hypr/monitors.conf # NOTE: This file is different for each system
# NOTE: Many of these are generated depending on the NixOS config
source = ~/.config/hypr/autostart.conf
source = ~/.config/hypr/floatingrules.conf
source = ~/.config/hypr/input.conf
# Execute your favorite apps at launch
# exec-once = waybar
exec-once = dunst
exec-once = hyprpaper
exec-once = kdeconnect-indicator # TODO: Only shows sometimes?
exec-once = nextcloud --background
exec-once = keepassxc
# exec-once = md.obsidian.Obsidian
# exec-once = firefox
exec-once = kitty
exec-once = wl-paste -t text --watch clipman store --no-persist
exec-once = wl-paste -p -t text --watch clipman store -P --histpath="~/.local/share/clipman-primary.json"
exec-once = hyprctl setcursor Bibata-Modern-Classic 16
# See https://wiki.hyprland.org/Configuring/Window-Rules/ for more
windowrulev2 = workspace 2, class:^(jetbrains-clion)$
windowrulev2 = workspace 2, class:^(code-url-handler)$
windowrulev2 = workspace 3, class:^(obsidian)$
windowrulev2 = workspace 4, class:^(firefox)$
windowrulev2 = workspace 4, class:^(chromium)$
# windowrulev2 = workspace 5, class:^(Steam)$
# windowrulev2 = workspace 5, class:^(steam_app_.+)$
# windowrulev2 = workspace 5, class:^(gamescope)$
windowrulev2 = workspace 9, class:^(mpv)$
windowrulev2 = workspace 10, class:^(Spotify)
windowrulev2 = workspace 10, class:^(discord)
windowrulev2 = float, class:^(org.kde.polkit-kde-authentication-agent-1)$
windowrulev2 = float, class:^(thunar)$, title:^(File Operation Progress)$
windowrulev2 = opacity 0.8 0.8, class:^(kitty)$
windowrulev2 = opacity 0.8 0.8, class:^(discord)$
windowrulev2 = opacity 0.8 0.8, class:^(Spotify)$
windowrulev2 = opacity 0.8 0.8, class:^(obsidian)$
windowrulev2 = opacity 0.8 0.8, class:^(jetbrains-clion)$
source = ~/.config/hypr/monitors.conf
source = ~/.config/hypr/polkit.conf
source = ~/.config/hypr/translucentrules.conf
source = ~/.config/hypr/waybar-reload.conf
source = ~/.config/hypr/workspaces.conf
source = ~/.config/hypr/workspacerules.conf
general {
# See https://wiki.hyprland.org/Configuring/Variables/ for more
gaps_in = 5
gaps_out = 20
border_size = 2
@ -57,8 +24,6 @@ general {
}
decoration {
# See https://wiki.hyprland.org/Configuring/Variables/ for more
rounding = 5
multisample_edges = on
blur = yes
@ -83,8 +48,6 @@ misc {
animations {
enabled = yes
# Some default animations, see https://wiki.hyprland.org/Configuring/Animations/ for more
bezier = myBezier, 0.05, 0.9, 0.1, 1.05
animation = windows, 1, 7, myBezier
@ -96,31 +59,20 @@ animations {
}
dwindle {
# See https://wiki.hyprland.org/Configuring/Dwindle-Layout/ for more
pseudotile = yes # master switch for pseudotiling. Enabling is bound to mainMod + P in the keybinds section below
preserve_split = yes # you probably want this
}
master {
# See https://wiki.hyprland.org/Configuring/Master-Layout/ for more
new_is_master = true
}
gestures {
# See https://wiki.hyprland.org/Configuring/Variables/ for more
workspace_swipe = off
}
# Example per-device config
# See https://wiki.hyprland.org/Configuring/Keywords/#executing for more
device:epic-mouse-v1 {
sensitivity = -0.5
}
# See https://wiki.hyprland.org/Configuring/Keywords/ for more
$mainMod = SUPER
# Example binds, see https://wiki.hyprland.org/Configuring/Binds/ for more
# bind = $mainMod, M, exit
# bind = $mainMod, P, pseudo # dwindle
# bind = $mainMod, J, togglesplit # dwindle
@ -147,7 +99,6 @@ bind = $mainMod, E, exec, kitty fish -c "nnncd -a -P p"
bind = $mainMod, P, exec, hyprpicker -a
bind = $mainMod, S, exec, grim -g "$(slurp)"
bind = $mainMod CTRL, S, exec, grim -g "$(slurp)" - | wl-copy
# bind = $mainMod, E, exec, dolphin
# Move windows in/out of groups
bind = $mainMod, G, togglegroup
@ -208,10 +159,6 @@ bind = CTRL ALT, R, moveworkspacetomonitor, 8 HDMI-A-1
bind = CTRL ALT, R, moveworkspacetomonitor, 9 HDMI-A-1
bind = CTRL ALT, R, moveworkspacetomonitor, 10 HDMI-A-2
# Scroll through existing workspaces with mainMod + scroll
# bind = $mainMod, mouse_down, workspace, e+1
# bind = $mainMod, mouse_up, workspace, e-1
# Move/resize windows with mainMod + LMB/RMB and dragging
bindm = $mainMod, mouse:272, movewindow
bindm = $mainMod, mouse:273, resizewindow

View File

@ -34,17 +34,16 @@ rec {
modules = {
chromium.enable = true;
# Config my modules
emacs = {
enable = false;
pgtkNativeComp = false;
nativeComp = false;
nixpkgs = true;
# emacs = {
# enable = false;
# pgtkNativeComp = false;
# nativeComp = false;
# nixpkgs = true;
doom.enable = true;
doom.autoSync = true;
doom.autoUpgrade = false; # Very volatile as the upgrade fails sometimes with bleeding edge emacs
};
# doom.enable = true;
# doom.autoSync = true;
# doom.autoUpgrade = false; # Very volatile as the upgrade fails sometimes with bleeding edge emacs
# };
email = {
enable = true;
@ -64,7 +63,7 @@ rec {
vaapi = false; # NOTE: Crashes AMDGPU driver fairly often (don't know why exactly)
disableTabBar = true;
defaultBookmarks = true;
gnomeTheme = true; # I like it also with Plasma
gnomeTheme = true;
};
fish.enable = true;
@ -86,6 +85,56 @@ rec {
helix.enable = true;
hyprland = {
enable = true;
theme = "Three-Bears";
autostart = [
"kdeconnect-indicator"
"nextcloud --background"
"keepassxc"
"kitty"
# "md.obsidian.Obsidian"
# "firefox"
];
workspacerules = {
"2" = [
"jetbrains-clion"
"code-url-handler"
];
"3" = [
"obsidian"
];
"4" = [
"firefox"
];
"10" = [
"discord"
"Spotify"
];
};
floating = [
{
class = "org.kde.polkit-kde-authentication-agent-1";
}
{
class = "thunar";
title = "File Operation Progress";
}
];
transparent = [
"kitty"
"discord"
"Spotify"
"obsidian"
"jetbrains-clion"
"code-url-handler"
];
};
kitty.enable = true;
misc = {
@ -103,7 +152,7 @@ rec {
};
# neovim = {
# enable = true;
# enable = false;
# alias = true;
# };
@ -114,10 +163,10 @@ rec {
nnn.enable = true;
ranger = {
enable = false;
preview = true;
};
# ranger = {
# enable = false;
# preview = true;
# };
vscode.enable = true;
};

View File

@ -18,54 +18,58 @@ rec {
config = {
modules = {
hyprland = {
enable = true;
theme = "Three-Bears";
kb-layout = "us";
kb-variant = "altgr-intl";
monitors = ''
# See https://wiki.hyprland.org/Configuring/Monitors/
monitor = HDMI-A-1, 2560x1440@144, 1920x0, 1
monitor = HDMI-A-2, 1920x1080@60, 0x0, 1
monitors = {
"HDMI-A-1" = {
width = 2560;
height = 1440;
rate = 144;
x = 1920;
y = 0;
scale = 1;
};
# I have the first 9 workspaces on the main monitor, the last one on the secondary monitor
workspace = 1, monitor:HDMI-A-1
workspace = 2, monitor:HDMI-A-1
workspace = 3, monitor:HDMI-A-1
workspace = 4, monitor:HDMI-A-1
workspace = 5, monitor:HDMI-A-1
workspace = 6, monitor:HDMI-A-1
workspace = 7, monitor:HDMI-A-1
workspace = 8, monitor:HDMI-A-1
workspace = 9, monitor:HDMI-A-1
workspace = 10, monitor:HDMI-A-2
'';
};
audio = {
enable = false;
carla.enable = false;
bitwig.enable = true; # TODO: Check what happens when upgrade plan ends, do I need to pin the version then?
tenacity.enable = true;
faust.enable = true;
bottles.enable = false;
yabridge.enable = true;
yabridge.autoSync = true;
noisesuppression = {
noisetorch.enable = false;
noisetorch.autostart = false;
easyeffects.enable = false;
easyeffects.autostart = false;
"HDMI-A-2" = {
width = 1920;
height = 1080;
rate = 60;
x = 0;
y = 0;
scale = 1;
};
};
cardinal.enable = true;
distrho.enable = true;
workspaces = {
"HDMI-A-1" = [1 2 3 4 5 6 7 8 9];
"HDMI-A-2" = [10];
};
};
# audio = {
# enable = false;
# carla.enable = false;
# bitwig.enable = true; # TODO: Check what happens when upgrade plan ends, do I need to pin the version then?
# tenacity.enable = true;
# faust.enable = true;
# bottles.enable = false;
# yabridge.enable = true;
# yabridge.autoSync = true;
# noisesuppression = {
# noisetorch.enable = false;
# noisetorch.autostart = false;
# easyeffects.enable = false;
# easyeffects.autostart = false;
# };
# cardinal.enable = true;
# distrho.enable = true;
# };
gaming = {
enable = true;

View File

@ -18,30 +18,25 @@ rec {
config = {
modules = {
hyprland = {
enable = true;
theme = "Three-Bears";
# kb-layout = "de";
# kb-variant = "nodeadkeys";
kb-layout = "us";
kb-variant = "altgr-intl";
monitors = ''
# See https://wiki.hyprland.org/Configuring/Monitors/
monitor = eDP-1, 1920x1080@60, 0x0, 1
monitors = {
"eDP-1" = {
width = 1920;
height = 1080;
rate = 60;
x = 0;
y = 0;
scale = 1;
};
};
# I have the first 9 workspaces on the main monitor, the last one on the secondary monitor
workspace = 1, monitor:eDP-1
workspace = 2, monitor:eDP-1
workspace = 3, monitor:eDP-1
workspace = 4, monitor:eDP-1
workspace = 5, monitor:eDP-1
workspace = 6, monitor:eDP-1
workspace = 7, monitor:eDP-1
workspace = 8, monitor:eDP-1
workspace = 9, monitor:eDP-1
'';
workspaces = {
"eDP-1" = [1 2 3 4 5 6 7 8 9];
};
};
};

View File

@ -71,7 +71,78 @@ in {
home.file.".config/hypr/polkit.conf".text = ''exec-once = ${pkgs.libsForQt5.polkit-kde-agent}/libexec/polkit-kde-authentication-agent-1'';
# Monitors for different systems
home.file.".config/hypr/monitors.conf".text = cfg.monitors;
home.file.".config/hypr/monitors.conf".text = let
# Used by mapAttrs
mkMonitor = name: conf: "monitor = ${name}, ${toString conf.width}x${toString conf.height}@${toString conf.rate}, ${toString conf.x}x${toString conf.y}, ${toString conf.scale}";
# Makes "HDMI-A-1" = {width=2560;...} to "HDMI-A-1" = "monitor = ..."
monitors-attrs = mapAttrs mkMonitor cfg.monitors;
# Makes "HDMI-A-1" = "monitor = ..." to "monitor = ..."
monitors-values = attrValues monitors-attrs;
monitors = concatStringsSep "\n" monitors-values;
in
monitors;
# Bind workspaces to monitors
home.file.".config/hypr/workspaces.conf".text = let
# Make a single monitor string
mkWorkspace = monitor: workspace: "workspace = ${toString workspace}, monitor:${toString monitor}";
# Used by mapAttrs
mkWorkspaces = monitor: workspace-list: map (mkWorkspace monitor) workspace-list;
# Makes {"HDMI-A-1" = [1 2]; ...} to {"HDMI-A-1" = ["monitor = ..." "monitor = ..."] ...}
workspaces-attrs = mapAttrs mkWorkspaces cfg.workspaces;
# Makes {"HDMI-A-1" = [1 2]; ...} to ["monitor = ..." "monitor = ..." ...]
workspaces-values = concatLists (attrValues workspaces-attrs);
workspaces = concatStringsSep "\n" workspaces-values;
in
workspaces;
# Autostart applications
home.file.".config/hypr/autostart.conf".text = let
# Stuff that is not negotiable
always-exec = [
"dunst" # Notifications
"hyprpaper"
"wl-paste -t text --watch clipman store --no-persist"
"wl-paste -p -t text --watch clipman store -P --histpath=\"~/.local/share/clipman-primary.json\""
"hyprctl setcursor Bibata-Modern-Classic 16"
];
mkExec = prog: "exec-once = ${prog}";
execs-list = map mkExec (cfg.autostart ++ always-exec);
execs = concatStringsSep "\n" execs-list;
in
execs;
# Assign windows to workspaces
home.file.".config/hypr/workspacerules.conf".text = let
mkWorkspaceRule = workspace: class: "windowrulev2 = workspace ${workspace}, class:^(${class})$";
mkWorkspaceRules = workspace: class-list: map (mkWorkspaceRule workspace) class-list;
workspace-rules-attrs = mapAttrs mkWorkspaceRules cfg.workspacerules;
workspace-rules-values = concatLists (attrValues workspace-rules-attrs);
workspace-rules = concatStringsSep "\n" workspace-rules-values;
in
workspace-rules;
# Make windows float
home.file.".config/hypr/floatingrules.conf".text = let
mkFloatingRule = attrs:
"windowrulev2 = float"
+ (lib.optionalString (hasAttr "class" attrs) ", class:^(${attrs.class})$")
+ (lib.optionalString (hasAttr "title" attrs) ", title:^(${attrs.title})$");
floating-rules-list = map mkFloatingRule cfg.floating;
floating-rules = concatStringsSep "\n" floating-rules-list;
in
floating-rules;
# Make windows translucent
home.file.".config/hypr/translucentrules.conf".text = let
opacity = 0.8;
mkTranslucentRule = class: "windowrulev2 = opacity ${toString opacity} ${toString opacity}, class:^(${class})$";
translucent-rules-list = map mkTranslucentRule cfg.transparent;
translucent-rules = concatStringsSep "\n" translucent-rules-list;
in
translucent-rules;
# Keyboard layout
home.file.".config/hypr/input.conf".text = ''
@ -92,6 +163,9 @@ in {
}
'';
# TODO: I want to generate the config in ~/.config/waybar through nix again
# to allow adding waybar options to the hyprland module (like monitor and style).
# The goal is to set the style completely through nix...
home.file.".config/hypr/waybar-reload.conf".text = let
waybar-reload = pkgs.writeScript "waybar-reload" ''
#! ${pkgs.bash}/bin/bash
@ -108,27 +182,22 @@ in {
exec-once = ${waybar-reload}
'';
home.file.".config/hypr/hyprpaper.conf".text = ''
# Set wallpaper for each configured monitor
home.file.".config/hypr/hyprpaper.conf".text = let
mkWallpaper = monitor: "wallpaper = ${monitor}, ${config.home.homeDirectory}/NixFlake/wallpapers/${cfg.theme}.png";
wallpapers-list = map mkWallpaper (attrNames cfg.monitors);
wallpapers = concatStringsSep "\n" wallpapers-list;
in ''
preload = ~/NixFlake/wallpapers/${cfg.theme}.png
wallpaper = HDMI-A-1, ~/NixFlake/wallpapers/${cfg.theme}.png
wallpaper = HDMI-A-2, ~/NixFlake/wallpapers/${cfg.theme}.png
${wallpapers}
'';
home.activation = {
# NOTE: Keep the hyprland/waybar config symlinked, to allow easy changes with hotreload
# TODO: Don't symlink at all, why not just tell Hyprland where the config is? Much easier
# TODO: Use this approach for every program that supports it, makes things much easier,
# as everything can just stay in ~/NixFlake/config
linkHyprlandConfig =
hm.dag.entryAfter ["writeBoundary"]
(mkLink "~/NixFlake/config/hyprland/hyprland.conf" "~/.config/hypr/hyprland.conf");
# linkWaybarConfig = hm.dag.entryAfter ["writeBoundary"]
# (mkLink "~/NixFlake/config/waybar/config" "~/.config/waybar/config");
# linkWaybarStyle = hm.dag.entryAfter ["writeBoundary"]
# (mkLink "~/NixFlake/config/waybar/style.css" "~/.config/waybar/style.css");
# linkWaybarColors = hm.dag.entryAfter ["writeBoundary"]
# (mkLink "~/NixFlake/config/waybar/colors" "~/.config/waybar/colors");
};
home.packages = with pkgs; [

View File

@ -9,21 +9,97 @@ with mylib.modules; {
kb-layout = mkOption {
type = types.str;
example = "us";
description = "Keyboard layout to use";
};
kb-variant = mkOption {
type = types.str;
example = "altgr-intl";
description = "Keyboard layout variant";
};
theme = mkOption {
type = types.str;
example = "Three-Bears";
description = "Wallpaper and colorscheme to use";
};
monitors = mkOption {
type = types.str;
description = "Hyprland monitor configuration";
type = types.attrs;
description = "Hyprland Monitor Configurations";
example = ''
{
"HDMI-A-1" = {
width = 2560;
height = 1440;
rate = 144;
x = 1920;
y = 0;
scale = 1;
}
}
'';
};
workspaces = mkOption {
type = types.attrs;
description = "How workspaces are distributed to monitors. These monitors will also receive a wallpaper.";
example = ''
{
"HDMI-A-1" = [1 2 3 4 5 6 7 8 9];
"HDMI-A-2" = [0];
}
'';
};
autostart = mkOption {
type = types.listOf types.str;
description = "Programs to launch when Hyprland starts";
example = ''
[
"keepassxc"
"nextcloud --background"
]
'';
};
workspacerules = mkOption {
type = types.attrs;
description = "Launch programs on specified workspaces, accepts window class.";
example = ''
{
"2" = [
"jetbrains-clion"
"code-url-handler"
];
}
'';
};
floating = mkOption {
type = types.listOf types.attrs;
description = "What programs are floating down here?";
example = ''
[
{
class = "thunar";
title = "File Operation Progress";
}
{
class = "org.kde.polkit-kde-authentication-agent-1";
}
]
'';
};
transparent = mkOption {
type = types.listOf types.str;
description = "What programs should be transparent? Accepts window class.";
example = ''
[
"kitty"
]
'';
};
}