From 4dcab58e6d1dea52d81bd9b22b736ce2d0461f8e Mon Sep 17 00:00:00 2001 From: Jonah Beckford <71855677+jonahbeckford@users.noreply.github.com> Date: Thu, 15 Feb 2024 10:00:54 -0800 Subject: [PATCH 1/2] Switch [directories] to [xdg] to work on Windows xdg.3.4.0 was the first version to have good Windows defaults. It should be the same configuration directory on Linux but not Windows (which was never working) and not macOS. macOS used to be $HOME/Library/Application Support/ where was qualifier.organization.application (org.sanette.bogue). Fixes https://github.com/sanette/bogue/issues/27 --- bogue.opam | 2 +- dune-project | 2 +- lib/b_theme.ml | 23 ++++++++--------------- lib/dune | 2 +- 4 files changed, 11 insertions(+), 18 deletions(-) diff --git a/bogue.opam b/bogue.opam index 3da7190..9a6328b 100644 --- a/bogue.opam +++ b/bogue.opam @@ -32,7 +32,7 @@ depends: [ "tsdl-ttf" {>= "0.3"} "ocaml" {>= "4.08.0"} "tsdl" {>= "0.9.7" & < "0.9.9"} - "directories" + "xdg" {>= "3.4.0"} "odoc" {with-doc} ] build: [ diff --git a/dune-project b/dune-project index a5130fc..56227c7 100644 --- a/dune-project +++ b/dune-project @@ -34,5 +34,5 @@ Threads when non-blocking reactions are needed.") (tsdl-ttf (>= 0.3)) (ocaml (>= 4.08.0)) (tsdl (and (>= 0.9.7) (< 0.9.9))) - directories + (xdg (>= 3.4.0)) )) diff --git a/lib/b_theme.ml b/lib/b_theme.ml index ea52960..d71252c 100644 --- a/lib/b_theme.ml +++ b/lib/b_theme.ml @@ -95,21 +95,14 @@ let (//) = Filename.concat (* Some global environment variables *) -module User_dirs = Directories.User_dirs () -module Project_dirs = Directories.Project_dirs (struct - let qualifier = "org" - let organization = "sanette" - let application = "bogue" -end -) - -let home = match User_dirs.home_dir with - | None -> failwith "Can't compute home directory path." - | Some home -> home - -let conf = match Project_dirs.config_dir with - | None -> failwith "Can't compute configuration directory path." - | Some config_dir -> config_dir +let xdg = Xdg.create ~env:Sys.getenv_opt () + +let home = Xdg.home_dir xdg + +let conf = + let application = "bogue" in + let config_dir = Xdg.config_dir xdg in + Filename.concat config_dir application let skip_comment buffer = let rec loop () = diff --git a/lib/dune b/lib/dune index d47802f..bde00a7 100644 --- a/lib/dune +++ b/lib/dune @@ -1,7 +1,7 @@ (library (name bogue) (public_name bogue) - (libraries directories str tsdl tsdl-image tsdl-ttf)) + (libraries xdg str tsdl tsdl-image tsdl-ttf)) (install (section share) From 4157a2b3f07178e5d7c2645718c4136bed0ccf3e Mon Sep 17 00:00:00 2001 From: Jonah Beckford <71855677+jonahbeckford@users.noreply.github.com> Date: Fri, 16 Feb 2024 12:00:06 -0800 Subject: [PATCH 2/2] Use // for consistency --- lib/b_theme.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/b_theme.ml b/lib/b_theme.ml index d71252c..af10e30 100644 --- a/lib/b_theme.ml +++ b/lib/b_theme.ml @@ -102,7 +102,7 @@ let home = Xdg.home_dir xdg let conf = let application = "bogue" in let config_dir = Xdg.config_dir xdg in - Filename.concat config_dir application + config_dir // application let skip_comment buffer = let rec loop () =