Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add kitty support #796

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
261 changes: 145 additions & 116 deletions .config/ags/scripts/color_generation/applycolor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ STATE_DIR="$XDG_STATE_HOME/ags"
term_alpha=100 #Set this to < 100 make all your terminals transparent
# sleep 0 # idk i wanted some delay or colors dont get applied properly
if [ ! -d "$CACHE_DIR"/user/generated ]; then
mkdir -p "$CACHE_DIR"/user/generated
mkdir -p "$CACHE_DIR"/user/generated
fi
cd "$CONFIG_DIR" || exit

Expand All @@ -26,157 +26,186 @@ colorvalues=()
# wallpath_png=$(sed 's/\//\\\\\//g' <<< "$wallpath_png")

transparentize() {
local hex="$1"
local alpha="$2"
local red green blue
local hex="$1"
local alpha="$2"
local red green blue

red=$((16#${hex:1:2}))
green=$((16#${hex:3:2}))
blue=$((16#${hex:5:2}))
red=$((16#${hex:1:2}))
green=$((16#${hex:3:2}))
blue=$((16#${hex:5:2}))

printf 'rgba(%d, %d, %d, %.2f)\n' "$red" "$green" "$blue" "$alpha"
printf 'rgba(%d, %d, %d, %.2f)\n' "$red" "$green" "$blue" "$alpha"
}

get_light_dark() {
lightdark=""
if [ ! -f "$STATE_DIR/user/colormode.txt" ]; then
echo "" > "$STATE_DIR/user/colormode.txt"
else
lightdark=$(sed -n '1p' "$STATE_DIR/user/colormode.txt")
fi
echo "$lightdark"
lightdark=""
if [ ! -f "$STATE_DIR/user/colormode.txt" ]; then
echo "" >"$STATE_DIR/user/colormode.txt"
else
lightdark=$(sed -n '1p' "$STATE_DIR/user/colormode.txt")
fi
echo "$lightdark"
}

apply_fuzzel() {
# Check if scripts/templates/fuzzel/fuzzel.ini exists
if [ ! -f "scripts/templates/fuzzel/fuzzel.ini" ]; then
echo "Template file not found for Fuzzel. Skipping that."
return
fi
# Copy template
mkdir -p "$CACHE_DIR"/user/generated/fuzzel
cp "scripts/templates/fuzzel/fuzzel.ini" "$CACHE_DIR"/user/generated/fuzzel/fuzzel.ini
# Apply colors
for i in "${!colorlist[@]}"; do
sed -i "s/{{ ${colorlist[$i]} }}/${colorvalues[$i]#\#}/g" "$CACHE_DIR"/user/generated/fuzzel/fuzzel.ini
done

cp "$CACHE_DIR"/user/generated/fuzzel/fuzzel.ini "$XDG_CONFIG_HOME"/fuzzel/fuzzel.ini
# Check if scripts/templates/fuzzel/fuzzel.ini exists
if [ ! -f "scripts/templates/fuzzel/fuzzel.ini" ]; then
echo "Template file not found for Fuzzel. Skipping that."
return
fi
# Copy template
mkdir -p "$CACHE_DIR"/user/generated/fuzzel
cp "scripts/templates/fuzzel/fuzzel.ini" "$CACHE_DIR"/user/generated/fuzzel/fuzzel.ini
# Apply colors
for i in "${!colorlist[@]}"; do
sed -i "s/{{ ${colorlist[$i]} }}/${colorvalues[$i]#\#}/g" "$CACHE_DIR"/user/generated/fuzzel/fuzzel.ini
done

cp "$CACHE_DIR"/user/generated/fuzzel/fuzzel.ini "$XDG_CONFIG_HOME"/fuzzel/fuzzel.ini
}

apply_kitty() {
if ! which kitty &>/dev/null; then
echo "Kitty is not installed. Skipping that."
return
fi

# Check if scripts/templates/kitty/dots-hyprland.conf exists
if [ ! -f "scripts/templates/kitty/dots-hyprland.conf" ]; then
echo "Template file not found for kitty. Skipping that."
return
fi

# Copy template
mkdir -p "$CACHE_DIR"/user/generated/kitty
cp "scripts/templates/kitty/dots-hyprland.conf" "$CACHE_DIR"/user/generated/kitty/dots-hyprland.conf

# Apply colors
for i in "${!colorlist[@]}"; do
sed -i "s/${colorlist[$i]} #/${colorvalues[$i]#\#}/g" "$CACHE_DIR"/user/generated/kitty/dots-hyprland.conf
done

# Make sure that kitty.conf has 'include current-theme.conf' in it
mkdir -p "$XDG_CONFIG_HOME"/kitty
cp "$CACHE_DIR"/user/generated/kitty/dots-hyprland.conf "$XDG_CONFIG_HOME"/kitty/current-theme.conf

# Reload theme in all open kitty terminals
kill -SIGUSR1 $(pgrep kitty)
}

apply_term() {
# Check if terminal escape sequence template exists
if [ ! -f "scripts/templates/terminal/sequences.txt" ]; then
echo "Template file not found for Terminal. Skipping that."
return
fi
# Copy template
mkdir -p "$CACHE_DIR"/user/generated/terminal
cp "scripts/templates/terminal/sequences.txt" "$CACHE_DIR"/user/generated/terminal/sequences.txt
# Apply colors
for i in "${!colorlist[@]}"; do
sed -i "s/${colorlist[$i]} #/${colorvalues[$i]#\#}/g" "$CACHE_DIR"/user/generated/terminal/sequences.txt
done

sed -i "s/\$alpha/$term_alpha/g" "$CACHE_DIR/user/generated/terminal/sequences.txt"

for file in /dev/pts/*; do
if [[ $file =~ ^/dev/pts/[0-9]+$ ]]; then
cat "$CACHE_DIR"/user/generated/terminal/sequences.txt > "$file"
fi
done
# Check if terminal escape sequence template exists
if [ ! -f "scripts/templates/terminal/sequences.txt" ]; then
echo "Template file not found for Terminal. Skipping that."
return
fi
# Copy template
mkdir -p "$CACHE_DIR"/user/generated/terminal
cp "scripts/templates/terminal/sequences.txt" "$CACHE_DIR"/user/generated/terminal/sequences.txt
# Apply colors
for i in "${!colorlist[@]}"; do
sed -i "s/${colorlist[$i]} #/${colorvalues[$i]#\#}/g" "$CACHE_DIR"/user/generated/terminal/sequences.txt
done

sed -i "s/\$alpha/$term_alpha/g" "$CACHE_DIR/user/generated/terminal/sequences.txt"

for file in /dev/pts/*; do
if [[ $file =~ ^/dev/pts/[0-9]+$ ]]; then
cat "$CACHE_DIR"/user/generated/terminal/sequences.txt >"$file"
fi
done
}

apply_hyprland() {
# Check if scripts/templates/hypr/hyprland/colors.conf exists
if [ ! -f "scripts/templates/hypr/hyprland/colors.conf" ]; then
echo "Template file not found for Hyprland colors. Skipping that."
return
fi
# Copy template
mkdir -p "$CACHE_DIR"/user/generated/hypr/hyprland
cp "scripts/templates/hypr/hyprland/colors.conf" "$CACHE_DIR"/user/generated/hypr/hyprland/colors.conf
# Apply colors
for i in "${!colorlist[@]}"; do
sed -i "s/{{ ${colorlist[$i]} }}/${colorvalues[$i]#\#}/g" "$CACHE_DIR"/user/generated/hypr/hyprland/colors.conf
done

cp "$CACHE_DIR"/user/generated/hypr/hyprland/colors.conf "$XDG_CONFIG_HOME"/hypr/hyprland/colors.conf
# Check if scripts/templates/hypr/hyprland/colors.conf exists
if [ ! -f "scripts/templates/hypr/hyprland/colors.conf" ]; then
echo "Template file not found for Hyprland colors. Skipping that."
return
fi
# Copy template
mkdir -p "$CACHE_DIR"/user/generated/hypr/hyprland
cp "scripts/templates/hypr/hyprland/colors.conf" "$CACHE_DIR"/user/generated/hypr/hyprland/colors.conf
# Apply colors
for i in "${!colorlist[@]}"; do
sed -i "s/{{ ${colorlist[$i]} }}/${colorvalues[$i]#\#}/g" "$CACHE_DIR"/user/generated/hypr/hyprland/colors.conf
done

cp "$CACHE_DIR"/user/generated/hypr/hyprland/colors.conf "$XDG_CONFIG_HOME"/hypr/hyprland/colors.conf
}

apply_hyprlock() {
# Check if scripts/templates/hypr/hyprlock.conf exists
if [ ! -f "scripts/templates/hypr/hyprlock.conf" ]; then
echo "Template file not found for hyprlock. Skipping that."
return
fi
# Copy template
mkdir -p "$CACHE_DIR"/user/generated/hypr/
cp "scripts/templates/hypr/hyprlock.conf" "$CACHE_DIR"/user/generated/hypr/hyprlock.conf
# Apply colors
# sed -i "s/{{ SWWW_WALL }}/${wallpath_png}/g" "$CACHE_DIR"/user/generated/hypr/hyprlock.conf
for i in "${!colorlist[@]}"; do
sed -i "s/{{ ${colorlist[$i]} }}/${colorvalues[$i]#\#}/g" "$CACHE_DIR"/user/generated/hypr/hyprlock.conf
done

cp "$CACHE_DIR"/user/generated/hypr/hyprlock.conf "$XDG_CONFIG_HOME"/hypr/hyprlock.conf
# Check if scripts/templates/hypr/hyprlock.conf exists
if [ ! -f "scripts/templates/hypr/hyprlock.conf" ]; then
echo "Template file not found for hyprlock. Skipping that."
return
fi
# Copy template
mkdir -p "$CACHE_DIR"/user/generated/hypr/
cp "scripts/templates/hypr/hyprlock.conf" "$CACHE_DIR"/user/generated/hypr/hyprlock.conf
# Apply colors
# sed -i "s/{{ SWWW_WALL }}/${wallpath_png}/g" "$CACHE_DIR"/user/generated/hypr/hyprlock.conf
for i in "${!colorlist[@]}"; do
sed -i "s/{{ ${colorlist[$i]} }}/${colorvalues[$i]#\#}/g" "$CACHE_DIR"/user/generated/hypr/hyprlock.conf
done

cp "$CACHE_DIR"/user/generated/hypr/hyprlock.conf "$XDG_CONFIG_HOME"/hypr/hyprlock.conf
}

apply_lightdark() {
lightdark=$(get_light_dark)
if [ "$lightdark" = "light" ]; then
gsettings set org.gnome.desktop.interface color-scheme 'prefer-light'
else
gsettings set org.gnome.desktop.interface color-scheme 'prefer-dark'
fi
lightdark=$(get_light_dark)
if [ "$lightdark" = "light" ]; then
gsettings set org.gnome.desktop.interface color-scheme 'prefer-light'
else
gsettings set org.gnome.desktop.interface color-scheme 'prefer-dark'
fi
}

apply_gtk() { # Using gradience-cli
usegradience=$(sed -n '4p' "$STATE_DIR/user/colormode.txt")
if [[ "$usegradience" = "nogradience" ]]; then
rm "$XDG_CONFIG_HOME/gtk-3.0/gtk.css"
rm "$XDG_CONFIG_HOME/gtk-4.0/gtk.css"
return
fi

# Copy template
mkdir -p "$CACHE_DIR"/user/generated/gradience
cp "scripts/templates/gradience/preset.json" "$CACHE_DIR"/user/generated/gradience/preset.json

# Apply colors
for i in "${!colorlist[@]}"; do
sed -i "s/{{ ${colorlist[$i]} }}/${colorvalues[$i]}/g" "$CACHE_DIR"/user/generated/gradience/preset.json
done

mkdir -p "$XDG_CONFIG_HOME/presets" # create gradience presets folder
gradience-cli apply -p "$CACHE_DIR"/user/generated/gradience/preset.json --gtk both

# And set GTK theme manually as Gradience defaults to light adw-gtk3
# (which is unreadable when broken when you use dark mode)
lightdark=$(get_light_dark)
if [ "$lightdark" = "light" ]; then
gsettings set org.gnome.desktop.interface gtk-theme 'adw-gtk3'
else
gsettings set org.gnome.desktop.interface gtk-theme adw-gtk3-dark
fi
usegradience=$(sed -n '4p' "$STATE_DIR/user/colormode.txt")
if [[ "$usegradience" = "nogradience" ]]; then
rm "$XDG_CONFIG_HOME/gtk-3.0/gtk.css"
rm "$XDG_CONFIG_HOME/gtk-4.0/gtk.css"
return
fi

# Copy template
mkdir -p "$CACHE_DIR"/user/generated/gradience
cp "scripts/templates/gradience/preset.json" "$CACHE_DIR"/user/generated/gradience/preset.json

# Apply colors
for i in "${!colorlist[@]}"; do
sed -i "s/{{ ${colorlist[$i]} }}/${colorvalues[$i]}/g" "$CACHE_DIR"/user/generated/gradience/preset.json
done

mkdir -p "$XDG_CONFIG_HOME/presets" # create gradience presets folder
gradience-cli apply -p "$CACHE_DIR"/user/generated/gradience/preset.json --gtk both

# And set GTK theme manually as Gradience defaults to light adw-gtk3
# (which is unreadable when broken when you use dark mode)
lightdark=$(get_light_dark)
if [ "$lightdark" = "light" ]; then
gsettings set org.gnome.desktop.interface gtk-theme 'adw-gtk3'
else
gsettings set org.gnome.desktop.interface gtk-theme adw-gtk3-dark
fi
}

apply_ags() {
ags run-js "handleStyles(false);"
ags run-js 'openColorScheme.value = true; Utils.timeout(2000, () => openColorScheme.value = false);'
ags run-js "handleStyles(false);"
ags run-js 'openColorScheme.value = true; Utils.timeout(2000, () => openColorScheme.value = false);'
}


colornames=$(cat $STATE_DIR/scss/_material.scss | cut -d: -f1)
colorstrings=$(cat $STATE_DIR/scss/_material.scss | cut -d: -f2 | cut -d ' ' -f2 | cut -d ";" -f1)
IFS=$'\n'
colorlist=( $colornames ) # Array of color names
colorvalues=( $colorstrings ) # Array of color values
colorlist=($colornames) # Array of color names
colorvalues=($colorstrings) # Array of color values

apply_ags &
apply_hyprland &
apply_hyprlock &
apply_lightdark &
apply_kitty &
apply_gtk &
apply_fuzzel &
apply_term &
80 changes: 80 additions & 0 deletions .config/ags/scripts/templates/kitty/dots-hyprland.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# vim:ft=kitty

## name: dots-hyperland
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hyprland doesn't contain an "e" lol

## author: pandalec
## license: MIT
## upstream: https://github.com/end-4/dots-hyprland
## blurb: Template for generating a kitty theme based on end-4s dots-hyprland



# The basic colors
foreground #$term7 #
background #$term0 #
selection_foreground #$onSurfaceVariant #
selection_background #$surfaceVariant #

# Cursor colors
cursor #$term1 #
cursor_text_color #$background #

# URL underline color when hovering with mouse
url_color #$term1 #

# Kitty window border colors
active_border_color #$onSurface #
inactive_border_color #$outline #
bell_border_color #$term3 #

# OS Window titlebar colors
wayland_titlebar_color system
macos_titlebar_color system

# Tab bar colors
active_tab_foreground #$onSurface #
active_tab_background #$surface #
inactive_tab_foreground #$onBackground #
inactive_tab_background #$background #
tab_bar_background #$term15 #

# Colors for marks (marked text in the terminal)
mark1_foreground #$secondaryContainer #
mark1_background #$onSurface #
mark2_foreground #$secondaryContainer #
mark2_background #$onSurface #
mark3_foreground #$secondaryContainer #
mark3_background #$onSurface #

# The 16 terminal colors

# black
color0 #$term0 #
color8 #$term8 #

# red
color1 #$term1 #
color9 #$term9 #

# green
color2 #$term2 #
color10 #$term10 #

# yellow
color3 #$term3 #
color11 #$term11 #

# blue
color4 #$term4 #
color12 #$term12 #

# magenta
color5 #$term5 #
color13 #$term13 #

# cyan
color6 #$term6 #
color14 #$term14 #

# white
color7 #$term7 #
color15 #$term15 #