summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/extra/clock19
-rwxr-xr-xbin/guiscripts/osurf-fill5
-rwxr-xr-xbin/menuscripts/pomo101
3 files changed, 63 insertions, 62 deletions
diff --git a/bin/extra/clock b/bin/extra/clock
index bd6efd2..6c5bfe0 100755
--- a/bin/extra/clock
+++ b/bin/extra/clock
@@ -1,12 +1,25 @@
#!/bin/sh
-clocks="${XDG_DATA_HOME:-$HOME}"/clocks.csv
+clocks="$HOME"/sync/share/clocks.csv
-if [ ! -f "$clocks" ]
-then
+# Create csv file with headers if not exist
+[ -f "$clocks" ] ||
printf 'start,end,message\n' > "$clocks"
+
+
+if [ "$1" = "-h" ]
+then
+ >&2 cat <<EOF
+usage: clock [OPTION]
+-h shows this help
+-p print clockings prettily
+
+With no option it will start clocking and prompt for a task.
+EOF
+ exit 1
fi
+
# print clocks file prettily
if [ "$1" = "-p" ]
then
diff --git a/bin/guiscripts/osurf-fill b/bin/guiscripts/osurf-fill
index 43af807..6ea8e7e 100755
--- a/bin/guiscripts/osurf-fill
+++ b/bin/guiscripts/osurf-fill
@@ -67,7 +67,7 @@ printf '%s : %s\n' "$username" "$password"
# Escape quotes and backslashes for javascript
javascript_escape() {
- printf '%s' "$1" | sed -s 's,['\''"\\\\],\\\\&,g'
+ printf '%s' "$1" | sed -s 's,['\''"\\\\],\\&,g'
}
js() {
@@ -99,15 +99,12 @@ cat <<EOF
input.focus();
input.value = "$(javascript_escape "$username")";
input.blur();
- console.log("user: $(javascript_escape "$username")")
}
if (input.type == "password" || input.name == "password" || input.autocomplete == "password" || input.id == "password" ) {
input.focus();
input.value = "$(javascript_escape "$password")";
input.blur();
- console.log("password: $(javascript_escape "$password")")
}
- console.log(input)
}
};
var forms = document.getElementsByTagName("form");
diff --git a/bin/menuscripts/pomo b/bin/menuscripts/pomo
index e8795e7..eb4c30b 100755
--- a/bin/menuscripts/pomo
+++ b/bin/menuscripts/pomo
@@ -1,78 +1,69 @@
#!/bin/sh
### FUNCTIONS
-notif() {
- herbe "pomo" "$1" &
- sleep 1
- pkill -SIGUSR1 herbe
+notif() {
+ herbe "pomo" "$1" &
+ sleep 1
+ pkill -SIGUSR1 herbe
}
-logn () { >&2 printf '%s\n' "$@"; }
-log () { >&2 printf '%s' "$@"; }
# Plays ringing sound
# Then wait for user input to start/end the break
-player_command()
-{
- >&2 printf ' > '
+player_command() {
+ printf >&2 ' > '
[ -r "$ringSound" ] || PLAYER=""
case "$PLAYER" in
- mpv) mpv --loop --msg-level=all=no "$ringSound" ;;
- "") head -n 1;;
- *) $PLAYER "$ringSound" ;;
+ mpv) mpv --loop --msg-level=all=no "$ringSound" ;;
+ "") head -n 1 ;;
+ *) $PLAYER "$ringSound" ;;
esac
}
# $1: time in minutes
# $2: msg for notification
-ring_ring()
-{
- logn "$(date '+%R') B $round"
+ring_ring() {
+ printf >&2 '%s B %s\n' "$(date '+%R')" "$round"
player_command
- herbe "pomo" "$2" &
- sleep "${1}m"
+ herbe "pomo" "$2" &
+ sleep "${1}m"
player_command
- >&2 printf '\n'
+ printf >&2 '\n'
}
-### PROGRAM
-main()
-{
- round="${1-0}"
- case "$round" in
- 0|1|2|3) ;;
- ring) ;;
- *) logn "Invalid \$round value." && exit 1 ;;
- esac
+### Program
- ringSound="${XDG_DATA_HOME:-$HOME/.local/share}"/pomo/ring.aac
- [ -r "$ringSound" ] && logn "ring: $ringSound"
+trap 'exit 1' INT
- if [ "$1" = "ring" ]
- then
- player_command
- exit
- fi
+round="${1:-0}"
+# args
+case "$round" in
+0 | 1 | 2 | 3) ;;
+ring) ;;
+*) printf >&2 'Invalid value: %s\n' "$round"; exit 1 ;;
+esac
- # Countdown
- for msg in "three" "two" "one"
- do notif "$msg"
- done
+ringSound="${XDG_DATA_HOME:-$HOME/.local/share}"/pomo/ring.aac
+[ -r "$ringSound" ] && printf >&2 'ring: %s\n' "$ringSound"
- while true
- do
- notif "START"
- logn "$(date '+%R') S $round"
- sleep 25m
- if [ "$round" -eq 3 ]
- then
- ring_ring 20 "GIGA BREAK TIME"
- round=0
- else
- ring_ring 5 "BREAK TIME"
- round=$((round+1))
- fi
- done
-}
+if [ "$1" = "ring" ]; then
+ player_command
+ exit
+fi
-trap 'exit 1' INT
-main "$@"
+# Countdown
+for msg in "three" "two" "one"; do
+ notif "$msg"
+done
+
+while true; do
+ notif "START"
+ printf >&2 '%s S %s\n' "$(date '+%R')" "$round"
+ sleep 25m
+ if [ "$round" -eq 3 ]; then
+ ring_ring 20 "GIGA BREAK TIME"
+ round=0
+ else
+ ring_ring 5 "BREAK TIME"
+ round=$((round + 1))
+ fi
+done