From d93d603cae32cc3895ad6657d838a18256dbe821 Mon Sep 17 00:00:00 2001 From: Ambrose Chua Date: Thu, 15 Feb 2024 16:41:04 +0800 Subject: [PATCH] Improve foot configuration --- .config/foot/foot.dark.ini | 40 +++++ .config/foot/foot.generate.py | 138 ++++++++++++++++++ .config/foot/foot.greyscale-dark.ini | 40 +++++ .../{foot.ini => foot.greyscale-light.ini} | 0 .config/foot/foot.ini.tmpl | 40 +++++ .config/foot/foot.light.ini | 40 +++++ .config/sway/config | 3 + .config/sway/framework | 2 +- .gitignore | 1 + .zshrc | 22 +-- 10 files changed, 316 insertions(+), 10 deletions(-) create mode 100644 .config/foot/foot.dark.ini create mode 100755 .config/foot/foot.generate.py create mode 100644 .config/foot/foot.greyscale-dark.ini rename .config/foot/{foot.ini => foot.greyscale-light.ini} (100%) create mode 100644 .config/foot/foot.ini.tmpl create mode 100644 .config/foot/foot.light.ini diff --git a/.config/foot/foot.dark.ini b/.config/foot/foot.dark.ini new file mode 100644 index 0000000..220ebd3 --- /dev/null +++ b/.config/foot/foot.dark.ini @@ -0,0 +1,40 @@ +font=Fira Code:size=11 +font-bold=Fira Code:weight=bold:size=11 +font-italic=IBM Plex Mono:slant=italic:size=11 +font-bold-italic=IBM Plex Mono:weight=bold:slant=italic:size=11 +line-height=18 +vertical-letter-offset=2 +dpi-aware=no +pad=20x20 +resize-delay-ms=500 + +[tweak] +#render-timer=osd + +[colors] +alpha=0.875 +#cursor_text_color=073642 +#cursor=839496 +foreground=839496 +background=002b36 +#selection_foreground=93a1a1 +#selection_background=073642 +regular0=073642 +regular1=dc322f +regular2=859900 +regular3=b58900 +regular4=268bd2 +regular5=d33682 +regular6=2aa198 +regular7=eee8d5 +bright0=002b36 +bright1=cb4b16 +bright2=586e75 +bright3=657b83 +bright4=839496 +bright5=6c71c4 +bright6=93a1a1 +bright7=fdf6e3 + +[csd] +border-width=8 diff --git a/.config/foot/foot.generate.py b/.config/foot/foot.generate.py new file mode 100755 index 0000000..3b59fac --- /dev/null +++ b/.config/foot/foot.generate.py @@ -0,0 +1,138 @@ +#!/usr/bin/env python + +import sys +import re + + +COLORSCHEMES = { + "dark": { + "theme": "solarized", + "palette": "solarized", + "cursor_text_color": "{base02}", + "cursor": "{base0}", + "foreground": "{base0}", + "background": "{base03}", + "selection_foreground": "{base1}", + "selection_background": "{base02}", + }, + "light": { + "theme": "solarized", + "palette": "solarized", + "cursor_text_color": "{base2}", + "cursor": "{base00}", + "foreground": "{base00}", + "background": "{base3}", + "selection_foreground": "{base01}", + "selection_background": "{base2}", + }, + "greyscale-dark": { + "theme": "solarized", + "palette": "solarized-greyscale", + "cursor_text_color": "{base02}", + "cursor": "{base0}", + "foreground": "{base0}", + "background": "{base03}", + "selection_foreground": "{base1}", + "selection_background": "{base02}", + }, + "greyscale-light": { + "theme": "solarized", + "palette": "solarized-greyscale", + "cursor_text_color": "{base2}", + "cursor": "{base00}", + "foreground": "{base00}", + "background": "{base3}", + "selection_foreground": "{base01}", + "selection_background": "{base2}", + }, +} + +THEMES = { + "solarized": { + "color0": "{base02}", + "color1": "{red}", + "color2": "{green}", + "color3": "{yellow}", + "color4": "{blue}", + "color5": "{magenta}", + "color6": "{cyan}", + "color7": "{base2}", + "color8": "{base03}", + "color9": "{orange}", + "color10": "{base01}", + "color11": "{base00}", + "color12": "{base0}", + "color13": "{violet}", + "color14": "{base1}", + "color15": "{base3}", + }, +} + +TABLE_HEADER = """ +" SOLARIZED HEX 16/8 TERMCOL XTERM/HEX L*A*B sRGB HSB +" --------- ------- ---- ------- ----------- ---------- ----------- ----------- +""".strip().split( + "\n" +) + + +def read_table(f): + match_window = [] + # Read until we find the table header + for line in f: + line = line.strip() + match_window.append(line) + if len(match_window) <= len(TABLE_HEADER): + continue + match_window.pop(0) + if match_window == TABLE_HEADER: + break + # Read table + for line in f: + parts = [p for p in re.split("[ \"']+", line) if len(p) > 0] + if len(parts) < 3: + break + yield (parts[0], parts[1]) + + +def read_palette(filename): + palette = {} + with open(filename, "r") as f: + for name, value in read_table(f): + palette[name] = value + return palette + + +PALETTES = { + "solarized": read_palette("../nvim/colors/solarized.vim"), + "solarized-greyscale": { + **read_palette("../nvim/colors/solarized.vim"), + **{ + "base03": "#202020", + "base02": "#2d2d2d", + "base01": "#606060", + "base00": "#6d6d6d", + "base0": "#969696", + "base1": "#a0a0a0", + "base2": "#eaeaea", + "base3": "#f9f9f9", + }, + }, +} + + +for name, scheme in COLORSCHEMES.items(): + theme = THEMES[scheme["theme"]] + palette = PALETTES[scheme["palette"]] + + values = {} + for key, value in scheme.items(): + values[key] = value.format(**palette).replace("#", "") + for key, value in theme.items(): + values[key] = value.format(**palette).replace("#", "") + + tmpl: str + with open("foot.ini.tmpl", "r") as f: + tmpl = f.read() + with open(f"foot.{name}.ini", "w") as f: + f.write(tmpl.format(**values)) diff --git a/.config/foot/foot.greyscale-dark.ini b/.config/foot/foot.greyscale-dark.ini new file mode 100644 index 0000000..13ca3aa --- /dev/null +++ b/.config/foot/foot.greyscale-dark.ini @@ -0,0 +1,40 @@ +font=Fira Code:size=11 +font-bold=Fira Code:weight=bold:size=11 +font-italic=IBM Plex Mono:slant=italic:size=11 +font-bold-italic=IBM Plex Mono:weight=bold:slant=italic:size=11 +line-height=18 +vertical-letter-offset=2 +dpi-aware=no +pad=20x20 +resize-delay-ms=500 + +[tweak] +#render-timer=osd + +[colors] +alpha=0.875 +#cursor_text_color=2d2d2d +#cursor=969696 +foreground=969696 +background=202020 +#selection_foreground=a0a0a0 +#selection_background=2d2d2d +regular0=2d2d2d +regular1=dc322f +regular2=859900 +regular3=b58900 +regular4=268bd2 +regular5=d33682 +regular6=2aa198 +regular7=eaeaea +bright0=202020 +bright1=cb4b16 +bright2=606060 +bright3=6d6d6d +bright4=969696 +bright5=6c71c4 +bright6=a0a0a0 +bright7=f9f9f9 + +[csd] +border-width=8 diff --git a/.config/foot/foot.ini b/.config/foot/foot.greyscale-light.ini similarity index 100% rename from .config/foot/foot.ini rename to .config/foot/foot.greyscale-light.ini diff --git a/.config/foot/foot.ini.tmpl b/.config/foot/foot.ini.tmpl new file mode 100644 index 0000000..204cd9e --- /dev/null +++ b/.config/foot/foot.ini.tmpl @@ -0,0 +1,40 @@ +font=Fira Code:size=11 +font-bold=Fira Code:weight=bold:size=11 +font-italic=IBM Plex Mono:slant=italic:size=11 +font-bold-italic=IBM Plex Mono:weight=bold:slant=italic:size=11 +line-height=18 +vertical-letter-offset=2 +dpi-aware=no +pad=20x20 +resize-delay-ms=500 + +[tweak] +#render-timer=osd + +[colors] +alpha=0.875 +#cursor_text_color={cursor_text_color} +#cursor={cursor} +foreground={foreground} +background={background} +#selection_foreground={selection_foreground} +#selection_background={selection_background} +regular0={color0} +regular1={color1} +regular2={color2} +regular3={color3} +regular4={color4} +regular5={color5} +regular6={color6} +regular7={color7} +bright0={color8} +bright1={color9} +bright2={color10} +bright3={color11} +bright4={color12} +bright5={color13} +bright6={color14} +bright7={color15} + +[csd] +border-width=8 diff --git a/.config/foot/foot.light.ini b/.config/foot/foot.light.ini new file mode 100644 index 0000000..8050ab0 --- /dev/null +++ b/.config/foot/foot.light.ini @@ -0,0 +1,40 @@ +font=Fira Code:size=11 +font-bold=Fira Code:weight=bold:size=11 +font-italic=IBM Plex Mono:slant=italic:size=11 +font-bold-italic=IBM Plex Mono:weight=bold:slant=italic:size=11 +line-height=18 +vertical-letter-offset=2 +dpi-aware=no +pad=20x20 +resize-delay-ms=500 + +[tweak] +#render-timer=osd + +[colors] +alpha=0.875 +#cursor_text_color=eee8d5 +#cursor=657b83 +foreground=657b83 +background=fdf6e3 +#selection_foreground=586e75 +#selection_background=eee8d5 +regular0=073642 +regular1=dc322f +regular2=859900 +regular3=b58900 +regular4=268bd2 +regular5=d33682 +regular6=2aa198 +regular7=eee8d5 +bright0=002b36 +bright1=cb4b16 +bright2=586e75 +bright3=657b83 +bright4=839496 +bright5=6c71c4 +bright6=93a1a1 +bright7=fdf6e3 + +[csd] +border-width=8 diff --git a/.config/sway/config b/.config/sway/config index 22e1b32..5df85b0 100644 --- a/.config/sway/config +++ b/.config/sway/config @@ -88,6 +88,9 @@ bindsym $mod+F10 input * xkb_switch_layout 1, input * xkb_options "lv3:menu_swit input type:touchpad { natural_scroll enabled + scroll_method two_finger + click_method clickfinger + pointer_accel 0.15 } input type:pointer { natural_scroll enabled diff --git a/.config/sway/framework b/.config/sway/framework index 4490d69..bc82c6a 100644 --- a/.config/sway/framework +++ b/.config/sway/framework @@ -2,7 +2,7 @@ # # Output configuration: # -set $output_laptop "Unknown 0x095F 0x00000000" +set $output_laptop "BOE 0x095F Unknown" output $output_laptop position 0 0 transform 0 scale 1.25 bindsym $mod+XF86MonBrightnessDown output $output_laptop scale 1.25 bindsym $mod+XF86MonBrightnessUp output $output_laptop scale 1.5 diff --git a/.gitignore b/.gitignore index 7a5a474..5368026 100644 --- a/.gitignore +++ b/.gitignore @@ -33,6 +33,7 @@ !.config/containers !.config/fontconfig !.config/foot +.config/foot/foot.ini !.config/git !.config/kitty .config/kitty/colorscheme.conf diff --git a/.zshrc b/.zshrc index 7c82c36..bc43674 100644 --- a/.zshrc +++ b/.zshrc @@ -567,19 +567,19 @@ slowest_functions+=( setup_nope ) # helper scripts function theme { - local iterm_profile kitty_theme kitty_variation gnome_theme macos_theme + local iterm_profile term_theme term_variation gnome_theme macos_theme case "$2" in g) - kitty_variation=greyscale- + term_variation=greyscale- ;; *) - kitty_variation= + term_variation= ;; esac case "$1" in light) iterm_profile=Light - kitty_theme=${kitty_variation}light + term_theme=${term_variation}light export LIGHT=true echo "export LIGHT=true" > ~/.zshrc-theme gnome_theme=Adwaita @@ -588,7 +588,7 @@ function theme { ;; dark) iterm_profile=Default - kitty_theme=${kitty_variation}dark + term_theme=${term_variation}dark export LIGHT=false echo "export LIGHT=false" > ~/.zshrc-theme gnome_theme=Adwaita-dark @@ -600,11 +600,15 @@ function theme { echo -e "\033]50;SetProfile=$ITERM_PROFILE\a" fi if [[ "$TERM" == "xterm-kitty" ]]; then - kitty @ set-colors -c -a ~/.config/kitty/colorscheme.$kitty_theme.conf + kitty @ set-colors -c -a ~/.config/kitty/colorscheme.$term_theme.conf kitty @ env LIGHT=$LIGHT - if [[ -z "$SSH_CLIENT" ]]; then - ln -sf colorscheme.$kitty_theme.conf ~/.config/kitty/colorscheme.conf - fi + fi + if [[ "$TERM" == "foot-extra" ]]; then + + fi + if [[ -z "$SSH_CLIENT" ]]; then + ln -sf foot.$term_theme.ini ~/.config/foot/foot.ini + ln -sf colorscheme.$term_theme.conf ~/.config/kitty/colorscheme.conf fi setup_prompt if [[ -z "$SSH_CLIENT" ]]; then