stylix: add config.lib.stylix.{mkHexColor,mkOpacityHexColor} functions
Co-authored-by: NAHO <90870942+trueNAHO@users.noreply.github.com>
This commit is contained in:
parent
9991299fe9
commit
1a83d26d4c
6 changed files with 29 additions and 0 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
|
||||
|
|
|
|||
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