treewide: optionalize stylix.image option (#717)
Optionalize the stylix.image option when stylix.base16Scheme is set,
making the following Stylix configurations valid:
[
// Now it possible to set 'stylix.image = null', if
// stylix.base16Scheme is set.
{
base16Scheme = /* ... */;
}
// This configuration was already possible.
{
image = /* ... */;
}
// This configuration was already possible.
{
base16Scheme = /* ... */;
image = /* ... */;
}
]
Closes: https://github.com/danth/stylix/issues/200
Closes: https://github.com/danth/stylix/issues/442
Link: https://github.com/danth/stylix/pull/717
Co-authored-by: NAHO <90870942+trueNAHO@users.noreply.github.com>
Reviewed-by: NAHO <90870942+trueNAHO@users.noreply.github.com>
Tested-by: NAHO <90870942+trueNAHO@users.noreply.github.com>
Reviewed-by: Daniel Thwaites <danth@danth.me>
This commit is contained in:
parent
f121a142ab
commit
c8e4a0d218
19 changed files with 401 additions and 290 deletions
7
.github/workflows/check.yml
vendored
7
.github/workflows/check.yml
vendored
|
|
@ -77,7 +77,12 @@ jobs:
|
|||
- uses: DeterminateSystems/nix-installer-action@v16
|
||||
with:
|
||||
extra-conf: |-
|
||||
allow-import-from-derivation = false
|
||||
allow-import-from-derivation = ${{
|
||||
startsWith(matrix.check.key, 'testbed:') &&
|
||||
contains(matrix.check.key, ':schemeless') &&
|
||||
'true' ||
|
||||
'false'
|
||||
}}
|
||||
|
||||
- run: |
|
||||
nix build --no-update-lock-file --print-build-logs \
|
||||
|
|
|
|||
|
|
@ -16,53 +16,12 @@ To enable the Stylix module, declare:
|
|||
> examples which don't include it. No other settings will take effect unless
|
||||
> `stylix.enable` is set to `true`.
|
||||
|
||||
## Wallpaper
|
||||
|
||||
To start theming, you need to set a wallpaper image.
|
||||
|
||||
```nix
|
||||
{
|
||||
stylix.image = ./wallpaper.png;
|
||||
}
|
||||
```
|
||||
|
||||
The option accepts derivations as well as paths, so you can fetch an image
|
||||
directly from the internet:
|
||||
|
||||
```nix
|
||||
{
|
||||
stylix.image = pkgs.fetchurl {
|
||||
url = "https://www.pixelstalk.net/wp-content/uploads/2016/05/Epic-Anime-Awesome-Wallpapers.jpg";
|
||||
sha256 = "enQo3wqhgf0FEPHj2coOCvo7DuZv+x5rL/WIo4qPI50=";
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
## Color scheme
|
||||
|
||||
### Generated schemes
|
||||
|
||||
If you only set a wallpaper, Stylix will use a
|
||||
[genetic algorithm](https://en.wikipedia.org/wiki/Genetic_algorithm)
|
||||
to create a color scheme. The quality of these schemes can vary, but more
|
||||
colorful images tend to have better results.
|
||||
|
||||
You can force a light or dark scheme using the polarity option:
|
||||
|
||||
```nix
|
||||
{
|
||||
stylix.polarity = "dark";
|
||||
}
|
||||
```
|
||||
|
||||
The current scheme can be previewed in a web browser at either
|
||||
[`/etc/stylix/palette.html`](file:///etc/stylix/palette.html) for NixOS, or
|
||||
`~/.config/stylix/palette.html` for Home Manager.
|
||||
|
||||
### Handmade schemes
|
||||
|
||||
If you prefer a handmade color scheme, you can choose anything from
|
||||
[the Tinted Theming repository](https://github.com/tinted-theming/schemes):
|
||||
To set a [Tinted Theming](https://github.com/tinted-theming/schemes) color
|
||||
scheme, declare:
|
||||
|
||||
```nix
|
||||
{
|
||||
|
|
@ -116,6 +75,46 @@ For more complex configurations you may find it simpler to use
|
|||
See [base16.nix](https://github.com/SenchoPens/base16.nix) documentation for
|
||||
usage examples.
|
||||
|
||||
## Wallpaper
|
||||
|
||||
To set a wallpaper, provide a path or an arbitrary derivation:
|
||||
|
||||
- ```nix
|
||||
{
|
||||
stylix.image = ./wallpaper.png;
|
||||
}
|
||||
```
|
||||
|
||||
- ```nix
|
||||
{
|
||||
stylix.image = pkgs.fetchurl {
|
||||
url = "https://www.pixelstalk.net/wp-content/uploads/2016/05/Epic-Anime-Awesome-Wallpapers.jpg";
|
||||
sha256 = "enQo3wqhgf0FEPHj2coOCvo7DuZv+x5rL/WIo4qPI50=";
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
If `stylix.base16Scheme` is undeclared, Stylix generates a color scheme based on
|
||||
the wallpaper using a [genetic
|
||||
algorithm](https://en.wikipedia.org/wiki/Genetic_algorithm). Note that more
|
||||
colorful images tend to yield better results. The algorithm's polarity can be
|
||||
schewed towards a dark or light theme with:
|
||||
|
||||
- ```nix
|
||||
{
|
||||
stylix.polarity = "dark";
|
||||
}
|
||||
```
|
||||
|
||||
- ```nix
|
||||
{
|
||||
stylix.polarity = "light";
|
||||
}
|
||||
```
|
||||
|
||||
The generated color scheme can be viewed at `/etc/stylix/palette.html` on NixOS,
|
||||
or at `~/.config/stylix/palette.html` on Home Manager.
|
||||
|
||||
## Fonts
|
||||
|
||||
The default combination of fonts is:
|
||||
|
|
|
|||
|
|
@ -4,16 +4,21 @@
|
|||
lib,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
cfg = config.stylix.targets.feh;
|
||||
in
|
||||
{
|
||||
options.stylix.targets.feh.enable =
|
||||
config.lib.stylix.mkEnableTarget "the desktop background using Feh" true;
|
||||
options.stylix.targets.feh = {
|
||||
enable = config.lib.stylix.mkEnableTarget "the desktop background using Feh" (
|
||||
config.stylix.image != null
|
||||
);
|
||||
};
|
||||
|
||||
config.xsession.initExtra =
|
||||
lib.mkIf
|
||||
(
|
||||
config.stylix.enable
|
||||
&& config.stylix.targets.feh.enable
|
||||
&& cfg.enable
|
||||
&& (
|
||||
with config.xsession.windowManager;
|
||||
bspwm.enable
|
||||
|
|
|
|||
|
|
@ -4,16 +4,21 @@
|
|||
lib,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
cfg = config.stylix.targets.feh;
|
||||
in
|
||||
{
|
||||
options.stylix.targets.feh.enable =
|
||||
config.lib.stylix.mkEnableTarget "the desktop background using Feh" true;
|
||||
options.stylix.targets.feh = {
|
||||
enable = config.lib.stylix.mkEnableTarget "the desktop background using Feh" (
|
||||
config.stylix.image != null
|
||||
);
|
||||
};
|
||||
|
||||
config.services.xserver.displayManager.sessionCommands =
|
||||
lib.mkIf
|
||||
(
|
||||
config.stylix.enable
|
||||
&& config.stylix.targets.feh.enable
|
||||
&& cfg.enable
|
||||
&& (with config.services.xserver.windowManager; xmonad.enable || i3.enable)
|
||||
)
|
||||
(
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ let
|
|||
inherit (config.stylix.fonts) sansSerif serif monospace;
|
||||
fontSize = toString config.stylix.fonts.sizes.applications;
|
||||
documentFontSize = toString (config.stylix.fonts.sizes.applications - 1);
|
||||
cfg = config.stylix.targets.gnome;
|
||||
|
||||
activator = pkgs.writeShellApplication {
|
||||
name = "stylix-activate-gnome";
|
||||
|
|
@ -42,10 +43,12 @@ let
|
|||
|
||||
in
|
||||
{
|
||||
options.stylix.targets.gnome.enable =
|
||||
config.lib.stylix.mkEnableTarget "GNOME" true;
|
||||
options.stylix.targets.gnome = {
|
||||
enable = config.lib.stylix.mkEnableTarget "GNOME" true;
|
||||
useWallpaper = config.lib.stylix.mkEnableWallpaper "GNOME" true;
|
||||
};
|
||||
|
||||
config = lib.mkIf (config.stylix.enable && config.stylix.targets.gnome.enable) {
|
||||
config = lib.mkIf (config.stylix.enable && cfg.enable) {
|
||||
dconf.settings = {
|
||||
"org/gnome/desktop/background" = {
|
||||
color-shading-type = "solid";
|
||||
|
|
@ -64,8 +67,8 @@ in
|
|||
# Seemingly no tile support... :(
|
||||
else
|
||||
"zoom";
|
||||
picture-uri = "file://${config.stylix.image}";
|
||||
picture-uri-dark = "file://${config.stylix.image}";
|
||||
picture-uri = lib.mkIf cfg.useWallpaper "file://${config.stylix.image}";
|
||||
picture-uri-dark = lib.mkIf cfg.useWallpaper "file://${config.stylix.image}";
|
||||
};
|
||||
|
||||
"org/gnome/desktop/interface" = {
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ with config.stylix.fonts;
|
|||
with config.lib.stylix.colors.withHashtag;
|
||||
|
||||
let
|
||||
cfg = config.stylix.targets.grub;
|
||||
# Grub requires fonts to be converted to "PFF2 format"
|
||||
# This function takes a font { name, package } and produces a .pf2 file
|
||||
mkGrubFont =
|
||||
|
|
@ -44,97 +45,107 @@ let
|
|||
"crop";
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
(lib.mkRenamedOptionModuleWith {
|
||||
from = [
|
||||
"stylix"
|
||||
"targets"
|
||||
"grub"
|
||||
"useImage"
|
||||
];
|
||||
sinceRelease = 2505;
|
||||
to = [
|
||||
"stylix"
|
||||
"targets"
|
||||
"grub"
|
||||
"useWallpaper"
|
||||
];
|
||||
})
|
||||
];
|
||||
options.stylix.targets.grub = {
|
||||
enable = config.lib.stylix.mkEnableTarget "GRUB" true;
|
||||
|
||||
useImage = lib.mkOption {
|
||||
description = "Whether to use your wallpaper image as the GRUB background.";
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
};
|
||||
useWallpaper = config.lib.stylix.mkEnableWallpaper "GRUB" false;
|
||||
};
|
||||
|
||||
config.boot.loader.grub =
|
||||
lib.mkIf (config.stylix.enable && config.stylix.targets.grub.enable)
|
||||
{
|
||||
backgroundColor = base00;
|
||||
# Need to override the NixOS splash, this will match the background
|
||||
splashImage = pixel "base00";
|
||||
config.boot.loader.grub = lib.mkIf (config.stylix.enable && cfg.enable) {
|
||||
backgroundColor = base00;
|
||||
# Need to override the NixOS splash, this will match the background
|
||||
splashImage = pixel "base00";
|
||||
|
||||
# This font will be used for the GRUB terminal
|
||||
font = toString (mkGrubFont monospace);
|
||||
# This font will be used for the GRUB terminal
|
||||
font = toString (mkGrubFont monospace);
|
||||
|
||||
# TODO: Include OS icons
|
||||
theme =
|
||||
pkgs.runCommand "stylix-grub"
|
||||
{
|
||||
themeTxt = ''
|
||||
desktop-image: "background.png"
|
||||
desktop-image-scale-method: "${image-scale}"
|
||||
desktop-color: "${base00}"
|
||||
# TODO: Include OS icons
|
||||
theme =
|
||||
pkgs.runCommand "stylix-grub"
|
||||
{
|
||||
themeTxt = ''
|
||||
desktop-image: "background.png"
|
||||
desktop-image-scale-method: "${image-scale}"
|
||||
desktop-color: "${base00}"
|
||||
|
||||
title-text: ""
|
||||
title-text: ""
|
||||
|
||||
terminal-left: "10%"
|
||||
terminal-top: "20%"
|
||||
terminal-width: "80%"
|
||||
terminal-height: "60%"
|
||||
terminal-left: "10%"
|
||||
terminal-top: "20%"
|
||||
terminal-width: "80%"
|
||||
terminal-height: "60%"
|
||||
|
||||
+ progress_bar {
|
||||
left = 25%
|
||||
top = 80%+20 # 20 pixels below boot menu
|
||||
width = 50%
|
||||
height = 30
|
||||
+ progress_bar {
|
||||
left = 25%
|
||||
top = 80%+20 # 20 pixels below boot menu
|
||||
width = 50%
|
||||
height = 30
|
||||
|
||||
id = "__timeout__"
|
||||
show_text = true
|
||||
font = "${sansSerif.name}"
|
||||
text = "@TIMEOUT_NOTIFICATION_MIDDLE@"
|
||||
id = "__timeout__"
|
||||
show_text = true
|
||||
font = "${sansSerif.name}"
|
||||
text = "@TIMEOUT_NOTIFICATION_MIDDLE@"
|
||||
|
||||
border_color = "${base00}"
|
||||
bg_color = "${base00}"
|
||||
fg_color = "${base0B}"
|
||||
text_color = "${base05}"
|
||||
}
|
||||
|
||||
+ boot_menu {
|
||||
left = 25%
|
||||
top = 20%
|
||||
width = 50%
|
||||
height = 60%
|
||||
menu_pixmap_style = "background_*.png"
|
||||
|
||||
item_height = 40
|
||||
item_icon_space = 8
|
||||
item_spacing = 0
|
||||
item_padding = 0
|
||||
item_font = "${sansSerif.name}"
|
||||
item_color = "${base05}"
|
||||
|
||||
selected_item_color = "${base01}"
|
||||
selected_item_pixmap_style = "selection_*.png"
|
||||
}
|
||||
'';
|
||||
passAsFile = [ "themeTxt" ];
|
||||
border_color = "${base00}"
|
||||
bg_color = "${base00}"
|
||||
fg_color = "${base0B}"
|
||||
text_color = "${base05}"
|
||||
}
|
||||
''
|
||||
mkdir $out
|
||||
cp $themeTxtPath $out/theme.txt
|
||||
|
||||
${
|
||||
if
|
||||
config.stylix.targets.grub.useImage
|
||||
# Make sure the background image is .png by asking to convert it
|
||||
then
|
||||
"${pkgs.imagemagick}/bin/convert ${config.stylix.image} png32:$out/background.png"
|
||||
else
|
||||
"cp ${pixel "base00"} $out/background.png"
|
||||
}
|
||||
+ boot_menu {
|
||||
left = 25%
|
||||
top = 20%
|
||||
width = 50%
|
||||
height = 60%
|
||||
menu_pixmap_style = "background_*.png"
|
||||
|
||||
cp ${pixel "base01"} $out/background_c.png
|
||||
cp ${pixel "base0B"} $out/selection_c.png
|
||||
item_height = 40
|
||||
item_icon_space = 8
|
||||
item_spacing = 0
|
||||
item_padding = 0
|
||||
item_font = "${sansSerif.name}"
|
||||
item_color = "${base05}"
|
||||
|
||||
cp ${mkGrubFont sansSerif} $out/sans_serif.pf2
|
||||
'';
|
||||
};
|
||||
selected_item_color = "${base01}"
|
||||
selected_item_pixmap_style = "selection_*.png"
|
||||
}
|
||||
'';
|
||||
passAsFile = [ "themeTxt" ];
|
||||
}
|
||||
''
|
||||
mkdir $out
|
||||
cp $themeTxtPath $out/theme.txt
|
||||
|
||||
${
|
||||
if
|
||||
cfg.useWallpaper
|
||||
# Make sure the background image is .png by asking to convert it
|
||||
then
|
||||
"${pkgs.imagemagick}/bin/convert ${config.stylix.image} png32:$out/background.png"
|
||||
else
|
||||
"cp ${pixel "base00"} $out/background.png"
|
||||
}
|
||||
|
||||
cp ${pixel "base01"} $out/background_c.png
|
||||
cp ${pixel "base0B"} $out/selection_c.png
|
||||
|
||||
cp ${mkGrubFont sansSerif} $out/sans_serif.pf2
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,9 @@
|
|||
{
|
||||
options.stylix.targets.hyprland = {
|
||||
enable = config.lib.stylix.mkEnableTarget "Hyprland" true;
|
||||
hyprpaper.enable = config.lib.stylix.mkEnableTarget "Hyprpaper" true;
|
||||
hyprpaper.enable = config.lib.stylix.mkEnableTarget "Hyprpaper" (
|
||||
config.stylix.image != null
|
||||
);
|
||||
};
|
||||
|
||||
config =
|
||||
|
|
|
|||
|
|
@ -1,21 +1,29 @@
|
|||
{ config, lib, ... }:
|
||||
|
||||
with config.lib.stylix;
|
||||
{
|
||||
options.stylix.targets.hyprlock.enable = mkEnableTarget "Hyprlock" true;
|
||||
|
||||
config =
|
||||
lib.mkIf (config.stylix.enable && config.stylix.targets.hyprlock.enable)
|
||||
{
|
||||
programs.hyprlock.settings = {
|
||||
background.path = "${config.stylix.image}";
|
||||
input-field = with colors; {
|
||||
outer_color = "rgb(${base03})";
|
||||
inner_color = "rgb(${base00})";
|
||||
font_color = "rgb(${base05})";
|
||||
fail_color = "rgb(${base08})";
|
||||
check_color = "rgb(${base0A})";
|
||||
};
|
||||
};
|
||||
let
|
||||
cfg = config.stylix.targets.hyprlock;
|
||||
in
|
||||
{
|
||||
options.stylix.targets.hyprlock = {
|
||||
enable = mkEnableTarget "Hyprlock" true;
|
||||
useWallpaper = mkEnableWallpaper "Hyprlock" true;
|
||||
};
|
||||
|
||||
config = lib.mkIf (config.stylix.enable && cfg.enable) {
|
||||
programs.hyprlock.settings = {
|
||||
background = {
|
||||
path = lib.mkIf cfg.useWallpaper config.stylix.image;
|
||||
color = "rgb(${base00})";
|
||||
};
|
||||
input-field = with colors; {
|
||||
outer_color = "rgb(${base03})";
|
||||
inner_color = "rgb(${base00})";
|
||||
font_color = "rgb(${base05})";
|
||||
fail_color = "rgb(${base08})";
|
||||
check_color = "rgb(${base0A})";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,18 @@
|
|||
{ config, lib, ... }:
|
||||
let
|
||||
cfg = config.stylix.targets.hyprpaper;
|
||||
in
|
||||
{
|
||||
options.stylix.targets.hyprpaper.enable =
|
||||
config.lib.stylix.mkEnableTarget "Hyprpaper" true;
|
||||
options.stylix.targets.hyprpaper = {
|
||||
enable = config.lib.stylix.mkEnableTarget "Hyprpaper" (
|
||||
config.stylix.image != null
|
||||
);
|
||||
};
|
||||
|
||||
config =
|
||||
lib.mkIf (config.stylix.enable && config.stylix.targets.hyprpaper.enable)
|
||||
{
|
||||
services.hyprpaper.settings = {
|
||||
preload = [ "${config.stylix.image}" ];
|
||||
wallpaper = [ ",${config.stylix.image}" ];
|
||||
};
|
||||
};
|
||||
config = lib.mkIf (config.stylix.enable && cfg.enable) {
|
||||
services.hyprpaper.settings = {
|
||||
preload = [ "${config.stylix.image}" ];
|
||||
wallpaper = [ ",${config.stylix.image}" ];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ let
|
|||
inherit (config.lib.stylix)
|
||||
colors
|
||||
mkEnableTarget
|
||||
mkEnableWallpaper
|
||||
;
|
||||
inherit (config.stylix)
|
||||
image
|
||||
|
|
@ -20,8 +21,7 @@ let
|
|||
let
|
||||
satisfies = check: (check default) && (check withImage);
|
||||
in
|
||||
# TODO: when adding `wallpaper` option to this module, replace this with `image == null || !cfg.wallpaper`
|
||||
if image == null then
|
||||
if image == null || !cfg.useWallpaper then
|
||||
default
|
||||
else if satisfies lib.isString then
|
||||
default + withImage
|
||||
|
|
@ -336,7 +336,7 @@ in
|
|||
{
|
||||
options.stylix.targets.kde = {
|
||||
enable = mkEnableTarget "KDE" true;
|
||||
|
||||
useWallpaper = mkEnableWallpaper "KDE" true;
|
||||
decorations = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "org.kde.breeze";
|
||||
|
|
|
|||
|
|
@ -1,10 +1,14 @@
|
|||
{ config, lib, ... }:
|
||||
|
||||
let
|
||||
cfg = config.stylix.targets.lightdm;
|
||||
in
|
||||
{
|
||||
options.stylix.targets.lightdm.enable =
|
||||
config.lib.stylix.mkEnableTarget "LightDM" true;
|
||||
options.stylix.targets.lightdm = {
|
||||
enable = config.lib.stylix.mkEnableTarget "LightDM" true;
|
||||
useWallpaper = config.lib.stylix.mkEnableWallpaper "LightDM" true;
|
||||
};
|
||||
|
||||
config.services.xserver.displayManager.lightdm.background = lib.mkIf (
|
||||
config.stylix.enable && config.stylix.targets.lightdm.enable
|
||||
config.stylix.enable && cfg.enable && cfg.useWallpaper
|
||||
) config.stylix.image;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,18 +4,18 @@
|
|||
lib,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
cfg = config.stylix.targets.regreet;
|
||||
in
|
||||
{
|
||||
options.stylix.targets.regreet.enable =
|
||||
config.lib.stylix.mkEnableTarget "ReGreet" true;
|
||||
options.stylix.targets.regreet = {
|
||||
enable = config.lib.stylix.mkEnableTarget "ReGreet" true;
|
||||
useWallpaper = config.lib.stylix.mkEnableWallpaper "ReGreet" true;
|
||||
};
|
||||
|
||||
config =
|
||||
lib.mkIf
|
||||
(
|
||||
config.stylix.enable
|
||||
&& config.stylix.targets.regreet.enable
|
||||
&& pkgs.stdenv.hostPlatform.isLinux
|
||||
)
|
||||
(config.stylix.enable && cfg.enable && pkgs.stdenv.hostPlatform.isLinux)
|
||||
{
|
||||
warnings =
|
||||
let
|
||||
|
|
@ -32,7 +32,7 @@
|
|||
"stylix: regreet: custom services.greetd.settings.default_session.command value may not work: ${config.services.greetd.settings.default_session.command}";
|
||||
programs.regreet = {
|
||||
settings.GTK.application_prefer_dark_theme = config.stylix.polarity == "dark";
|
||||
settings.background = {
|
||||
settings.background = lib.mkIf cfg.useWallpaper {
|
||||
path = config.stylix.image;
|
||||
fit =
|
||||
let
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@
|
|||
with config.lib.stylix.colors.withHashtag;
|
||||
|
||||
let
|
||||
cfg = config.stylix.targets.sway;
|
||||
|
||||
text = base05;
|
||||
urgent = base08;
|
||||
focused = base0D;
|
||||
|
|
@ -15,11 +17,13 @@ let
|
|||
|
||||
in
|
||||
{
|
||||
options.stylix.targets.sway.enable =
|
||||
config.lib.stylix.mkEnableTarget "Sway" true;
|
||||
options.stylix.targets.sway = {
|
||||
enable = config.lib.stylix.mkEnableTarget "Sway" true;
|
||||
useWallpaper = config.lib.stylix.mkEnableWallpaper "Sway" true;
|
||||
};
|
||||
|
||||
config = lib.mkMerge [
|
||||
(lib.mkIf (config.stylix.enable && config.stylix.targets.sway.enable) {
|
||||
(lib.mkIf (config.stylix.enable && cfg.enable) {
|
||||
wayland.windowManager.sway.config = {
|
||||
inherit fonts;
|
||||
|
||||
|
|
@ -57,7 +61,8 @@ in
|
|||
};
|
||||
};
|
||||
|
||||
output."*".bg = "${config.stylix.image} ${config.stylix.imageScalingMode}";
|
||||
output."*".bg =
|
||||
lib.mkIf cfg.useWallpaper "${config.stylix.image} ${config.stylix.imageScalingMode}";
|
||||
seat."*".xcursor_theme =
|
||||
''"${config.stylix.cursor.name}" ${toString config.stylix.cursor.size}'';
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
{
|
||||
pkgs,
|
||||
options,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
|
|
@ -9,6 +8,8 @@
|
|||
with config.lib.stylix.colors;
|
||||
|
||||
let
|
||||
cfg = config.stylix.targets.swaylock;
|
||||
|
||||
inside = base01-hex;
|
||||
outside = base01-hex;
|
||||
ring = base05-hex;
|
||||
|
|
@ -18,16 +19,26 @@ let
|
|||
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
(lib.mkRenamedOptionModuleWith {
|
||||
from = [
|
||||
"stylix"
|
||||
"targets"
|
||||
"swaylock"
|
||||
"useImage"
|
||||
];
|
||||
sinceRelease = 2505;
|
||||
to = [
|
||||
"stylix"
|
||||
"targets"
|
||||
"swaylock"
|
||||
"useWallpaper"
|
||||
];
|
||||
})
|
||||
];
|
||||
options.stylix.targets.swaylock = {
|
||||
enable = config.lib.stylix.mkEnableTarget "Swaylock" true;
|
||||
useImage = lib.mkOption {
|
||||
description = ''
|
||||
Whether to use your wallpaper image for the Swaylock background.
|
||||
If this is disabled, a plain color will be used instead.
|
||||
'';
|
||||
type = lib.types.bool;
|
||||
default = true;
|
||||
};
|
||||
useWallpaper = config.lib.stylix.mkEnableWallpaper "Swaylock" true;
|
||||
};
|
||||
|
||||
config =
|
||||
|
|
@ -71,7 +82,7 @@ in
|
|||
text-ver-color = text;
|
||||
text-wrong-color = text;
|
||||
}
|
||||
// lib.optionalAttrs config.stylix.targets.swaylock.useImage {
|
||||
// lib.optionalAttrs cfg.useWallpaper {
|
||||
image = "${config.stylix.image}";
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -4,60 +4,65 @@
|
|||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.stylix.targets.wayfire;
|
||||
in
|
||||
|
||||
{
|
||||
options.stylix.targets.wayfire.enable =
|
||||
config.lib.stylix.mkEnableTarget "wayfire" true;
|
||||
options.stylix.targets.wayfire = {
|
||||
enable = config.lib.stylix.mkEnableTarget "wayfire" true;
|
||||
useWallpaper = config.lib.stylix.mkEnableWallpaper "wayfire" true;
|
||||
};
|
||||
|
||||
config =
|
||||
lib.mkIf (config.stylix.enable && config.stylix.targets.wayfire.enable)
|
||||
(
|
||||
let
|
||||
inherit (config.lib.stylix) colors;
|
||||
rgba = rgb: a: "\\#${rgb}${a}";
|
||||
rgb = (lib.flip rgba) "ff";
|
||||
config = lib.mkIf (config.stylix.enable && cfg.enable) (
|
||||
let
|
||||
inherit (config.lib.stylix) colors;
|
||||
rgba = rgb: a: "\\#${rgb}${a}";
|
||||
rgb = (lib.flip rgba) "ff";
|
||||
|
||||
wayfireConfig = config.wayland.windowManager.wayfire;
|
||||
wayfireConfig = config.wayland.windowManager.wayfire;
|
||||
|
||||
wayfireBackground = pkgs.runCommand "wayfire-background.png" { } ''
|
||||
${lib.getExe' pkgs.imagemagick "convert"} ${config.stylix.image} $out
|
||||
'';
|
||||
in
|
||||
{
|
||||
wayland.windowManager.wayfire.settings = lib.mkIf wayfireConfig.enable {
|
||||
cube = {
|
||||
background = rgb colors.base00;
|
||||
cubemap_image = "${wayfireBackground}";
|
||||
skydome_texture = "${wayfireBackground}";
|
||||
};
|
||||
|
||||
expo.background = rgb colors.base00;
|
||||
vswitch.background = rgb colors.base00;
|
||||
vswipe.background = rgb colors.base00;
|
||||
core.background_color = rgb colors.base00;
|
||||
|
||||
decoration = {
|
||||
font = "${config.stylix.fonts.monospace.name} ${builtins.toString config.stylix.fonts.sizes.desktop}";
|
||||
active_color = rgb colors.base0D;
|
||||
inactive_color = rgb colors.base03;
|
||||
};
|
||||
};
|
||||
|
||||
wayland.windowManager.wayfire.wf-shell.settings =
|
||||
lib.mkIf wayfireConfig.wf-shell.enable
|
||||
{
|
||||
background.image = "${wayfireBackground}";
|
||||
background.fill_mode =
|
||||
if config.stylix.imageScalingMode == "stretch" then
|
||||
"stretch"
|
||||
else if config.stylix.imageScalingMode == "fit" then
|
||||
"preserve_aspect"
|
||||
else
|
||||
"fill_and_crop";
|
||||
|
||||
panel.background_color = rgb colors.base01;
|
||||
panel.menu_icon = "${pkgs.nixos-icons}/share/icons/hicolor/256x256/apps/nix-snowflake.png";
|
||||
};
|
||||
}
|
||||
wayfireBackground = lib.mkIf cfg.useWallpaper (
|
||||
pkgs.runCommand "wayfire-background.png" { } ''
|
||||
${lib.getExe' pkgs.imagemagick "convert"} ${config.stylix.image} $out
|
||||
''
|
||||
);
|
||||
in
|
||||
{
|
||||
wayland.windowManager.wayfire.settings = lib.mkIf wayfireConfig.enable {
|
||||
cube = {
|
||||
background = rgb colors.base00;
|
||||
cubemap_image = lib.mkIf cfg.useWallpaper "${wayfireBackground}";
|
||||
skydome_texture = lib.mkIf cfg.useWallpaper "${wayfireBackground}";
|
||||
};
|
||||
|
||||
expo.background = rgb colors.base00;
|
||||
vswitch.background = rgb colors.base00;
|
||||
vswipe.background = rgb colors.base00;
|
||||
core.background_color = rgb colors.base00;
|
||||
|
||||
decoration = {
|
||||
font = "${config.stylix.fonts.monospace.name} ${builtins.toString config.stylix.fonts.sizes.desktop}";
|
||||
active_color = rgb colors.base0D;
|
||||
inactive_color = rgb colors.base03;
|
||||
};
|
||||
};
|
||||
|
||||
wayland.windowManager.wayfire.wf-shell.settings =
|
||||
lib.mkIf wayfireConfig.wf-shell.enable
|
||||
{
|
||||
background.image = lib.mkIf cfg.useWallpaper "${wayfireBackground}";
|
||||
background.fill_mode =
|
||||
if config.stylix.imageScalingMode == "stretch" then
|
||||
"stretch"
|
||||
else if config.stylix.imageScalingMode == "fit" then
|
||||
"preserve_aspect"
|
||||
else
|
||||
"fill_and_crop";
|
||||
|
||||
panel.background_color = rgb colors.base01;
|
||||
panel.menu_icon = "${pkgs.nixos-icons}/share/icons/hicolor/256x256/apps/nix-snowflake.png";
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,35 +1,38 @@
|
|||
{ config, lib, ... }:
|
||||
|
||||
let
|
||||
cfg = config.stylix.targets.wpaperd;
|
||||
in
|
||||
{
|
||||
options.stylix.targets.wpaperd.enable =
|
||||
config.lib.stylix.mkEnableTarget "wpaperd" true;
|
||||
options.stylix.targets.wpaperd = {
|
||||
enable = config.lib.stylix.mkEnableTarget "wpaperd" (
|
||||
config.stylix.image != null
|
||||
);
|
||||
};
|
||||
|
||||
config =
|
||||
lib.mkIf (config.stylix.enable && config.stylix.targets.wpaperd.enable)
|
||||
(
|
||||
let
|
||||
inherit (config.stylix) imageScalingMode;
|
||||
config = lib.mkIf (config.stylix.enable && cfg.enable) (
|
||||
let
|
||||
inherit (config.stylix) imageScalingMode;
|
||||
|
||||
# wpaperd doesn't have any mode close to the described behavior of center
|
||||
modeMap = {
|
||||
"stretch" = "stretch";
|
||||
# wpaperd's center mode is closest to the described behavior of fill
|
||||
"fill" = "center";
|
||||
"fit" = "fit";
|
||||
"tile" = "tile";
|
||||
};
|
||||
# wpaperd doesn't have any mode close to the described behavior of center
|
||||
modeMap = {
|
||||
"stretch" = "stretch";
|
||||
# wpaperd's center mode is closest to the described behavior of fill
|
||||
"fill" = "center";
|
||||
"fit" = "fit";
|
||||
"tile" = "tile";
|
||||
};
|
||||
|
||||
modeAttrs =
|
||||
if builtins.hasAttr imageScalingMode modeMap then
|
||||
{ mode = modeMap.${imageScalingMode}; }
|
||||
else
|
||||
lib.info "stylix: wpaperd: unsupported image scaling mode: ${imageScalingMode}"
|
||||
{ };
|
||||
in
|
||||
{
|
||||
programs.wpaperd.settings.any = {
|
||||
path = "${config.stylix.image}";
|
||||
} // modeAttrs;
|
||||
}
|
||||
);
|
||||
modeAttrs =
|
||||
if builtins.hasAttr imageScalingMode modeMap then
|
||||
{ mode = modeMap.${imageScalingMode}; }
|
||||
else
|
||||
lib.info "stylix: wpaperd: unsupported image scaling mode: ${imageScalingMode}"
|
||||
{ };
|
||||
in
|
||||
{
|
||||
programs.wpaperd.settings.any = {
|
||||
path = "${config.stylix.image}";
|
||||
} // modeAttrs;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,13 +29,14 @@ in
|
|||
};
|
||||
|
||||
image = lib.mkOption {
|
||||
type = with lib.types; coercedTo package toString path;
|
||||
type = with lib.types; nullOr (coercedTo package toString path);
|
||||
description = ''
|
||||
Wallpaper image.
|
||||
|
||||
This is set as the background of your desktop environment, if possible,
|
||||
and used to generate a colour scheme if you don't set one manually.
|
||||
'';
|
||||
default = null;
|
||||
};
|
||||
|
||||
imageScalingMode = lib.mkOption {
|
||||
|
|
@ -158,6 +159,13 @@ in
|
|||
# https://github.com/SenchoPens/base16.nix/blob/b390e87cd404e65ab4d786666351f1292e89162a/README.md#theme-step-22
|
||||
lib.stylix.colors = (cfg.base16.mkSchemeAttrs cfg.base16Scheme).override cfg.override;
|
||||
|
||||
assertions = [
|
||||
{
|
||||
assertion = !(cfg.image == null && cfg.base16Scheme == null);
|
||||
message = "One of `stylix.image` or `stylix.base16Scheme` must be set";
|
||||
}
|
||||
];
|
||||
|
||||
stylix.generated.fileTree = {
|
||||
# The raw output of the palette generator.
|
||||
"stylix/generated.json" = {
|
||||
|
|
|
|||
|
|
@ -31,17 +31,31 @@
|
|||
};
|
||||
};
|
||||
|
||||
config.lib.stylix.mkEnableTarget =
|
||||
config.lib.stylix =
|
||||
let
|
||||
cfg = config.stylix;
|
||||
in
|
||||
humanName: autoEnable:
|
||||
lib.mkEnableOption "theming for ${humanName}"
|
||||
// {
|
||||
default = cfg.enable && cfg.autoEnable && autoEnable;
|
||||
example = !autoEnable;
|
||||
}
|
||||
// lib.optionalAttrs autoEnable {
|
||||
defaultText = lib.literalMD "same as `stylix.autoEnable`";
|
||||
{
|
||||
mkEnableTarget =
|
||||
humanName: autoEnable:
|
||||
lib.mkEnableOption "theming for ${humanName}"
|
||||
// {
|
||||
default = cfg.enable && cfg.autoEnable && autoEnable;
|
||||
example = !autoEnable;
|
||||
}
|
||||
// lib.optionalAttrs autoEnable {
|
||||
defaultText = lib.literalMD "same as `stylix.autoEnable`";
|
||||
};
|
||||
mkEnableWallpaper =
|
||||
humanName: autoEnable:
|
||||
lib.mkOption {
|
||||
default = config.stylix.image != null && autoEnable;
|
||||
example = config.stylix.image == null;
|
||||
description = "Whether to set the wallpaper for ${humanName}.";
|
||||
type = lib.types.bool;
|
||||
}
|
||||
// lib.optionalAttrs autoEnable {
|
||||
defaultText = lib.literalMD "`stylix.image != null`";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -137,6 +137,8 @@ let
|
|||
testbed.module
|
||||
testbed.name
|
||||
stylix.polarity
|
||||
"image${lib.optionalString (stylix.image or null == null) "less"}"
|
||||
"scheme${lib.optionalString (stylix.base16Scheme or null == null) "less"}"
|
||||
];
|
||||
|
||||
system = lib.nixosSystem {
|
||||
|
|
@ -181,28 +183,45 @@ let
|
|||
|
||||
# This generates a copy of each testbed for each of the following themes.
|
||||
makeTestbeds =
|
||||
testbed:
|
||||
map (makeTestbed testbed) [
|
||||
{
|
||||
enable = true;
|
||||
image = pkgs.fetchurl {
|
||||
let
|
||||
images = {
|
||||
dark = pkgs.fetchurl {
|
||||
name = "mountains.jpg";
|
||||
url = "https://unsplash.com/photos/ZqLeQDjY6fY/download?ixid=M3wxMjA3fDB8MXxhbGx8fHx8fHx8fHwxNzE2MzY1NDY4fA&force=true";
|
||||
hash = "sha256-Dm/0nKiTFOzNtSiARnVg7zM0J1o+EuIdUQ3OAuasM58=";
|
||||
};
|
||||
|
||||
light = pkgs.fetchurl {
|
||||
name = "three-bicycles.jpg";
|
||||
url = "https://unsplash.com/photos/hwLAI5lRhdM/download?ixid=M3wxMjA3fDB8MXxhbGx8fHx8fHx8fHwxNzE2MzYxNDcwfA&force=true";
|
||||
hash = "sha256-S0MumuBGJulUekoGI2oZfUa/50Jw0ZzkqDDu1nRkFUA=";
|
||||
};
|
||||
};
|
||||
in
|
||||
testbed:
|
||||
map (makeTestbed testbed) [
|
||||
{
|
||||
enable = true;
|
||||
image = images.light;
|
||||
base16Scheme = "${inputs.tinted-schemes}/base16/catppuccin-latte.yaml";
|
||||
polarity = "light";
|
||||
}
|
||||
{
|
||||
enable = true;
|
||||
image = pkgs.fetchurl {
|
||||
name = "mountains.jpg";
|
||||
url = "https://unsplash.com/photos/ZqLeQDjY6fY/download?ixid=M3wxMjA3fDB8MXxhbGx8fHx8fHx8fHwxNzE2MzY1NDY4fA&force=true";
|
||||
hash = "sha256-Dm/0nKiTFOzNtSiARnVg7zM0J1o+EuIdUQ3OAuasM58=";
|
||||
};
|
||||
image = images.dark;
|
||||
base16Scheme = "${inputs.tinted-schemes}/base16/catppuccin-macchiato.yaml";
|
||||
polarity = "dark";
|
||||
}
|
||||
{
|
||||
enable = true;
|
||||
base16Scheme = "${inputs.tinted-schemes}/base16/catppuccin-macchiato.yaml";
|
||||
polarity = "dark";
|
||||
}
|
||||
{
|
||||
enable = true;
|
||||
image = images.dark;
|
||||
polarity = "dark";
|
||||
}
|
||||
];
|
||||
|
||||
in
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue