wallpaper changer

wallpaper changer

Postby drum » 04 Mar 2014, 18:32

Is it possible to have a wallpaperchanger that changes every hour your desktop in point linux?
Point Linux = freedom, reliability, stability, configurability, flexibility, security Image

The "Penguin" has arrived - and he's not going away - ever.

point linux = semper fidelis
User avatar
drum
 
Posts: 111
Joined: 24 Oct 2013, 06:57
Location: Belgium

Re: wallpaper changer

Postby Maroman » 04 Mar 2014, 19:20

probably yes. I do not know if caja can generate desktop/wallpaper. if not my guest is that nitrogen should be installed and used (in lxde wallpaper changer script can use pcmanfm. installing pcmanfm is not good idea due to dependencies). here is the script (it's modification of known script for lxde) to change wallpaper every 15 minutes (can be changed)
Code: Select all
#!/bin/bash

# the directory with your wallpapers *.jpg
DIR=~/Pictures/wallpapers

FLOOR=1
RANGE=`ls -1 "$DIR"/*.jpg | wc | awk '// {print $1}'`

number=0

while [ 1 -eq 1 ]; do
   
   number=$RANDOM
   while [ "$number" -le $FLOOR ]; do
        number=$RANDOM
   done
   let "number %= $RANGE"  # Scales $number down within $RANGE.
   COUNTER=1
   for X in "$DIR"/*.jpg
   do
      if [ $number -eq $COUNTER ]; then
         nitrogen --set-auto "$X"
      fi
   COUNTER=$(($COUNTER+1))
   done
   COUNTER=1
   sleep 15m
done

you can change the mode of a script (executed) and put it in /usr/local/bin directory. then create start-up file.

there is different script to randomly change wallpaper
Code: Select all
bash -c 'nitrogen --set-auto "$(find /media/Depot/Pictures/wallpapers -type f | shuf -n1)"'

(the analogon of script used in lxle distro)

But I do not know if and how they work with mate. and have no time for experiments. if you decide to check, please jot down a line.

cheers,
ride my bike,
User avatar
Maroman
 
Posts: 369
Joined: 02 Jun 2013, 09:17
Location: Warsaw Metropolitan Area, Poland

Re: wallpaper changer

Postby drum » 04 Mar 2014, 22:34

But I do not know if and how they work with mate. and have no time for experiments. if you decide to check, please jot down a line.

Tnx. for the help Maroman but i'm done with experimenting, just looking if it can be done in the settings maybe in the cosmos?
Point Linux = freedom, reliability, stability, configurability, flexibility, security Image

The "Penguin" has arrived - and he's not going away - ever.

point linux = semper fidelis
User avatar
drum
 
Posts: 111
Joined: 24 Oct 2013, 06:57
Location: Belgium

Re: wallpaper changer

Postby Maroman » 02 Apr 2014, 10:37

I think I have found solution. it's both easy and difficult. easy because all is done in the system, difficult because I've come to it recently.

first create directory in any place. in my case it is ~/wallpapers. and collect some images (jpg or png) in the directory. I called them 001.png up to 016.png (not very innovative but names are important). next xml file should be created (analogous to /usr/share/backgrounds/cosmos/background-1.xml). name of the file is not important. let's call it ~/wallpapers/extra.xml. the file is as follows
Code: Select all
<background>
  <starttime>
    <year>2014</year>
    <month>04</month>
    <day>01</day>
    <hour>00</hour>
    <minute>00</minute>
    <second>00</second>
  </starttime>
<!-- This animation will start at midnight. -->
  <static>
    <duration>595.0</duration>
    <file>/home/maroman/wallpapers/001.png</file>
  </static>
  <transition>
    <duration>5.0</duration>
    <from>/home/maroman/wallpapers/001.png</from>
    <to>/home/maroman/wallpapers/002.png</to>
  </transition>
  <static>
    <duration>595.0</duration>
    <file>/home/maroman/wallpapers/002.png</file>
  </static>
  <transition>
    <duration>5.0</duration>
    <from>/home/maroman/wallpapers/002.png</from>
    <to>/home/maroman/wallpapers/003.png</to>
  </transition>
  <static>
    <duration>595.0</duration>
    <file>/home/maroman/wallpapers/003.png</file>
  </static>
  <transition>
    <duration>5.0</duration>
    <from>/home/maroman/wallpapers/003.png</from>
    <to>/home/maroman/wallpapers/004.png</to>
  </transition>
  <static>
    <duration>595.0</duration>
    <file>/home/maroman/wallpapers/004.png</file>
  </static>
  <transition>
    <duration>5.0</duration>
    <from>/home/maroman/wallpapers/004.png</from>
    <to>/home/maroman/wallpapers/005.png</to>
  </transition>
  <static>
    <duration>595.0</duration>
    <file>/home/maroman/wallpapers/005.png</file>
  </static>
  <transition>
    <duration>5.0</duration>
    <from>/home/maroman/wallpapers/005.png</from>
    <to>/home/maroman/wallpapers/006.png</to>
  </transition>
  <static>
    <duration>595.0</duration>
    <file>/home/maroman/wallpapers/006.png</file>
  </static>
  <transition>
    <duration>5.0</duration>
    <from>/home/maroman/wallpapers/006.png</from>
    <to>/home/maroman/wallpapers/007.png</to>
  </transition>
  <static>
    <duration>595.0</duration>
    <file>/home/maroman/wallpapers/007.png</file>
  </static>
  <transition>
    <duration>5.0</duration>
    <from>/home/maroman/wallpapers/007.png</from>
    <to>/home/maroman/wallpapers/008.png</to>
  </transition>
  <static>
    <duration>595.0</duration>
    <file>/home/maroman/wallpapers/008.png</file>
  </static>
  <transition>
    <duration>5.0</duration>
    <from>/home/maroman/wallpapers/008.png</from>
    <to>/home/maroman/wallpapers/009.png</to>
  </transition>
  <static>
    <duration>595.0</duration>
    <file>/home/maroman/wallpapers/009.png</file>
  </static>
  <transition>
    <duration>5.0</duration>
    <from>/home/maroman/wallpapers/009.png</from>
    <to>/home/maroman/wallpapers/010.png</to>
  </transition>
  <static>
    <duration>595.0</duration>
    <file>/home/maroman/wallpapers/010.png</file>
  </static>
  <transition>
    <duration>5.0</duration>
    <from>/home/maroman/wallpapers/010.png</from>
    <to>/home/maroman/wallpapers/011.png</to>
  </transition>
  <static>
    <duration>595.0</duration>
    <file>/home/maroman/wallpapers/011.png</file>
  </static>
  <transition>
    <duration>5.0</duration>
    <from>/home/maroman/wallpapers/011.png</from>
    <to>/home/maroman/wallpapers/012.png</to>
  </transition>
  <static>
    <duration>595.0</duration>
    <file>/home/maroman/wallpapers/012.png</file>
  </static>
  <transition>
    <duration>5.0</duration>
    <from>/home/maroman/wallpapers/012.png</from>
    <to>/home/maroman/wallpapers/013.png</to>
  </transition>
  <static>
    <duration>595.0</duration>
    <file>/home/maroman/wallpapers/013.png</file>
  </static>
  <transition>
    <duration>5.0</duration>
    <from>/home/maroman/wallpapers/013.png</from>
    <to>/home/maroman/wallpapers/014.png</to>
  </transition>
  <static>
    <duration>595.0</duration>
    <file>/home/maroman/wallpapers/014.png</file>
  </static>
  <transition>
    <duration>5.0</duration>
    <from>/home/maroman/wallpapers/014.png</from>
    <to>/home/maroman/wallpapers/015.png</to>
  </transition>
  <static>
    <duration>595.0</duration>
    <file>/home/maroman/wallpapers/015.png</file>
  </static>
  <transition>
    <duration>5.0</duration>
    <from>/home/maroman/wallpapers/015.png</from>
    <to>/home/maroman/wallpapers/016.png</to>
  </transition>
  <static>
    <duration>595.0</duration>
    <file>/home/maroman/wallpapers/016.png</file>
  </static>
  <transition>
    <duration>5.0</duration>
    <from>/home/maroman/wallpapers/016.png</from>
    <to>/home/maroman/wallpapers/001.png</to>
   </transition>
</background>


please notice that the paths to images should be explicite given ($HOME or ~ do not work). rename the path to your case. you can also change given time. in the example it's approx. 10 minutes for image. extra.xml is text file so you can change it any time as you wish.

to start just open preferences > appearance (or click with mouse on the desktop) to change the desktop background. press the button +add and go to desired directory. to see xml file you should change type of file from image to all (look bottom of the frame). press and accept xml file. and done.

Image
(my xml file is in different directory than said above). you can see I have a few collections of slides. you can create as many as you wish.

the method is deterministic. the sequence of images is given in xml file. but to have a loop the last transition should goes from the last image to the first one. so if you want to have more or less files you should add or substruct some sections of the xml file. be carefull.

if you have many pictures with different names it takes a lot of time to prepare xml file. the file structure is known and quite obvious. so if you have more files it's up to you to create xml file. but it might be problem for somebody to generate xml file with given names of images from let say one directory.

all settings on backgrounds are kept in the xml file $HOME/.config/mate/backgrounds.xml. so if you want to change the name of your collection please look and change something between tags <name> and </name> respectively.

at the moment I'm using this method for changing wallpapers. works fine (I'm using mate 1.6 and hope it works for 1.4).

if anybody can improve the method or any further suggestions - always welcome.

cheers,
ride my bike,
User avatar
Maroman
 
Posts: 369
Joined: 02 Jun 2013, 09:17
Location: Warsaw Metropolitan Area, Poland

Re: wallpaper changer

Postby Maroman » 28 Aug 2014, 17:19

hello girls and boys. vacations are almost over. it would be nice to see photos from vacations as slide show in the background. the only problem is to prepare background xml file to determine the slide show sequence. once I found (sorry at the moment I do not remember its source) bash script for building the xml file. I've modified it a bit and here you are
Code: Select all
#!/bin/bash

#
#script generates background-1.xml set for gnome/mate slideshow
#

# IFS parameter backup
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")

FILE="background-1.xml"
DURATION=895.0
TRANSITION=5.0

# Random order
IMGS=($(ls *.{jpg,jpeg,png,gif,JPG,JPEG,PNG,GIF} 2>/dev/null | sort -R))
COUNTER=`expr ${#IMGS[*]} - 1`
CURRENTDIR=$(pwd)

echo "<background><starttime><year>$(date +%Y)</year><month>$(date +%m)</month><day>$(date +%d)</day><hour>00</hour><minute>00</minute><second>00</second></starttime>" > $FILE


for ((i=0; i<$COUNTER; ++i))
do
    echo "<static><duration>$DURATION</duration><file>$CURRENTDIR/${IMGS[$i]}</file></static>" >> $FILE
    echo "<transition><duration>$TRANSITION</duration><from>$CURRENTDIR/${IMGS[$i]}</from>" >> $FILE
    echo "<to>$CURRENTDIR/${IMGS[`expr $i + 1`]}</to></transition>" >> $FILE
done

# last picture to first one to close the loop
echo "<static><duration>$DURATION</duration><file>$CURRENTDIR/${IMGS[$COUNTER]}</file></static>" >> $FILE
echo "<transition><duration>$TRANSITION</duration><from>$CURRENTDIR/${IMGS[$COUNTER]}</from>" >> $FILE
echo "<to>$CURRENTDIR/${IMGS[0]}</to></transition>" >> $FILE

echo "</background>" >> $FILE

# IFS parameter restore
IFS=$SAVEIFS

you can change file name, times (duration, transition) sorting method as you wish. let say the text file with the above content is called background. next please copy the file to /usr/local/bin directory and make it executable
Code: Select all
sudo chmod +x /usr/local/bin/background

in this way there is application in your system for generating background-1.xml file in given directory.
if we have pictures in one directory, let say /media/depot/Pictures/space then
Code: Select all
cd /media/depot/Pictures/space
background

and /media/depot/Pictures/space/background-1.xml is created (pictures are given i random order). the script is quite fast, think takes a second to generate xml file for 500 photos. however starttime markup content is not essential I'm using it for setting file version.
now by changing desktop background option, xml file can be chosen and slide show starts. enjoy.

cheers,
ride my bike,
User avatar
Maroman
 
Posts: 369
Joined: 02 Jun 2013, 09:17
Location: Warsaw Metropolitan Area, Poland


Return to MATE Desktop

Who is online

Users browsing this forum: No registered users and 1 guest

cron