refactor: change custom wallpaper engine module to homemanger option
This commit is contained in:
parent
f7409e0537
commit
dc8f796e18
4 changed files with 93 additions and 220 deletions
80
home/user/wallpaper-engine.nix
Normal file
80
home/user/wallpaper-engine.nix
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
{
|
||||
assetsPath ? null,
|
||||
fps ? 30,
|
||||
# example: [
|
||||
# { monitor = "HDMI-A1"; id = "12938798"; }
|
||||
# ]
|
||||
monitorIdPairs ? [ ],
|
||||
}:
|
||||
{
|
||||
lib,
|
||||
config,
|
||||
osConfig,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
inherit (lib) mkForce mkIf;
|
||||
defaultSettings = {
|
||||
inherit fps;
|
||||
audio = {
|
||||
silent = true;
|
||||
processing = true;
|
||||
};
|
||||
scaling = "default";
|
||||
};
|
||||
|
||||
defaultAssetsPath = ''""'';
|
||||
finalAssetsPath = if assetsPath == null then defaultAssetsPath else assetsPath;
|
||||
cfg = config.services.linux-wallpaperengine;
|
||||
in
|
||||
{
|
||||
services.swww.enable = mkForce false;
|
||||
|
||||
services.linux-wallpaperengine = {
|
||||
enable = true;
|
||||
wallpapers = map (
|
||||
pair:
|
||||
{
|
||||
wallpaperId = toString pair.id;
|
||||
monitor = pair.monitor;
|
||||
}
|
||||
// defaultSettings
|
||||
) monitorIdPairs;
|
||||
};
|
||||
|
||||
systemd.user.services."linux-wallpaperengine" =
|
||||
let
|
||||
args = lib.lists.forEach cfg.wallpapers (
|
||||
each:
|
||||
lib.concatStringsSep " " (
|
||||
lib.cli.toGNUCommandLine { } {
|
||||
screen-root = each.monitor;
|
||||
inherit (each) scaling;
|
||||
noautomute = !each.audio.automute;
|
||||
no-audio-processing = !each.audio.processing;
|
||||
}
|
||||
++ each.extraOptions
|
||||
)
|
||||
# This has to be the last argument in each group
|
||||
+ " --bg ${each.wallpaperId}"
|
||||
);
|
||||
in
|
||||
{
|
||||
Service = {
|
||||
ExecStart = mkForce (toString [
|
||||
(lib.getExe cfg.package)
|
||||
"--fps ${toString fps}"
|
||||
"--silent"
|
||||
"--assets-dir ${finalAssetsPath}"
|
||||
(lib.strings.concatStringsSep " " args)
|
||||
]);
|
||||
Environment = mkIf osConfig.hardware.nvidia.prime.offload.enableOffloadCmd [
|
||||
"__NV_PRIME_RENDER_OFFLOAD=1"
|
||||
"__NV_PRIME_RENDER_OFFLOAD_PROVIDER=NVIDIA-G0"
|
||||
"__GLX_VENDOR_LIBRARY_NAME=nvidia"
|
||||
"__VK_LAYER_NV_optimus=NVIDIA_only"
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue