Page 1 of 1

Script to move Wonderwall wallpapers

Posted: Tue Aug 06, 2024 12:07 pm
by ripwardog

Bear in mind that I'm new to Puppies, new to EasyOS, new to scripting, etc.

Anyway I installed 'Wonderwall' (A wallpaper downloader/setter) as a flatpak in EasyOS and for the life of me couldn't get the thing to set a wallpaper of my choice.

If anyone knows how to work around the 'backend choices', don't be shy, elucidate me.

So what I did.

I did some research on scripting basics and YAD basics to come up with a script that offers a choice to move the wallpapers, if any, from the wonderwall download folder into the system backgrounds folder upon closing 'Wonderwall.' After which the user can open the standard background changer via the menu and change the wallpaper. I'm sure it could be more streamlined, but as I said, I'm new to all this.

Code: Select all

#!/bin/sh

#	Define two string variables
_wonderfolder='/root/.var/app/com.ktechpit.wonderwall/data/ktechpit/WonderWall/download/'
_backgrounds='/usr/share/backgrounds'

#	Fake return code to force yes/no choice
_ret=252

#	Look to see if there are any files in _wonderfolder
_numlines=$(ls $_wonderfolder | wc -l)

#	If there are any files in _wonderfolder open a yes/no dialog
#	If there are no files the script exits
#	This check takes place each time you exit Wonderwall
#	You can choose to move the files (if any) to the system
#	backgrounds folder or not. Your choice.
if [[ $_numlines -gt 0 ]]
    then
#	Append wildcard to _wonderfolder string
	_wonderfolder=$_wonderfolder'*.*'
#	Loop until a yes/no choice hase been made
	while [ $_ret -eq 252 ]
	do
#	Open dialog
	    yad --width=200 \
	        --center \
	        --image="dialog-question" \
	        --title="Wallpaper Mover" \
	        --text="Move wallpapers?" \
	        --button="YES:0" \
	        --button="NO:1" \

	    _ret=$?
#	When yes/no choice is made finish loop
	done
	[[ $_ret -eq 1 ]] && exit
	[[ $_ret -eq 0 ]] && mv $_wonderfolder $_backgrounds
fi
exit

Here's an early version of the script and shows how I chained it to 'Wonderwall.'
Image


Re: Script to move Wonderwall wallpapers

Posted: Tue Aug 06, 2024 11:51 pm
by ripwardog

Apparently using Flapi to install 'Wonderwall' results in different folder structures being created.

This script will only work if you manually installed the Flatpak vs. doing a custom Flapi installation.

Looks like I have more scripting to do to get this to actually work no matter the method of installation.


Re: Script to move Wonderwall wallpapers

Posted: Wed Aug 07, 2024 1:39 pm
by ripwardog

Revisiting to explain some things and so on and so forth.

Apparently when you install a flatpak via a custom entry in the Flapi package manager you get an entirely different install location and thus container than you would get if you installed the same Flatpak via the 'flatpak install' command line.

On one Easy install I used the command line to install 'Wonderwall,' and on the other I created a custom Flapi installation.
The manual install places the flatpak into the '/home' folder structure while the custom package install places it into the '/root' folder structure.

Which means any scripting having anything to do with any flatpak installations MUST check to see how the flatpak was installed BEFORE doing anything productive.

What worked on one iteration of Easy failed miserably on the other and vice versa. I started with a script that contained one line.

Code: Select all

mv /home/wonderwall/.var/app/com.ktechpit.wonderwall/data/ktechpit/wonderwall/downloads/*.* /usr/share/backgrounds

While this worked on my first installation of 'Wonderwall' on my first iteration of Easy, it seriously needed some work.
Obviously this is overly simplistic, but it worked. It didn't check to see if any files were present to move, it just executed, files be damned.
I went on to add a check to see if any files were present in the 'Wonderwall' downloads folder because if there isn't why bother using mv.
I then went on from there to write the script with a more robust 'feel' to it and even cut my teeth with Yet Another Dialog as can be seen in my OP

Thinking, 'Man I'm on to something here,' I copied the script over to the other iteration of Easy and was surprised it didn't work. It was designed to fail from the start now that I look back.
Not having a firm grasp on WTH was happening between the two iterations of Easy I drew darn near despondent. I decided I would take a deep dive into the way things worked under the hood.
Digging around a bit in the folder hierarchies I discovered the difference in the installation methods of command line and Flapi automated.
Knowing what I know now, I have taken that one line of code and refined it just a bit to check which of the two ways 'Wonderwall' was installed and to take the appropriate actions.

Code: Select all

#!/bin/sh

_fc=0	#	place holder for filecount of folder

#	Define some string variables
_one='/root/'
_two='/home/wonderwall/'
_baseloc='.var/app/'
_confloc='config/ktechpit/'
_dataloc='data/ktechpit/WonderWall/download/'
_name='com.ktechpit.wonderwall/'
_backgrounds='/usr/share/backgrounds'
_filename='WonderWall.conf'

#	concat string variables
_config1=$_one$_baseloc$_name$_confloc				#	Location of Wonderwall config?
_config2=$_two$_baseloc$_name$_confloc				#	Location of Wonderwall config?

if  [ -f $_config1$_filename ]; then				#	Does config file exist here?
  _wonderfolder=$_one$_baseloc$_name$_dataloc'*.*'	#	Location of Wonderwall downloads?
  _fc=$(ls $_wonderfolder | wc -l)					#	If config file exists how many if any downloads exist?
    if [ $_fc -gt 0 ]; then							#	If more than zero downloads exist,
	  mv $_wonderfolder $_backgrounds				#	Move them to the backgrounds folder,
	fi												#	Exit.
else												#	If not there they must be here.
  _wonderfolder=$_two$_baseloc$_name$_dataloc'*.*'	#	Location of Wonderwall downloads.
  _fc=$(ls $_wonderfolder | wc -l)					#	How many if any downloads exist?
    if [ $_fc -gt 0 ]; then							#	If more than zero downloads exist,
      mv $_wonderfolder $_backgrounds				#	Move them to the backgrounds folder,
	fi												#	Exit.
fi

Forgive the formatting it looks much better on my end.
Image


Re: Script to move Wonderwall wallpapers

Posted: Wed Aug 07, 2024 6:30 pm
by ripwardog

Heh 'Wonderwall' has a 20 file trial limit.

Anyway this is my final product.

Code: Select all

#!/bin/sh

yadbox () {
if [[ $_fc -gt 0 ]]
    then
#	Append wildcard to _wonderfolder string
	_wonderfolder=$_wonderfolder'*.*'
#	Loop until a move or copy choice has been made
	while [ $_ret -eq 252 ]
	do
#	Open dialog
	    yad --width=200 \
	        --center \
	        --image="dialog-question" \
	        --title="Wallpaper Mover "$_ss \
	        --text="Move wallpapers?" \
	        --button="MOVE:0" \
	        --button="COPY:1" \

	    _ret=$?
#	When move or copy choice is made finish loop
	done
	[[ $_ret -eq 1 ]] && cp $_wonderfolder $_backgrounds
	[[ $_ret -eq 0 ]] && mv $_wonderfolder $_backgrounds
fi
}

_fc=0		#	place holder for filecount of folder
_ret=252	#	No exit code.

#	Define some string variables
_one='/root/'
_two='/home/wonderwall/'
_baseloc='.var/app/'
_name='com.ktechpit.wonderwall/'
_confloc='config/ktechpit/'
_dataloc='data/ktechpit/WonderWall/download/'
_backgrounds='/usr/share/backgrounds'
_filename='WonderWall.conf'

#	concat string variables
_config1=$_one$_baseloc$_name$_confloc				#	Location of Wonderwall config?

#	main routine
if  [ -f $_config1$_filename ]; then				#	Does config file exist here?
	_ss=1
	_wonderfolder=$_one$_baseloc$_name$_dataloc		#	Location of Wonderwall downloads?
	_fc=$(ls $_wonderfolder | wc -l)				#	If config file exists how many if any downloads exist?
	yadbox
else												#	If not there they must be here.
	_ss=2
	_wonderfolder=$_two$_baseloc$_name$_dataloc		#	Location of Wonderwall downloads.
	_fc=$(ls $_wonderfolder | wc -l)				#	How many if any downloads exist?
	yadbox
fi
exit
exit