|
|
@ -1,6 +1,8 @@ |
|
|
|
module Project_dirs = Directories.Project_dirs (struct |
|
|
|
let qualifier = "org" |
|
|
|
|
|
|
|
let organization = "zapashcanon" |
|
|
|
|
|
|
|
let application = "ccbg" |
|
|
|
end) |
|
|
|
|
|
|
@ -16,12 +18,12 @@ let config_dir = |
|
|
|
| Some dir -> dir |
|
|
|
|
|
|
|
let wallpaper_dir = |
|
|
|
match User_dirs.picture_dir with |
|
|
|
match User_dirs.picture_dir with |
|
|
|
| None -> err "can't compute picture directory path" |
|
|
|
| Some dir -> |
|
|
|
Filename.concat dir "wallpaper" |
|
|
|
| Some dir -> Filename.concat dir "wallpaper" |
|
|
|
|
|
|
|
let time = 600 |
|
|
|
|
|
|
|
let time = Format.sprintf "%ds" time |
|
|
|
|
|
|
|
let () = Random.self_init () |
|
|
@ -29,24 +31,30 @@ let () = Random.self_init () |
|
|
|
let wallpaper_files = |
|
|
|
match Bos.OS.Dir.contents (Fpath.v wallpaper_dir) with |
|
|
|
| Ok cnt -> |
|
|
|
let cnt = List.filter (fun path -> |
|
|
|
match Bos.OS.Dir.exists path with |
|
|
|
| Ok false -> true |
|
|
|
| Ok true -> false |
|
|
|
| _ -> false |
|
|
|
) cnt in |
|
|
|
let cnt = |
|
|
|
List.filter |
|
|
|
(fun path -> |
|
|
|
match Bos.OS.Dir.exists path with |
|
|
|
| Ok false -> true |
|
|
|
| Ok true -> false |
|
|
|
| _ -> false ) |
|
|
|
cnt |
|
|
|
in |
|
|
|
Array.of_list (List.map Fpath.to_string cnt) |
|
|
|
| Error (`Msg e) -> err e |
|
|
|
|
|
|
|
let random_wallpaper = |
|
|
|
let len = Array.length wallpaper_files in |
|
|
|
fun () -> |
|
|
|
wallpaper_files.(Random.int len) |
|
|
|
fun () -> wallpaper_files.(Random.int len) |
|
|
|
|
|
|
|
let rec new_wallpaper () = |
|
|
|
match Bos.OS.Cmd.run Bos.Cmd.(v "timeout" % time % "swaybg" % "--mode" % "fill" %"--image" % (random_wallpaper ())) with |
|
|
|
| _ -> |
|
|
|
new_wallpaper () |
|
|
|
match |
|
|
|
Bos.OS.Cmd.run |
|
|
|
Bos.Cmd.( |
|
|
|
v "timeout" % time % "swaybg" % "--mode" % "fill" % "--image" |
|
|
|
% random_wallpaper () ) |
|
|
|
with |
|
|
|
| _ -> new_wallpaper () |
|
|
|
|
|
|
|
let () = |
|
|
|
match Bos.OS.Cmd.run Bos.Cmd.(v "killall" % "swaybg") with |
|
|
|