28cda06cba4a9fb93d2120b44c05103c9b0f7ed6
[xscreensaver] / driver / xscreensaver.kss.in
1 #!/bin/sh -
2
3 # script - "xscreensaver.kss"
4 #
5 # Author: Shane Smit <shane_smit@calderasystems.com>
6 #
7 # Modification History:
8 #  [08/23/1999] - Shane Smit: Creation
9 #
10 # Description:
11 #  This script file enables users to use XScreenSaver via the
12 #  KDE Display Properties. 
13
14 # Permission to use, copy, modify, distribute, and sell this software and its
15 # documentation for any purpose is hereby granted without fee, provided that
16 # the above copyright notice appear in all copies and that both that
17 # copyright notice and this permission notice appear in supporting
18 # documentation.  No representations are made about the suitability of this
19 # software for any purpose.  It is provided "as is" without express or 
20 # implied warranty.
21
22
23 # Locking is turned off by default.
24 lockmode="-no-lock-mode"
25
26 prefix="@prefix@"
27 exec_prefix="@exec_prefix@"
28 bindir="@bindir@"
29 hackdir="@HACKDIR@"
30
31 while [ -n "$1" ]; do
32   case "$1" in
33
34     -desc) 
35       # This is the name in the list box.
36       echo "XScreenSaver"
37       exit
38       ;;
39
40     -preview)
41       # This simply runs xflame in the preview window.  For this to be "real",
42       # it needs to run xscreensaver with a -window-id parameter for each hack.
43       # There are two ways to do this:
44       # 1) Hack xscreensaver to allow global parameters.
45       # 2) Hack xscreensaver to accept alternate setup files, and create one on
46       #    the fly here.
47       shift
48       $hackdir/xflame -delay 1 -window-id $1 &                       # Start new preview 
49       echo "$!" > $HOME/.kss-preview$1.pid.`hostname`                # Write PID 
50       wait $!                                                        # Wait for it to get killed
51       exit
52       ;;
53
54     -setup)
55       $bindir/xscreensaver -no-splash &            # daemon must be started
56       $bindir/xscreensaver-demo                    # or the setup will produce
57       kill $!                                      # a warning.
58       exit
59       ;;
60
61 # I don't know what "-test" was supposed to do, but I suspect the
62 # answer is "something stupid."  Also, it uses /tmp insecurely.
63 # So let's just comment it out, shall we?  -jwz, 10-Nov-2003.
64 #
65 #    -test)
66 #      # I was unable to grep stdout because xscreensaver nabs it. But I was able
67 #      # to output it to a file, and grep the file.
68 #      TEMP_FILE=/tmp/xsc.$RANDOM
69 #      $bindir/xscreensaver -no-splash -verbose -no-capture-stderr 2> $TEMP_FILE &
70 #      $bindir/xscreensaver-command -activate
71 #      while true; do
72 #        ExitNow=$(grep -E -c unblanking\|already $TEMP_FILE)
73 #        if [ $ExitNow != 0 ]; then
74 #          kill $!
75 #          rm $TEMP_FILE
76 #          exit
77 #        fi
78 #        sleep 1
79 #      done
80 #      exit     # It should never get this far.
81 #      ;;
82
83 #    -corners)
84 #      echo "Not yet supported"
85 #      ;;
86     -delay)
87       shift
88       timeout="-timeout $1"
89       ;;
90     -install)
91       Install="TRUE"
92       ;;
93     -lock)
94 #      if [ ! -f "/etc/shadow" ]; then      
95         lockmode="-lock-mode"
96 #      fi
97       ;;
98 #    -allow-root)
99 #      echo "Not yet supported"
100 #      ;;
101     -nice)
102       shift
103       Nice="-nice $1"
104       ;;
105 #    -inroot)
106 #      echo "Not yet supported"
107 #      ;;
108     *)
109       echo "Unknown parameter: $1"
110       ;;
111   esac
112   shift
113 done
114
115 if [ -n "$Install" ] ; then
116   PID_FILE=$HOME/.kss-install.pid.`hostname`
117   if [ -r "$PID_FILE" ] ; then
118     kill `cat $PID_FILE`                                # Kill old screensaver 
119   fi
120   echo "$$" > $PID_FILE                                 # Write PID of this script
121   $bindir/xscreensaver -no-splash $timeout $lockmode $Nice &    # Start XScreenSaver daemon
122   trap "kill $!" SIGTERM                                # Set these to kill the daemon
123   trap "kill $!" SIGKILL
124
125 # KDE sends SIGUSER1 to indicate the user has hit the "lock" button.
126   trap "$bindir/xscreensaver-command -lock" SIGUSR1
127
128   wait $!                                               # Do not exit, just wait for signals.
129
130 else
131   echo "Usage: ./xscreensaver.kss -install|-setup|-desc [-delay num] [-lock] [-nice num]"
132 #  echo "  -corners xxxx     Placing cursor in corner performs action:"
133 #  echo "                     x = i  no action (ignore)"
134 #  echo "                     x = s  save screen"
135 #  echo "                     x = l  lock screen"
136 #  echo "                    order: top-left, top-right, bottom-left, bottom-right"
137   echo "  -delay num        Amount of idle time before screen saver starts  (default 10min)"
138   echo "  -desc             Print the screen saver's description to stdout"
139   echo "  -install          Install screen saver"
140   echo "  -lock             Require password to stop screen saver"
141 #  echo "  -allow-root       Accept root password to unlock"
142   echo "  -nice num         Run with specified nice value"
143   echo "  -preview wid      Run in the specified XWindow"
144 #  echo "  -inroot           Run in the root window"
145   echo "  -setup            Setup screen saver"
146 #  echo "  -test             Invoke the screen saver immediately"
147 fi
148
149 # End of script - "xscreensaver.kss"