wok-6.x view xpenguins/stuff/xpenguins.sh @ rev 20875

updated erlang (R15B01 -> 21.2.5)
author Hans-G?nter Theisgen
date Sat Feb 23 15:57:08 2019 +0100 (2019-02-23)
parents
children 02c70d036ea0
line source
1 #!/bin/sh
2 icon=--window-icon=/usr/share/pixmaps/xpenguins.png
3 toons=$(xpenguins -l | yad --list --title="xpenguins settings (1/2)" $icon \
4 --text="Select all the toons you want to display" --height=330 \
5 --column="Theme name" --multiple --separator='')
6 [ $? -eq 0 ] || exit 1
7 [ -z $toons ] && toons=$(xpenguins -l)
8 themes=''
9 # double-quote theme names (some have spaces) then use xargs
10 while read theme ; do themes=$themes' -t "'$theme'"' ; done <<EOT
11 $toons
12 EOT
13 settings=$(LC_NUMERIC=C yad --form --title="xpenguins settings (2/2)" $icon \
14 --field="Animation update delay (ms) (0 = default)":NUM \
15 --field="Number of toons (-1 = default)":NUM \
16 --field="Ignore popup windows":CHK --field="Don't show any blood":CHK \
17 --field="Don't show any angel":CHK \
18 --field="Destroy toons with mouseclick":CHK \
19 --field="Duration (min) (0 = unlimited)":NUM \
20 -- '0' '-1!-1..256' false false false true 0)
21 [ $? -eq 0 ] || exit 2
22 pid1=$(pgrep -fl 'spacefm --desktop'|cut -f1 -d' ')
23 pid2=$(pgrep -fl 'pcmanfm --desktop'|cut -f1 -d' ')
24 [ -n "$pid1" -o -n "$pid2" ] && yad --title=Warning $icon \
25 --text="Your file manager windows will be closed, and your desktop icons \
26 temporarily removed. Continue?"
27 [ $? -eq 0 ] || exit 3
28 [ -n "$pid1" ] && kill $pid1
29 [ -n "$pid2" ] && kill $pid2
30 #add dummy var to gobble last |
31 IFS='|' read delay number nopopup noblood noangel squish duration dummy<<EOT
32 $settings
33 EOT
34 flags=''
35 [ $nopopup == TRUE ] && flags=$flags" -p"
36 [ $noblood == TRUE ] && flags=$flags" -b"
37 [ $noangel == TRUE ] && flags=$flags" -a"
38 [ $squish == TRUE ] && flags=$flags" -s"
39 printf '%s' "$themes" | xargs xpenguins -m ${delay%.*} -n ${number%.*} $flags \
40 >/dev/null 2>&1 &
41 yad --button=gtk-stop --title='Stop xpenguins' $icon \
42 --timeout=$((60*${duration%.*}))
43 pkill -x xpenguins
44 alias pcmanfm='pcmanfm --desktop 2>/dev/null &'
45 alias spacefm='spacefm --desktop 2>/dev/null &'
46 # restart filemanager(s)
47 if [ -n "$pid1" ]; then
48 if [ -n "$pid2" ]; then
49 # in case both were running
50 if [ $pid1 -lt $pid2 ]; then
51 spacefm
52 pcmanfm
53 else
54 pcmanfm
55 spacefm
56 fi
57 else
58 spacefm
59 fi
60 elif [ -n "$pid2" ]; then
61 pcmanfm
62 fi