#!/bin/sh
# 2010, 2014 by Paul Sherman...
# hacked-up version of xlock script by
# Barry Kauler 2005,2006 GPL www.pupweb.org

conf_file="$HOME/XLock"
PARAM1="$1"
oldline=`grep "^XLock.mode:" $conf_file`
CURRMODE=`echo $oldline | cut -d ":" -f2`

#CURRMODE=`grep "^XLock.mode:" $conf_file | cut -d ":" -f2`
PRETEXT="\"		This window is for choosing the image 			
		(mode) for the system screen locker.

    After previewing, click the OK button for one you want...\""

export MAINDIALOG="<window title=\"Xlock: current mode is $CURRMODE\" icon_name=\"system-lock-screen\" width_request=\"410\" height_request=\"500\">
<vbox>
<text use_markup=\"true\"><label>$PRETEXT</label>
</text>
  <tree>
   <label>Mode | Description</label>
   <variable>MODE</variable>
   <height>300</height>
   <item>blank | black screen</item>
   <item>pyro2 | Fireworks display</item>
   <item>strange| Strange attractors</item>
   <item>galaxy | Crashing spiral galaxies</item>
   <item>drift | Cosmix drifting flame fractals</item>
   <item>dclock | Floating digital clock</item>
   <item>eyes | Colorful eyes following character</item>
   <item>fadeplot | Snake-like plot of sine squared</item>
   <item>fiberlamp | Fiber optic lamp</item>
   <item>lightning | Lightning bolts on black</item>
   <item>laser | Spinning lasers</item>
   <item>matrix | Matrix streaming characters</item>
   <item>munch | Munching squares devour screen</item>
   <item>pacman | Pacman on autoplay</item>           
   <item>space | Journey into space</item>
   <item>swarm | Swarming things that look alive</item>
   <item>xjack | Jack having a bad day</item>
  </tree>
<hbox>
<button>
<input file icon=\"image-x-generic\"></input>
<label>Preview</label>
<action>xlock -inwindow -mode \$MODE 2>/dev/null</action>
</button>
<button cancel><action>exit:abort</action></button>
<button ok></button>
</hbox>
</vbox>
</window>
"
gtkdialog --center --program MAINDIALOG > $HOME/.config/xlocktmp
. $HOME/.config/xlocktmp
rm -f $HOME/.config/xlocktmp
[ "$EXIT" = "abort" ] && exit 0

#paranoid precaution...
if [ "`echo "$MODE" | grep --extended-regexp "strange|galaxy|drift|eyes|fadeplot|fiberlamp|lightning|matrix|laser|munch|dclock|pacman|pyro2|space|swarm|xjack|blank"`" = "" ];then
MODE="$CURRMODE"
fi

newline="XLock.mode: $MODE"
sed -i "s%$oldline%$newline%" $conf_file
exit 0



