wok-next diff xpenguins/stuff/xpenguins.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
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/xpenguins/stuff/xpenguins.sh	Thu Jan 14 22:11:10 2016 +0100
     1.3 @@ -0,0 +1,62 @@
     1.4 +#!/bin/sh
     1.5 +icon=--window-icon=/usr/share/pixmaps/xpenguins.png
     1.6 +toons=$(xpenguins -l | yad --list --title="xpenguins settings (1/2)" $icon \
     1.7 +	--text="Select all the toons you want to display" --height=330 \
     1.8 +	--column="Theme name" --multiple --separator='')
     1.9 +[ $? -eq 0 ] || exit 1
    1.10 +[ -z $toons ] && toons=$(xpenguins -l)
    1.11 +themes=''
    1.12 +# double-quote theme names (some have spaces) then use xargs
    1.13 +while read theme ; do themes=$themes' -t "'$theme'"' ; done <<EOT
    1.14 +$toons
    1.15 +EOT
    1.16 +settings=$(LC_NUMERIC=C yad --form --title="xpenguins settings (2/2)" $icon \
    1.17 +	--field="Animation update delay (ms) (0 = default)":NUM \
    1.18 +	--field="Number of toons (-1 = default)":NUM \
    1.19 +	--field="Ignore popup windows":CHK --field="Don't show any blood":CHK \
    1.20 +	--field="Don't show any angel":CHK \
    1.21 +	--field="Destroy toons with mouseclick":CHK \
    1.22 +	--field="Duration (min) (0 = unlimited)":NUM \
    1.23 +	-- '0' '-1!-1..256' false false false true 0)
    1.24 +[ $? -eq 0 ] || exit 2
    1.25 +pid1=$(pgrep -fl 'spacefm --desktop'|cut -f1 -d' ')
    1.26 +pid2=$(pgrep -fl 'pcmanfm --desktop'|cut -f1 -d' ')
    1.27 +[ -n "$pid1" -o -n "$pid2" ] && yad --title=Warning $icon \
    1.28 +	--text="Your file manager windows will be closed, and your desktop icons \
    1.29 +temporarily removed. Continue?"
    1.30 +[ $? -eq 0 ] || exit 3
    1.31 +[ -n "$pid1" ] && kill $pid1
    1.32 +[ -n "$pid2" ] && kill $pid2
    1.33 +#add dummy var to gobble last |
    1.34 +IFS='|' read delay number nopopup noblood noangel squish duration dummy<<EOT
    1.35 +$settings
    1.36 +EOT
    1.37 +flags=''
    1.38 +[ $nopopup == TRUE ] && flags=$flags" -p"
    1.39 +[ $noblood == TRUE ] && flags=$flags" -b"
    1.40 +[ $noangel == TRUE ] && flags=$flags" -a"
    1.41 +[ $squish == TRUE ] && flags=$flags" -s"
    1.42 +printf '%s' "$themes" | xargs xpenguins -m ${delay%.*} -n ${number%.*} $flags \
    1.43 +	>/dev/null 2>&1 &
    1.44 +yad --button=gtk-stop --title='Stop xpenguins' $icon \
    1.45 +	--timeout=$((60*${duration%.*}))
    1.46 +pkill -x xpenguins
    1.47 +alias pcmanfm='pcmanfm --desktop 2>/dev/null &'
    1.48 +alias spacefm='spacefm --desktop 2>/dev/null &'
    1.49 +# restart filemanager(s)
    1.50 +if [ -n "$pid1" ]; then
    1.51 +	if [ -n "$pid2" ]; then
    1.52 +		# in case both were running
    1.53 +		if [ $pid1 -lt $pid2 ]; then
    1.54 +			spacefm
    1.55 +			pcmanfm
    1.56 +		else
    1.57 +			pcmanfm
    1.58 +			spacefm
    1.59 +		fi
    1.60 +	else
    1.61 +		spacefm
    1.62 +	fi
    1.63 +elif [ -n "$pid2" ]; then
    1.64 +	pcmanfm
    1.65 +fi