Dynamically change all opened terminals colorscheme with wallpaper (#210)

This commit is contained in:
end-4 2024-01-29 11:47:31 +07:00 committed by GitHub
commit 22fdb9894a
5 changed files with 41 additions and 15 deletions

View file

@ -41,7 +41,7 @@ get_light_dark() {
lightdark=""
if [ ! -f ~/.cache/ags/user/colormode.txt ]; then
echo "" > ~/.cache/ags/user/colormode.txt
else
else
lightdark=$(cat ~/.cache/ags/user/colormode.txt) # either "" or "-l"
fi
echo "$lightdark"
@ -55,7 +55,7 @@ apply_gtklock() {
sassc ~/.config/ags/scripts/templates/gtklock/main.scss ~/.config/gtklock/style.css
return
fi
# Check if scripts/templates/gtklock/style.css exists
if [ ! -f "scripts/templates/gtklock/style.css" ]; then
echo "Template file not found for Gtklock. Skipping that."
@ -99,6 +99,29 @@ apply_foot() {
cp "$HOME/.config/foot/foot_new.ini" "$HOME/.config/foot/foot.ini"
}
apply_term() {
# Check if scripts/templates/foot/foot.ini exists
if [ ! -f "scripts/templates/terminal/sequences.material" ]; then
echo "Template file not found for Terminal. Skipping that."
return
fi
if [ ! -d $HOME/.cache/ags/user/colorschemes ]; then
mkdir -p $HOME/.cache/ags/user/colorschemes
fi
# Copy template
cp "scripts/templates/terminal/sequences.material" "$HOME/.cache/ags/user/colorschemes/sequences"
# Apply colors
for i in "${!colorlist[@]}"; do
sed -i "s/${colorlist[$i]} #/${colorvalues[$i]#\#}/g" "$HOME/.cache/ags/user/colorschemes/sequences"
done
for file in /dev/pts/*; do
if [[ $file =~ ^/dev/pts/[0-9]+$ ]]; then
cat "$HOME/.cache/ags/user/colorschemes/sequences" > $file
fi
done
}
apply_hyprland() {
# Check if scripts/templates/hypr/colors.conf exists
if [ ! -f "scripts/templates/hypr/colors.conf" ]; then
@ -111,14 +134,14 @@ apply_hyprland() {
for i in "${!colorlist[@]}"; do
sed -i "s/{{ ${colorlist[$i]} }}/${colorvalues[$i]#\#}/g" "$HOME/.config/hypr/colors_new.conf"
done
mv "$HOME/.config/hypr/colors_new.conf" "$HOME/.config/hypr/colors.conf"
}
apply_gtk() { # Using gradience-cli
lightdark=$(get_light_dark)
# Copy template
# Copy template
cp "scripts/templates/gradience/preset_template.json" "scripts/templates/gradience/preset.json"
# Apply colors
@ -129,8 +152,8 @@ apply_gtk() { # Using gradience-cli
mkdir -p "$HOME/.config/presets" # create gradience presets folder
gradience-cli apply -p scripts/templates/gradience/preset.json --gtk both
# Set light/dark preference
# And set GTK theme manually as Gradience defaults to light adw-gtk3
# Set light/dark preference
# And set GTK theme manually as Gradience defaults to light adw-gtk3
# (which is unreadable when broken when you use dark mode)
if [ "$lightdark" = "-l" ]; then
gsettings set org.gnome.desktop.interface gtk-theme 'adw-gtk3'
@ -152,4 +175,4 @@ apply_hyprland &
apply_gtk &
apply_gtklock &
apply_fuzzel &
apply_foot
apply_term

View file

@ -10,14 +10,14 @@ fi
lightdark=""
if [ ! -f "$HOME/.cache/ags/user/colormode.txt" ]; then
echo "" > "$HOME/.cache/ags/user/colormode.txt"
else
else
lightdark=$(cat "$HOME/.cache/ags/user/colormode.txt") # either "" or "-l"
fi
# check if the file ~/.cache/ags/user/colorbackend.txt exists. if not, create it. else, read it to $lightdark
backend="material"
if [ ! -f "$HOME/.cache/ags/user/colorbackend.txt" ]; then
echo "material" > "$HOME/.cache/ags/user/colorbackend.txt"
else
else
backend=$(cat "$HOME/.cache/ags/user/colorbackend.txt") # either "" or "-l"
fi
@ -37,11 +37,11 @@ elif [ "$backend" = "material" ]; then
elif [ "$backend" = "pywal" ]; then
# clear and generate
wal -c
echo wal -i "$1" -n -t -s -e "$lightdark" -q
wal -i "$1" -n -t -s -e $lightdark -q
#echo wal -i "$1" -n -t -s -e "$lightdark" -q
wal -i "$1" -n $lightdark -q
# copy scss
cp "$HOME/.cache/wal/colors.scss" $HOME/.cache/ags/user/generated_colors.txt
cat color_generation/pywal_to_material.scss >> $HOME/.cache/ags/user/generated_colors.txt
if [ "$2" = "--apply" ]; then
sassc $HOME/.cache/ags/user/generated_colors.txt $HOME/.cache/ags/user/generated_colors_classes.scss --style compact

View file

@ -0,0 +1 @@
]4;0;#$background #\]4;1;#$error #\]4;2;#$inversePrimary #\]4;3;#$onPrimaryContainer #\]4;4;#$onPrimaryContainer #\]4;5;#$onSecondaryContainer #\]4;6;#$primary #\]4;7;#$onSurfaceVariant #\]4;8;#$background #\]4;9;#$error #\]4;10;#$inversePrimary #\]4;11;#$onPrimaryContainer #\]4;12;#$onPrimaryContainer #\]4;13;#$onSecondaryContainer #\]4;14;#$primary #\]4;15;#$onSurfaceVariant #\]10;#$onSurfaceVariant #\]11;#$background #\]12;#$onSurfaceVariant #\]13;#$onSurfaceVariant #\]17;#$onSurfaceVariant #\]19;#$background #\]4;232;#$background #\]4;256;#$onSurfaceVariant #\]708;#$background #\

View file

@ -0,0 +1 @@
]4;0;#regular0\]4;1;#regular1\]4;2;#regular2\]4;3;#regular3\]4;4;#regular4\]4;5;#regular5\]4;6;#regular6\]4;7;#regular7\]4;8;#bright0\]4;9;#bright1\]4;10;#bright2\]4;11;#bright3\]4;12;#bright4\]4;13;#bright5\]4;14;#bright6\]4;15;#bright7\]10;#regular7\]11;#regular0\]12;#regular7\]13;#regular7\]17;#regular7\]19;#regular0\]4;232;#regular0\]4;256;#regular7\]708;#regular0\

View file

@ -13,8 +13,9 @@ if status is-interactive
end
starship init fish | source
cat ~/.cache/ags/user/colorschemes/sequences
# function fish_prompt
# set_color cyan; echo (pwd)
# set_color cyan; echo (pwd)
# set_color green; echo '> '
# end
# end