wok annotate xsnow/stuff/xsnow.sh @ rev 18814

Add GUI to xsnow and xpenguins
author Lucas Levrel <llevrel@yahoo.fr>
date Thu Jan 14 22:11:10 2016 +0100 (2016-01-14)
parents
children 36d70656dfc2
rev   line source
llevrel@18814 1 #!/bin/sh
llevrel@18814 2 icon=--window-icon=/usr/share/pixmaps/xsnow.png
llevrel@18814 3 # egrep -v '[A-Z]|gray|[0-9]$' /usr/share/X11/rgb.txt |cut -f 3 |tr '\n' '!'
llevrel@18814 4 colors='snow!ghost white!white smoke!gainsboro!floral white!old lace!linen!antique white!papaya whip!blanched almond!bisque!peach puff!navajo white!moccasin!cornsilk!ivory!lemon chiffon!seashell!honeydew!mint cream!azure!alice blue!lavender!lavender blush!misty rose!white!black!dark slate grey!dim grey!slate grey!light slate grey!grey!light grey!midnight blue!navy!navy blue!cornflower blue!dark slate blue!slate blue!medium slate blue!light slate blue!medium blue!royal blue!blue!dodger blue!deep sky blue!sky blue!light sky blue!steel blue!light steel blue!light blue!powder blue!pale turquoise!dark turquoise!medium turquoise!turquoise!cyan!light cyan!cadet blue!medium aquamarine!aquamarine!dark green!dark olive green!dark sea green!sea green!medium sea green!light sea green!pale green!spring green!lawn green!green!chartreuse!medium spring green!green yellow!lime green!yellow green!forest green!olive drab!dark khaki!khaki!pale goldenrod!light goldenrod yellow!light yellow!yellow!gold!light goldenrod!goldenrod!dark goldenrod!rosy brown!indian red!saddle brown!sienna!peru!burlywood!beige!wheat!sandy brown!tan!chocolate!firebrick!brown!dark salmon!salmon!light salmon!orange!dark orange!coral!light coral!tomato!orange red!red!hot pink!deep pink!pink!light pink!pale violet red!maroon!medium violet red!violet red!magenta!violet!plum!orchid!medium orchid!dark orchid!dark violet!blue violet!purple!medium purple!thistle!dark grey!dark blue!dark cyan!dark magenta!dark red!light green'
llevrel@18814 5 settings=$(LC_NUMERIC=C yad --form --columns=2 --title="xsnow settings" $icon \
llevrel@18814 6 --field="Number of snowflakes":NUM \
llevrel@18814 7 --field="Snow color":CB --field="Set background color":CHK \
llevrel@18814 8 --field="Background color":CB --field="Christmas trees color":CB \
llevrel@18814 9 --field="Santa Claus's size":NUM --field="Sleigh speed (-1 = default)":NUM \
llevrel@18814 10 --field="Sleigh refresh factor 1/":NUM --field="Snow update delay (ms)":NUM \
llevrel@18814 11 --field="Smooth snow movement":CHK --field="Snow whirling speed (max)":NUM \
llevrel@18814 12 --field="Snow drifting speed (max)":NUM \
llevrel@18814 13 --field="Snow falling speed (max)":NUM \
llevrel@18814 14 --field="Windy periods":CHK --field="Windy periods interval (s)":NUM \
llevrel@18814 15 --field="Maximal snow depth on windows":NUM \
llevrel@18814 16 --field="Maximal snow depth on screen bottom":NUM \
llevrel@18814 17 --field="Vertical offset of snow layers":NUM \
llevrel@18814 18 --field="Christmas trees":CHK --field="Santa Claus":CHK --field="Rudolf":CHK \
llevrel@18814 19 --field="Snow layers on windows":CHK \
llevrel@18814 20 --field="Snow layer on screen bottom":CHK \
llevrel@18814 21 --field="Check this if snow layering doesn't work":CHK \
llevrel@18814 22 --field="Duration (min) (0 = unlimited)":NUM \
llevrel@18814 23 -- '100!1..1000' "$colors" 'true' SkyBlue3\!"$colors" \
llevrel@18814 24 chartreuse\!"${colors/chartreuse/}" '2!0..2' '-1!-1..inf' '3!1..inf' \
llevrel@18814 25 50 true 3 2 '10!1..inf' true 30 15 50 0 true true true true true false 0)
llevrel@18814 26 [ $? -eq 0 ] || exit 1
llevrel@18814 27 pid1=$(pgrep -fl 'spacefm --desktop'|cut -f1 -d' ')
llevrel@18814 28 pid2=$(pgrep -fl 'pcmanfm --desktop'|cut -f1 -d' ')
llevrel@18814 29 [ -n "$pid1" -o -n "$pid2" ] && yad --title=Warning $icon \
llevrel@18814 30 --text="Your file manager windows will be closed, and your desktop icons \
llevrel@18814 31 temporarily removed. Continue?"
llevrel@18814 32 [ $? -eq 0 ] || exit 2
llevrel@18814 33 [ -n "$pid1" ] && kill $pid1
llevrel@18814 34 [ -n "$pid2" ] && kill $pid2
llevrel@18814 35 # add dummy var to gobble last |
llevrel@18814 36 IFS='|' read sf sc back bc tc ssiz ssp suf delay smooth wf xs ys wind wtimer \
llevrel@18814 37 winsd scrsd off trees santa rud winsn scrsn popupsn duration dummy<<EOT
llevrel@18814 38 $settings
llevrel@18814 39 EOT
llevrel@18814 40 [ $back == FALSE ] && back=''
llevrel@18814 41 flags=''
llevrel@18814 42 [ $smooth == FALSE ] && flags=$flags" -unsmooth"
llevrel@18814 43 [ $wind == FALSE ] && flags=$flags" -nowind"
llevrel@18814 44 [ $trees == FALSE ] && flags=$flags" -notrees"
llevrel@18814 45 [ $santa == FALSE ] && flags=$flags" -nosanta"
llevrel@18814 46 [ $rud == FALSE ] && flags=$flags" -norudolf"
llevrel@18814 47 if [ $winsn == FALSE -a $scrsn == FALSE ]; then flags=$flags" -nokeepsnow"
llevrel@18814 48 elif [ $winsn == FALSE ]; then flags=$flags" -nokeepsnowonwindows"
llevrel@18814 49 elif [ $scrsn == FALSE ]; then flags=$flags" -nokeepsnowonscreen"
llevrel@18814 50 fi
llevrel@18814 51 [ $popupsn == TRUE ] && flags=$flags" -nonopopup"
llevrel@18814 52 xsnow -snowflakes ${sf%.*} -sc "$sc" ${back:+-solidbg -bg "$bc"} -tc "$tc" \
llevrel@18814 53 -santa ${ssiz%.*} -santaspeed ${ssp%.*} -santaupdatefactor ${suf%.*} \
llevrel@18814 54 -delay ${delay%.*} -whirl ${wf%.*} -xspeed ${xs%.*} -yspeed ${ys%.*} \
llevrel@18814 55 -windtimer ${wtimer%.*} -wsnowdepth ${winsd%.*} -ssnowdepth ${scrsd%.*} \
llevrel@18814 56 -offset ${off%.*} $flags >/dev/null 2>&1 &
llevrel@18814 57 yad --button=gtk-stop --title='Stop xsnow' $icon \
llevrel@18814 58 --timeout=$((60*${duration%.*}))
llevrel@18814 59 pkill -x xsnow
llevrel@18814 60 alias pcmanfm='pcmanfm --desktop 2>/dev/null &'
llevrel@18814 61 alias spacefm='spacefm --desktop 2>/dev/null &'
llevrel@18814 62 # restart filemanager(s)
llevrel@18814 63 if [ -n "$pid1" ]; then
llevrel@18814 64 if [ -n "$pid2" ]; then
llevrel@18814 65 # in case both were running
llevrel@18814 66 if [ $pid1 -lt $pid2 ]; then
llevrel@18814 67 spacefm
llevrel@18814 68 pcmanfm
llevrel@18814 69 else
llevrel@18814 70 pcmanfm
llevrel@18814 71 spacefm
llevrel@18814 72 fi
llevrel@18814 73 else
llevrel@18814 74 spacefm
llevrel@18814 75 fi
llevrel@18814 76 elif [ -n "$pid2" ]; then
llevrel@18814 77 pcmanfm
llevrel@18814 78 fi