1
0
Fork 0

Improve wallpaper change

This commit is contained in:
Malte Brandy 2020-05-09 17:01:10 +02:00
parent 4f5e60a649
commit d696bad7f3
No known key found for this signature in database
GPG key ID: 226A2D41EF5378C9

View file

@ -6,12 +6,16 @@ let
imports = [ "System.Random" ];
bins = [ pkgs.coreutils pkgs.sway ];
} ''
linkPath = "/home/maralorn/volatile/wallpaper.jpg"
main = do
mode <- cat "/home/maralorn/tmp/mode" |> captureTrim
(lines . decodeUtf8 -> files) <- ls ([i|/home/maralorn/.wallpapers/#{mode}|] :: String) |> captureTrim
((files Unsafe.!!) -> file) <- getStdRandom $ randomR (0, length files - 1)
cp ([i|/home/maralorn/.wallpapers/#{mode}/#{file}|] :: String) "/home/maralorn/volatile/wallpaper.jpg"
swaymsg "output * bg /home/maralorn/volatile/wallpaper.jpg fill"
(decodeUtf8 -> current) <- readlink linkPath |> captureTrim
let new = [i|/home/maralorn/.wallpapers/#{mode}/#{file}|] :: String
when (new /= current) $ do
ln "-s" new linkPath
swaymsg "output * bg /home/maralorn/volatile/wallpaper.jpg fill"
'';
in {
home.packages = [ randomWallpaper ];