Skip to content

Instantly share code, notes, and snippets.

@shellheim
Last active December 24, 2024 05:24
Show Gist options
  • Save shellheim/4d0386f5af17bcca62a57789be8fd73f to your computer and use it in GitHub Desktop.
Save shellheim/4d0386f5af17bcca62a57789be8fd73f to your computer and use it in GitHub Desktop.
Change kitty terminal's background image with a shortcut
#!/usr/bin/bash
kitty_config="$HOME/.config/kitty/"
kitty_conf_file="$HOME/.config/kitty/kitty.conf"
# Change these as per your liking
dark_theme="Catppuccin-Mocha"
light_theme="Catppuccin-Latte"
cd "$kitty_config" || exit 1
dark_mode=true
rg "$dark_theme" &>/dev/null
status="$?"
if [[ $status -ne 0 ]]; then
dark_mode=false
fi
if [[ "$dark_mode" = true ]]; then
sed -i "s#include $dark_theme#include $light_theme# " "$kitty_conf_file"
else
sed -i "s#include $light_theme#include $dark_theme#" "$kitty_conf_file"
fi
# Press 'Ctrl + Shift + F5' to reload kitty.conf for the change to take effect. ydotool requires ydotoold to be running, you can use a user systemd service to always run ydotoold.
ydotool key 29:1 42:1 63:1 29:0 42:0 63:0
@shellheim
Copy link
Author

shellheim commented Mar 7, 2024

The 'include' adds the theme files, given they are on the same level as kitty.conf. You can get this theme here.

I use the fish-shell and have set up a shortcut to execute this script on Ctrl + K

bind \cK 'change_kitty_background'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment