feat: modular hyprland's configurations

This commit is contained in:
Ryan Yin
2023-12-24 22:09:18 +08:00
parent 55e12cddaf
commit 3aaaeb49ca
50 changed files with 71 additions and 76 deletions

View File

@@ -11,7 +11,7 @@
gtk.enable = true;
x11.enable = true;
package = pkgs.bibata-cursors;
name = "Bibata-Modern-Classic";
name = "Bibata-Modern-Ice";
size = 24;
};

View File

@@ -1,28 +1,3 @@
## Hyprland configuration file
# color-scheme: cappuccin-mocha
source=~/.config/hypr/themes/mocha.conf
env = _JAVA_AWT_WM_NONREPARENTING,1
env = QT_WAYLAND_DISABLE_WINDOWDECORATION,1
# fix https://github.com/hyprwm/Hyprland/issues/1520
env = WLR_NO_HARDWARE_CURSORS,1
#-- Output ----------------------------------------------------
# Configure your Display resolution, offset, scale and Monitors here, use `hyprctl monitors` to get the info.
# format:
# monitor=name,resolution,position,scale
# monitor=DP-2,3840x2160@144,0x0,1.6
# workspace=DP-2,1
# Shoukei's builtin display(Macbook Pro 2022 13.3 inch)
monitor=eDP-1,2560x1660@60,0x0,1.5
workspace=eDP-1,1
#-- Input ----------------------------------------------------
# Configure mouse and touchpad here.
input {
@@ -206,10 +181,9 @@ bind=SUPER,mouse_up,workspace,e-1
#-- Startup ----------------------------------------------------
exec-once=~/.config/hypr/scripts/startup
#-- Fcitx5 input method ----------------------------------------------------
# -- Fcitx5 input method
windowrule=pseudo,fcitx # enable this will make fcitx5 works, but fcitx5-configtool will not work!
exec-once=cp ~/.config/fcitx5/profile-bak ~/.config/fcitx5/profile # restore fcitx5 profile manged by nixos
exec-once=cp ~/.config/fcitx5/profile-bak ~/.config/fcitx5/profile # restore fcitx5 profile managed by nixos
exec-once=fcitx5 -d --replace # start fcitx5 daemon
bind=ALT,E,exec,pkill fcitx5 -9;sleep 1;fcitx5 -d --replace; sleep 1;fcitx5-remote -r
@@ -220,20 +194,4 @@ windowrulev2 = size 640 400, class:^(.*jetbrains.*)$, title:^(splash)$
# -- Fix input method in vscode
exec-once = hyprctl setcursor "Bibata-Modern-Ice" 24
# 效果是 wayland 原生窗口缩放完全正常
# xwayland 窗口先渲染到 200% 再降到 hyprland config 里 monitor 设置的值,看上去和原生没啥区别
# 相比较一开始的方案输入法字体大小也正确了.唯一有点问题的可能是 xwayland 窗口下的鼠标指针大小不对
exec-once = xprop -root -f _XWAYLAND_GLOBAL_OUTPUT_SCALE 32c -set _XWAYLAND_GLOBAL_OUTPUT_SCALE 2
-- Fix HiDPI - xwayland
# change monitor to high resolution, the last argument is the scale factor
monitor=,highres,auto,2
# unscale XWayland
xwayland {
force_zero_scaling = true
}
# toolkit-specific scale
env = GDK_SCALE,2
env = XCURSOR_SIZE,32

View File

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 32 KiB

View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

View File

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

View File

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 32 KiB

View File

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

View File

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

View File

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

View File

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

View File

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 34 KiB

View File

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 29 KiB

View File

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 33 KiB

View File

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

View File

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

View File

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

View File

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

View File

Before

Width:  |  Height:  |  Size: 8.4 KiB

After

Width:  |  Height:  |  Size: 8.4 KiB

View File

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

View File

Before

Width:  |  Height:  |  Size: 7.8 KiB

After

Width:  |  Height:  |  Size: 7.8 KiB

View File

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

View File

Before

Width:  |  Height:  |  Size: 7.0 KiB

After

Width:  |  Height:  |  Size: 7.0 KiB

View File

@@ -10,22 +10,38 @@ with lib; let
in {
imports = [
anyrun.homeManagerModules.default
./nvidia.nix
./options
];
options.modules.desktop.hyprland = {
enable = mkEnableOption "hyprland compositor";
settings = lib.mkOption {
type = with lib.types; let
valueType =
nullOr (oneOf [
bool
int
float
str
path
(attrsOf valueType)
(listOf valueType)
])
// {
description = "Hyprland configuration value";
};
in
valueType;
default = {};
};
};
config = mkIf cfg.enable (
mkMerge
(map
(path: import path args)
[
./hyprland.nix
./packages.nix
./anyrun.nix
./wayland-apps.nix
])
mkMerge ([
{
wayland.windowManager.hyprland.settings = cfg.settings;
}
]
++ (import ./values args))
);
}

View File

@@ -0,0 +1,3 @@
{mylib, ...}: {
imports = mylib.scanPaths ./.;
}

View File

@@ -17,8 +17,8 @@ in {
"XDG_SESSION_TYPE" = "wayland";
"GBM_BACKEND" = "nvidia-drm";
"__GLX_VENDOR_LIBRARY_NAME" = "nvidia";
# fix https://github.com/hyprwm/Hyprland/issues/1520
"WLR_NO_HARDWARE_CURSORS" = "1";
"WLR_EGL_NO_MODIFIRES" = "1";
};
};
}

View File

@@ -0,0 +1,4 @@
{mylib, ...} @ args:
map
(path: import path args)
(mylib.scanPaths ./.)

View File

@@ -11,9 +11,11 @@
# they are all depending on hyprland/i3's user graphical-session
wayland.windowManager.hyprland = {
enable = true;
settings = {
source = "${nur-ryan4yin.packages.${pkgs.system}.catppuccin-hyprland}/themes/mocha.conf";
};
package = hyprland.packages.${pkgs.system}.hyprland;
settings = {};
extraConfig = builtins.readFile ./hypr-conf/hyprland.conf;
extraConfig = builtins.readFile ../conf/hyprland.conf;
# gammastep/wallpaper-switcher need this to be enabled.
systemd.enable = true;
};
@@ -28,29 +30,25 @@
# hyprland configs, based on https://github.com/notwidow/hyprland
xdg.configFile = {
"hypr/mako" = {
source = ./hypr-conf/mako;
source = ../conf/mako;
recursive = true;
};
"hypr/scripts" = {
source = ./hypr-conf/scripts;
source = ../conf/scripts;
recursive = true;
};
"hypr/waybar" = {
source = ./hypr-conf/waybar;
source = ../conf/waybar;
recursive = true;
};
"hypr/wlogout" = {
source = ./hypr-conf/wlogout;
recursive = true;
};
"hypr/themes" = {
source = "${nur-ryan4yin.packages.${pkgs.system}.catppuccin-hyprland}/themes";
source = ../conf/wlogout;
recursive = true;
};
# music player - mpd
"mpd" = {
source = ./mpd;
source = ../conf/mpd;
recursive = true;
};
};
@@ -59,8 +57,14 @@
fonts.fontconfig.enable = true;
systemd.user.sessionVariables = {
"NIXOS_OZONE_WL" = "1"; # for any ozone-based browser & electron apps to run on wayland
"MOZ_ENABLE_WAYLAND" = "1"; # for firefox to run on wayland
"MOZ_WEBRENDER" = "1";
NIXOS_OZONE_WL = "1"; # for any ozone-based browser & electron apps to run on wayland
MOZ_ENABLE_WAYLAND = "1"; # for firefox to run on wayland
MOZ_WEBRENDER = "1";
# toolkit-specific scale
GDK_SCALE = "2";
XCURSOR_SIZE = "32";
# misc
_JAVA_AWT_WM_NONREPARENTING = "1";
QT_WAYLAND_DISABLE_WINDOWDECORATION = "1";
};
}

View File

@@ -1,9 +1,14 @@
{
modules.desktop.hyprland = {
nvidia = false;
# settings = {
# monitor = "";
# };
settings = {
# Configure your Display resolution, offset, scale and Monitors here, use `hyprctl monitors` to get the info.
# highres: get the best possible resolution
# auto: postition automatically
# 1.5: scale to 1.5 times
# bitdepth,10: enable 10 bit support
monitor = "eDP-1,highres,auto,1.5,bitdepth,10";
};
};
modules.desktop.i3 = {

View File

@@ -1,9 +1,14 @@
{
modules.desktop.hyprland = {
nvidia = false;
# settings = {
# monitor = "";
# };
settings = {
# Configure your Display resolution, offset, scale and Monitors here, use `hyprctl monitors` to get the info.
# highres: get the best possible resolution
# auto: postition automatically
# 1.5: scale to 1.5 times
# bitdepth,10: enable 10 bit support
monitor = "DP-2,highres,auto,1.5,bitdepth,10";
};
};
modules.desktop.i3 = {