[mythtv-users] Full screen time display, with screen on [SOLVED]

Dave M G martin at autotelic.com
Sat Mar 5 10:56:43 UTC 2011


Brian et al,

Disregard my last posting. Worked it out.

All I did to solve the issue I was having was reverse the if statement.
Now it tests on if the monitor is "Off", and if so, uses the ImageMagick
statement. Otherwise, it uses the aosd_cat command.

Works great! Whenever the monitor is on, it overlays the time on top of
whatever is being shown. When the monitor is off, it pops on, shows the
time, and then turns off.

Thanks so much for all your help, and I hope this script is of use to
others.

Time display script (final):

- - -

#!/bin/bash

# Script to display time on screen.
# Shows a full screen display when screen is off,
# shows time overlaid current interface when screen
# is off.

# Be careful of line breaks if copying and pasting
# the contents of this file.
# Make sure you have the necessary apps:
# sudo apt-get install qiv aosd_cat imagemagick


#Create the date string.
#Use 'tr' to insert a line feed to place date and time on separate lines
DATESTRING=`date +".%H:%M..%A.%B %d, %Y" | tr "." "\n"`

STATUS=`xset -q | grep "Monitor is" | awk '{print $3}'`

if [ "${STATUS}" = "Off" ]
then

#Define background image file location
BGFILE='/home/mythbuntu/.lirc/black_bg.jpg'

#Define clock image file location
CLOCKFILE='/home/mythbuntu/.lirc/black_clock.jpg'

#Get display width
WIDTH=`xdpyinfo | grep 'dimensions:' | awk '{print $2}' | cut -dx -f1`

#Get display height
HEIGHT=`xdpyinfo | grep 'dimensions:' | awk '{print $2}' | cut -dx -f2`

#Define text height as a function of display height
POINTSZ=$(echo $HEIGHT/6 | bc)

#Remove the background image file because 'convert' will auto increment
and not overwrite
rm -f $BGFILE

#Create a blank canvas
convert -size ${WIDTH}x${HEIGHT} xc:black $BGFILE

#Write date/time over blank canvas
convert -font ubuntu -fill white -pointsize $POINTSZ -draw 'text
100,200 "'"$DATESTRING"'"' $BGFILE $CLOCKFILE

xdotool key shift;
xset dpms force on;

#Display date/time image
qiv --fullscreen --scale_down -i $CLOCKFILE &

#Get procid
PID=$!

#Keep image on display for 5 seconds
sleep 5

xset dpms force off;

#Kill qiv to remove date/time image from display ('killall qiv' could
also be used)
kill -9 $PID

else

date +"%H:%M, %A %B, %d, %Y" | aosd_cat --font="Ubuntu 48"
--shadow-offset=1 --back-color=black --back-opacity=200 --position=4
--padding=32 --fore-color=white --lines=0 --fade-in=0 --fade-out=0
--lines=3 --age=1;
fi
exit 0

- - -

-- 
Dave M G


More information about the mythtv-users mailing list