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

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

@ -1,5 +1,5 @@
#!/usr/bin/env sh #!/usr/bin/env sh
timerrun() {
TIME=$( TIME=$(
echo "$@" | echo "$@" |
sed 's#h#*60m#g'| sed 's#h#*60m#g'|
@ -21,3 +21,31 @@ while :;
sxmo_vibratepine 1000 sxmo_vibratepine 1000
sleep 0.5 sleep 0.5
done 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 #!/usr/bin/env sh
change() {
echo "Changing timezone to $1"
sudo setup-timezone -z "$1"
echo 1 > /tmp/sxmo_bar
echo Timezone changed ok
read
}
menu() {
T="$( T="$(
find /usr/share/zoneinfo -type f | find /usr/share/zoneinfo -type f |
sed 's#^/usr/share/zoneinfo/##g' | sed 's#^/usr/share/zoneinfo/##g' |
sort | sort |
sxmo_dmenu_with_kb.sh -p Timezone -c -l 10 -fn Terminus-20 -i sxmo_dmenu_with_kb.sh -p Timezone -c -l 10 -fn Terminus-20 -i
)" )"
st -e "$0" change "$T"
}
st -e sh -c 'sudo setup-timezone -z '$T' && echo 1 > /tmp/sxmo_bar && echo Timezone changed ok && read' [ $# -gt 0 ] && $@ || menu
Loading…
Cancel
Save