Wallpaper: Add video support.

This commit is contained in:
Dmitry Voronin 2025-01-01 13:57:05 +03:00
parent 3238a48d41
commit 6df3fc101f
Signed by: voronind
SSH key fingerprint: SHA256:3kBb4iV2ahufEBNq+vFbUe4QYfHt98DHQjN7QaptY9k
7 changed files with 47 additions and 42 deletions

View file

@ -40,6 +40,6 @@ Newest first.
<br><a href="https://i.imgur.com/Q8ZTZCH.png">Wallpaper link</a>
</details>
[My current wallpaper](config/Wallpaper.nix#L4)
[My current wallpaper](config/Wallpaper.nix#L11)
Color theming based on wallpaper thanks to [Stylix](https://github.com/danth/stylix).

View file

@ -45,6 +45,7 @@ in
module = {
keyd.enable = true;
sway.enable = true;
wallpaper.video = false;
kernel = {
enable = true;
hardening = true;
@ -63,6 +64,7 @@ in
keyd.enable = true;
sway.enable = true;
kernel.enable = true;
wallpaper.video = false;
package = {
common = true;
core = true;
@ -114,6 +116,7 @@ in
(lib.mkIf cfg.server {
module = {
wallpaper.video = false;
kernel = {
enable = true;
hardening = true;

View file

@ -246,5 +246,6 @@ in
include /etc/sway/config.d/*
''
+ builtins.readFile swayRc
+ lib.concatStringsSep "\n" config.module.sway.extraConfig;
+ lib.concatStringsSep "\n" config.module.sway.extraConfig
+ lib.optionalString config.module.wallpaper.video "\nexec mpvpaper -o 'no-audio --loop-file --panscan=1' '*' ${config.module.wallpaper.videoPath}";
}

View file

@ -45,9 +45,7 @@
"t-ru.org"
"medium.com"
];
udpPorts = [
"443"
];
udpPorts = [ "443" ];
};
amd = {
cpu.enable = true;

View file

@ -1,43 +1,37 @@
# Download the wallpaper here.
{ pkgs, lib, ... }:
{
config,
lib,
pkgs,
...
}:
let
url = "https://i.imgur.com/kMY55kW.png";
sha256 = "sha256-OcGrjvGAs6zZY9FLPojMMSufQp4GMLWynEokZ3zJ0DA=";
cfg = config.module.wallpaper;
url = "https://preview.redd.it/snfs0gloct491.gif?width=640&format=mp4&s=7e50d8f89ad5724b7addd900fdd5045e03c0c612";
sha256 = "sha256-ECVd9juwzLGVtTVBKV+zs8EiqSg9DAcYqu2M+DwxWsQ=";
# Use video.
video = true;
# Forse black and white for text.
forceContrastText = false;
# Predefined scheme instead of generated.
# SEE: /etc/stylix/palette.json
# SEE: https://github.com/tinted-theming/schemes
# Colors: #212337 #403c64 #596399 #748cd6 #a1abe0 #a3ace1 #b4a4f4 #ef43fa #ff5370 #f67f81 #ffc777 #2df4c0 #40ffff #04d1f9 #b994f1 #ecb2f0
# scheme = "${pkgs.base16-schemes}/share/themes/moonlight.yaml";
# Colors: #282c34 #2c323b #3e4451 #665c54 #928374 #a89984 #d5c4a1 #fdf4c1 #83a598 #a07e3b #a07e3b #528b8b #83a598 #83a598 #d75f5f #a87322
# scheme = "${pkgs.base16-schemes}/share/themes/sandcastle.yaml";
# Colors: #272822 #383830 #49483e #75715e #a59f85 #f8f8f2 #f5f4f1 #f9f8f5 #f92672 #fd971f #f4bf75 #a6e22e #a1efe4 #66d9ef #ae81ff #cc6633
# scheme = "${pkgs.base16-schemes}/share/themes/monokai.yaml";
# Colors: #2E3440 #3B4252 #434C5E #4C566A #D8DEE9 #E5E9F0 #ECEFF4 #8FBCBB #BF616A #D08770 #EBCB8B #A3BE8C #88C0D0 #81A1C1 #B48EAD #5E81AC
# scheme = "${pkgs.base16-schemes}/share/themes/nord.yaml";
# Colors: #1A1B26 #16161E #2F3549 #444B6A #787C99 #A9B1D6 #CBCCD1 #D5D6DB #C0CAF5 #A9B1D6 #0DB9D7 #9ECE6A #B4F9F8 #2AC3DE #BB9AF7 #F7768E
# scheme = "${pkgs.base16-schemes}/share/themes/tokyo-night-dark.yaml";
# Colors: #3C4C55 #556873 #6A7D89 #899BA6 #899BA6 #C5D4DD #899BA6 #556873 #83AFE5 #7FC1CA #A8CE93 #7FC1CA #F2C38F #83AFE5 #9A93E1 #F2C38F
# scheme = "${pkgs.base16-schemes}/share/themes/nova.yaml"; # Needs text contrast.
# Colors: #263238 #2E3C43 #314549 #546E7A #B2CCD6 #EEFFFF #EEFFFF #FFFFFF #F07178 #F78C6C #FFCB6B #C3E88D #89DDFF #82AAFF #C792EA #FF5370
# scheme = "${pkgs.base16-schemes}/share/themes/material.yaml";
# Colors: #1e1e3f #43d426 #f1d000 #808080 #6871ff #c7c7c7 #ff77ff #ffffff #d90429 #f92a1c #ffe700 #3ad900 #00c5c7 #6943ff #ff2c70 #79e8fb
# scheme = "${pkgs.base16-schemes}/share/themes/shades-of-purple.yaml";
# Colors: #3B3228 #534636 #645240 #7e705a #b8afad #d0c8c6 #e9e1dd #f5eeeb #cb6077 #d28b71 #f4bc87 #beb55b #7bbda4 #8ab3b5 #a89bb9 #bb9584
# scheme = "${pkgs.base16-schemes}/share/themes/mocha.yaml";
# Colors: #1d2021 #3c3836 #504945 #665c54 #bdae93 #d5c4a1 #ebdbb2 #fbf1c7 #fb4934 #fe8019 #fabd2f #b8bb26 #8ec07c #83a598 #d3869b #d65d0e
# scheme = "${pkgs.base16-schemes}/share/themes/gruvbox-dark-hard.yaml";
# Use wallpaper to generate color. SEE: /etc/stylix/palette.json
scheme = null;
# Extract image from video.
videoImage =
if video then
pkgs.runCommandNoCC "wallpaper-video-image" { } ''
${pkgs.ffmpeg}/bin/ffmpeg -i ${cfg.videoPath} Image.jpg || true
cp Image.jpg $out
''
else
null;
in
{
options.module.wallpaper = {
@ -46,9 +40,17 @@ in
type = lib.types.bool;
};
path = lib.mkOption {
default = pkgs.fetchurl { inherit url sha256; };
default = if video then videoImage else pkgs.fetchurl { inherit url sha256; };
type = lib.types.path;
};
video = lib.mkOption {
default = video;
type = lib.types.bool;
};
videoPath = lib.mkOption {
default = if video then pkgs.fetchurl { inherit url sha256; } else null;
type = with lib.types; nullOr path;
};
scheme = lib.mkOption {
default = scheme;
type =

View file

@ -92,6 +92,7 @@
fuzzel # Application launcher.
grim # Screenshots.
mako # Notification system.
mpvpaper # Video wallpapers.
networkmanagerapplet # Internet configuration.
pamixer # Sound controls.
pavucontrol # Sound applet.