#
#   _____     _     _            _         _
#  |_   _| __(_) __| | __ _  ___| |_ _   _| |
#    | || '__| |/ _` |/ _` |/ __| __| | | | |
#    | || |  | | (_| | (_| | (__| |_| |_| | |
#    |_||_|  |_|\__,_|\__,_|\___|\__|\__, |_|
#                                    |___/
#
#    :: Entrypoint for Tridactyl config ::
#

# NOTE: Explore current config with: `:viewconfig`
# NOTE: `jsb` logs into the Browser Console, can access the logs for the extension
#   only by going to `about:debugging` -> this Firefox -> Tridactyl -> Inspect


fillcmdline_tmp 2000 Reloading Tridactyl config...... (takes ~20s seconds)

# @2025-05 Let's try again 🤔
# NOTE: _might_ be broken in some cases
# TRACKING-ISSUE: https://github.com/tridactyl/tridactyl/issues/1409
sanitize tridactyllocal tridactylsync
# From `:h sanitize`:
# - tridactyllocal: Removes all tridactyl storage local to this machine
# - tridactylsync: Removes all tridactyl storage associated with your Firefox Account
#     (i.e, all user configuration, by default)

# Restore default config on-demand, use `:source` to get back my config
command reset_to_defaults sanitize tridactyllocal tridactylsync

# Source the given file, relative to this file.
# Can be restricted to specific OS.
# SEE ./js-actions/source_cfg.js for details
#
# % Usage:
# source_cfg ./file
# source_cfg for-os:THE-OS ./file
command source_cfg jsb -d§ -r ./js-actions/source_cfg.js§
# /!\ The ending `§` is NOT separated from the filename
#   … until that PR is merged and released: https://github.com/tridactyl/tridactyl/pull/5222

# Theme 'shydactyl' puts the command promp in the middle of the window, like
# fuzzy launchers in some editors. It allows to _always_ see the mode
# indicator, even when a fillcmdline_tmp 'toast' is visible. With the 'dark'
# theme, the mode indicator is hidden behind the command prompt..
colors shydactyl

source_cfg ./mappings.rc

source_cfg ./options.rc

source_cfg ./url-specifc.rc

source_cfg for-os:linux ./os.linux.rc
source_cfg for-os:mac ./os.mac.rc

# --------------------------------------------------------
# Indicates the config reloaded, with the date
# (must be at the end, indicates config finished loading!)
composite js new Date().toISOString() | fillcmdline_tmp 2000 Config loaded! @

# vim:set ft=conf:
