feat: video wallpaper select

This commit is contained in:
hesam-init 2024-02-26 19:04:02 +03:30
parent d5183e70c5
commit d22cb14f2d
4 changed files with 42 additions and 15 deletions

View file

@ -24,7 +24,7 @@ fi
random_video=${video_files[$RANDOM % ${#video_files[@]}]}
if [[ $(pidof mpvpaper) ]]; then
pkill mpvpaper
pkill -f mpvpaper
fi
mpvpaper -o "loop-file" "*" $random_video

View file

@ -2,10 +2,6 @@
source $HOME/.config/environments/env.sh
if [[ ! $(pidof swww-daemon) ]]; then
swww init
fi
files=($(find "${WALLPAPERS_DIR}" -type f))
if [ ${#files[@]} -eq 0 ]; then

View file

@ -11,16 +11,23 @@ case $WALLPAPER_DAEMON in
"swaybg")
pkill -f swww-daemon
pkill -f mpvpaper
exec $HOME/.config/hypr/scripts/swaybg-random.sh
;;
"swww")
pkill -f swaybg
pkill -f mpvpaper
if [[ ! $(pidof swww-daemon) ]]; then
swww init
fi
exec $HOME/.config/hypr/scripts/swww-random.sh
;;
"mpvpaper")
pkill -f swaybg
pkill -f swww-daemon
exec $HOME/.config/hypr/scripts/mpvpaper-random.sh
;;
*)

View file

@ -6,7 +6,7 @@ dir="$HOME/.config/rofi/wallpaper/type-1"
theme='style-8'
rofi_cmd() {
rofi -dmenu -theme "${dir}/${theme}.rasi" -p "Chad"
rofi -dmenu -theme "${dir}/${theme}.rasi"
}
show_image_preview() {
@ -15,32 +15,51 @@ show_image_preview() {
done
}
show_video_preview() {
find "$LIVE_WALLPAPERS_DIR" -maxdepth 1 -type f \( -iname \*.mp4 \) -exec basename {} \; | while read -r A; do
echo -en "$A\x00icon\x1f$LIVE_WALLPAPERS_DIR/$A\n"
done
}
set_wallpaper() {
local wallpaper="$WALLPAPERS_DIR/$1"
if [ $WALLPAPER_DAEMON == "mpvpaper" ]; then
local wallpaper="$LIVE_WALLPAPERS_DIR/$1"
else
local wallpaper="$WALLPAPERS_DIR/$1"
fi
if [ -f "$wallpaper" ]; then
case $WALLPAPER_DAEMON in
"swaybg")
if [[ $(pidof swww-daemon) ]]; then
pkill swww-daemon
fi
pkill -f swww-daemon
pkill -f mpvpaper
if [[ $(pidof swaybg) ]]; then
pkill swaybg
pkill -f swaybg
fi
swaybg -i "$wallpaper"
;;
"swww")
pkill -f swaybg
pkill -f mpvpaper
if [[ ! $(pidof swww-daemon) ]]; then
swww init
fi
if [[ $(pidof swaybg) ]]; then
pkill swaybg
swww img "$wallpaper" --transition-fps "$SWWW_FPS" --transition-type any --transition-duration "$SWWW_DURATION"
;;
"mpvpaper")
pkill -f swaybg
pkill -f swww-daemon
if [[ $(pidof mpvpaper) ]]; then
pkill -f mpvpaper
fi
swww img "$wallpaper" --transition-fps "$SWWW_FPS" --transition-type any --transition-duration "$SWWW_DURATION"
mpvpaper -o "loop-file" "*" $wallpaper
;;
*)
echo "Unknown value for WALLPAPER_DAEMON: $WALLPAPER_DAEMON"
@ -53,9 +72,14 @@ set_wallpaper() {
fi
}
choice=$(show_image_preview | rofi_cmd)
if [ $WALLPAPER_DAEMON == "mpvpaper" ]; then
choice=$(show_video_preview | rofi_cmd)
else
choice=$(show_image_preview | rofi_cmd)
fi
if [ -n "$choice" ]; then
echo $choice
set_wallpaper "$choice"
else
echo "No wallpaper selected."