stylix: add config.lib.stylix.{mkHexColor,mkOpacityHexColor} functions (#1274)
Link: https://github.com/nix-community/stylix/pull/1274 Approved-by: awwpotato <awwpotato@voidq.com> Reviewed-by: NAHO <90870942+trueNAHO@users.noreply.github.com>
This commit is contained in:
commit
834a743c11
7 changed files with 34 additions and 5 deletions
|
|
@ -182,6 +182,15 @@ individually.
|
|||
Also note that reading generated files with `builtins.readFile` can be very slow
|
||||
and should be avoided.
|
||||
|
||||
|
||||
### Hexadecimal colors
|
||||
|
||||
- config.lib.stylix.mkHexColor`: Converts a hex `color` (e.g., `RRGGBB` or
|
||||
`#RRGGBB`) to `0xRRGGBB`.
|
||||
|
||||
- `config.lib.stylix.mkOpacityHexColor`: Converts a hex `color` and `opacity`
|
||||
(0–1) to `0xRRGGBBAA`.
|
||||
|
||||
## How to apply other things
|
||||
|
||||
For everything else, like fonts and wallpapers, you can just take option values
|
||||
|
|
|
|||
|
|
@ -6,14 +6,14 @@
|
|||
config = lib.mkIf (config.stylix.enable && config.stylix.targets.river.enable) {
|
||||
wayland.windowManager.river.settings =
|
||||
let
|
||||
inherit (config.lib.stylix) colors;
|
||||
inherit (config.lib.stylix) colors mkHexColor;
|
||||
inherit (config.stylix) cursor;
|
||||
in
|
||||
{
|
||||
border-color-focused = "0x${colors.base0D}";
|
||||
border-color-unfocused = "0x${colors.base03}";
|
||||
border-color-urgent = "0x${colors.base08}";
|
||||
background-color = "0x${colors.base00}";
|
||||
border-color-focused = mkHexColor colors.base0D;
|
||||
border-color-unfocused = mkHexColor colors.base03;
|
||||
border-color-urgent = mkHexColor colors.base08;
|
||||
background-color = mkHexColor colors.base00;
|
||||
xcursor-theme = lib.mkIf (
|
||||
config.stylix.cursor != null
|
||||
) "${cursor.name} ${toString cursor.size}";
|
||||
|
|
|
|||
16
stylix/colors.nix
Normal file
16
stylix/colors.nix
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
{ lib, ... }:
|
||||
{
|
||||
config.lib.stylix = {
|
||||
mkHexColor = color: "0x${lib.removePrefix "#" color}";
|
||||
|
||||
mkOpacityHexColor =
|
||||
let
|
||||
opacityHex =
|
||||
percentage:
|
||||
lib.throwIfNot (percentage >= 0 && percentage <= 1)
|
||||
"value must be between 0 and 1 (inclusive): ${toString percentage}"
|
||||
(lib.toHexString (builtins.floor (percentage * 255 + 0.5)));
|
||||
in
|
||||
color: opacity: "0x${opacityHex opacity}${lib.removePrefix "#" color}";
|
||||
};
|
||||
}
|
||||
|
|
@ -9,6 +9,7 @@ in
|
|||
{
|
||||
imports = [
|
||||
./palette.nix
|
||||
../colors.nix
|
||||
../fonts.nix
|
||||
../home-manager-integration.nix
|
||||
../opacity.nix
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ in
|
|||
imports = [
|
||||
./fonts.nix
|
||||
./palette.nix
|
||||
../colors.nix
|
||||
../fonts.nix
|
||||
../home-manager-integration.nix
|
||||
../opacity.nix
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ in
|
|||
./cursor.nix
|
||||
./icons.nix
|
||||
./palette.nix
|
||||
../colors.nix
|
||||
../cursor.nix
|
||||
../fonts.nix
|
||||
../icons.nix
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ in
|
|||
imports = [
|
||||
./cursor.nix
|
||||
./palette.nix
|
||||
../colors.nix
|
||||
../cursor.nix
|
||||
../fonts.nix
|
||||
../home-manager-integration.nix
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue