Browse Source

updated dark light switcher

pull/88/head^2
JaKooLit 2 years ago
parent
commit
7d9d5b9ae8
  1. 95
      config/hypr/scripts/DarkLight.sh

95
config/hypr/scripts/DarkLight.sh

@ -20,12 +20,28 @@ swww query || swww init
swww="swww img" swww="swww img"
effect="--transition-bezier .43,1.19,1,.4 --transition-fps 60 --transition-type grow --transition-pos 0.925,0.977 --transition-duration 2" effect="--transition-bezier .43,1.19,1,.4 --transition-fps 60 --transition-type grow --transition-pos 0.925,0.977 --transition-duration 2"
# Determine current theme mode
if [ "$(cat $HOME/.cache/.theme_mode)" = "Light" ]; then
next_mode="Dark"
# Logic for Dark mode
wallpaper_path="$dark_wallpapers"
else
next_mode="Light"
# Logic for Light mode
wallpaper_path="$light_wallpapers"
fi
# Function to update theme mode for the next cycle
update_theme_mode() {
echo "$next_mode" > ~/.cache/.theme_mode
}
# Function to notify user # Function to notify user
notify_user() { notify_user() {
dunstify -u low -i "$dunst_notif" "Switching to $1 mode" dunstify -u low -i "$dunst_notif" "Switching to $1 mode"
} }
# Function to set Waybar style # Function to set Waybar style (example with placeholder command)
set_waybar_style() { set_waybar_style() {
theme="$1" theme="$1"
waybar_styles="$HOME/.config/waybar/style" waybar_styles="$HOME/.config/waybar/style"
@ -41,24 +57,8 @@ set_waybar_style() {
fi fi
} }
# Determine current wallpaper mode
if [ "$(cat ~/.cache/.wallpaper_mode)" = "Light" ]; then
next_mode="Dark"
wallpaper_path="$dark_wallpapers"
kvantum_theme="Tokyo-Night"
qt5ct_color_scheme="$HOME/.config/qt5ct/colors/Tokyo-Night.conf"
qt6ct_color_scheme="$HOME/.config/qt6ct/colors/Tokyo-Night.conf"
else
next_mode="Light"
wallpaper_path="$light_wallpapers"
kvantum_theme="Tokyo-Day"
qt5ct_color_scheme="$HOME/.config/qt5ct/colors/Tokyo-Day.conf"
qt6ct_color_scheme="$HOME/.config/qt6ct/colors/Tokyo-Day.conf"
fi
# Call the function after determining the mode # Call the function after determining the mode
set_waybar_style "$next_mode" set_waybar_style "$next_mode"
notify_user "$next_mode" notify_user "$next_mode"
# Change background for dunst # Change background for dunst
@ -70,35 +70,38 @@ else
sed -i '/foreground = /s/.*/ foreground = "#00000095"/' "${dunst_config}/dunstrc" sed -i '/foreground = /s/.*/ foreground = "#00000095"/' "${dunst_config}/dunstrc"
fi fi
# QT APPS Change Kvantum Manager theme & QT5CT Settings # Set Dynamic Wallpaper for Dark or Light Mode
# QT Icons at below with GTK Icons
kvantummanager --set "$kvantum_theme"
sed -i "s|^color_scheme_path=.*$|color_scheme_path=$qt5ct_color_scheme|" "$HOME/.config/qt5ct/qt5ct.conf"
sed -i "s|^color_scheme_path=.*$|color_scheme_path=$qt6ct_color_scheme|" "$HOME/.config/qt6ct/qt6ct.conf"
# Set Rofi Themes
if [ "$next_mode" = "Dark" ]; then if [ "$next_mode" = "Dark" ]; then
ln -sf $dark_rofi_pywal "$HOME/.config/rofi/pywal-color/pywal-theme.rasi" next_wallpaper="$(find "${dark_wallpapers}" -type f \( -iname "*.jpg" -o -iname "*.png" \) -print0 | shuf -n1 -z | xargs -0)"
else else
ln -sf $light_rofi_pywal "$HOME/.config/rofi/pywal-color/pywal-theme.rasi" next_wallpaper="$(find "${light_wallpapers}" -type f \( -iname "*.jpg" -o -iname "*.png" \) -print0 | shuf -n1 -z | xargs -0)"
fi fi
# Set Dynamic Wallpaper for Dark Mode # Update wallpaper using swww command
if [ "$next_mode" = "Dark" ]; then $swww "${next_wallpaper}" $effect
next_wallpaper="$(find "${dark_wallpapers}" -type f \( -iname "*.jpg" -o -iname "*.png" \) -print0 | shuf -n1 -z | xargs -0)"
fi
# Set Dynamic Wallpaper for Light Mode
if [ "$next_mode" = "Light" ]; then
next_wallpaper="$(find "${light_wallpapers}" -type f \( -iname "*.jpg" -o -iname "*.png" \) -print0 | shuf -n1 -z | xargs -0)"
fi
# Set Kvantum Manager theme & QT5/QT6 settings
if [ "$next_mode" = "Dark" ]; then
kvantum_theme="Tokyo-Night"
qt5ct_color_scheme="$HOME/.config/qt5ct/colors/Tokyo-Night.conf"
qt6ct_color_scheme="$HOME/.config/qt6ct/colors/Tokyo-Night.conf"
else
kvantum_theme="Tokyo-Day"
qt5ct_color_scheme="$HOME/.config/qt5ct/colors/Tokyo-Day.conf"
qt6ct_color_scheme="$HOME/.config/qt6ct/colors/Tokyo-Day.conf"
fi
$swww "${next_wallpaper}" $effect kvantummanager --set "$kvantum_theme"
sed -i "s|^color_scheme_path=.*$|color_scheme_path=$qt5ct_color_scheme|" "$HOME/.config/qt5ct/qt5ct.conf"
sed -i "s|^color_scheme_path=.*$|color_scheme_path=$qt6ct_color_scheme|" "$HOME/.config/qt6ct/qt6ct.conf"
# This is a referrence point for next cycle # Set Rofi Themes
echo "$next_mode" > ~/.cache/.wallpaper_mode if [ "$next_mode" = "Dark" ]; then
echo "$next_wallpaper" > ~/.cache/.current_wallpaper ln -sf "$dark_rofi_pywal" "$HOME/.config/rofi/pywal-color/pywal-theme.rasi"
else
ln -sf "$light_rofi_pywal" "$HOME/.config/rofi/pywal-color/pywal-theme.rasi"
fi
# GTK themes and icons switching # GTK themes and icons switching
set_custom_gtk_theme() { set_custom_gtk_theme() {
@ -161,13 +164,19 @@ set_custom_gtk_theme() {
# Call the function to set GTK theme and icon theme based on mode # Call the function to set GTK theme and icon theme based on mode
set_custom_gtk_theme "$next_mode" set_custom_gtk_theme "$next_mode"
# Run remaining scripts # Update theme mode for the next cycle
${SCRIPTSDIR}/PywalSwww.sh & update_theme_mode
sleep 2
sleep 0.5
# Run remaining scripts (placeholders)
${SCRIPTSDIR}/PywalSwww.sh
sleep 1
${SCRIPTSDIR}/Refresh.sh ${SCRIPTSDIR}/Refresh.sh
dunstify -u low -i "$dunst_notif" "GTK theme set to $selected_theme" # Display notifications for theme and icon changes
dunstify -u low -i "$dunst_notif" "Icon theme set to $selected_icon" dunstify -u normal -i "$dunst_notif" "Themes are set to $selected_theme"
dunstify -u normal -i "$dunst_notif" "Icon themes set to $selected_icon"
exit 0 exit 0

Loading…
Cancel
Save