Difference between revisions of "Use my own pictures in the Screen Saver"

From LinuxMCE
Jump to: navigation, search
(Setting an attribute from the command line: fixes hardcode in script)
 
(29 intermediate revisions by 5 users not shown)
Line 1: Line 1:
The photo screen saver does a great job and ensures that media is displayed all the time, even if you just happen to be listening to music.
+
{| align="right"
By default, the photos come from flickr and are downloaded regularly to your local drives.
+
  | __TOC__
 +
  |}
 +
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.
  
But it would be nice to use your own photos in this screen saver, perhaps alongside the flickr ones or perhaps as a replacement.
+
However, it is nice to use your own photos for the screen saver, either by themselves or alongside the flickr images.
  
This is a guide to do just that...
+
In the current version it's possible to select photos for the screensaver easily.
  
 +
*Goto the [[LinuxMCE Admin Website]]-->Files & Media -> Screensaver menu.
 +
 +
 +
The following sections are included for legacy reference only.
  
 
=== Background ===
 
=== Background ===
All media on your linuxMCE system is catalogued and stored in a database. The database allows for attributes to be stored for each media file.
+
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". By setting this attribute this picture will be used as one of the pictures for the Media Director Screen Saver.
+
 
Photos are selected by random from all the photos that exist with the "Screen Saver For MD" attribute set.
+
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;
 
There are a number of ways to set this attribute for individual files. They are;
Line 16: Line 25:
 
* Setting an attribute from the command line
 
* Setting an attribute from the command line
 
* Assigning a picture to the screen saver from the Orbiter
 
* Assigning a picture to the screen saver from the Orbiter
 
  
 
=== Setting an attribute from the web admin screens ===
 
=== Setting an attribute from the web admin screens ===
'''NOTE:  Pictures must be smaller than 1240 x 1240.    Hope this saves some a bit of fustration.  ''' 
 
There is a section on the web admin screens that allow the setting of attributes for media.
 
It is available under Files & Media -> Media Files Sync
 
  
The left hand window frame gives a tree view into the directory structure of home/public/data.
+
*Goto [[LinuxMCE Admin Website]]-->Files & Media--> Media Files Sync
 +
 
 +
*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.
 
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.
 
The right hand window frame gives a view of the files found and their status with relation to linuxMCE's database.
  
Firstly determine the pictures you wish to use, and locate them using the directory browser.
+
*Determine the pictures you wish to use, and locate them using the directory browser.
Then ensure that the files are ticked to indicate existing in both the database and on disk. If not then choose the type as 'LinuxMCE Pictures' and press the 'Add to database' button.
+
*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) associated with them.
+
  
Part of the details include any currently set attributes for the file, which you can choose to Edit or Remove.
+
*Once they are added to the database you should be able to select them and see the details (metadata) that are associated with them.
There is also a section to Add Attributes. Only attribute that have been associated with the particular file types can be selected from the drop down box.
+
:*Part of the details include any currently set attributes for the file, which you can choose to Edit or Remove.
''Note: If you do not see 'Screen Saver For MD' in this box then you will need to Associate the attribute.''
+
:*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.
+
:*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 and you should start to see your selected picture as one of the screen saver files.
+
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 ====
 
==== 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, who knows. Anyway, to associate it you will need to run the following piece of SQL to put the required association into the database.
+
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:
 
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:
Line 48: Line 55:
 
  mysql -u root -D pluto_media -N -e "INSERT into MediaType_AttributeType(EK_MediaType, FK_AttributeType, Identifier, CombineAsOne) values(7,30,0,1)"
 
  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
+
Do a [[quick reload router]] and then the attribute should show up in the dropdown box under add attributes.
 
+
''Note: If someone knows a better way to do this or can see some adverse side effects please update''
+
  
 
=== Setting an attribute from the command line ===
 
=== 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 to the right device. This is what the flickr.pl script uses to assign the downloaded files the right attributes.
+
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 flickr.pl 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).
The commands can be executed from anything that can send linuxMCE messages (including the web admin screens) but this method will utilise the MessageSend utility available from the linux command line.
+
  
You will need to firstly determine the full filename and path for the file you wish to set the attribute for.
+
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.
This method assumes that the file has already been sync'd with linuxMCE and exists in the data base.
+
  
The first command queries the database for the file ID of a particular filename.
+
You will need to determine the full filename and path for the file you wish to set the attribute for.
  
The second command assigns an attribute type/value to the returned file ID
+
*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 get to the linux command prompt
+
* Logon to your LinuxMCE Core and go to the Linux command prompt.
* execute the following command
+
* Execute the following command:
 
  /usr/pluto/bin/MessageSend dcerouter -targetType template -r -o 0 2 1 819 13 <pathtofile>
 
  /usr/pluto/bin/MessageSend dcerouter -targetType template -r -o 0 2 1 819 13 <pathtofile>
  
Substituting your full path to the file where is says <pathtofile>
+
Substitute the "full path to the file" where is says <pathtofile>. For example:
  
''eg: /usr/pluto/bin/MessageSend dcerouter -targetType template -r -o 0 2 1 819 13 /home/public/data/pictures/sample.jpg''
+
/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:
+
*You should get a response something like this:
 
  0:OK
 
  0:OK
 
  145:11392
 
  145:11392
Line 78: Line 82:
 
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.
 
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
+
*Now execute the following command:
 
  /usr/pluto/bin/MessageSend dcerouter -targetType template -r -o 0 2 1 391 145 <fileID> 122 30 5 "*"
 
  /usr/pluto/bin/MessageSend dcerouter -targetType template -r -o 0 2 1 391 145 <fileID> 122 30 5 "*"
  
Substituting the fileID that you just discovered where it says <fileID>
+
*Substitute the fileID that you just discovered where it says <fileID>. For example:
  
''eg: /usr/pluto/bin/MessageSend dcerouter -targetType template -r -o 0 2 1 391 145 11392 122 30 5 "*"''
+
/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
+
*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
 
Below is a simple script which takes all the jpg files in the current directory, resizes them
Line 97: Line 101:
 
  # Use this at your own risk.
 
  # Use this at your own risk.
 
   
 
   
  for FILE in `ls *.jpg` ; do
+
MAX_SIZE=1024 #don't set it bigger than 1240
 +
 +
  for FILE in `ls *.jpg *.JPG` ; do
 
     PWD=`pwd`
 
     PWD=`pwd`
     FILEID=`/usr/pluto/bin/MessageSend dcerouter -targetType template -r -o 0 2 1 819 13 $PWD/$FILE | tail -n 1 | sed -e 's/^.*://$
+
     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 }'`
 
     RES=`identify -verbose $FILE | head -n1 | awk '{ print $3 }'`
 
     WIDTH=`echo $RES | sed -e 's/x.*//g'`
 
     WIDTH=`echo $RES | sed -e 's/x.*//g'`
Line 106: Line 112:
 
     NEW_WIDTH=$WIDTH
 
     NEW_WIDTH=$WIDTH
 
     NEW_HEIGHT=$HEIGHT
 
     NEW_HEIGHT=$HEIGHT
     if [ $WIDTH ">" 1024 -o $HEIGHT ">" 1024 ] ; then
+
     if [ $WIDTH -gt $MAX_SIZE -o $HEIGHT -gt $MAX_SIZE ] ; then
         if [ $WIDTH ">" $HEIGHT ] ; then
+
         if [ $WIDTH -gt $HEIGHT ] ; then
             NEW_WIDTH=1024
+
             NEW_WIDTH=$MAX_SIZE
 
             NEW_HEIGHT=`expr $NEW_WIDTH "*" $HEIGHT "/" $WIDTH`
 
             NEW_HEIGHT=`expr $NEW_WIDTH "*" $HEIGHT "/" $WIDTH`
 
         else
 
         else
             NEW_HEIGHT=1024
+
             NEW_HEIGHT=$MAX_SIZE
 
             NEW_WIDTH=`expr $NEW_HEIGHT "*" $WIDTH "/" $HEIGHT`
 
             NEW_WIDTH=`expr $NEW_HEIGHT "*" $WIDTH "/" $HEIGHT`
 
         fi
 
         fi
 
     fi
 
     fi
 
   
 
   
    echo file id: $FILEID old dim: $RES : w $WIDTH : h $HEIGHT \-\> new dim: $NEW_WIDTH $NEW_HEIGHT
 
 
   
 
   
 
     if [ $WIDTH != $NEW_WIDTH -o $HEIGHT != $NEW_HEIGHT ] ; then
 
     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
 
         convert $FILE -resize ${NEW_WIDTH}x${NEW_HEIGHT}! resized_$FILE
 
         mv resized_$FILE $FILE
 
         mv resized_$FILE $FILE
 +
    else
 +
        echo file id: $FILEID old dim: $RES : w $WIDTH : h $HEIGHT
 
     fi
 
     fi
 
   
 
   
     echo /usr/pluto/bin/MessageSend dcerouter -targetType template -r -o 0 2 1 391 145 ${FILEID} 122 30 5 "*"
+
     /usr/pluto/bin/MessageSend dcerouter -targetType template -r -o 0 2 1 391 145 ${FILEID} 122 30 5 "*"
 
  done
 
  done
 +
 +
New simpler script for 0710 which does not resize the images:
 +
 +
#!/bin/bash
 +
 +
HOST=dcerouter
 +
 +
for FILE in `ls *.jpg` ; do
 +
    PWD=`pwd`
 +
    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 "*"
 +
done
 +
=== 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?
 +
* yes there is and the command is:
 +
/usr/pluto/bin/MessageSend $HOST -targetType template -o 0 1825 1 606'
  
 
=== Assigning a picture to the screen saver from the Orbiter ===
 
=== Assigning a picture to the screen saver from the Orbiter ===

Latest revision as of 12:34, 4 May 2014

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.

Background

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 flickr.pl 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:
0:OK
145:11392

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.

#!/bin/bash

# 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
    PWD=`pwd`
    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'`

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


    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
    else
        echo file id: $FILEID old dim: $RES : w $WIDTH : h $HEIGHT
    fi

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

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

#!/bin/bash

HOST=dcerouter

for FILE in `ls *.jpg` ; do
    PWD=`pwd`
    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 "*"
done

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?

  • yes there is and the command is:
/usr/pluto/bin/MessageSend $HOST -targetType template -o 0 1825 1 606'

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.