1
1
Fork 1
mirror of https://github.com/oddlama/nix-config.git synced 2025-10-10 23:00:39 +02:00

feat: add random wallpaper change

This commit is contained in:
oddlama 2024-06-13 00:35:40 +02:00
parent 71bd2f8054
commit 364632a89a
No known key found for this signature in database
GPG key ID: 14EFE510775FE39A
3 changed files with 39 additions and 28 deletions

View file

@ -7,8 +7,6 @@
writeShellApplication {
name = "brightness";
text = ''
set -euo pipefail
${brightnessctl}/bin/brightnessctl "$1" "$2"
case "$2" in
"+"*) image=${./assets}/brightness-increase.svg ;;

View file

@ -7,8 +7,6 @@
writeShellApplication {
name = "volume";
text = ''
set -euo pipefail
${wireplumber}/bin/wpctl "$1" "$2" "$3"
current_volume=$(${wireplumber}/bin/wpctl get-volume "$2")
case "''${2,,}" in

View file

@ -1,7 +1,30 @@
{pkgs, ...}: {
{
lib,
pkgs,
...
}: let
swww-update-wallpaper = pkgs.writeShellApplication {
name = "swww-update-wallpaper";
runtimeInputs = [
pkgs.swww
];
text = ''
FILES=("$HOME/.local/share/wallpapers/"*)
TYPES=("wipe" "wave" "any")
ANGLES=(0 15 30 45 60 75 90 105 120 135 150 165 180 195 210 225 240 255 270 285 300 315 330 345)
swww img "''${FILES[RANDOM%''${#FILES[@]}]}" \
--transition-type "''${TYPES[RANDOM%''${#TYPES[@]}]}" \
--transition-angle "''${ANGLES[RANDOM%''${#ANGLES[@]}]}" \
--transition-fps 144 \
--transition-duration 1.5
'';
};
in {
systemd.user = {
services = {
swww = {
Install.WantedBy = ["graphical-session.target"];
Unit = {
Description = "Wayland wallpaper daemon";
PartOf = ["graphical-session.target"];
@ -10,30 +33,22 @@
ExecStart = "${pkgs.swww}/bin/swww-daemon";
Restart = "on-failure";
};
Install.WantedBy = ["graphical-session.target"];
};
#swww-random = {
# Unit = {
# Description = "switch random wallpaper powered by swww";
# };
# Service = {
# Type = "oneshot";
# ExecStart = "${pkgs.swww-switch}/bin/swww-switch random";
# };
# Install = {
# WantedBy = ["default.target"];
# };
#};
swww-update-wallpaper = {
Install.WantedBy = ["default.target"];
Unit.Description = "Update the wallpaper";
Service = {
Type = "oneshot";
Restart = "on-failure";
RestartSec = "2m";
ExecStart = lib.getExe swww-update-wallpaper;
};
};
};
timers.swww-update-wallpaper = {
Install.WantedBy = ["timers.target"];
Unit.Description = "Periodically switch to a new wallpaper";
Timer.OnCalendar = "*:0/5"; # Every 5 minutes
};
#timers.swww-random = {
# Unit = {
# Description = "switch random wallpaper powered by swww timer";
# };
# Timer = {
# OnUnitActiveSec = "60min";
# OnBootSec = "60min";
# };
# Install = {WantedBy = ["timers.target"];};
#};
};
}