aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJaKooLit <jimmielovejay@gmail.com>2023-11-12 13:51:03 +0900
committerJaKooLit <jimmielovejay@gmail.com>2023-11-12 13:51:03 +0900
commitb3a7ac2b3f99f5a2ffb6574b5f2b4c80b15f63c3 (patch)
tree07ed057fd4fb222aa0a4b68d7068e4a4ebe87cdb
parent022fa1b4f26d347bf976757f000af88521c49da1 (diff)
code clean up, no action if no wallpaper selected
-rwxr-xr-xconfig/hypr/scripts/WallpaperSelect.sh85
-rwxr-xr-xconfig/hypr/scripts/WaybarStyles.sh40
2 files changed, 60 insertions, 65 deletions
diff --git a/config/hypr/scripts/WallpaperSelect.sh b/config/hypr/scripts/WallpaperSelect.sh
index f56f6df7..c989adf3 100755
--- a/config/hypr/scripts/WallpaperSelect.sh
+++ b/config/hypr/scripts/WallpaperSelect.sh
@@ -1,74 +1,65 @@
#!/bin/bash
-
# WALLPAPERS PATH
DIR=$HOME/Pictures/wallpapers
-
-# Transition config (type swww img --help for more settings
+# Transition config
FPS=30
TYPE="simple"
DURATION=3
-
SWWW_PARAMS="--transition-fps $FPS --transition-type $TYPE --transition-duration $DURATION"
-PICS=($(ls ${DIR} | grep -e ".jpg$" -e ".jpeg$" -e ".png$" -e ".gif$"))
-#PICS=($(find ${DIR} -type f \( -name "*.jpg" -o -name "*.jpeg" -o -name "*.png" \)))
-
-RANDOM_PIC=${PICS[ $RANDOM % ${#PICS[@]} ]}
-RANDOM_PIC_NAME="${#PICS[@]}. random"
-
-# to check if swaybg is running
-if [[ $(pidof swaybg) ]]; then
+# Check if swaybg is running
+if pidof swaybg > /dev/null; then
pkill swaybg
fi
-## Rofi Command
+# Retrieve image files
+PICS=($(ls "${DIR}" | grep -E ".jpg$|.jpeg$|.png$|.gif$"))
+RANDOM_PIC="${PICS[$((RANDOM % ${#PICS[@]}))]}"
+RANDOM_PIC_NAME="${#PICS[@]}. random"
+
+# Rofi command
rofi_command="rofi -dmenu -config ~/.config/rofi/config-short.rasi"
-menu(){
- # Here we are looping in the PICS array that is composed of all images in the $DIR folder
- for i in ${!PICS[@]}; do
- # keeping the .gif to make sue you know it is animated
- if [[ -z $(echo ${PICS[$i]} | grep .gif$) ]]; then
- printf "$i. $(echo ${PICS[$i]} | cut -d. -f1)\n" # n°. <name_of_file_without_identifier>
- else
- printf "$i. ${PICS[$i]}\n"
- fi
- done
+menu() {
+ for i in "${!PICS[@]}"; do
+ # Displaying .gif to indicate animated images
+ if [[ -z $(echo "${PICS[$i]}" | grep .gif$) ]]; then
+ printf "$i. $(echo "${PICS[$i]}" | cut -d. -f1)\n"
+ else
+ printf "$i. ${PICS[$i]}\n"
+ fi
+ done
- printf "$RANDOM_PIC_NAME"
+ printf "$RANDOM_PIC_NAME"
}
swww query || swww init
main() {
- choice=$(menu | ${rofi_command})
+ choice=$(menu | ${rofi_command})
- # no choice case
- if [[ -z $choice ]]; then return; fi
+ # No choice case
+ if [[ -z $choice ]]; then
+ exit 0
+ fi
- # random choice case
- if [ "$choice" = "$RANDOM_PIC_NAME" ]; then
- swww img ${DIR}/${RANDOM_PIC} $SWWW_PARAMS
- return
- fi
-
- pic_index=$(echo $choice | cut -d. -f1)
- swww img ${DIR}/${PICS[$pic_index]} $SWWW_PARAMS
+ # Random choice case
+ if [ "$choice" = "$RANDOM_PIC_NAME" ]; then
+ swww img "${DIR}/${RANDOM_PIC}" $SWWW_PARAMS
+ exit 0
+ fi
+
+ pic_index=$(echo "$choice" | cut -d. -f1)
+ swww img "${DIR}/${PICS[$pic_index]}" $SWWW_PARAMS
}
# Check if rofi is already running
-if pidof rofi >/dev/null; then
- pkill rofi
- exit 0
-else
- main
+if pidof rofi > /dev/null; then
+ pkill rofi
+ exit 0
fi
-exec $HOME/.config/hypr/scripts/PywalSwww.sh &
-
-exec $HOME/.config/hypr/scripts/Refresh.sh
+main
-# Uncomment to launch something if a choice was made
-# if [[ -n "$choice" ]]; then
- # Restart Waybar
-# fi \ No newline at end of file
+$HOME/.config/hypr/scripts/PywalSwww.sh &
+$HOME/.config/hypr/scripts/Refresh.sh
diff --git a/config/hypr/scripts/WaybarStyles.sh b/config/hypr/scripts/WaybarStyles.sh
index 0e714627..5051fa35 100755
--- a/config/hypr/scripts/WaybarStyles.sh
+++ b/config/hypr/scripts/WaybarStyles.sh
@@ -5,26 +5,32 @@ THEMEIS=$(realpath ~/.config/waybar/style.css | sed 's/.*-\(.*\)\.css/\1/')
# Array for the styles
STYLES=(
-"pywal"
-"dark"
-"light"
-"Black-&-White"
+"pywal"
+"dark"
+"light"
+"Black-&-White"
"colors"
-"colors-border"
-"colors-line"
-"colorful"
-"catppuccin-mocha"
-"catppuccin-latte"
- )
+"colors-border"
+"colors-line"
+"colorful"
+"catppuccin-mocha"
+"catppuccin-latte"
+)
# Build ROFI
SELECTED_STYLE=$(printf "%s\n" "${STYLES[@]}" | rofi -dmenu -config ~/.config/rofi/config-waybar.rasi "${#STYLES[@]}")
-# Here you verify the selected theme
+# Check if rofi is already running
+if pidof rofi > /dev/null; then
+ pkill rofi
+ exit 0
+fi
+
+# Verify the selected theme
if [[ " ${STYLES[@]} " =~ " $SELECTED_STYLE " ]]; then
SWITCHTO="${SELECTED_STYLE}"
else
- echo "It is not valid =c"
+ echo "Invalid selection"
exit 1
fi
@@ -32,17 +38,15 @@ fi
THEMEFILE="$HOME/.config/waybar/style/style-${SWITCHTO}.css"
if [ -f "$THEMEFILE" ]; then
ln -sf "$THEMEFILE" "$HOME/.config/waybar/style.css"
-
-
else
echo "Error: $THEMEFILE not found"
exit 1
fi
-_ps=(waybar mako dunst)
-for _prs in "${_ps[@]}"; do
- if [[ $(pidof ${_prs}) ]]; then
- pkill ${_prs}
+# Restart relevant processes
+for process in waybar mako dunst; do
+ if pidof "$process" > /dev/null; then
+ pkill "$process"
fi
done
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage