Last active
January 13, 2023 13:02
-
-
Save mizlan/83fa45dfd6a798b1d936569c5815a60f to your computer and use it in GitHub Desktop.
Configuration for seamless transition between light and dark modes. See video https://youtu.be/TSSkUD7vY00.
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
# CHANGE THE COLORS TO THE RELEVANT ONES FOR YOUR COLORSCHEME | |
fzf() { | |
if grep -q dark "$HOME/theme"; then | |
FZF_DEFAULT_OPTS="$FZF_DEFAULT_OPTS --color=fg:#e0def4,bg:#2a273f,hl:#6e6a86 --color=fg+:#908caa,bg+:#232136,hl+:#908caa --color=info:#9ccfd8,prompt:#f6c177,pointer:#c4a7e7 --color=marker:#ea9a97,spinner:#eb6f92,header:#ea9a97" /opt/homebrew/bin/fzf | |
else | |
FZF_DEFAULT_OPTS="$FZF_DEFAULT_OPTS --color=fg:#575279,bg:#fffaf3,hl:#9893a5 --color=fg+:#797593,bg+:#faf4ed,hl+:#797593 --color=info:#56949f,prompt:#56949f,pointer:#907aa9 --color=marker:#d7827e,spinner:#b4637a,header:#d7827e" /opt/homebrew/bin/fzf | |
fi | |
} |
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
local uv = vim.loop | |
-- trim function, taken from http://lua-users.org/wiki/StringTrim | |
function trim6(s) | |
return s:match '^()%s*$' and '' or s:match '^%s*(.*%S)' | |
end | |
-- taken from https://github.com/nvim-lua/plenary.nvim | |
local read_file = function(path, callback) | |
uv.fs_open(path, "r", 438, function(err, fd) | |
assert(not err, err) | |
uv.fs_fstat(fd, function(err, stat) | |
assert(not err, err) | |
uv.fs_read(fd, stat.size, 0, function(err, data) | |
assert(not err, err) | |
uv.fs_close(fd, function(err) | |
assert(not err, err) | |
callback(data) | |
end) | |
end) | |
end) | |
end) | |
end | |
-- CHANGE THIS TO THE FILEPATH YOU'RE USING | |
local themepath = "/Users/ml/theme" | |
function adjust_theme() | |
read_file(themepath, vim.schedule_wrap(function(data) | |
if trim6(data) == 'light' then | |
vim.opt.background = 'light' | |
else | |
vim.opt.background = 'dark' | |
end | |
end)) | |
end | |
adjust_theme() | |
local fse = vim.loop.new_fs_event() | |
vim.loop.fs_event_start(fse, themepath, {}, function(err, fname, status) | |
if (err) then | |
print("Error " .. err) | |
else | |
adjust_theme() | |
end | |
end) |
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
#!/bin/sh | |
if [ $# -eq 0 ]; then | |
if grep -q dark "$HOME/theme"; then | |
theme=light | |
else | |
theme=dark | |
fi | |
else | |
theme="$1" | |
fi | |
# CHANGE THE THEMES TO THE ONES RELEVANT TO YOU | |
if [ "$theme" = "light" ]; then | |
kitty @ kitten themes "Rosé Pine Dawn" | |
kitty @ set-colors -a "$HOME/.config/kitty/Rosé Pine Dawn.conf" | |
echo 'light' > "$HOME/theme" | |
else | |
kitty @ kitten themes "Rosé Pine Moon" | |
kitty @ set-colors -a "$HOME/.config/kitty/Rosé Pine Moon.conf" | |
echo 'dark' > "$HOME/theme" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment