Improve wallpaper change
This commit is contained in:
parent
4f5e60a649
commit
d696bad7f3
|
@ -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 ];
|
||||
|
|
Loading…
Reference in a new issue