Recently I had a customer who had heavily invested in using their PC screensaver to deliver information to their employees. They were using static images, much like presentation slides, to inform about Program web sites, nice tips and tricks, and even a few jokes.

This was an informal way to remind folks about happenings around the office.

They were interested in doing a Sun Ray pilot displaying full screen Windows. They wanted the ability for the DTUs to display this information when they were idle.

Fortunately, these folks were using cards for mobility, so I took the opportunity to write a little script to display these images when there was no card inserted. This is also a good method of displaying a welcome, or how-to message to users which could be a lot more useful then the Insert Card icon on the OSD.

I used the program xli (xloadimage) to load an image to the screen. This was a little tricky because in most CAM environments, there is a dtsession running which covers the root window with a fake root window so that things like right click on the background works.

You must install the xli binary which you can download from here:

I used a few tricks to figure out the window id and then use xli to load the new background. The first image is selected at random from the image directory, then the images are displayed in order from that point. The images are then looped. I have set a delay of 30 seconds between images.

Since both card and non-card sessions must use the same CAM script, There is a little bit of logic to determine if there is a card inserted. If there is no card, start displaying the images. If there is a card, launch the Sun Ray Connector for Windows.

Your images must be no larger than the smallest screen that you have deployed. I suggest either 1024x768 or 1280x1024 images.

You must also size your systems slightly differently. This method, as opposed to no access for non-card sessions, takes about 25mb per DTU to load dtsession and display the images. If your images are complex or quite large this can go up. There is virtually no load here, only a RAM requirement.

NOTE: Don't forget to change the image directory and the location of the xli binary in your script.

NOTE 2: At a minimum, your policy should allow CAM mode for non-card users. For example "/opt/SUNWut/sbin/utpolicy -a -g -k card -z both". My example below was written for CAM mode for all token types. See man utpolicy for more details.

NOTE 3: Ths images will display immediately upon session startup, but by default the screen will enter a low power state after 15 minutes of inactivity. Im my script below, I have changed the timeout using "xset" to never blank or standby

NOTE 4: There is a CAM script fallout time so that it will pick up any new images from the image directoy. It is set at 30 minutes by default.

#!/bin/bash

# Image Directory - images must have 3 letter extensions
IMAGEDIR=/opt/SUNWwbt/images
# Image display time in seconds
IMAGE_DELAY=30
# Set CAM timeout minutes
MIN_RESET_MIN=30
# xli binary location
XLI=/opt/SUNWwbt/bin/xli

XPROP=/usr/openwin/bin/xprop

# Convrt timeout to seconds
MIN_RESET_SEC=`expr $MIN_RESET_MIN \* 60`

# Capture start time in seconds
START_TIME=`perl -e 'print time(), "\n";'`

# Wait for dtsession to start
sleep 3

# Check if desktop or card session
case $SUN_SUNRAY_TOKEN in

# Non card, desktop-based token
pseudo.*)

    # Set sleep and blanking timeouts to 0
    /usr/openwin/bin/xset -dpms s off

    # Get Window Manager info id
    WM_INFO=`$XPROP -notype -root _MOTIF_WM_INFO | awk '{ print $4 }'`

    # Find Workspace 0 Window id
    WINID=`$XPROP -notype -id $WM_INFO | grep _INFO_ws0 | awk '{ print $9 }'| sed 's/\"//g'`

    # Generate list of image files
    IMAGES=(`find $IMAGEDIR -name \\*.???`)

    # Get Random number from 1 to number of images
    # Subtract 1 from max as arrays start at 0
    INDEX=$RANDOM
    let "MAX=${#IMAGES[*]} - 1"
    let "INDEX %= $MAX"

    while [ 1 ]; do
        if [ $INDEX -le $MAX ]; then
            $XLI -windowid $WINID -border white -center ${IMAGES[$INDEX]}
            let "INDEX = $INDEX + 1"
        else
            let "INDEX = 0"
        fi

        # Check elapsed time, if too long, break
	CURRENT_TIME=`perl -e 'print time(), "\n";'`
	ELAPSED_TIME=`expr $CURRENT_TIME - $START_TIME`
	if [ $ELAPSED_TIME -gt $MIN_RESET_SEC ]; then
	    break
	fi

        sleep $IMAGE_DELAY
    done
    ;;



# Card Based Session
*)
    /usr/openwin/bin/xset led 1 
    /opt/SUNWuttsc/bin/uttsc -m -b -r disk:USB=/tmp/SUNWut/mnt/$USER/ ts_server_name
    ;;

esac
		
Comments:

Hi There This is good, but where did you put the script and how did you call it.

Posted by Rodger on August 08, 2006 at 03:06 PM PDT #

This is a CAM script which decides whether or not to either launch the Windows Connector (RDP client) or to display inages in the background. I put the script in /opt/SUNWwbt/ and it was called by SRSS CAM as a critical application.

Posted by bhlackey on August 08, 2006 at 05:25 PM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed

This blog copyright 2009 by ThinGuy