wallust: start splitting templates into nix modules because needing nix environment

This commit is contained in:
Tigor Hutasuhut 2024-10-21 17:15:48 +07:00
parent b1529215a6
commit 69b175b9f5
12 changed files with 779 additions and 116 deletions

View file

@ -19,7 +19,6 @@ in
# ./hyprpaper.nix # ./hyprpaper.nix
./pyprland.nix ./pyprland.nix
./rofi.nix ./rofi.nix
./wallust.nix
./waybar.nix ./waybar.nix
./wlogout.nix ./wlogout.nix
# ./swappy.nix # ./swappy.nix
@ -28,6 +27,8 @@ in
./swaync.nix ./swaync.nix
./ntfy-sh.nix ./ntfy-sh.nix
./gnome-keyring.nix ./gnome-keyring.nix
./wallust
]; ];
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
home.packages = with pkgs; [ home.packages = with pkgs; [

View file

@ -1,47 +0,0 @@
{
lib,
fetchFromGitea,
rustPlatform,
nix-update-script,
imagemagick,
makeWrapper,
pkgs,
}:
rustPlatform.buildRustPackage rec {
pname = "wallust";
version = "3.0.0";
src = fetchFromGitea {
domain = "codeberg.org";
owner = "explosion-mental";
repo = "wallust";
rev = version;
hash = "sha256-vZTHlonepK1cyxHhGu3bVBuOmExPtRFrAnYp71Jfs8c=";
};
cargoHash = "sha256-o6VRekazqbKTef6SLjHqs9/z/Q70auvunP+yFDkclpg=";
nativeBuildInputs = [
makeWrapper
pkgs.rust-bin.stable."1.79.0".default
];
postFixup = ''
wrapProgram $out/bin/wallust \
--prefix PATH : "${lib.makeBinPath [ imagemagick ]}"
'';
passthru.updateScript = nix-update-script { };
meta = {
description = "A better pywal";
homepage = "https://codeberg.org/explosion-mental/wallust";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [
onemoresuza
iynaix
];
downloadPage = "https://codeberg.org/explosion-mental/wallust/releases/tag/${version}";
mainProgram = "wallust";
};
}

View file

@ -18,3 +18,9 @@
@define-color color13 {{color13}}; @define-color color13 {{color13}};
@define-color color14 {{color14}}; @define-color color14 {{color14}};
@define-color color15 {{color15}}; @define-color color15 {{color15}};
window {
background: url("${config.home.homeDirectory}/.cache/wallpaper/blurred.png");
background-size: cover;
}

View file

@ -0,0 +1,153 @@
{
pkgs,
unstable,
lib,
config,
...
}:
let
cfg = config.profile.hyprland;
inherit (lib.meta) getExe;
wallpaperDir = "${config.home.homeDirectory}/.cache/wallpaper";
initWallPaperScript =
pkgs.writeShellScriptBin "init-wallpaper.sh"
# sh
''
init_wallpaper="${../wallpaper.jpeg}"
cache_file="${wallpaperDir}/current"
blurred="${wallpaperDir}/blurred.png"
square="${wallpaperDir}/square.png"
mkdir -p "${wallpaperDir}"
if [ ! -f "$cache_file" ]; then
cp "$init_wallpaper" "$cache_file"
fi
if [ ! -f "$blurred" ]; then
${pkgs.graphicsmagick}/bin/gm convert -resize 75% -blur 50x30 "$cache_file" "$blurred"
fi
if [ ! -f "$square" ]; then
${pkgs.imagemagick}/bin/magick "$cache_file" -resize 25% -gravity Center -extent 1:1 "$square"
fi
if [ ! -f "${config.home.homeDirectory}/.cache/wallust/sequences" ]; then
wallust run "$cache_file"
fi
'';
in
{
imports = [
./foot.nix
./hyprland.nix
./kitty.nix
./waybar.nix
./wlogout.nix
];
config = lib.mkIf cfg.enable {
home.packages = [
pkgs.imagemagick
unstable.wallust
];
wayland.windowManager.hyprland.settings.exec-once = lib.mkOrder 10 ([
(getExe initWallPaperScript)
]);
# See https://codeberg.org/explosion-mental/wallust/src/branch/master/wallust.toml
profile.hyprland.wallust.settings = {
backend = "kmeans";
color_space = "lch";
alpha = 100;
threshold = 1;
palette = "dark";
checkContrast = true;
};
home.file.".config/wallust/wallust.toml".source = (
(pkgs.formats.toml { }).generate "wallust.toml" cfg.wallust.settings
);
# home.file.".config/wallust/wallust.toml".source = (
# (pkgs.formats.toml { }).generate "wallust.toml" {
# # See https://codeberg.org/explosion-mental/wallust/src/branch/master/wallust.toml
# # for more information about the configuration options.
#
# # How the image is parse, in order to get the colors:
# # full - resized - wal - thumb - fastresize - kmeans
# backend = wallust.backend;
#
# # What color space to use to produce and select the most prominent colors:
# # lab - labmixed - lch - lchmixed
# color_space = wallust.colorSpace;
# threshold = wallust.threshold;
#
# # Use the most prominent colors in a way that makes sense, a scheme color palette:
# # dark - dark16 - darkcomp - darkcomp16
# # light - light16 - lightcomp - lightcomp16
# # harddark - harddark16 - harddarkcomp - harddarkcomp16
# # softdark - softdark16 - softdarkcomp - softdarkcomp16
# # softlight - softlight16 - softlightcomp - softlightcomp16
# palette = wallust.palette;
#
# # Ensures a "readable contrast" (OPTIONAL, disabled by default)
# # Should only be enabled when you notice an unreadable contrast frequently happening
# # with your images. The reference color for the contrast is the background color.
# check_contrast = wallust.checkContrast;
#
# # Color saturation, between [1% and 100%] (OPTIONAL, disabled by default)
# # usually something higher than 50 increases the saturation and below
# # decreases it (on a scheme with strong and vivid colors)
# # saturation = 50;
#
# # Alpha value for templating, by default 100 (no other use whatsoever)
# alpha = wallust.alpha;
#
# templates =
# # Templates requires certain syntax
# #
# # See: https://codeberg.org/explosion-mental/wallust/wiki/wallust.1-Man-Page
# # Note that the documentation is for 3.x and above.
# let
# out = config.home.homeDirectory + "/.cache/wallust";
# in
# {
# waybar = {
# template = "waybar.css";
# # target = out + "/waybar.css";
# target = "${config.home.homeDirectory}/.config/waybar/style.css";
# };
# wlogout = {
# template = "wlogout.css";
# target = out + "/wlogout.css";
# };
# hyprland = {
# template = "hyprland.conf";
# target = out + "/hyprland.conf";
# };
# kitty = {
# template = "kitty.conf";
# target = "${config.home.homeDirectory}/.config/kitty/kitty.d/99-colors.conf";
# };
# base16-nvim = {
# template = "base16-nvim.lua";
# target = out + "/base16-nvim.lua";
# };
# rofi = {
# template = "rofi.rasi";
# target = out + "/rofi.rasi";
# };
# alacritty = {
# template = "alacritty.toml";
# target = out + "/alacritty.toml";
# };
# foot = {
# template = "foot.ini";
# target = "${config.home.homeDirectory}/.config/foot/colors.ini";
# };
# };
# }
# );
};
}

View file

@ -0,0 +1,43 @@
{ config, lib, ... }:
let
cfg = config.profile.hyprland;
inherit (lib.generators) toINI;
in
{
config = lib.mkIf cfg.enable {
home.file.".config/wallust/templates/foot.ini".text = (toINI { }) {
colors = {
alpha = "{{ alpha/100 }}";
background = "{{ background | strip }}";
foreground = "{{ foreground | strip }}";
flash = "{{ color2 | strip }}";
flash-alpha = "0.5";
regular0 = "{{ color0 | strip }}";
regular1 = "{{ color1 | strip }}";
regular2 = "{{ color2 | strip }}";
regular3 = "{{ color3 | strip }}";
regular4 = "{{ color4 | strip }}";
regular5 = "{{ color5 | strip }}";
regular6 = "{{ color6 | strip }}";
regular7 = "{{ color7 | strip }}";
bright0 = "{{ color8 | strip }}";
bright1 = "{{ color9 | strip }}";
bright2 = "{{ color10 | strip }}";
bright3 = "{{ color11 | strip }}";
bright4 = "{{ color12 | strip }}";
bright5 = "{{ color13 | strip }}";
bright6 = "{{ color14 | strip }}";
bright7 = "{{ color15 | strip }}";
};
};
profile.hyprland.wallust.settings.templates.foot =
let
out = config.home.homeDirectory + "/.cache/wallust";
in
{
template = "foot.ini";
target = out + "/foot.ini";
};
};
}

View file

@ -0,0 +1,47 @@
{ config, lib, ... }:
let
cfg = config.profile.hyprland;
in
{
config = lib.mkIf cfg.enable {
home.file.".config/wallust/templates/hyprland.conf".text =
# hyprlang
''
$background = rgb({{background | strip}})
$foreground = rgb({{foreground | strip}})
$color0 = rgb({{color0 | strip}})
$color1 = rgb({{color1 | strip}})
$color2 = rgb({{color2 | strip}})
$color3 = rgb({{color3 | strip}})
$color4 = rgb({{color4 | strip}})
$color5 = rgb({{color5 | strip}})
$color6 = rgb({{color6 | strip}})
$color7 = rgb({{color7 | strip}})
$color8 = rgb({{color8 | strip}})
$color9 = rgb({{color9 | strip}})
$color10 = rgb({{color10 | strip}})
$color11 = rgb({{color11 | strip}})
$color12 = rgb({{color12 | strip}})
$color13 = rgb({{color13 | strip}})
$color14 = rgb({{color14 | strip}})
$color15 = rgb({{color15 | strip}})
general {
col.inactive_border = $color11
}
decoration {
inactive_opacity = {{alpha / 100}}
}
'';
profile.hyprland.wallust.settings.templates.hyprland =
let
out = config.home.homeDirectory + "/.cache/wallust";
in
{
template = "hyprland.conf";
target = out + "/hyprland.conf";
};
};
}

View file

@ -0,0 +1,47 @@
{ config, lib, ... }:
let
cfg = config.profile.hyprland;
in
{
config = lib.mkIf (cfg.enable && config.profile.kitty.enable) {
home.file.".config/wallust/templates/kitty.conf".text =
# css
''
foreground {{foreground}}
background {{background}}
background_opacity {{ alpha / 100 }}
cursor {{cursor}}
active_tab_foreground {{background}}
active_tab_background {{foreground}}
inactive_tab_foreground {{foreground}}
inactive_tab_background {{background}}
active_border_color {{foreground}}
inactive_border_color {{background}}
bell_border_color {{color1}}
color0 {{color0}}
color1 {{color1}}
color2 {{color2}}
color3 {{color3}}
color4 {{color4}}
color5 {{color5}}
color6 {{color6}}
color7 {{color7}}
color8 {{color8}}
color9 {{color9}}
color10 {{color10}}
color11 {{color11}}
color12 {{color12}}
color13 {{color13}}
color14 {{color14}}
color15 {{color15}}
'';
profile.hyprland.wallust.settings.templates.kitty = {
template = "kitty.conf";
target = "${config.home.homeDirectory}/.config/kitty/kitty.d/99-colors.conf";
};
};
}

View file

@ -0,0 +1,426 @@
{ config, lib, ... }:
let
cfg = config.profile.hyprland;
in
{
config = lib.mkIf cfg.enable {
home.file.".config/wallust/templates/waybar.css".text = # css
''
@define-color foreground {{foreground}};
@define-color background {{background}};
@define-color cursor {{cursor}};
@define-color color0 {{color0}};
@define-color color1 {{color1}};
@define-color color2 {{color2}};
@define-color color3 {{color3 | lighten(0.5)}};
@define-color color4 {{color4}};
@define-color color5 {{color5}};
@define-color color6 {{color6}};
@define-color color7 {{color7}};
@define-color color8 {{color8}};
@define-color color9 {{color9}};
@define-color color10 {{color10}};
@define-color color11 {{color11}};
@define-color color12 {{color12}};
@define-color color13 {{color13}};
@define-color color14 {{color14}};
@define-color color15 {{color15}};
@define-color backgroundlight {{color8}};
@define-color backgrounddark {{foreground}};
@define-color workspacesbackground1 {{foreground | darken(0.4)}};
@define-color workspacesbackground2 {{foreground}};
@define-color bordercolor {{color8}};
@define-color textcolor1 {{color8}};
@define-color textcolor2 {{foreground}};
@define-color textcolor3 {{foreground}};
@define-color iconcolor {{foreground}};
@define-color group-background-color rgba({{color2 | rgb}}, 0.3);
@define-color group-border-color rgba({{foreground | rgb}}, 0.8);
@define-color tooltip-background-color rgba({{color1 | rgb}}, 0.95);
@define-color text-base {{foreground}};
@define-color text-alt {{color8}};
* {
font-family: "Fira Sans Semibold", FontAwesome, Roboto, Helvetica, Arial, sans-serif;
border: none;
border-radius: 0px;
}
window#waybar {
background-color: rgba({{background | rgb}}, 0.3);
border: 0px;
color: {{foreground}};
transition-property: background-color;
transition-duration: 0.5s;
}
/* -----------------------------------------------------
* Workspaces
* ----------------------------------------------------- */
#workspaces {
background: @group-background-color;
margin: 5px 1px 6px 1px;
padding: 0px 0.75rem;
border-radius: 24px;
border: 2px solid @group-border-color;
font-weight: bold;
font-style: normal;
font-size: 16px;
}
#workspaces button {
padding: 0px 5px;
margin: 4px 3px;
border-radius: 15px;
border: 0px;
color: @textcolor1;
background-color: @workspacesbackground2;
transition: all 0.3s ease-in-out;
}
#workspaces button.active {
color: @textcolor1;
background: @workspacesbackground2;
border-radius: 15px;
min-width: 40px;
transition: all 0.3s ease-in-out;
opacity: 1;
}
#workspaces button:hover {
color: @textcolor1;
background: @workspacesbackground2;
border-radius: 15px;
opacity: 0.7;
}
/* -----------------------------------------------------
* Tooltips
* ----------------------------------------------------- */
tooltip {
border-radius: 10px;
background-color: @tooltip-background-color;
padding: 20px;
margin: 0px;
border: 1px solid @textcolor2;
}
tooltip label {
color: @textcolor2;
}
/* -----------------------------------------------------
* Window
* ----------------------------------------------------- */
#window {
background: @group-background-color;
border: 2px solid @group-border-color;
margin: 8px 15px 8px 0px;
padding: 2px 10px 0px 10px;
border-radius: 12px;
color: @textcolor2;
font-size: 16px;
font-weight: normal;
}
window#waybar.empty #window {
background-color: transparent;
border: 0px;
}
/* -----------------------------------------------------
* Taskbar
* ----------------------------------------------------- */
#taskbar {
background: @backgroundlight;
margin: 6px 15px 6px 0px;
padding: 0px;
border-radius: 15px;
font-weight: normal;
font-style: normal;
opacity: 0.8;
border: 3px solid @backgroundlight;
}
#taskbar button {
margin: 0;
border-radius: 15px;
padding: 0px 5px 0px 5px;
}
/* -----------------------------------------------------
* Modules
* ----------------------------------------------------- */
.modules-left {
padding-left: 1rem;
}
.modules-left > widget:first-child > #workspaces {
margin-left: 0;
}
.modules-right > widget:last-child > #workspaces {
margin-right: 0;
}
/* -----------------------------------------------------
* Custom Quicklinks
* ----------------------------------------------------- */
#custom-brave,
#custom-browser,
#custom-keybindings,
#custom-outlook,
#custom-filemanager,
#custom-teams,
#custom-chatgpt,
#custom-calculator,
#custom-windowsvm,
#custom-cliphist,
#custom-wallpaper,
#custom-settings,
#custom-wallpaper,
#custom-system,
#custom-waybarthemes {
margin-right: 23px;
font-size: 20px;
font-weight: bold;
opacity: 0.8;
color: @iconcolor;
}
#custom-system {
margin-right: 15px;
}
#custom-wallpaper {
margin-right: 25px;
}
#custom-waybarthemes,
#custom-settings {
margin-right: 20px;
}
#custom-ml4w-welcome {
margin-right: 12px;
background-image: url("../assets/ml4w-icon.png");
background-repeat: no-repeat;
background-position: center;
padding-right: 24px;
}
#custom-ml4w-hyprland-settings {
margin-right: 12px;
background-image: url("../assets/hyprland-icon.png");
background-repeat: no-repeat;
background-position: center;
padding-right: 16px;
}
#custom-chatgpt {
margin-right: 12px;
background-image: url("../assets/ai-icon-20.png");
background-repeat: no-repeat;
background-position: center;
padding-right: 24px;
}
/* -----------------------------------------------------
* Idle Inhibator
* ----------------------------------------------------- */
#idle_inhibitor {
margin-right: 17px;
font-size: 20px;
font-weight: bold;
opacity: 0.8;
color: @iconcolor;
}
#idle_inhibitor.activated {
margin-right: 15px;
font-size: 20px;
font-weight: bold;
opacity: 0.8;
color: #dc2f2f;
}
/* -----------------------------------------------------
* Custom Modules
* ----------------------------------------------------- */
#custom-appmenu {
background-color: @backgrounddark;
font-size: 16px;
color: @textcolor1;
border-radius: 15px;
padding: 0px 10px 0px 10px;
margin: 8px 14px 8px 14px;
opacity: 0.8;
border: 3px solid @bordercolor;
}
/* -----------------------------------------------------
* Custom Exit
* ----------------------------------------------------- */
#custom-exit {
margin: 0px 20px 0px 0px;
padding: 0px;
font-size: 20px;
color: @iconcolor;
}
/* -----------------------------------------------------
* Clock
* ----------------------------------------------------- */
#clock {
background-color: @group-background-color;
font-size: 16px;
color: @text-base;
border-radius: 15px;
padding: 1px 10px 0px 10px;
margin: 8px 15px 8px 0px;
border: 3px solid @group-border-color;
}
/* -----------------------------------------------------
* Pulseaudio
* ----------------------------------------------------- */
#pulseaudio {
background-color: @group-background-color;
font-size: 16px;
border: 2px solid @group-border-color;
color: @textcolor2;
border-radius: 15px;
padding: 2px 10px 0px 10px;
margin: 8px 15px 8px 0px;
}
#pulseaudio.muted {
color: @color3;
border-color: @color3;
}
/* -----------------------------------------------------
* Network
* ----------------------------------------------------- */
#network {
background-color: @group-background-color;
border: 2px solid @group-border-color;
font-size: 16px;
color: @text-base;
border-radius: 15px;
padding: 2px 10px 0px 10px;
margin: 8px 15px 8px 0px;
}
/* -----------------------------------------------------
* Bluetooth
* ----------------------------------------------------- */
#bluetooth,
#bluetooth.on,
#bluetooth.connected {
background-color: @group-background-color;
border: 2px solid @group-border-color;
font-size: 16px;
color: @text-base;
border-radius: 15px;
padding: 2px 10px 0px 10px;
margin: 8px 15px 8px 0px;
}
#bluetooth.off {
background-color: transparent;
padding: 0px;
margin: 0px;
}
/* -----------------------------------------------------
* Battery
* ----------------------------------------------------- */
#battery {
background-color: @group-background-color;
border: 2px solid @group-border-color;
font-size: 16px;
color: @text-base;
border-radius: 15px;
padding: 2px 15px 0px 10px;
margin: 8px 15px 8px 0px;
opacity: 0.8;
}
#battery.charging,
#battery.plugged {
color: @text-base;
}
@keyframes blink {
to {
background-color: @backgroundlight;
color: @textcolor2;
}
}
#battery.critical:not(.charging) {
background-color: #f53c3c;
color: @textcolor3;
animation-name: blink;
animation-duration: 0.5s;
animation-timing-function: linear;
animation-iteration-count: infinite;
animation-direction: alternate;
}
/* -----------------------------------------------------
* Tray
* ----------------------------------------------------- */
#tray {
padding: 0px 15px 0px 0px;
color: @textcolor3;
}
#tray > .passive {
-gtk-icon-effect: dim;
}
#tray > .needs-attention {
-gtk-icon-effect: highlight;
}
#custom-notification {
font-family: "NotoSansMono Nerd Font";
margin-right: 20px;
margin-left: 20px;
font-size: 20px;
font-weight: bold;
opacity: 0.8;
color: @iconcolor;
}
'';
profile.hyprland.wallust.settings.templates.waybar =
let
out = config.home.homeDirectory + "/.cache/wallust";
in
{
template = "waybar.css";
target = out + "/waybar.css";
};
};
}

View file

@ -0,0 +1,46 @@
{ config, lib, ... }:
let
cfg = config.profile.hyprland;
in
{
config = lib.mkIf cfg.enable {
home.file.".config/wallust/templates/wlogout.css".text = # css
''
@define-color foreground {{foreground}};
@define-color background {{background}};
@define-color cursor {{cursor}};
@define-color color0 {{color0}};
@define-color color1 {{color1}};
@define-color color2 {{color2}};
@define-color color3 {{color3}};
@define-color color4 {{color4}};
@define-color color5 {{color5}};
@define-color color6 {{color6}};
@define-color color7 {{color7}};
@define-color color8 {{color8}};
@define-color color9 {{color9}};
@define-color color10 {{color10}};
@define-color color11 {{color11}};
@define-color color12 {{color12}};
@define-color color13 {{color13}};
@define-color color14 {{color14}};
@define-color color15 {{color15}};
window {
background: url("${config.home.homeDirectory}/.cache/wallpaper/blurred.png");
background-size: cover;
}
'';
profile.hyprland.wallust.settings.templates.wlogout =
let
out = config.home.homeDirectory + "/.cache/wallust";
in
{
template = "wlogout.css";
target = out + "/wlogout.css";
};
};
}

View file

@ -28,11 +28,6 @@ in
box-shadow: none; box-shadow: none;
} }
window {
background: url("${config.home.homeDirectory}/.cache/wallpaper/blurred.png");
background-size: cover;
}
button { button {
color: #ffffff; color: #ffffff;
font-size: 20px; font-size: 20px;

View file

@ -1,4 +1,9 @@
{ lib, config, ... }: {
lib,
pkgs,
config,
...
}:
let let
types = lib.types; types = lib.types;
in in
@ -75,67 +80,9 @@ in
default = "0"; default = "0";
}; };
wallust = { wallust.settings = lib.mkOption {
backend = lib.mkOption { type = (pkgs.formats.toml { }).type;
type = lib.types.enum [ default = { };
"full"
"resized"
"wal"
"thumb"
"fastresize"
"kmeans"
];
default = "kmeans";
description = "How the image is parse, in order to get the colors";
};
colorSpace = lib.mkOption {
type = lib.types.enum [
"lab"
"labmixed"
"lch"
"lchmixed"
];
default = "lch";
description = "What color space to use to produce and select the most prominent colors";
};
alpha = lib.mkOption {
type = lib.types.int;
default = 100;
};
threshold = lib.mkOption {
type = lib.types.int;
default = 1;
};
palette = lib.mkOption {
type = lib.types.enum [
"dark"
"dark16"
"darkcomp"
"darkcomp16"
"light"
"light16"
"lightcomp"
"lightcomp16"
"harddark"
"harddark16"
"harddarkcomp"
"harddarkcomp16"
"softdark"
"softdark16"
"softdarkcomp"
"softdarkcomp16"
"softlight"
"softlight16"
"softlightcomp"
"softlightcomp16"
];
default = "dark";
description = ''Use the most prominent colors in a way that makes sense. A Scheme color palette.'';
};
checkContrast = lib.mkOption {
type = lib.types.bool;
default = true;
};
}; };
}; };
} }

View file

@ -42,7 +42,6 @@
]; ];
}; };
pyprland.wallpaper-dirs = [ "/home/tigor/Syncthing/Redmage/Laptop-Kerja" ]; pyprland.wallpaper-dirs = [ "/home/tigor/Syncthing/Redmage/Laptop-Kerja" ];
wallust.alpha = 80;
}; };
discord = { discord = {
enable = true; enable = true;