2019-11-29 16:52:50 +00:00
|
|
|
{ lib, pkgs, config, ... }:
|
|
|
|
let
|
|
|
|
inherit (import ../../lib) writeHaskellScript;
|
|
|
|
randomWallpaper = writeHaskellScript {
|
|
|
|
name = "random-wallpaper";
|
2020-01-19 16:40:02 +00:00
|
|
|
imports = [ "System.Random" ];
|
2019-11-29 16:52:50 +00:00
|
|
|
bins = [ pkgs.coreutils pkgs.sway ];
|
|
|
|
} ''
|
2020-01-19 17:42:41 +00:00
|
|
|
main = do
|
|
|
|
(lines . decodeUtf8 -> files) <- ls "/home/maralorn/.wallpapers" |> captureTrim
|
|
|
|
((files Unsafe.!!) -> file) <- getStdRandom $ randomR (0, length files - 1)
|
2019-11-29 16:52:50 +00:00
|
|
|
cp ([i|/home/maralorn/.wallpapers/#{file}|] :: String) "/home/maralorn/volatile/wallpaper.jpg"
|
|
|
|
swaymsg "output * bg /home/maralorn/volatile/wallpaper.jpg fill"
|
|
|
|
'';
|
|
|
|
in {
|
|
|
|
|
|
|
|
systemd.user = {
|
|
|
|
services.random-wallpaper = {
|
|
|
|
Unit = { Description = "Random Wallpaper"; };
|
2019-12-09 15:40:58 +00:00
|
|
|
Service = {
|
|
|
|
ExecStart = "${randomWallpaper}/bin/random-wallpaper";
|
2020-01-19 16:40:02 +00:00
|
|
|
Type = "oneshot";
|
2019-12-09 15:40:58 +00:00
|
|
|
};
|
2020-01-19 16:40:02 +00:00
|
|
|
};
|
|
|
|
timers.random-wallpaper = {
|
2020-01-19 17:42:41 +00:00
|
|
|
Timer = { OnCalendar = "*:00/5:00"; };
|
2020-01-19 16:40:02 +00:00
|
|
|
Install = { WantedBy = [ "timers.target" ]; };
|
2019-11-29 16:52:50 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|