fix randomize feature

This commit is contained in:
speedie 2022-12-02 16:39:54 +01:00
parent 8af696d6de
commit 35dfd711d5

View file

@ -256,27 +256,13 @@ SWAL_SETWALLPAPER()
# Export script to autostart on login
SWAL_EXPORT_SCRIPT()
{
if [ "$SWAL_RANDOMIZE" = "false" ]; then
printf "#!/bin/sh\n$SWAL_OPT $SWAL_TYPE ""'$SWAL_WALLPAPERDIR/$SWAL_SELWALLPAPER'""" > $SWAL_EXPORTDIR/swal_wm
if [ -e "$SWAL_EXPORTDIR/CurrentWallpaper" ]; then
rm -f $SWAL_EXPORTDIR/CurrentWallpaper_prev ; ln -s "$(readlink $SWAL_EXPORTDIR/CurrentWallpaper)" $SWAL_EXPORTDIR/CurrentWallpaper_prev
fi
rm -f $SWAL_EXPORTDIR/CurrentWallpaper ; ln -s "$SWAL_WALLPAPERDIR/$SWAL_SELWALLPAPER" $SWAL_EXPORTDIR/CurrentWallpaper
else
printf "#!/bin/sh" > $SWAL_EXPORTDIR/swal_wm
printf "\nSWAL_WALLPAPERDIR=""'$SWAL_OLDWALLPAPERDIR'""" >> $SWAL_EXPORTDIR/swal_wm
printf "\nSWAL_EXPORTDIR=""'$SWAL_EXPORTDIR'""" >> $SWAL_EXPORTDIR/swal_wm
printf '\nSWAL_SELWALLPAPER="$(find "$SWAL_WALLPAPERDIR"/* -type f | shuf -n 1)"' >> $SWAL_EXPORTDIR/swal_wm
printf "\n$SWAL_OPT $SWAL_TYPE " >> $SWAL_EXPORTDIR/swal_wm
printf '"$SWAL_SELWALLPAPER"' >> $SWAL_EXPORTDIR/swal_wm
printf "\nrm -f $SWAL_EXPORTDIR/CurrentWallpaper_prev" >> $SWAL_EXPORTDIR/swal_wm
printf '\nln -s "$(readlink $SWAL_EXPORTDIR/CurrentWallpaper)" ' >> $SWAL_EXPORTDIR/swal_wm
printf "$SWAL_EXPORTDIR/CurrentWallpaper_prev" >> $SWAL_EXPORTDIR/swal_wm
printf "\nrm -f $SWAL_EXPORTDIR/CurrentWallpaper" >> $SWAL_EXPORTDIR/swal_wm
printf '\nln -s "$SWAL_SELWALLPAPER" ' >> $SWAL_EXPORTDIR/swal_wm
printf "$SWAL_EXPORTDIR/CurrentWallpaper" >> $SWAL_EXPORTDIR/swal_wm
[ "$SWAL_RANDOMIZE" != "true" ] && printf "#!/bin/sh\n$SWAL_OPT $SWAL_TYPE ""'$SWAL_WALLPAPERDIR/$SWAL_SELWALLPAPER'""" > $SWAL_EXPORTDIR/swal_wm || printf "#!/bin/sh\n$0 --randomize\nreturn\n" > $SWAL_EXPORTDIR/swal_wm
if [ -e "$SWAL_EXPORTDIR/CurrentWallpaper" ]; then
rm -f $SWAL_EXPORTDIR/CurrentWallpaper_prev ; ln -s "$(readlink $SWAL_EXPORTDIR/CurrentWallpaper)" $SWAL_EXPORTDIR/CurrentWallpaper_prev
fi
rm -f $SWAL_EXPORTDIR/CurrentWallpaper ; ln -s "$SWAL_WALLPAPERDIR/$SWAL_SELWALLPAPER" $SWAL_EXPORTDIR/CurrentWallpaper
chmod +x $SWAL_EXPORTDIR/swal_wm
}
@ -284,23 +270,7 @@ SWAL_EXPORT_SCRIPT()
# Export script to autostart on login for Pywal users
SWAL_EXPORT_SCRIPT_WAL()
{
if [ "$SWAL_RANDOMIZE" = "false" ]; then
printf "#!/bin/sh\n$SWAL_OPT $SWAL_TYPE ""'$SWAL_WALLPAPERDIR/$SWAL_SELWALLPAPER'""\nwal -qi ""'$SWAL_WALLPAPERDIR/$SWAL_SELWALLPAPER'"" || rm -rf $HOME/.cache/wal ; xrdb -remove\nxrdb ~/.cache/wal/colors.Xresources" > $SWAL_EXPORTDIR/swal_wm
else
printf "#!/bin/sh" > $SWAL_EXPORTDIR/swal_wm
printf "\nSWAL_WALLPAPERDIR=""'$SWAL_OLDWALLPAPERDIR'""" >> $SWAL_EXPORTDIR/swal_wm
printf "\nSWAL_EXPORTDIR=""'$SWAL_EXPORTDIR'""" >> $SWAL_EXPORTDIR/swal_wm
printf '\nSWAL_SELWALLPAPER="$(find "$SWAL_WALLPAPERDIR"/* -type f | shuf -n 1)"' >> $SWAL_EXPORTDIR/swal_wm
printf "\n$SWAL_OPT $SWAL_TYPE " >> $SWAL_EXPORTDIR/swal_wm
printf '"$SWAL_SELWALLPAPER"' >> $SWAL_EXPORTDIR/swal_wm
printf '\nwal -nqi "$SWAL_SELWALLPAPER" || rm -rf $HOME/.cache/wal ; xrdb -remove\nxrdb $HOME/.cache/wal/colors.Xresources\nxrdb $HOME/.cache/wal/colors.Xresources' >> $SWAL_EXPORTDIR/swal_wm
printf "\nrm -f $SWAL_EXPORTDIR/CurrentWallpaper_prev" >> $SWAL_EXPORTDIR/swal_wm
printf '\nln -s "$(readlink $SWAL_EXPORTDIR/CurrentWallpaper)" ' >> $SWAL_EXPORTDIR/swal_wm
printf "$SWAL_EXPORTDIR/CurrentWallpaper_prev" >> $SWAL_EXPORTDIR/swal_wm
printf "\nrm -f $SWAL_EXPORTDIR/CurrentWallpaper" >> $SWAL_EXPORTDIR/swal_wm
printf '\nln -s "$SWAL_SELWALLPAPER" ' >> $SWAL_EXPORTDIR/swal_wm
printf "$SWAL_EXPORTDIR/CurrentWallpaper" >> $SWAL_EXPORTDIR/swal_wm
fi
[ "$SWAL_RANDOMIZE" != "true" ] && printf "#!/bin/sh\n$SWAL_OPT $SWAL_TYPE ""'$SWAL_WALLPAPERDIR/$SWAL_SELWALLPAPER'""\nwal -qi ""'$SWAL_WALLPAPERDIR/$SWAL_SELWALLPAPER'"" || rm -rf $HOME/.cache/wal ; xrdb -remove\nxrdb ~/.cache/wal/colors.Xresources" > $SWAL_EXPORTDIR/swal_wm || printf "#!/bin/sh\n$0 --randomize\nreturn\n" > $SWAL_EXPORTDIR/swal_wm
# make script executable
chmod +x $SWAL_EXPORTDIR/swal_wm