74 lines
3.2 KiB
Text
74 lines
3.2 KiB
Text
|
|
;; This Source Code Form is subject to the terms of the Mozilla Public
|
||
|
|
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
||
|
|
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||
|
|
|
||
|
|
;; (bjomarks-gui) — bookmarks in a window.
|
||
|
|
;;
|
||
|
|
;; bjo run . [SHARED [LOCAL]]
|
||
|
|
;;
|
||
|
|
;; SHARED is the folder that the devices share, through a file syncer or a
|
||
|
|
;; mounted WebDAV share: BJOMARKS_SHARED unless given, else the folder chosen
|
||
|
|
;; on the first screen, else ~/Sync/bookmarks. The first screen lists the
|
||
|
|
;; folders added, saved in ~/.config/bjomarks/settings.json, with "Add
|
||
|
|
;; new…" after them; it is there only when neither SHARED nor
|
||
|
|
;; BJOMARKS_SHARED is given.
|
||
|
|
;; LOCAL is this device's own folder: BJOMARKS_LOCAL, or "bjomarks" in the
|
||
|
|
;; user's data folder, unless given. See (bjomarks-gui app) for the window.
|
||
|
|
;;
|
||
|
|
;; Enter opens a bookmark with the system's opener (xdg-open on Linux; in a
|
||
|
|
;; distrobox container, the host's, through host-spawn), or with the program
|
||
|
|
;; BJOMARKS_BROWSER names: see (bjomarks-gui browser).
|
||
|
|
;;
|
||
|
|
;; A title is fetched from the site only when the button beside the title,
|
||
|
|
;; in the dialog, is clicked.
|
||
|
|
;;
|
||
|
|
;; The window has KDE's look: AvaUnion draws it with the session's Union
|
||
|
|
;; style, colours and fonts, or with the Breeze snapshot it carries when
|
||
|
|
;; there is no KDE session. BJOMARKS_LOOK=fluent draws it with Avalonia's
|
||
|
|
;; Fluent theme instead.
|
||
|
|
|
||
|
|
(import (std prelude))
|
||
|
|
(import (std os))
|
||
|
|
(import (bjogui app))
|
||
|
|
(import (bjomarks store))
|
||
|
|
(import (bjomarks-gui app))
|
||
|
|
(import (bjomarks-gui settings))
|
||
|
|
|
||
|
|
(import/class
|
||
|
|
(UnionTheme (: AvaUnion.UnionTheme (-> UnionTheme))))
|
||
|
|
|
||
|
|
(: (-> string (List IStyle)))
|
||
|
|
(defun (themes look)
|
||
|
|
(match look
|
||
|
|
("fluent" (list (fluent-theme)))
|
||
|
|
(_ (list (cast IStyle (UnionTheme.))))))
|
||
|
|
|
||
|
|
(: (-> (Vec string) int string string string))
|
||
|
|
(defun (arg-or args i variable fallback)
|
||
|
|
(if (> (vec-length args) i)
|
||
|
|
(vec-ref args i)
|
||
|
|
(option-ref-or (get-environment-variable variable) fallback)))
|
||
|
|
|
||
|
|
(: (-> (Vec string) int))
|
||
|
|
(defun (main args)
|
||
|
|
(def settings (settings-folder))
|
||
|
|
;; An argument or BJOMARKS_SHARED fixes the shared folder. Else it is the
|
||
|
|
;; one saved in the settings, which the first screen can change.
|
||
|
|
(def fixed (or (> (vec-length args) 0) (some? (get-environment-variable "BJOMARKS_SHARED"))))
|
||
|
|
(def shared (arg-or args 0 "BJOMARKS_SHARED"
|
||
|
|
(option-ref-or (read-shared-folder settings)
|
||
|
|
(path-combine (home-directory) "Sync" "bookmarks"))))
|
||
|
|
;; An argument or BJOMARKS_LOCAL fixes this device's folder. Else each
|
||
|
|
;; shared folder has one of its own, in the app's data folder.
|
||
|
|
(def root (path-combine (data-directory) "bjomarks"))
|
||
|
|
(def local (arg-or args 1 "BJOMARKS_LOCAL" ""))
|
||
|
|
(def look (option-ref-or (get-environment-variable "BJOMARKS_LOOK") ""))
|
||
|
|
(run-app (initial-model (folder-storage shared) local #:settings (if fixed "" settings)
|
||
|
|
#:root (if (string-empty? local) (Some root) None)
|
||
|
|
#:vaults (if fixed [] (read-vaults settings))) gui-update view
|
||
|
|
#:windows windows #:keys keys #:subscriptions subscriptions
|
||
|
|
#:on-close (Some CloseAsked)
|
||
|
|
#:themes (fun () (themes look))
|
||
|
|
#:title "Bjomarks" #:width 640.0 #:height 520.0)
|
||
|
|
0)
|