diff --git a/dots.toml b/dots.toml new file mode 100644 index 0000000..92194b6 --- /dev/null +++ b/dots.toml @@ -0,0 +1,39 @@ +# Deployment metadata for HyDE. +# +# HyDE consumes this over the branch archive, so it needs no second git remote: +# +# [[wezterm.files]] +# source = "https://github.com/HyDE-Project/terminal-emulators/archive/refs/heads/main.zip" +# +# The archive contains a single top-level directory, which the installer strips, +# so every path below is written as if this file sat at the root. + +[wezterm] + description = "A GPU-accelerated cross-platform terminal emulator and multiplexer" + owner = "The HyDE Project" + +[[wezterm.dependency]] + dnf = [ "wezterm" ] + pacman = [ "wezterm" ] + +# HyDE's defaults. Replaced on update. +[[wezterm.files]] + action = "sync" + paths = "hyde.lua" + source_root = "wezterm" + target_root = "${XDG_CONFIG_HOME}/wezterm" + +# The user's entry point. Never overwritten once it exists. +[[wezterm.files]] + action = "preserve" + paths = "wezterm.lua" + source_root = "wezterm" + target_root = "${XDG_CONFIG_HOME}/wezterm" + +# The wallbash template. Rendered to ${XDG_CONFIG_HOME}/wezterm/hyde.toml on a +# theme change, which WezTerm picks up through the watch list in hyde.lua. +[[wezterm.files]] + action = "sync" + paths = "wezterm.dcol" + source_root = "wezterm" + target_root = "${XDG_DATA_HOME}/wallbash/theme" diff --git a/wezterm/README.md b/wezterm/README.md index bb9ab08..fea7bb9 100644 --- a/wezterm/README.md +++ b/wezterm/README.md @@ -1,22 +1,49 @@ # WezTerm -## Adding Templates +## With HyDE -To add templates, follow these steps: +Select the `wezterm` dot during install, or deploy it directly. HyDE reads +`dots.toml` in the root of this repository over the branch archive, so nothing +has to be copied by hand. -1. Copy the file `/wezterm.dcol` to either `~/.config/hyde/wallbash/always` or `~/.config/hyde/wallbash/theme`. -2. Run `hyde-shell reload` to generate the file. +| File | Deployed to | Managed | +| --- | --- | --- | +| `hyde.lua` | `$XDG_CONFIG_HOME/wezterm/hyde.lua` | replaced on update | +| `wezterm.lua` | `$XDG_CONFIG_HOME/wezterm/wezterm.lua` | yours, never overwritten | +| `wezterm.dcol` | `$XDG_DATA_HOME/wallbash/theme/wezterm.dcol` | replaced on update | -**NOTE** The target file's directory should exist first `$XDG_CONFIG_HOME/wezterm/` +## By hand -## Applying and Reloading the Theme through `wezterm.lua` +1. Copy `wezterm.dcol` into `~/.config/hyde/wallbash/theme` or + `~/.config/hyde/wallbash/always`. +2. Copy `hyde.lua` and `wezterm.lua` into `~/.config/wezterm/`. +3. Run `hyde-shell reload`. -To apply the theme, include or copy the `./wezterm.lua` file in your WezTerm configuration. +`~/.config/wezterm/` has to exist first: wallbash skips a template whose target +directory is missing. -**Note:** The Lua script tries to find the set config home. +## How the colours reach WezTerm -For more information on configuring and theming the WezTerm terminal, you can visit the following resources: +`wezterm.dcol` renders to `~/.config/wezterm/hyde.toml`, a native WezTerm colour +scheme named `wallbash`. `hyde.lua` puts that path on WezTerm's config reload +watch list, so a theme change reloads the terminal on its own with no signal and +no apply hook. -- [WezTerm Wiki](https://github.com/wez/wezterm/wiki) -- [WezTerm Theming Guide](https://wezfurlong.org/wezterm/config/files.html#theming) -- [This Guide to handle dynamic files](https://github.com/wez/wezterm/issues/1036) +The scheme is selected only once the file exists. Naming a scheme that is not +there makes WezTerm log an error on every start, which is what a fresh install +looks like before the first theme switch. + +## Your own settings + +`wezterm.lua` is three lines and stays yours: + +```lua +local config = require("hyde").config() +config.font_size = 12 +return config +``` + +## References + +- [WezTerm configuration files](https://wezfurlong.org/wezterm/config/files.html) +- [WezTerm colour schemes](https://wezfurlong.org/wezterm/config/appearance.html#defining-a-color-scheme-in-a-separate-file) diff --git a/wezterm/hyde.lua b/wezterm/hyde.lua new file mode 100644 index 0000000..ec60be1 --- /dev/null +++ b/wezterm/hyde.lua @@ -0,0 +1,82 @@ +--! ░▒▓ +--! ░▒▒░▓▓ +--! ░▒▒▒░░░▓▓ ___________ +--! ░░▒▒▒░░░░░▓▓ //___________/ +--! ░░▒▒▒░░░░░▓▓ _ _ _ _ _____ +--! ░░▒▒░░░░░▓▓▓▓▓▓ | | | | | | | __/ +--! ░▒▒░░░░▓▓ ▓▓ | |_| | |_/ /| |___ +--! ░▒▒░░▓▓ ▓▓ \__ |____/ |____/ █░█░█ █▀▀ ▀█ ▀█▀ █▀▀ █▀█ █▀▄▀█ +--! ░▒▓▓ ▓▓ //____/ ▀▄▀▄▀ ██▄ █▄ ░█░ ██▄ █▀▄ █░▀░█ + +-- HyDE's WezTerm defaults. +-- +-- This file is replaced on update. Put your own settings in wezterm.lua, +-- which HyDE never overwrites. + +local wezterm = require("wezterm") + +local M = {} + +local config_dir = (os.getenv("XDG_CONFIG_HOME") or (os.getenv("HOME") .. "/.config")) .. "/wezterm" + +-- config_builder validates keys and reports typos, but only exists on builds +-- from 2022 onwards. An older WezTerm gets a plain table instead of an error. +local function new_config() + if type(wezterm.config_builder) == "function" then + return wezterm.config_builder() + end + return {} +end + +--- Returns HyDE's defaults as a config table. +--- +--- Merge your own settings on top of it: +--- +--- local config = require("hyde").config() +--- config.font_size = 12 +--- return config +function M.config() + local config = new_config() + + -- wallbash writes hyde.toml here as a native colour scheme named + -- "wallbash". Watching that file means a theme switch reloads WezTerm on + -- its own, with nothing to signal and no need to touch the entry point. + -- + -- The scheme is only selected once the file exists: naming a scheme that is + -- not there makes WezTerm log an error on every start, which is what a + -- fresh install looks like before the first theme switch runs. + local palette = config_dir .. "/hyde.toml" + wezterm.add_to_config_reload_watch_list(palette) + + local handle = io.open(palette, "r") + if handle then + handle:close() + config.color_scheme_dirs = {config_dir} + config.color_scheme = "wallbash" + end + + config.font = wezterm.font_with_fallback({ + "JetBrainsMono Nerd Font", + "mononoki Nerd Font", + "monospace", + }) + config.font_size = 11 + + config.window_background_opacity = 0.8 + config.window_decorations = "NONE" + config.window_padding = {left = 8, right = 8, top = 8, bottom = 8} + + config.use_fancy_tab_bar = false + config.hide_tab_bar_if_only_one_tab = true + config.tab_bar_at_bottom = false + + config.scrollback_lines = 10000 + config.enable_scroll_bar = false + + config.audible_bell = "Disabled" + config.check_for_updates = false + + return config +end + +return M diff --git a/wezterm/wezterm.dcol b/wezterm/wezterm.dcol index d0fe6bb..dd258de 100644 --- a/wezterm/wezterm.dcol +++ b/wezterm/wezterm.dcol @@ -1,5 +1,5 @@ -${HOME}/.config/wezterm/hyde.toml -# Visit https://github.com/HyDE-Project/terminals-hyde for more info +${confDir}/wezterm/hyde.toml +# Renders a native WezTerm colour scheme named wallbash. # Template by: The HyDE Project [metadata] diff --git a/wezterm/wezterm.lua b/wezterm/wezterm.lua index 3bde2d6..4d89e46 100644 --- a/wezterm/wezterm.lua +++ b/wezterm/wezterm.lua @@ -1,12 +1,14 @@ -local wezterm = require 'wezterm' -local home = os.getenv("HOME") -local config_home = os.getenv("XDG_CONFIG_HOME") or (home .. "/.config") -local wezterm_config_dir = config_home .. "/wezterm" +-- Your WezTerm configuration. +-- +-- HyDE does not manage this file, so anything you put here survives an +-- update. HyDE's defaults and the wallbash colours live in hyde.lua, which is +-- replaced on every update. -wezterm.add_to_config_reload_watch_list(wezterm_config_dir .. "/hyde.toml") +local config = require("hyde").config() -return { - color_scheme_dirs = {wezterm_config_dir}, - color_scheme = "wallbash", - font = wezterm.font("CaskaydiaCove Nerd Font Mono"), -} \ No newline at end of file +-- Your settings go below. They override the defaults, for example: +-- +-- config.font_size = 12 +-- config.window_background_opacity = 1.0 + +return config