Skip to content

Commit

Permalink
Switch [directories] to [xdg] to work on Windows (#29)
Browse files Browse the repository at this point in the history
* 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/<project_path> where <project_path> was qualifier.organization.application (org.sanette.bogue).

Fixes #27

* Use // for consistency
  • Loading branch information
jonahbeckford authored Feb 17, 2024
1 parent ccfc5ec commit ad184ee
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 18 deletions.
2 changes: 1 addition & 1 deletion bogue.opam
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down
2 changes: 1 addition & 1 deletion dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -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))
))
23 changes: 8 additions & 15 deletions lib/b_theme.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
config_dir // application

let skip_comment buffer =
let rec loop () =
Expand Down
2 changes: 1 addition & 1 deletion lib/dune
Original file line number Diff line number Diff line change
@@ -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)
Expand Down

0 comments on commit ad184ee

Please sign in to comment.