From 50dcc46fe6e75587dd899fbcbdead914153b9d16 Mon Sep 17 00:00:00 2001 From: Luc Chabassier Date: Sun, 19 Mar 2023 19:39:32 +0100 Subject: [PATCH] Add options to set font sizes (#60) Fixes #35 and #59 Co-authored-by: Daniel Thwaites --- modules/alacritty/hm.nix | 1 + modules/bemenu/hm.nix | 2 +- modules/dunst/hm.nix | 2 +- modules/grub/nixos.nix | 2 +- modules/gtk/hm.nix | 5 ++++- modules/i3/hm.nix | 6 ++++-- modules/kitty/hm.nix | 5 ++++- modules/mako/hm.nix | 2 +- modules/qutebrowser/hm.nix | 18 ++++++++++-------- modules/rofi/hm.nix | 2 +- modules/sway/hm.nix | 2 +- modules/vim/hm.nix | 6 ++++-- modules/xresources/hm.nix | 1 + stylix/fonts.nix | 37 +++++++++++++++++++++++++++++++++++++ 14 files changed, 71 insertions(+), 20 deletions(-) diff --git a/modules/alacritty/hm.nix b/modules/alacritty/hm.nix index f118c48..2677247 100644 --- a/modules/alacritty/hm.nix +++ b/modules/alacritty/hm.nix @@ -23,6 +23,7 @@ in family = monospace.name; style = "Regular"; }; + size = sizes.terminal; }; import = [ themeFile ]; }; diff --git a/modules/bemenu/hm.nix b/modules/bemenu/hm.nix index ed76be6..8d55f3f 100644 --- a/modules/bemenu/hm.nix +++ b/modules/bemenu/hm.nix @@ -7,7 +7,7 @@ with config.stylix.fonts; enable = config.lib.stylix.mkEnableTarget "bemenu" true; fontSize = lib.mkOption { type = with lib.types; nullOr int; - default = null; + default = sizes.popups; }; # optional argument alternate = lib.mkOption { type = lib.types.bool; default = false; }; }; diff --git a/modules/dunst/hm.nix b/modules/dunst/hm.nix index f3bd11b..a0d8667 100644 --- a/modules/dunst/hm.nix +++ b/modules/dunst/hm.nix @@ -11,7 +11,7 @@ with config.stylix.fonts; services.dunst.settings = { global = { separator_color = base02; - font = sansSerif.name; + font = "${sansSerif.name} ${toString sizes.popups}"; }; urgency_low = { diff --git a/modules/grub/nixos.nix b/modules/grub/nixos.nix index 9edff7f..7b985be 100644 --- a/modules/grub/nixos.nix +++ b/modules/grub/nixos.nix @@ -19,7 +19,7 @@ let ) # Convert to .pf2 - ${pkgs.grub2}/bin/grub-mkfont $font --output $out --size 17 + ${pkgs.grub2}/bin/grub-mkfont $font --output $out --size ${toString sizes.applications} ''; in { diff --git a/modules/gtk/hm.nix b/modules/gtk/hm.nix index 44776b2..91f8aef 100644 --- a/modules/gtk/hm.nix +++ b/modules/gtk/hm.nix @@ -38,7 +38,10 @@ in { # programs.dconf.enable = true; required in system config gtk = { enable = true; - font = config.stylix.fonts.sansSerif; + font = { + inherit (config.stylix.fonts.sansSerif) package name; + size = config.stylix.fonts.sizes.applications; + }; theme = { package = pkgs.adw-gtk3; name = "adw-gtk3"; diff --git a/modules/i3/hm.nix b/modules/i3/hm.nix index f93ebc7..e58cb5f 100644 --- a/modules/i3/hm.nix +++ b/modules/i3/hm.nix @@ -8,8 +8,10 @@ let focused = base0A; unfocused = base03; - fonts = { - names = [ config.stylix.fonts.sansSerif.name ]; + fonts = let + fonts = config.stylix.fonts; + in { + names = [ "${fonts.sansSerif.name} ${fonts.sizes.desktop}" ]; }; in { diff --git a/modules/kitty/hm.nix b/modules/kitty/hm.nix index 32f9d70..481a113 100644 --- a/modules/kitty/hm.nix +++ b/modules/kitty/hm.nix @@ -19,7 +19,10 @@ in { config = lib.mkIf cfg.enable { programs.kitty = { - font = config.stylix.fonts.monospace; + font = { + inherit (config.stylix.fonts.monospace) package name; + size = config.stylix.fonts.sizes.terminal; + }; extraConfig = builtins.readFile theme; }; }; diff --git a/modules/mako/hm.nix b/modules/mako/hm.nix index 0d95b24..a760126 100644 --- a/modules/mako/hm.nix +++ b/modules/mako/hm.nix @@ -13,7 +13,7 @@ with config.stylix.fonts; borderColor = base0D; textColor = base05; progressColor = "over ${base02}"; - font = sansSerif.name; + font = "${sansSerif.name} ${toString sizes.popups}"; # I wish the mako hm module was like the dunst one extraConfig = '' [urgency=low] diff --git a/modules/qutebrowser/hm.nix b/modules/qutebrowser/hm.nix index 4fa8d1b..7420d64 100644 --- a/modules/qutebrowser/hm.nix +++ b/modules/qutebrowser/hm.nix @@ -197,15 +197,17 @@ in { }; }; - fonts = { - default_family = sansSerif.name; + fonts = let + mkFont = name: "${name} ${toString sizes.applications}pt"; + in { + default_family = mkFont sansSerif.name; web.family = { - cursive = serif.name; - fantasy = serif.name; - fixed = monospace.name; - sans_serif = sansSerif.name; - serif = serif.name; - standard = sansSerif.name; + cursive = mkFont serif.name; + fantasy = mkFont serif.name; + fixed = mkFont monospace.name; + sans_serif = mkFont sansSerif.name; + serif = mkFont serif.name; + standard = mkFont sansSerif.name; }; }; }; diff --git a/modules/rofi/hm.nix b/modules/rofi/hm.nix index 8fedb9d..189519b 100644 --- a/modules/rofi/hm.nix +++ b/modules/rofi/hm.nix @@ -18,7 +18,7 @@ in config = lib.mkIf config.stylix.targets.rofi.enable { programs.rofi = { - font = monospace.name; + font = "${monospace.name} ${toString sizes.popups}"; theme = themeFile; }; }; diff --git a/modules/sway/hm.nix b/modules/sway/hm.nix index 0465ae5..11d5129 100644 --- a/modules/sway/hm.nix +++ b/modules/sway/hm.nix @@ -10,7 +10,7 @@ let fonts = { names = [ config.stylix.fonts.sansSerif.name ]; - size = 8.0; + size = config.stylix.fonts.sizes.desktop + 0.0; }; in { diff --git a/modules/vim/hm.nix b/modules/vim/hm.nix index 1836944..50ad62f 100644 --- a/modules/vim/hm.nix +++ b/modules/vim/hm.nix @@ -24,13 +24,15 @@ let ''; }; - vimOptions = { + vimOptions = let + fonts = config.stylix.fonts; + in { plugins = [ themePlugin ]; extraConfig = '' set termguicolors colorscheme base16-stylix unlet g:colors_name - set guifont=${escape [" "] config.stylix.fonts.monospace.name}:h10 + set guifont=${escape [" "] fonts.monospace.name}:h${toString fonts.sizes.terminal} ''; }; diff --git a/modules/xresources/hm.nix b/modules/xresources/hm.nix index 2e56542..4bde9be 100644 --- a/modules/xresources/hm.nix +++ b/modules/xresources/hm.nix @@ -20,6 +20,7 @@ in xresources = { properties = { "*.faceName" = monospace.name; + "*.faceSize" = sizes.terminal; "*.renderFont" = true; }; extraConfig = builtins.readFile themeFile; diff --git a/stylix/fonts.nix b/stylix/fonts.nix index 96cba91..7c14b26 100644 --- a/stylix/fonts.nix +++ b/stylix/fonts.nix @@ -3,6 +3,7 @@ with lib; let + cfg = config.stylix.fonts; fromOs = import ./fromos.nix { inherit lib args; }; @@ -57,5 +58,41 @@ in { name = "Noto Color Emoji"; }; }; + + sizes = { + desktop = mkOption { + description = '' + The font size used in window titles/bars/widgets elements of + the desktop. + ''; + type = types.ints.unsigned; + default = fromOs [ "fonts" "sizes" "desktop" ] 10; + }; + + applications = mkOption { + description = '' + The font size used by applications. + ''; + type = types.ints.unsigned; + default = fromOs [ "fonts" "sizes" "applications" ] 12; + }; + + terminal = mkOption { + description = '' + The font size for terminals/text editors. + ''; + type = types.ints.unsigned; + default = fromOs [ "fonts" "sizes" "terminal" ] cfg.sizes.applications; + }; + + popups = mkOption { + description = '' + The font size for notifications/popups and in general overlay + elements of the desktop. + ''; + type = types.ints.unsigned; + default = fromOs [ "fonts" "sizes" "popups" ] cfg.sizes.desktop; + }; + }; }; }