diff --git a/bin/omarchy-display-text-size b/bin/omarchy-display-text-size index 657854387f5f..6646492c64ba 100755 --- a/bin/omarchy-display-text-size +++ b/bin/omarchy-display-text-size @@ -12,6 +12,7 @@ # • the terminal font point size (12px -> 9pt, so terminal_pt = px * 9/12) # The shell override layers on top of the active theme (so the size survives # theme switches) and the shell watches the file, so shell text re-flows live. +# The terminal side goes through omarchy-font-size, which also sets it alone. # Accepts an integer from 9 to 20 (px). MIN=9 @@ -133,70 +134,6 @@ term_pt_for() { 'BEGIN { printf "%d", int(s * p / b + 0.5) }' } -# Set the font point size in terminal configs, creating Kitty overrides when -# it inherits its size from the system config. Family is left -# untouched — that is omarchy-font-set's job. Live-reload signals mirror -# omarchy-font-set; foot has no reload signal, so running instances are nudged. -set_terminal_size() { - local pt="$1" - - if [[ -f ~/.config/alacritty/alacritty.toml ]]; then - sed --follow-symlinks -i -E "s/^size[[:space:]]*=.*/size = $pt/" ~/.config/alacritty/alacritty.toml - fi - - if [[ -f ~/.config/kitty/kitty.conf ]] || omarchy-cmd-present kitty; then - mkdir -p ~/.config/kitty - if grep -qE '^[[:space:]]*font_size[[:space:]]+' ~/.config/kitty/kitty.conf 2>/dev/null; then - sed --follow-symlinks -i -E "s/^[[:space:]]*font_size[[:space:]]+.*/font_size $pt.0/" ~/.config/kitty/kitty.conf - else - printf '\nfont_size %s.0\n' "$pt" >>~/.config/kitty/kitty.conf - fi - pkill -USR1 kitty 2>/dev/null || true - fi - - if [[ -f ~/.config/ghostty/config ]]; then - sed --follow-symlinks -i -E "s/^font-size = .*/font-size = $pt/" ~/.config/ghostty/config - pkill -SIGUSR2 ghostty 2>/dev/null || true - fi - - if [[ -f ~/.config/foot/foot.ini ]]; then - sed --follow-symlinks -i -E "s/(:size=)[0-9.]+/\1$pt/" ~/.config/foot/foot.ini - # Foot has no config-reload signal, so a running instance keeps its startup - # size until relaunched (new windows pick up the change). Nudge the user — - # but reuse the same notification id (freedesktop replaces_id) so dragging - # through several sizes refreshes one toast instead of stacking a pile. - if pgrep -x foot >/dev/null 2>&1; then - local id_file="${XDG_RUNTIME_DIR:-/tmp}/omarchy-display-text-size.foot-notif-id" - local prev_id="" - [[ -f $id_file ]] && read -r prev_id <"$id_file" 2>/dev/null - local replace=() - [[ $prev_id =~ ^[0-9]+$ ]] && replace=(-r "$prev_id") - local new_id - new_id="$(omarchy-notification-send \ - "$(omarchy-i18n display.restartFootForFontSize)" \ - "${replace[@]}" -p 2>/dev/null)" || true - [[ $new_id =~ ^[0-9]+$ ]] && printf '%s\n' "$new_id" >"$id_file" - fi - fi -} - -# Report the current terminal point size from whichever config we find first. -term_current_pt() { - if [[ -f ~/.config/ghostty/config ]]; then - grep -oP '^font-size = \K[0-9.]+' ~/.config/ghostty/config | head -1 - elif [[ -f ~/.config/alacritty/alacritty.toml ]]; then - grep -oP '^size[[:space:]]*=[[:space:]]*\K[0-9.]+' ~/.config/alacritty/alacritty.toml | head -1 - elif [[ -f ~/.config/kitty/kitty.conf ]]; then - local pt - pt=$(grep -oP '^[[:space:]]*font_size[[:space:]]+\K[0-9.]+' ~/.config/kitty/kitty.conf | tail -1) - echo "${pt:-$TERM_DEFAULT_PT}" - elif [[ -f ~/.config/foot/foot.ini ]]; then - grep -oP ':size=\K[0-9.]+' ~/.config/foot/foot.ini | head -1 - elif omarchy-cmd-present kitty; then - echo "$TERM_DEFAULT_PT" - fi -} - case "${1:-}" in -h | --help) usage @@ -206,7 +143,7 @@ case "${1:-}" in cur="$(current_base_size)" size="${cur:-12 (default)}" factor="$(gsettings get "$GKEY_SCHEMA" "$GKEY_NAME" 2>/dev/null)" - term="$(term_current_pt)" + term="$(omarchy-font-size)" printf 'text size: %s px\ngtk text-scaling-factor: %s\nterminal font: %s pt\n' \ "$size" "$factor" "${term:-n/a}" exit 0 @@ -214,7 +151,7 @@ case "${1:-}" in reset | default) reset_base_size gsettings reset "$GKEY_SCHEMA" "$GKEY_NAME" 2>/dev/null || true - set_terminal_size "$TERM_DEFAULT_PT" + omarchy-font-size reset exit 0 ;; esac @@ -237,4 +174,4 @@ factor="$(awk -v s="$size" -v b="$SHELL_DEFAULT_PX" -v f="$(gtk_font_pt)" \ set_factor "$factor" # Terminal side: point size anchored so 12px == 9pt. -set_terminal_size "$(term_pt_for "$size")" +omarchy-font-size "$(term_pt_for "$size")" diff --git a/bin/omarchy-font-size b/bin/omarchy-font-size new file mode 100755 index 000000000000..c50b44be96a3 --- /dev/null +++ b/bin/omarchy-font-size @@ -0,0 +1,112 @@ +#!/bin/bash + +# omarchy:summary=Show or set the terminal font size +# omarchy:args=[size|reset] +# omarchy:examples=omarchy font size | omarchy font size 12 | omarchy font size reset + +# Sets the font point size in every terminal config Omarchy manages: Alacritty, +# Ghostty, Kitty and Foot. The font family is omarchy-font-set's job, and +# omarchy-display-text-size calls this to keep terminals in proportion with the +# shell and GTK, so a size set here lasts until the next desktop text size change. +# Accepts an integer from 6 to 24 (pt). + +MIN=6 +MAX=24 +DEFAULT_PT=9 + +usage() { + echo "Usage: omarchy-font-size [size|reset]" + echo " (no args) print the current terminal font size in pt" + echo " set the terminal font size in pt ($MIN–$MAX)" + echo " reset return terminals to the default ${DEFAULT_PT}pt" +} + +# Set the font point size in terminal configs, creating Kitty overrides when +# it inherits its size from the system config. Live-reload signals mirror +# omarchy-font-set; foot has no reload signal, so running instances are nudged. +set_terminal_size() { + local pt="$1" + + if [[ -f ~/.config/alacritty/alacritty.toml ]]; then + sed --follow-symlinks -i -E "s/^[[:space:]]*size[[:space:]]*=.*/size = $pt/" ~/.config/alacritty/alacritty.toml + fi + + if [[ -f ~/.config/kitty/kitty.conf ]] || omarchy-cmd-present kitty; then + mkdir -p ~/.config/kitty + if grep -qE '^[[:space:]]*font_size[[:space:]]+' ~/.config/kitty/kitty.conf 2>/dev/null; then + sed --follow-symlinks -i -E "s/^[[:space:]]*font_size[[:space:]]+.*/font_size $pt.0/" ~/.config/kitty/kitty.conf + else + printf '\nfont_size %s.0\n' "$pt" >>~/.config/kitty/kitty.conf + fi + pkill -USR1 kitty 2>/dev/null || true + fi + + if [[ -f ~/.config/ghostty/config ]]; then + sed --follow-symlinks -i -E "s/^[[:space:]]*font-size[[:space:]]*=.*/font-size = $pt/" ~/.config/ghostty/config + pkill -SIGUSR2 ghostty 2>/dev/null || true + fi + + if [[ -f ~/.config/foot/foot.ini ]]; then + # Foot keeps fallback fonts after the primary on the same line; the first + # comma ends the primary entry. Add a size when the primary has none, then + # change only that entry, leaving fallback sizes untouched. + sed --follow-symlinks -i -E \ + -e "/^font=[^,]*:size=/! s/^font=([^,]*)/font=\1:size=$pt/" \ + -e "s/^font=([^,]*):size=[0-9.]+/font=\1:size=$pt/" \ + ~/.config/foot/foot.ini + # Foot has no config-reload signal, so a running instance keeps its startup + # size until relaunched (new windows pick up the change). Nudge the user — + # but reuse the same notification id (freedesktop replaces_id) so dragging + # through several sizes refreshes one toast instead of stacking a pile. + if pgrep -x foot >/dev/null 2>&1; then + local id_file="${XDG_RUNTIME_DIR:-/tmp}/omarchy-font-size.foot-notif-id" + local prev_id="" + [[ -f $id_file ]] && read -r prev_id <"$id_file" 2>/dev/null + local replace=() + [[ $prev_id =~ ^[0-9]+$ ]] && replace=(-r "$prev_id") + local new_id + new_id="$(omarchy-notification-send \ + "$(omarchy-i18n display.restartFootForFontSize)" \ + "${replace[@]}" -p 2>/dev/null)" || true + [[ $new_id =~ ^[0-9]+$ ]] && printf '%s\n' "$new_id" >"$id_file" + fi + fi +} + +# Print the current terminal point size from whichever config we find first. +current_size() { + if [[ -f ~/.config/ghostty/config ]]; then + grep -oP '^[[:space:]]*font-size[[:space:]]*=[[:space:]]*\K[0-9.]+' ~/.config/ghostty/config | head -1 + elif [[ -f ~/.config/alacritty/alacritty.toml ]]; then + grep -oP '^[[:space:]]*size[[:space:]]*=[[:space:]]*\K[0-9.]+' ~/.config/alacritty/alacritty.toml | head -1 + elif [[ -f ~/.config/kitty/kitty.conf ]]; then + local pt + pt=$(grep -oP '^[[:space:]]*font_size[[:space:]]+\K[0-9.]+' ~/.config/kitty/kitty.conf | tail -1) + echo "${pt:-$DEFAULT_PT}" + elif [[ -f ~/.config/foot/foot.ini ]]; then + grep -oP ':size=\K[0-9.]+' ~/.config/foot/foot.ini | head -1 + elif omarchy-cmd-present kitty; then + echo "$DEFAULT_PT" + fi +} + +case "${1:-}" in + -h | --help) + usage + ;; + "") + current_size + ;; + reset | default) + set_terminal_size "$DEFAULT_PT" + ;; + *) + if [[ $1 =~ ^[0-9]+$ ]] && ((10#$1 >= MIN && 10#$1 <= MAX)); then + set_terminal_size "$((10#$1))" + else + echo "Size must be an integer between $MIN and $MAX (pt)." >&2 + usage >&2 + exit 1 + fi + ;; +esac diff --git a/default/agents/skills/omarchy/SKILL.md b/default/agents/skills/omarchy/SKILL.md index dac9d1ad068d..a14d7abfb4eb 100644 --- a/default/agents/skills/omarchy/SKILL.md +++ b/default/agents/skills/omarchy/SKILL.md @@ -310,6 +310,7 @@ This skill intentionally does not cover Omarchy source development. Do not use t - "Add a Danish keyboard layout" -> `kb_layout = "us,dk"` in `~/.config/hypr/input.lua` (or `omarchy setup keyboard`) - "Set an environment variable for all apps" -> A file in `~/.config/uwsm/env.d/`, applied at next login - "Make text bigger everywhere" -> `omarchy display text size <9-20>` +- "Make only the terminal font bigger" -> `omarchy font size <6-24>` - "Set a reminder to pickup jack in 15 minutes" -> `omarchy reminder 15 "Pickup Jack"` - "Show my reminders" -> `omarchy reminder show` - "Clear all reminders" -> `omarchy reminder clear` diff --git a/default/agents/skills/omarchy/theming.md b/default/agents/skills/omarchy/theming.md index 248739650af4..f0d312c1a51d 100644 --- a/default/agents/skills/omarchy/theming.md +++ b/default/agents/skills/omarchy/theming.md @@ -57,10 +57,11 @@ omarchy theme set catppuccin-custom omarchy font list # Available fonts omarchy font current # Current font omarchy font set # Change the monospace font used everywhere +omarchy font size [size|reset] # Terminal font size in pt (6–24, default 9) omarchy font cjk [jp|kr|sc|tc|hk|default] # Glyph forms for Chinese, Japanese, and Korean text ``` -`omarchy font list` shows installed Nerd Fonts; a new one comes from the menu's Install > Style > Font, or `omarchy install font `. +`omarchy font list` shows installed Nerd Fonts; a new one comes from the menu's Install > Style > Font, or `omarchy install font `. `omarchy font size` changes only the terminal; `omarchy display text size` scales the whole desktop. ## App Icons diff --git a/manual/33-monitors.md b/manual/33-monitors.md index 928e99a1f21f..1cf2b5002eb3 100644 --- a/manual/33-monitors.md +++ b/manual/33-monitors.md @@ -27,7 +27,7 @@ Monitor scaling changes the size of everything. If all you want is bigger or sma omarchy display text size 14 ``` -That takes a pixel size between 9 and 20, and moves the Omarchy shell, GTK applications, and your terminal together, so the whole desktop stays in proportion. Run it without an argument to see where you're at, and `omarchy display text size reset` to go back to the default. Foot is the one straggler: it has no way to reload its config, so running terminals keep their old size until you open a new one. +That takes a pixel size between 9 and 20, and moves the Omarchy shell, GTK applications, and your terminal together, so the whole desktop stays in proportion. Run it without an argument to see where you're at, and `omarchy display text size reset` to go back to the default. Foot is the one straggler: it has no way to reload its config, so running terminals keep their old size until you open a new one. To change only the terminal, use `omarchy font size` (see [Fonts](38-fonts.md)). ### Extending and mirroring laptop displays diff --git a/manual/38-fonts.md b/manual/38-fonts.md index 63b493dfe408..63a3a015a980 100644 --- a/manual/38-fonts.md +++ b/manual/38-fonts.md @@ -8,6 +8,12 @@ You can change this through the _Appearance > Font_ menu in the Omarchy menu (`S You can install other popular programming fonts via _Install > Style > Font_ in the Omarchy menu: Cascadia Mono, Meslo LG Mono, Fira Code, Victor Code, Bitstream Vera Mono, and Iosevka are all one click away, in their Nerd Font versions so the glyphs in the bar and terminal keep working. Installing one also switches the whole system to it, and you can switch back any time under _Appearance > Font_. +## Terminal font size + +The terminal font is 9pt by default. To make only the terminal bigger or smaller, run `omarchy font size 12` (any whole size from 6 to 24), `omarchy font size` to see the current one, and `omarchy font size reset` to go back to 9pt. It changes Alacritty, Ghostty, Kitty, and Foot together and leaves the bar, menus, and apps alone. Running terminals pick it up right away, except Foot, which needs a new window. + +To scale text across the whole desktop instead, use `omarchy display text size` (see [Monitors](33-monitors.md)). That sets the terminal too, in proportion with everything else, so run `omarchy font size` after it if you want the terminal to differ. + ## Chinese, Japanese, and Korean Chinese, Japanese, and Korean share many characters but draw some of them differently, so the same character looks right to one reader and foreign to another. Picking one of these languages under _Setup > Region > Language_, or its input method, sets the matching forms. To choose them yourself, run `omarchy font cjk jp`, `kr`, `sc`, `tc` (Taiwan), or `hk` (Hong Kong) in a terminal; `omarchy font cjk default` goes back to the system's choice, which is Japanese forms. Text a web page or document marks with its own language, and the whole desktop while it is in one of these languages, keeps that language's forms. diff --git a/test/shell.d/desktop-helpers-test.sh b/test/shell.d/desktop-helpers-test.sh index 47de74252cc1..b7fde89e348d 100755 --- a/test/shell.d/desktop-helpers-test.sh +++ b/test/shell.d/desktop-helpers-test.sh @@ -68,6 +68,79 @@ HOME="$tmp/home" XDG_RUNTIME_DIR="$tmp" PATH="$tmp/bin:$ROOT/bin:$PATH" "$ROOT/b fail "omarchy-display-text-size reset clears base-size in symlinked shell.toml" "$(<"$tmp/dots/shell.toml")" pass "omarchy-display-text-size preserves symlinked shell and terminal configs" +# omarchy-font-size sets only terminal sizes, leaves font families alone, and +# changes the primary Foot entry without touching fallback sizes. +printf 'family = "Test"\nsize = 9\n' >"$tmp/dots/alacritty.toml" +printf 'font-family = "Test"\nfont-size = 9\n' >"$tmp/dots/ghostty.conf" +printf 'font=Test:size=9\n' >"$tmp/dots/foot.ini" +printf 'font_family Test\nfont_size 9.0\n' >"$tmp/dots/kitty.conf" +rm -f "$tmp/home/.config/kitty/kitty.conf" +ln -s "$tmp/dots/kitty.conf" "$tmp/home/.config/kitty/kitty.conf" + +font_sizes() { + printf '%s|%s|%s|%s' \ + "$(sed -n 's/^size = //p' "$tmp/dots/alacritty.toml")" \ + "$(sed -n 's/^font-size = //p' "$tmp/dots/ghostty.conf")" \ + "$(sed -n 's/^font_size //p' "$tmp/dots/kitty.conf" | tail -1)" \ + "$(grep -oP '^font=[^,]*:size=\K[0-9.]+' "$tmp/dots/foot.ini")" +} + +run_font_size() { + HOME="$tmp/home" OMARCHY_PATH="$ROOT" XDG_RUNTIME_DIR="$tmp" \ + PATH="$tmp/bin:$ROOT/bin:$PATH" omarchy font size "$@" +} + +[[ $(run_font_size) == "9" ]] || fail "omarchy font size reports the stock terminal size" "$(run_font_size)" +pass "omarchy font size reports the stock terminal size" + +run_font_size 12 +[[ $(font_sizes) == "12|12|12.0|12" ]] || fail "omarchy font size sets every terminal" "$(font_sizes)" +[[ $(run_font_size) == "12" ]] || fail "omarchy font size reads back the new size" +grep -Fxq 'font-family = "Test"' "$tmp/dots/ghostty.conf" || fail "omarchy font size leaves the Ghostty family alone" +grep -Fxq 'font=Test:size=12' "$tmp/dots/foot.ini" || fail "omarchy font size leaves the Foot family alone" +pass "omarchy font size sets only terminal sizes" + +run_font_size 08 +[[ $(font_sizes) == "8|8|8.0|8" ]] || fail "reads a leading zero as decimal" "$(font_sizes)" +pass "omarchy font size reads a leading zero as decimal" + +for bad in 5 25 abc 1.5; do + if run_font_size "$bad" 2>/dev/null; then + fail "omarchy font size rejects $bad" + fi +done +[[ $(font_sizes) == "8|8|8.0|8" ]] || fail "a rejected size changes nothing" "$(font_sizes)" +pass "omarchy font size rejects sizes outside 6–24 and non-integers" + +run_font_size reset +[[ $(font_sizes) == "9|9|9.0|9" ]] || fail "reset returns to 9pt" "$(font_sizes)" +pass "omarchy font size reset returns to 9pt" + +# The first comma ends Foot's primary entry; fallback sizes must survive. +printf 'font=Primary,Fallback:size=10\n' >"$tmp/dots/foot.ini" +run_font_size 12 +grep -Fxq 'font=Primary:size=12,Fallback:size=10' "$tmp/dots/foot.ini" || + fail "adds a primary Foot size without changing the fallback" "$(<"$tmp/dots/foot.ini")" +printf 'font=Primary:size=9,Fallback:size=10\n' >"$tmp/dots/foot.ini" +run_font_size 13 +grep -Fxq 'font=Primary:size=13,Fallback:size=10' "$tmp/dots/foot.ini" || + fail "changes only the primary Foot size" "$(<"$tmp/dots/foot.ini")" +pass "omarchy font size changes only the primary Foot entry" + +printf 'font=Test:size=14\n' >"$tmp/dots/foot.ini" +HOME="$tmp/home" OMARCHY_PATH="$ROOT" XDG_RUNTIME_DIR="$tmp" \ + PATH="$tmp/bin:$ROOT/bin:$PATH" "$ROOT/bin/omarchy-font-set" "$font_name" >/dev/null +grep -Fxq "font=$font_name:size=14" "$tmp/dots/foot.ini" || + fail "omarchy font set keeps Foot's size" "$(<"$tmp/dots/foot.ini")" +pass "omarchy font set keeps the Foot size set by omarchy font size" + +run_font_size 13 +[[ $(font_sizes) == "13|13|13.0|13" ]] || fail "writes the size through symlinked configs" "$(font_sizes)" +for link in alacritty/alacritty.toml ghostty/config kitty/kitty.conf foot/foot.ini; do + [[ -L "$tmp/home/.config/$link" ]] || fail "keeps $link a symlink" +done +pass "omarchy font size writes through symlinked terminal configs" + # Clipboard helpers fail cleanly on missing --history-index value instead of looping. for helper in omarchy-clipboard-open omarchy-clipboard-paste-text; do if timeout 2s "$ROOT/bin/$helper" --history-index >/dev/null 2>&1; then