-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adds leuven theme to kitty, adds toggle custom theme switch kitten, m…
…oves all kitty config to separate dir and adjust makefile accordingly.
- Loading branch information
Showing
8 changed files
with
232 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from typing import List | ||
from pathlib import Path | ||
from kitty.boss import Boss | ||
from kittens.tui.handler import result_handler | ||
|
||
def main(args: List[str]) -> str: | ||
pass | ||
|
||
@result_handler(no_ui=True) | ||
def handle_result(args: List[str], result: None, target_window_id: int, boss: Boss) -> None: | ||
args = args[1:] | ||
files = [] | ||
w = boss.window_id_map.get(target_window_id) | ||
for arg in args: | ||
file = Path(arg).expanduser() | ||
if file.exists(): | ||
files.append(file) | ||
if len(files) == 0: | ||
return | ||
try: | ||
imgviewer = next(boss.match_windows(f"title:imgviewer{w.id}")) | ||
except StopIteration: | ||
imgviewer = boss.launch("--window-title", f"imgviewer{w.id}", | ||
"--cwd", "current", "--keep-focus") | ||
imgviewer = next(boss.match_windows(f"title:imgviewer{w.id}")) | ||
imgviewer.write_to_child("export HISTFILE=\r") | ||
imgviewer.write_to_child(f"timg {' '.join(str(f) for f in files)}\r") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
def main(): | ||
pass | ||
|
||
|
||
def handle_result(args, result, target_window_id, boss): | ||
boss.active_tab.neighboring_window(args[1]) | ||
|
||
|
||
handle_result.no_ui = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import re | ||
|
||
from kittens.tui.handler import result_handler | ||
from kitty.fast_data_types import encode_key_for_tty | ||
from kitty.key_encoding import KeyEvent, parse_shortcut | ||
|
||
|
||
def is_window_app(window, app_id): | ||
info = [p['cmdline'] for p in window.child.foreground_processes] | ||
info.append([window.title]) | ||
return any(re.search(app_id, i[0] if len(i) else '', re.I) for i in info) | ||
|
||
|
||
def encode_key_mapping(key_mapping): | ||
mods, key = parse_shortcut(key_mapping) | ||
event = KeyEvent( | ||
mods=mods, | ||
key=key, | ||
shift=bool(mods & 1), | ||
alt=bool(mods & 2), | ||
ctrl=bool(mods & 4), | ||
super=bool(mods & 8), | ||
hyper=bool(mods & 16), | ||
meta=bool(mods & 32), | ||
).as_window_system_event() | ||
|
||
return encode_key_for_tty( | ||
event.key, event.shifted_key, event.alternate_key, event.mods, event.action | ||
) | ||
|
||
|
||
def main(): | ||
pass | ||
|
||
|
||
@result_handler(no_ui=True) | ||
def handle_result(args, result, target_window_id, boss): | ||
window = boss.window_id_map.get(target_window_id) | ||
direction = args[2] | ||
key_mapping = args[3] | ||
app_id = args[4] if len(args) > 4 else "(n?vim|emacs)" | ||
|
||
if window is None: | ||
return | ||
if is_window_app(window, app_id): | ||
encoded = encode_key_mapping(key_mapping) | ||
window.write_to_child(encoded) | ||
else: | ||
boss.active_tab.neighboring_window(direction) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# dracula theme with minor modifications | ||
foreground #bbbbbb | ||
background #282a36 | ||
selection_foreground #ffffff | ||
selection_background #44475a | ||
url_color #8be9fd | ||
|
||
# black | ||
color0 #656b73 | ||
color8 #444759 | ||
|
||
# red | ||
color1 #ff5555 | ||
color9 #ff6e6e | ||
|
||
# green | ||
color2 #50fa7b | ||
color10 #69ff94 | ||
|
||
# yellow | ||
color3 #f1fa8c | ||
color11 #ffffa5 | ||
|
||
# blue | ||
color4 #bd93f9 | ||
color12 #d6acff | ||
|
||
# magenta | ||
color5 #ff79c6 | ||
color13 #ff92df | ||
|
||
# cyan | ||
color6 #8be9fd | ||
color14 #a4ffff | ||
|
||
# white | ||
color7 #f8f8f2 | ||
color15 #ffffff | ||
|
||
# Cursor colors | ||
cursor #f8f8f2 | ||
cursor_text_color background | ||
|
||
# tab bar colors | ||
active_tab_foreground #282a36 | ||
active_tab_background #f8f8f2 | ||
inactive_tab_foreground #282a36 | ||
inactive_tab_background #6272a4 | ||
|
||
# marks | ||
mark1_foreground #282a36 | ||
mark1_background #ff5555 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# leuven theme | ||
foreground #333333 | ||
background #f8fbf8 | ||
selection_foreground #000000 | ||
selection_background #8ed3ff | ||
url_color #006daf | ||
|
||
# black | ||
color0 #000000 | ||
color8 #000000 | ||
|
||
# red | ||
color1 #cd0000 | ||
color9 #ffe6e4 | ||
|
||
# green | ||
color2 #228b22 | ||
color10 #00cd00 | ||
|
||
# yellow | ||
color3 #cdcd00 | ||
color11 #fff68f | ||
|
||
# blue | ||
color4 #0000ff | ||
color12 #0000ee | ||
|
||
# magenta | ||
color5 #cd00cd | ||
color13 #cd00cd | ||
|
||
# cyan | ||
color6 #00bfff | ||
color14 #00cdcd | ||
|
||
# white | ||
color7 #7f7f7f | ||
color15 #ffffff | ||
|
||
# Cursor colors | ||
cursor #0fb300 | ||
cursor_text_color #000000 | ||
|
||
# tab bar colors | ||
# active_tab_foreground #282a36 | ||
# active_tab_background #f8f8f2 | ||
# inactive_tab_foreground #282a36 | ||
# inactive_tab_background #6272a4 | ||
|
||
# marks | ||
#282a36 | ||
# mark1_foreground | ||
#ff5555 | ||
# mark1_background |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import filecmp | ||
from typing import List | ||
from pathlib import Path | ||
from kitty.boss import Boss | ||
from kittens.tui.handler import result_handler | ||
from kitty.constants import config_dir | ||
from kitty.utils import reload_conf_in_all_kitties | ||
|
||
def main(args: List[str]) -> None: | ||
pass | ||
|
||
@result_handler(no_ui=True) | ||
def handle_result(args: List[str], result: None, target_window_id: int, boss: Boss) -> None: | ||
current_theme = Path(config_dir) / "current-theme.conf" | ||
dracula = Path(config_dir) / "themes/dracula.conf" | ||
leuven = Path(config_dir) / "themes/leuven.conf" | ||
if current_theme.is_symlink(): | ||
current_theme.unlink() | ||
if not Path.exists(current_theme): | ||
current_theme.touch() | ||
if dracula.exists() and leuven.exists() and not filecmp.cmp(current_theme, leuven): | ||
current_theme.write_text(leuven.read_text()) | ||
elif dracula.exists(): | ||
current_theme.write_text(dracula.read_text()) | ||
reload_conf_in_all_kitties() | ||
|
||
|
||
|