feat(home-manager)!: add support for global cursors (#195)
* feat(home-manager)!: add support for global cursors this replaces the previous gtk module options * fix: document function types correctly in lib
This commit is contained in:
parent
2fb16f2d6f
commit
6e77fdd91d
5 changed files with 133 additions and 62 deletions
|
@ -4,6 +4,7 @@
|
||||||
./bottom.nix
|
./bottom.nix
|
||||||
./btop.nix
|
./btop.nix
|
||||||
./cava.nix
|
./cava.nix
|
||||||
|
./cursor.nix
|
||||||
./delta.nix
|
./delta.nix
|
||||||
./dunst.nix
|
./dunst.nix
|
||||||
./fcitx5.nix
|
./fcitx5.nix
|
||||||
|
|
28
modules/home-manager/cursor.nix
Normal file
28
modules/home-manager/cursor.nix
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
pkgs,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
inherit (lib) ctp mkIf;
|
||||||
|
cfg = config.catppuccin.pointerCursor;
|
||||||
|
|
||||||
|
# "dark" and "light" can be used alongside the regular accents
|
||||||
|
cursorAccentType = ctp.mergeEnums ctp.types.accentOption (
|
||||||
|
lib.types.enum [
|
||||||
|
"dark"
|
||||||
|
"light"
|
||||||
|
]
|
||||||
|
);
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.catppuccin.pointerCursor = ctp.mkCatppuccinOpt "cursors" // {
|
||||||
|
accent = ctp.mkBasicOpt "accent" cursorAccentType "cursors";
|
||||||
|
};
|
||||||
|
|
||||||
|
config.home.pointerCursor = mkIf cfg.enable {
|
||||||
|
name = "catppuccin-${cfg.flavor}-${cfg.accent}-cursors";
|
||||||
|
package = pkgs.catppuccin-cursors.${cfg.flavor + ctp.mkUpper cfg.accent};
|
||||||
|
};
|
||||||
|
}
|
|
@ -6,27 +6,24 @@
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
inherit (lib)
|
inherit (lib)
|
||||||
|
concatStringsSep
|
||||||
ctp
|
ctp
|
||||||
mkOption
|
mkIf
|
||||||
mkEnableOption
|
mkEnableOption
|
||||||
|
mkMerge
|
||||||
|
mkOption
|
||||||
|
mkRenamedOptionModule
|
||||||
types
|
types
|
||||||
;
|
;
|
||||||
cfg = config.gtk.catppuccin;
|
cfg = config.gtk.catppuccin;
|
||||||
enable = cfg.enable && config.gtk.enable;
|
enable = cfg.enable && config.gtk.enable;
|
||||||
# "dark" and "light" can be used alongside the regular accents
|
|
||||||
cursorAccentType = ctp.mergeEnums ctp.types.accentOption (
|
|
||||||
lib.types.enum [
|
|
||||||
"dark"
|
|
||||||
"light"
|
|
||||||
]
|
|
||||||
);
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.gtk.catppuccin = ctp.mkCatppuccinOpt "gtk" // {
|
options.gtk.catppuccin = ctp.mkCatppuccinOpt "gtk" // {
|
||||||
# NOTE: we are overriding the previous declaration of `enable` here
|
# NOTE: we are overriding the previous declaration of `enable` here
|
||||||
# as this module is deprecated and we do not want it to apply with
|
# as this module is deprecated and we do not want it to apply with
|
||||||
# the global `catppuccin.enable`
|
# the global `catppuccin.enable`
|
||||||
enable = lib.mkEnableOption "Catppuccin theme";
|
enable = mkEnableOption "Catppuccin theme";
|
||||||
|
|
||||||
accent = ctp.mkAccentOpt "gtk";
|
accent = ctp.mkAccentOpt "gtk";
|
||||||
size = mkOption {
|
size = mkOption {
|
||||||
|
@ -48,31 +45,74 @@ in
|
||||||
default = [ "normal" ];
|
default = [ "normal" ];
|
||||||
description = "Catppuccin tweaks for gtk";
|
description = "Catppuccin tweaks for gtk";
|
||||||
};
|
};
|
||||||
gnomeShellTheme = mkEnableOption "Catppuccin gtk theme for GNOME Shell";
|
|
||||||
|
|
||||||
cursor = ctp.mkCatppuccinOpt "gtk cursors" // {
|
gnomeShellTheme = mkEnableOption "Catppuccin gtk theme for GNOME Shell";
|
||||||
accent = ctp.mkBasicOpt "accent" cursorAccentType "gtk cursors";
|
|
||||||
};
|
|
||||||
|
|
||||||
icon = ctp.mkCatppuccinOpt "gtk modified Papirus icon theme" // {
|
icon = ctp.mkCatppuccinOpt "gtk modified Papirus icon theme" // {
|
||||||
accent = ctp.mkAccentOpt "gtk modified Papirus icon theme";
|
accent = ctp.mkAccentOpt "gtk modified Papirus icon theme";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = lib.mkIf enable {
|
imports = [
|
||||||
warnings = [
|
(mkRenamedOptionModule
|
||||||
''
|
[
|
||||||
`gtk.catppuccin` is deprecated and will be removed in a future release.
|
"gtk"
|
||||||
|
"catppuccin"
|
||||||
|
"cursor"
|
||||||
|
"enable"
|
||||||
|
]
|
||||||
|
[
|
||||||
|
"catppuccin"
|
||||||
|
"pointerCursor"
|
||||||
|
"enable"
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
The upstream port has been archived and support will no longer be provided.
|
(mkRenamedOptionModule
|
||||||
Please see https://github.com/catppuccin/gtk/issues/262
|
[
|
||||||
''
|
"gtk"
|
||||||
];
|
"catppuccin"
|
||||||
|
"cursor"
|
||||||
|
"flavor"
|
||||||
|
]
|
||||||
|
[
|
||||||
|
"catppuccin"
|
||||||
|
"pointerCursor"
|
||||||
|
"flavor"
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
gtk = {
|
(mkRenamedOptionModule
|
||||||
theme =
|
[
|
||||||
|
"gtk"
|
||||||
|
"catppuccin"
|
||||||
|
"cursor"
|
||||||
|
"accent"
|
||||||
|
]
|
||||||
|
[
|
||||||
|
"catppuccin"
|
||||||
|
"pointerCursor"
|
||||||
|
"accent"
|
||||||
|
]
|
||||||
|
)
|
||||||
|
];
|
||||||
|
|
||||||
|
config = mkMerge [
|
||||||
|
(mkIf (enable || cfg.gnomeShellTheme) {
|
||||||
|
warnings = [
|
||||||
|
''
|
||||||
|
`gtk.catppuccin.enable` and `gtk.catppuccin.gnomeShellTheme` are deprecated and will be removed in a future release.
|
||||||
|
|
||||||
|
The upstream port has been archived and support will no longer be provided.
|
||||||
|
Please see https://github.com/catppuccin/gtk/issues/262
|
||||||
|
''
|
||||||
|
];
|
||||||
|
})
|
||||||
|
|
||||||
|
(mkIf enable {
|
||||||
|
gtk.theme =
|
||||||
let
|
let
|
||||||
gtkTweaks = lib.concatStringsSep "," cfg.tweaks;
|
gtkTweaks = concatStringsSep "," cfg.tweaks;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
name = "catppuccin-${cfg.flavor}-${cfg.accent}-${cfg.size}+${gtkTweaks}";
|
name = "catppuccin-${cfg.flavor}-${cfg.accent}-${cfg.size}+${gtkTweaks}";
|
||||||
|
@ -83,49 +123,51 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
cursorTheme =
|
xdg.configFile =
|
||||||
let
|
let
|
||||||
accentUpper = ctp.mkUpper cfg.cursor.accent;
|
gtk4Dir = "${config.gtk.theme.package}/share/themes/${config.gtk.theme.name}/gtk-4.0";
|
||||||
in
|
in
|
||||||
lib.mkIf cfg.cursor.enable {
|
{
|
||||||
name = "catppuccin-${cfg.cursor.flavor}-${cfg.cursor.accent}-cursors";
|
"gtk-4.0/assets".source = "${gtk4Dir}/assets";
|
||||||
package = pkgs.catppuccin-cursors.${cfg.cursor.flavor + accentUpper};
|
"gtk-4.0/gtk.css".source = "${gtk4Dir}/gtk.css";
|
||||||
|
"gtk-4.0/gtk-dark.css".source = "${gtk4Dir}/gtk-dark.css";
|
||||||
};
|
};
|
||||||
|
})
|
||||||
|
|
||||||
iconTheme =
|
(mkIf cfg.icon.enable {
|
||||||
|
gtk.iconTheme =
|
||||||
let
|
let
|
||||||
# use the light icon theme for latte
|
# use the light icon theme for latte
|
||||||
polarity = if cfg.icon.flavor == "latte" then "Light" else "Dark";
|
polarity = if cfg.icon.flavor == "latte" then "Light" else "Dark";
|
||||||
in
|
in
|
||||||
lib.mkIf cfg.icon.enable {
|
{
|
||||||
name = "Papirus-${polarity}";
|
name = "Papirus-${polarity}";
|
||||||
package = pkgs.catppuccin-papirus-folders.override { inherit (cfg.icon) accent flavor; };
|
package = pkgs.catppuccin-papirus-folders.override { inherit (cfg.icon) accent flavor; };
|
||||||
};
|
};
|
||||||
};
|
})
|
||||||
|
|
||||||
xdg.configFile =
|
(mkIf cfg.gnomeShellTheme {
|
||||||
let
|
assertions = [
|
||||||
gtk4Dir = "${config.gtk.theme.package}/share/themes/${config.gtk.theme.name}/gtk-4.0";
|
{
|
||||||
in
|
assertion = enable;
|
||||||
{
|
message = "`gtk.enable` and `gtk.catppuccin.enable` must be `true` to use the GNOME shell theme";
|
||||||
"gtk-4.0/assets".source = "${gtk4Dir}/assets";
|
}
|
||||||
"gtk-4.0/gtk.css".source = "${gtk4Dir}/gtk.css";
|
];
|
||||||
"gtk-4.0/gtk-dark.css".source = "${gtk4Dir}/gtk-dark.css";
|
|
||||||
};
|
|
||||||
|
|
||||||
home.packages = lib.mkIf cfg.gnomeShellTheme [ pkgs.gnomeExtensions.user-themes ];
|
home.packages = [ pkgs.gnomeExtensions.user-themes ];
|
||||||
|
|
||||||
dconf.settings = lib.mkIf cfg.gnomeShellTheme {
|
dconf.settings = {
|
||||||
"org/gnome/shell" = {
|
"org/gnome/shell" = {
|
||||||
disable-user-extensions = false;
|
disable-user-extensions = false;
|
||||||
enabled-extensions = [ "user-theme@gnome-shell-extensions.gcampax.github.com" ];
|
enabled-extensions = [ "user-theme@gnome-shell-extensions.gcampax.github.com" ];
|
||||||
|
};
|
||||||
|
"org/gnome/shell/extensions/user-theme" = {
|
||||||
|
inherit (config.gtk.theme) name;
|
||||||
|
};
|
||||||
|
"org/gnome/desktop/interface" = {
|
||||||
|
color-scheme = if cfg.flavor == "latte" then "default" else "prefer-dark";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
"org/gnome/shell/extensions/user-theme" = {
|
})
|
||||||
inherit (config.gtk.theme) name;
|
];
|
||||||
};
|
|
||||||
"org/gnome/desktop/interface" = {
|
|
||||||
color-scheme = if cfg.flavor == "latte" then "default" else "prefer-dark";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ let
|
||||||
inherit (config.catppuccin) sources;
|
inherit (config.catppuccin) sources;
|
||||||
cfg = config.wayland.windowManager.hyprland.catppuccin;
|
cfg = config.wayland.windowManager.hyprland.catppuccin;
|
||||||
enable = cfg.enable && config.wayland.windowManager.hyprland.enable;
|
enable = cfg.enable && config.wayland.windowManager.hyprland.enable;
|
||||||
inherit (config.gtk.catppuccin) cursor;
|
inherit (config.catppuccin) pointerCursor;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.wayland.windowManager.hyprland.catppuccin = lib.ctp.mkCatppuccinOpt "hyprland" // {
|
options.wayland.windowManager.hyprland.catppuccin = lib.ctp.mkCatppuccinOpt "hyprland" // {
|
||||||
|
@ -11,9 +11,9 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
config = lib.mkIf enable {
|
config = lib.mkIf enable {
|
||||||
home.sessionVariables = lib.mkIf cursor.enable {
|
home.sessionVariables = lib.mkIf pointerCursor.enable {
|
||||||
HYPRCURSOR_SIZE = "24";
|
HYPRCURSOR_SIZE = "24";
|
||||||
HYPRCURSOR_THEME = "catppuccin-${cursor.flavor}-${cursor.accent}-cursors";
|
HYPRCURSOR_THEME = "catppuccin-${pointerCursor.flavor}-${pointerCursor.accent}-cursors";
|
||||||
};
|
};
|
||||||
|
|
||||||
wayland.windowManager.hyprland.settings = {
|
wayland.windowManager.hyprland.settings = {
|
||||||
|
@ -25,7 +25,7 @@ in
|
||||||
$accentAlpha=''$${cfg.accent}Alpha
|
$accentAlpha=''$${cfg.accent}Alpha
|
||||||
'')
|
'')
|
||||||
]
|
]
|
||||||
++ lib.optionals cursor.enable [
|
++ lib.optionals pointerCursor.enable [
|
||||||
(builtins.toFile "hyprland-cursors.conf" ''
|
(builtins.toFile "hyprland-cursors.conf" ''
|
||||||
env = HYPRCURSOR_THEME,MyCursor
|
env = HYPRCURSOR_THEME,MyCursor
|
||||||
env = HYPRCURSOR_SIZE,24
|
env = HYPRCURSOR_SIZE,24
|
||||||
|
|
|
@ -9,7 +9,7 @@ let
|
||||||
inherit (lib) ctp;
|
inherit (lib) ctp;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
# string -> type -> string -> a -> a
|
# string -> type -> string -> a
|
||||||
# this is an internal function and shouldn't be
|
# this is an internal function and shouldn't be
|
||||||
# used unless you know what you're doing. it takes
|
# used unless you know what you're doing. it takes
|
||||||
# a string (the name of the property, i.e., flavor
|
# a string (the name of the property, i.e., flavor
|
||||||
|
@ -23,7 +23,7 @@ in
|
||||||
description = "Catppuccin ${attr} for ${name}";
|
description = "Catppuccin ${attr} for ${name}";
|
||||||
};
|
};
|
||||||
|
|
||||||
# string -> a -> a
|
# string -> a
|
||||||
# this creates a flavor option for modules
|
# this creates a flavor option for modules
|
||||||
# the first string should be the name of the module,
|
# the first string should be the name of the module,
|
||||||
# followed by the local config attrset
|
# followed by the local config attrset
|
||||||
|
@ -105,7 +105,7 @@ in
|
||||||
in
|
in
|
||||||
fromJSON (readFile json);
|
fromJSON (readFile json);
|
||||||
|
|
||||||
# string -> a -> a
|
# string -> a
|
||||||
# this creates a basic attrset only containing an
|
# this creates a basic attrset only containing an
|
||||||
# enable and flavor option. the fist string should
|
# enable and flavor option. the fist string should
|
||||||
# be the name of the module, followed by the local config
|
# be the name of the module, followed by the local config
|
||||||
|
@ -117,7 +117,7 @@ in
|
||||||
flavor = ctp.mkFlavorOpt name;
|
flavor = ctp.mkFlavorOpt name;
|
||||||
};
|
};
|
||||||
|
|
||||||
# string -> a -> a
|
# string -> a
|
||||||
# this creates an accent option for modules
|
# this creates an accent option for modules
|
||||||
# the first string should be the name of the module,
|
# the first string should be the name of the module,
|
||||||
# followed by the local config attrset
|
# followed by the local config attrset
|
||||||
|
|
Loading…
Reference in a new issue