Use my own pictures in the Screen Saver

From LinuxMCE
Jump to: navigation, search

The photo screen saver does a great job in ensuring that media is displayed on the Media Station screen at all times, even if you just happen to be listening to music. By default, the photos come from flickr and are downloaded regularly to your local drive.

However, it is nice to use your own photos for the screen saver, either by themselves or alongside the flickr images.

In the current version it's possible to select photos for the screensaver easily.

The following sections are included for legacy reference only.


All media on a LinuxMCE system is catalogued and stored in a database. The database allows for attributes to be stored for each media file.

One such attribute is "Screen Saver For MD". If this attribute is set for a picture, it will be used as one of the pictures for the Media Director Screen Saver. Pictures must be smaller than 1240x1240px.

Photos are selected by random from all the photos with the "Screen Saver For MD" attribute set.

There are a number of ways to set this attribute for individual files. They are;

  • Setting an attribute from the web admin screens
  • Setting an attribute from the command line
  • Assigning a picture to the screen saver from the Orbiter

Setting an attribute from the web admin screens

  • The left hand window frame gives a tree view into the directory structure of home/public/data.

Typically photos will be stored under the pictures sub-directory. The right hand window frame gives a view of the files found and their status with relation to linuxMCE's database.

  • Determine the pictures you wish to use, and locate them using the directory browser.
  • Ensure that the files are ticked to indicate that they exist in both the database and on the disk. If not, then choose the type as 'LinuxMCE Pictures' and press the 'Add to database' button.
  • Once they are added to the database you should be able to select them and see the details (metadata) that are associated with them.
  • Part of the details include any currently set attributes for the file, which you can choose to Edit or Remove.
  • There is also a section to Add Attributes. Only attributes that have been associated with the particular file type can be selected from the drop down box.
  • Note: If you do not see 'Screen Saver For MD,' then 'Associate the attribute.'
  • Select the attribute 'Screen Saver For MD' and enter or select the Attribute name value of '*'. Then press the Add button next to the box and your done.

A quick reload router should be enough to ensure that files are refreshed from the database. The selected picture should then be seen to be one of the screen saver files.

Associate the attribute

The instructions in this section may be obsolete.

Unfortunately by default this attribute has not been associated with the picture media type. (Perhaps a bug?) To associate it you will need to run the following piece of SQL to put the required association into the database.

You will need to get to the command prompt of your CORE machine and from the command prompt (your default user should be fine) run:

mysql -u root -D pluto_media -N -e "INSERT into MediaType_AttributeType(EK_MediaType, FK_AttributeType, Identifier, CombineAsOne) values(7,30,0,1)"

Do a quick reload router and then the attribute should show up in the dropdown box under add attributes.

Setting an attribute from the command line

There is functionality built into the system that allows an attribute to be set through a sequence of Command Messages sent directly to the right device. This is the method the script uses to assign the downloaded files the right attributes. The commands can be executed from anything that sends LinuxMCE messages (including the LinuxMCE Admin Website screens).

This method utilises the MessageSend utility available from the Linux command line. This method assumes that the file has already been sync'd with LinuxMCE and already exists in the database.

You will need to determine the full filename and path for the file you wish to set the attribute for.

  • The first command queries the database for the file ID of a particular filename.

The second command assigns an attribute type/value to the returned file ID.

  • Logon to your LinuxMCE Core and go to the Linux command prompt.
  • Execute the following command:
/usr/pluto/bin/MessageSend dcerouter -targetType template -r -o 0 2 1 819 13 <pathtofile>

Substitute the "full path to the file" where is says <pathtofile>. For example:

/usr/pluto/bin/MessageSend dcerouter -targetType template -r -o 0 2 1 819 13 /home/public/data/pictures/sample.jpg
  • You should get a response something like this:

The number next to the '145:' is the important part. This is the fileID. If this is zero then your command has not found a match in the database and you may need to take other measures to ensure that the database is sync'd with your files.

  • Now execute the following command:
/usr/pluto/bin/MessageSend dcerouter -targetType template -r -o 0 2 1 391 145 <fileID> 122 30 5 "*"
  • Substitute the fileID that you just discovered where it says <fileID>. For example:
/usr/pluto/bin/MessageSend dcerouter -targetType template -r -o 0 2 1 391 145 11392 122 30 5 "*"
  • You can then repeat for any other files that you want to use

Below is a simple script which takes all the jpg files in the current directory, resizes them to a screensaver safe size, and then marks them as being usable by the screensaver. There is no error checking and it shrinks all the images in place, so make sure you make a copy of the images first and place them in another directory. Note: this would normally be run on a directory below /home/public/data/pictures.


# Copyright 2008 (c) Daniel Kristjansson
# You may use this for any purpose whatsoever, so long as you preserve the copyright notice.
# You may relicense this and add your own contributions freely.
# Use this at your own risk.

MAX_SIZE=1024 #don't set it bigger than 1240

for FILE in `ls *.jpg *.JPG` ; do
    FILEID=`/usr/pluto/bin/MessageSend dcerouter -targetType template -r -o 0 2 1 819 13 $PWD/$FILE | tail -n 1 | sed -e 's/^.*://g'`
    RES=`identify -verbose $FILE | head -n1 | awk '{ print $3 }'`
    WIDTH=`echo $RES | sed -e 's/x.*//g'`
    HEIGHT=`echo $RES | sed -e 's/.*x//g'`

    if [ $WIDTH -gt $MAX_SIZE -o $HEIGHT -gt $MAX_SIZE ] ; then
        if [ $WIDTH -gt $HEIGHT ] ; then
           NEW_HEIGHT=`expr $NEW_WIDTH "*" $HEIGHT "/" $WIDTH`
           NEW_WIDTH=`expr $NEW_HEIGHT "*" $WIDTH "/" $HEIGHT`

    if [ $WIDTH != $NEW_WIDTH -o $HEIGHT != $NEW_HEIGHT ] ; then
        echo file id: $FILEID old dim: $RES : w $WIDTH : h $HEIGHT \-\> new dim: $NEW_WIDTH $NEW_HEIGHT
        convert $FILE -resize ${NEW_WIDTH}x${NEW_HEIGHT}! resized_$FILE
        mv resized_$FILE $FILE
        echo file id: $FILEID old dim: $RES : w $WIDTH : h $HEIGHT

    /usr/pluto/bin/MessageSend dcerouter -targetType template -r -o 0 2 1 391 145 ${FILEID} 122 30 5 "*"

New simpler script for 0710 which does not resize the images:



for FILE in `ls *.jpg` ; do
    FILEID=`/usr/pluto/bin/MessageSend $HOST -targetType template -r -o 0 2 1 819 13 $PWD/$FILE | tail -n 1 | sed -e 's/^.*://g'`
    echo file id: $FILEID old dim: $RES : w $WIDTH : h $HEIGHT
    /usr/pluto/bin/MessageSend $HOST -targetType template -r -o 0 2 1 391 145 ${FILEID} 122 30 5 "*"

Reload the Screen Saver

After adding the photos you might want to reload the screen saver. You can do this from the web interface by going to the Files & Media >> Screen Saver page. I would like the option to do this from the command line at the end of my script adding the photos, is there a command line command to reload the screen saver?

Assigning a picture to the screen saver from the Orbiter

Sounds like a good idea??? Unfortunately it is not currently possible, but I thought that this sounded like a logical thing to do so have put this placeholder in.

Essentially, screens in the Orbiter have buttons that trigger message Command to be sent. So setting up a button in the Picture view screen "add to Screen Saver" should be quite straight forward.

If you feel like getting involved maybe this is somewhere you can start.....

NOTE: Pictures must be smaller than 1240 x 1240. Hope this saves some a bit of fustration.