Update scripting system.

This commit is contained in:
2026-09-10 19:19:13 +01:00
parent 3a273d1ee8
commit 5caf6fb658
4 changed files with 74 additions and 29 deletions
+11 -4
View File
@@ -1,16 +1,23 @@
let () =
let startup_script =
if Array.length Sys.argv <> 2 then None else Some Sys.argv.(1)
if Array.length Sys.argv = 2 then Some Sys.argv.(1)
else
let default =
Filename.concat (Sys.getenv "HOME") ".config/kutu/config.rb"
in
if Sys.file_exists default then Some default else None
in
let state = Kutu.State.new_state in
print_endline "Started Kutu WM";
Bindings.Core.register_callbacks state;
Mruby.Core.mrb_load_string state.mrb Mruby.Initial.initial_code;
(match startup_script with
| None -> ()
| Some s -> Mruby.Core.mrb_load_file state.mrb s);
| Some s ->
Mruby.Core.mrb_load_string state.mrb (Mruby.Initial.initial_code s)
| None -> Mruby.Core.mrb_load_string state.mrb "");
Mruby.Core.error_check state.mrb;
if Xcb.Connection.flush state.conn <= 0 then exit 1;