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[@]}]} random_video=${video_files[$RANDOM % ${#video_files[@]}]}
if [[ $(pidof mpvpaper) ]]; then if [[ $(pidof mpvpaper) ]]; then
pkill mpvpaper pkill -f mpvpaper
fi fi
mpvpaper -o "loop-file" "*" $random_video mpvpaper -o "loop-file" "*" $random_video

View file

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

View file

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

View file

@ -6,7 +6,7 @@ dir="$HOME/.config/rofi/wallpaper/type-1"
theme='style-8' theme='style-8'
rofi_cmd() { rofi_cmd() {
rofi -dmenu -theme "${dir}/${theme}.rasi" -p "Chad" rofi -dmenu -theme "${dir}/${theme}.rasi"
} }
show_image_preview() { show_image_preview() {
@ -15,32 +15,51 @@ show_image_preview() {
done 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() { 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 if [ -f "$wallpaper" ]; then
case $WALLPAPER_DAEMON in case $WALLPAPER_DAEMON in
"swaybg") "swaybg")
if [[ $(pidof swww-daemon) ]]; then pkill -f swww-daemon
pkill swww-daemon pkill -f mpvpaper
fi
if [[ $(pidof swaybg) ]]; then if [[ $(pidof swaybg) ]]; then
pkill swaybg pkill -f swaybg
fi fi
swaybg -i "$wallpaper" swaybg -i "$wallpaper"
;; ;;
"swww") "swww")
pkill -f swaybg
pkill -f mpvpaper
if [[ ! $(pidof swww-daemon) ]]; then if [[ ! $(pidof swww-daemon) ]]; then
swww init swww init
fi fi
if [[ $(pidof swaybg) ]]; then swww img "$wallpaper" --transition-fps "$SWWW_FPS" --transition-type any --transition-duration "$SWWW_DURATION"
pkill swaybg ;;
"mpvpaper")
pkill -f swaybg
pkill -f swww-daemon
if [[ $(pidof mpvpaper) ]]; then
pkill -f mpvpaper
fi 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" echo "Unknown value for WALLPAPER_DAEMON: $WALLPAPER_DAEMON"
@ -53,9 +72,14 @@ set_wallpaper() {
fi 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 if [ -n "$choice" ]; then
echo $choice
set_wallpaper "$choice" set_wallpaper "$choice"
else else
echo "No wallpaper selected." echo "No wallpaper selected."