Improve wallpaper change
This commit is contained in:
parent
4f5e60a649
commit
d696bad7f3
1 changed files with 6 additions and 2 deletions
|
@ -6,12 +6,16 @@ let
|
||||||
imports = [ "System.Random" ];
|
imports = [ "System.Random" ];
|
||||||
bins = [ pkgs.coreutils pkgs.sway ];
|
bins = [ pkgs.coreutils pkgs.sway ];
|
||||||
} ''
|
} ''
|
||||||
|
linkPath = "/home/maralorn/volatile/wallpaper.jpg"
|
||||||
main = do
|
main = do
|
||||||
mode <- cat "/home/maralorn/tmp/mode" |> captureTrim
|
mode <- cat "/home/maralorn/tmp/mode" |> captureTrim
|
||||||
(lines . decodeUtf8 -> files) <- ls ([i|/home/maralorn/.wallpapers/#{mode}|] :: String) |> captureTrim
|
(lines . decodeUtf8 -> files) <- ls ([i|/home/maralorn/.wallpapers/#{mode}|] :: String) |> captureTrim
|
||||||
((files Unsafe.!!) -> file) <- getStdRandom $ randomR (0, length files - 1)
|
((files Unsafe.!!) -> file) <- getStdRandom $ randomR (0, length files - 1)
|
||||||
cp ([i|/home/maralorn/.wallpapers/#{mode}/#{file}|] :: String) "/home/maralorn/volatile/wallpaper.jpg"
|
(decodeUtf8 -> current) <- readlink linkPath |> captureTrim
|
||||||
swaymsg "output * bg /home/maralorn/volatile/wallpaper.jpg fill"
|
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 {
|
in {
|
||||||
home.packages = [ randomWallpaper ];
|
home.packages = [ randomWallpaper ];
|
||||||
|
|
Loading…
Reference in a new issue