Skip to content

lkubb/salt-tool-hammerspoon-formula

Repository files navigation

Hammerspoon Formula

Manages Hammerspoon in the user environment.

Applying tool_hammerspoon will make sure hammerspoon is configured as specified.

This formula

The general configuration structure is in line with all other formulae from the tool suite, for details see :ref:`toolsuite`. An example pillar is provided, see :ref:`pillar.example`. Note that you do not need to specify everything by pillar. Often, it's much easier and less resource-heavy to use the parameters/<grain>/<value>.yaml files for non-sensitive settings. The underlying logic is explained in :ref:`map.jinja`.

User-specific

The following shows an example of tool_hammerspoon per-user configuration. If provided by pillar, namespace it to tool_global:users and/or tool_hammerspoon:users. For the parameters YAML file variant, it needs to be nested under a values parent key. The YAML files are expected to be found in

  1. salt://tool_hammerspoon/parameters/<grain>/<value>.yaml or
  2. salt://tool_global/parameters/<grain>/<value>.yaml.
user:

    # Force the usage of XDG directories for this user.
  xdg: true

    # Sync this user's config from a dotfiles repo.
    # The available paths and their priority can be found in the
    # rendered `config/sync.sls` file (currently, @TODO docs).
    # Overview in descending priority:
    # salt://dotconfig/<minion_id>/<user>/hammerspoon
    # salt://dotconfig/<minion_id>/hammerspoon
    # salt://dotconfig/<os_family>/<user>/hammerspoon
    # salt://dotconfig/<os_family>/hammerspoon
    # salt://dotconfig/default/<user>/hammerspoon
    # salt://dotconfig/default/hammerspoon
  dotconfig:              # can be bool or mapping
    file_mode: '0600'     # default: keep destination or salt umask (new)
    dir_mode: '0700'      # default: 0700
    clean: false          # delete files in target. default: false

    # Persist environment variables used by this formula for this
    # user to this file (will be appended to a file relative to $HOME)
  persistenv: '.config/zsh/zshenv'

    # Add runcom hooks specific to this formula to this file
    # for this user (will be appended to a file relative to $HOME)
  rchook: '.config/zsh/zshrc'

    # This user's configuration for this formula. Will be overridden by
    # user-specific configuration in `tool_hammerspoon:users`.
    # Set this to `false` to disable configuration for this user.
  hammerspoon:
      # Make sure some repos are cloned/absent to/from HS config dir.
    spoons:
      absent:
          # Just the dir name as it would be produced by a `git clone`.
        - stackline
        # automatically update spoons with git.latest
      update_auto: true
      wanted:
          # either git URL
        - https://github.com/AdamWagner/stackline
          # or git URL: branch mapping
        - https://git.my.example/my/stackline: my

Formula-specific

tool_hammerspoon:

    # Specify an explicit version (works on most Linux distributions) or
    # keep the packages updated to their latest version on subsequent runs
    # by leaving version empty or setting it to 'latest'
    # (again for Linux, brew does that anyways).
  version: latest

    # Default formula configuration for all users.
  defaults:
    spoons: default value for all users

Dotfiles

tool_hammerspoon.config.sync will recursively apply templates from

  • salt://dotconfig/<minion_id>/<user>/hammerspoon
  • salt://dotconfig/<minion_id>/hammerspoon
  • salt://dotconfig/<os_family>/<user>/hammerspoon
  • salt://dotconfig/<os_family>/hammerspoon
  • salt://dotconfig/default/<user>/hammerspoon
  • salt://dotconfig/default/hammerspoon

to the user's config dir for every user that has it enabled (see user.dotconfig). The target folder will not be cleaned by default (ie files in the target that are absent from the user's dotconfig will stay).

The URL list above is in descending priority. This means user-specific configuration from wider scopes will be overridden by more system-specific general configuration.

The following states are found in this formula:

Meta-state.

Performs all operations described in this formula according to the specified configuration.

Installs the Hammerspoon package only.

Ensures Hammerspoon adheres to the XDG spec as best as possible for all managed users. Has a dependency on tool_hammerspoon.package.

Manages the Hammerspoon package configuration by

  • recursively syncing from a dotfiles repo

Has a dependency on tool_hammerspoon.package.

Meta-state.

Undoes everything performed in the tool_hammerspoon meta-state in reverse order.

Removes Hammerspoon XDG compatibility crutches for all managed users.

Removes the configuration of the Hammerspoon package.

Contributing to this repo

Commit messages

Commit message formatting is significant.

Please see How to contribute for more details.

pre-commit

pre-commit is configured for this formula, which you may optionally use to ease the steps involved in submitting your changes. First install the pre-commit package manager using the appropriate method, then run bin/install-hooks and now pre-commit will run automatically on each git commit.

$ bin/install-hooks
pre-commit installed at .git/hooks/pre-commit
pre-commit installed at .git/hooks/commit-msg

State documentation

There is a script that semi-autodocuments available states: bin/slsdoc.

If a .sls file begins with a Jinja comment, it will dump that into the docs. It can be configured differently depending on the formula. See the script source code for details currently.

This means if you feel a state should be documented, make sure to write a comment explaining it.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published