irongit
hygoland/scripts/Kitty_themes.sh
45 lines1.6 KBBourne Again Shell (bash)
1#!/bin/bash
2# /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ #
3# Kitty Themes Source https://github.com/dexpota/kitty-themes #
4
5# Define directories and variables
6kitty_themes_DiR="$HOME/.config/kitty/kitty-themes" # Kitty Themes Directory
7theme_path="$kitty_themes_DiR/$theme.conf"
8kitty_config="$HOME/.config/kitty/kitty.conf"
9iDIR="$HOME/.config/swaync/images"
10rofi_theme="$HOME/.config/rofi/config-kitty-theme.rasi"
11
12# Check if the Kitty Themes directory exists
13if [ ! -d "$kitty_themes_DiR" ]; then
14 notify-send -i "$iDIR/error.png" "E-R-R-O-R" "Unable to locate Kitty Themes directory. Exiting....."
15 exit 1
16fi
17
18# List the kitty-theme files from the themes directory
19theme=$(ls "$kitty_themes_DiR"/*.conf | xargs -n 1 basename | sed 's/\.conf$//' | rofi -dmenu -config $rofi_theme)
20
21# Check if no theme was selected, and exit if empty
22if [ -z "$theme" ]; then
23 notify-send -u low -i "$iDIR/note.png" "No kitty theme" "selected. Exiting....."
24 exit 1
25fi
26
27# Uncomment the line that includes the kitty themes if it's commented
28if grep -q '#include ./kitty-themes/' "$kitty_config"; then
29 sed -i "s|#include ./kitty-themes/|include ./kitty-themes/$theme.conf|g" "$kitty_config"
30
31 notify-send -u low -i "$iDIR/ja.png" "$theme" "Kitty Theme Loaded"
32
33 for pid_kitty in $(pidof kitty); do
34 kill -SIGUSR1 "$pid_kitty"
35 done
36else
37 # If the line is already uncommented, just add the chosen theme
38 sed -i "s|include ./kitty-themes/.*|include ./kitty-themes/$theme.conf|g" "$kitty_config"
39
40 notify-send -u low -i "$iDIR/ja.png" "$theme" "Kitty Theme Loaded"
41
42 for pid_kitty in $(pidof kitty); do
43 kill -SIGUSR1 "$pid_kitty"
44 done
45fi