From 4dca9dd491b595ceca38b145a3ee4158f7d36c5c Mon Sep 17 00:00:00 2001
From: Hadeed Ahmad <hadeedji@gmail.com>
Date: Wed, 27 Sep 2023 08:15:43 +0500
Subject: [PATCH] Write a script to output kitty codepoints

This should fix all font issues forever
---
 bin/write_symbol_map.py | 40 ++++++++++++++++++++++++++++++++++++++++
 docs/pacman_pkgs.txt    |  9 +--------
 kitty/kitty.conf        |  1 +
 3 files changed, 42 insertions(+), 8 deletions(-)
 create mode 100755 bin/write_symbol_map.py

diff --git a/bin/write_symbol_map.py b/bin/write_symbol_map.py
new file mode 100755
index 0000000..eec57b5
--- /dev/null
+++ b/bin/write_symbol_map.py
@@ -0,0 +1,40 @@
+#! /usr/bin/env python3
+
+import os
+import subprocess
+import sys
+
+font_file = "/usr/share/fonts/TTF/SymbolsNerdFontMono-Regular.ttf"
+if not os.path.exists(font_file):
+    sys.stderr.write(f"Error: The font file does not exist.\n")
+    sys.exit(1)
+
+def create_maps(numbers):
+    start = numbers[0]
+    end = start
+    maps = []
+
+    for number in numbers[1:]:
+        if number == end + 1:
+            end = number
+        else:
+            codepoints = f"U+{start:X}" if start == end else f"U+{start:X}-U+{end:X}"
+            maps.append(f"symbol_map {codepoints} Symbols Nerd Font Mono")
+
+            start = end = number
+
+    codepoints = f"U+{start:X}" if start == end else f"U+{start:X}-U+{end:X}"
+    maps.append(f"symbol_map {codepoints} Symbols Nerd Font Mono")
+
+    return maps
+
+output = subprocess.check_output(f"otfinfo -u {font_file} | cut -c4-7", shell=True, text=True)
+numbers = [int(line.strip(), 16) for line in output.strip().split('\n')]
+maps = create_maps(numbers)
+
+symbol_map_file = os.path.join(os.getenv("HOME"), ".config", "kitty", "symbol_map.conf")
+with open(symbol_map_file, "w") as file:
+    for map in maps:
+        file.write(f"{map}\n")
+
+print("Symbol map written successfully!")
diff --git a/docs/pacman_pkgs.txt b/docs/pacman_pkgs.txt
index 2c60738..f2083d6 100644
--- a/docs/pacman_pkgs.txt
+++ b/docs/pacman_pkgs.txt
@@ -1,18 +1,11 @@
 bat
-bear
-ccls
 exa
 fd
 kitty
 neovim
-python-pillow
-python-pygments
-qmk
 ripgrep
 starship
 ttf-jetbrains-mono
-ttf-nerd-fonts-symbols
-unclutter
+ttf-nerd-fonts-symbols-mono
 xclip
-zola
 zsh
diff --git a/kitty/kitty.conf b/kitty/kitty.conf
index 442ebe0..7eec583 100644
--- a/kitty/kitty.conf
+++ b/kitty/kitty.conf
@@ -11,4 +11,5 @@ tab_bar_style hidden
 hide_window_decorations yes
 
 include keys.conf
+include symbol_map.conf
 include themes/gruvbox.conf