+** This file is part of ocaml-chbg.
+** ocaml-chbg is free software: you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation, either version 3 of the License, or
+** (at your option) any later version.
+** ocaml-chbg is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+** You should have received a copy of the GNU General Public License
+** along with ocaml-chbg. If not, see <http://www.gnu.org/licenses/>.
+let _tbl = Hashtbl.create 17
+let _logstart = U.gettimeofday ()
+ let time = U.gettimeofday () -. _logstart in
+ P.printf "%.3f: %s%!" time str
+ let stats = U.stat str in
+ match stats.U.st_kind with
+let feh_exec file = match U.fork () with
+ Unix.execvp "feh" [| "feh"; "--bg-scale"; file |]
+ | pid -> let _, _ = U.waitpid  pid in
+ log (P.sprintf "Changing background to %s\n" file)
+ let handle = U.opendir str in
+ let l, step = ref , ref true in
+ l := (U.readdir handle) :: !l ;
+ with End_of_file -> step := false
+ let rec make_sub n = function
+ P.sprintf "Length of _tbl : %d , length of n : %d\n"
+ | hd :: tl when isfile (P.sprintf "%s/%s" !_bgdir hd) ->
+ Hashtbl.add _tbl n hd ;
+ | _ :: tl -> make_sub n tl
+ log (P.sprintf "Recording directory name, %s\n" dir) ;
+ make_sub 0 (to_list dir)
+ _bg := Hashtbl.find _tbl (Random.int n) ;
+ feh_exec (P.sprintf "%s/%s" !_bgdir !_bg) ;
+ log (P.sprintf "Sleeping for %d seconds\n" delay) ;
+ P.printf "usage: %s <directory> <delay in seconds>\n"
+let main () = match Sys.argv with
+ | [| _; bg |] when isfile bg ->
+ | [| _; background; delay |] ->
+ let n = make_tbl background in