Rework timer script and timezone script to use $# checking/recursive call trick

master
Miles Alan 5 years ago
parent e84246021a
commit 9a16998e64
  1. 66
      scripts/appscripts/sxmo_timer.sh
  2. 21
      scripts/appscripts/sxmo_timermenu.sh
  3. 26
      scripts/core/sxmo_timezonechange.sh

@ -1,23 +1,51 @@
#!/usr/bin/env sh
timerrun() {
TIME=$(
echo "$@" |
sed 's#h#*60m#g'|
sed 's#m#*60s#g'|
sed 's#s#*1#g'|
sed 's# #+#g' |
bc
)
TIME=$(
echo "$@" |
sed 's#h#*60m#g'|
sed 's#m#*60s#g'|
sed 's#s#*1#g'|
sed 's# #+#g' |
bc
)
date1=$((`date +%s` + $TIME));
while [ "$date1" -ge `date +%s` ]; do
echo -ne "$(date -u --date @$(($date1 - `date +%s`)) +%H:%M:%S) \r";
sleep 0.1
done
echo "Done with $@"
date1=$((`date +%s` + $TIME));
while [ "$date1" -ge `date +%s` ]; do
echo -ne "$(date -u --date @$(($date1 - `date +%s`)) +%H:%M:%S) \r";
sleep 0.1
done
echo "Done with $@"
while :;
do notify-send "Done with $@";
sxmo_vibratepine 1000
sleep 0.5
done
}
while :;
do notify-send "Done with $@";
sxmo_vibratepine 1000
sleep 0.5
done
menu() {
pidof svkbd-sxmo || svkbd-sxmo &
TIMEINPUT="$(
echo -e "
1h
10m
9m
8m
7m
6m
5m
4m
3m
2m
1m
30s
Close Menu
" | awk 'NF' | awk '{$1=$1};1' | dmenu -p Timer -c -fn "Terminus-30" -l 20
)"
pkill svkbd-sxmo
[[ "Close Menu" == "$TIMEINPUT" ]] && exit 0
st -f Monospace-50 -e $0 timerrun $TIMEINPUT
}
[ $# -gt 0 ] && $@ || menu

@ -1,21 +0,0 @@
#!/usr/bin/env sh
pidof svkbd-sxmo || svkbd-sxmo &
TIMEINPUT="$(
echo "1h
10m
9m
8m
7m
6m
5m
4m
3m
2m
1m
30s
Close Menu" | dmenu -p Timer -c -fn "Terminus-30" -l 20
)"
pkill svkbd-sxmo
[[ "Close Menu" == "$TIMEINPUT" ]] && exit 0
st -f Monospace-50 -e sxmo_timer.sh $TIMEINPUT

@ -1,9 +1,21 @@
#!/usr/bin/env sh
T="$(
find /usr/share/zoneinfo -type f |
sed 's#^/usr/share/zoneinfo/##g' |
sort |
sxmo_dmenu_with_kb.sh -p Timezone -c -l 10 -fn Terminus-20 -i
)"
st -e sh -c 'sudo setup-timezone -z '$T' && echo 1 > /tmp/sxmo_bar && echo Timezone changed ok && read'
change() {
echo "Changing timezone to $1"
sudo setup-timezone -z "$1"
echo 1 > /tmp/sxmo_bar
echo Timezone changed ok
read
}
menu() {
T="$(
find /usr/share/zoneinfo -type f |
sed 's#^/usr/share/zoneinfo/##g' |
sort |
sxmo_dmenu_with_kb.sh -p Timezone -c -l 10 -fn Terminus-20 -i
)"
st -e "$0" change "$T"
}
[ $# -gt 0 ] && $@ || menu
Loading…
Cancel
Save