diff options
| author | JaKooLit <jimmielovejay@gmail.com> | 2023-10-22 15:55:57 +0900 |
|---|---|---|
| committer | JaKooLit <jimmielovejay@gmail.com> | 2023-10-22 15:55:57 +0900 |
| commit | c222e1bad2ba5e779c3af5b956906c82ead43271 (patch) | |
| tree | a5253e0861c200ff90354169e1f67ef42ebf0ef9 /config/hypr/scripts/DarkLight.sh | |
| parent | bb0be21dba7980fc1c047eaba24eda1712bd7f31 (diff) | |
Initial upload
Diffstat (limited to 'config/hypr/scripts/DarkLight.sh')
| -rwxr-xr-x | config/hypr/scripts/DarkLight.sh | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/config/hypr/scripts/DarkLight.sh b/config/hypr/scripts/DarkLight.sh new file mode 100755 index 00000000..c7db9280 --- /dev/null +++ b/config/hypr/scripts/DarkLight.sh @@ -0,0 +1,66 @@ +#!/bin/bash +set -x +# Define the path +wallpaper_path="$HOME/Pictures/wallpapers/Dynamic-Wallpapers" +hypr_config_path="$HOME/.config/hypr" +waybar_config="$HOME/.config/waybar" +dunst_config="$HOME/.config/dunst" +wofi_config="$HOME/.config/wofi" + +# Tokyo Night +light_gtk_theme="Tokyonight-Light-B" +dark_gtk_theme="Tokyonight-Dark-B" +light_icon_theme="TokyoNight-SE" +dark_icon_theme="TokyoNight-SE" + +pkill swaybg + +# Initialize swww if needed +swww query || swww init + +# Set swww options +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" + +# Define functions for notifying user and updating symlinks +notify_user() { + notify-send -h string:x-canonical-private-synchronous:sys-notify -u normal "Switching to $1 mode" +} + +# Determine the current wallpaper mode by checking a configuration file +if [ "$(cat ~/.wallpaper_mode)" = "light" ]; then + current_mode="light" + next_mode="dark" +else + current_mode="dark" + next_mode="light" +fi +path_param=$(echo $next_mode | sed 's/.*/\u&/') + +notify_user "$next_mode" +ln -sf "${waybar_config}/style/style-${next_mode}.css" "${waybar_config}/style.css" +ln -sf "${dunst_config}/styles/dunstrc-${next_mode}" "${dunst_config}/styles/dunstrc" +ln -sf "${wofi_config}/styles/style-${next_mode}.css" "${wofi_config}/style.css" + +gtk_theme="${next_mode}_gtk_theme" +icon_theme="${next_mode}_icon_theme" + +gsettings set org.gnome.desktop.interface gtk-theme "${!gtk_theme}" +gsettings set org.gnome.desktop.interface icon-theme "${!icon_theme}" + +# Find the next wallpaper if one exists +current_wallpaper="$(cat ~/.current_wallpaper)" +next_wallpaper="${current_wallpaper/_"$current_mode"/_"$next_mode"}" + +if ! [ -f "$next_wallpaper" ]; then + next_wallpaper="$(find "${wallpaper_path/"${path_param}"}" -type f -iname "*_"${next_mode}".jpg" -print0 | shuf -n1 -z | xargs -0)" +fi + +$swww "${next_wallpaper}" $effect + +# Update the configuration file to reflect the new wallpaper mode and current wallpaper +echo "$next_mode" > ~/.wallpaper_mode +echo "$next_wallpaper" > ~/.current_wallpaper + +sleep 2 +exec ~/.config/hypr/scripts/Refresh.sh &
\ No newline at end of file |
