~anjan/sxmo-userscripts

ref: 0541bd1d23e30cac3b71f06b65994675bde9a00c sxmo-userscripts/workout/workout.sh -rwxr-xr-x 2.6 KiB
0541bd1dBaroque0 improved my_photos.sh with a thumbnails view (in practice two separate windows, one for the thumbnails and one for the picture.). also enforced that rotation, using < and > be automatically saved in place of original image. (requires libjpeg-turbo-tools for jpegtran) 6 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/bin/sh
DATA_FOLDER=~/Documents/workout
MAXES_FILE=$DATA_FOLDER/_maxes.tsv
TODAY_WORKOUT=$DATA_FOLDER/$(date +'%Y-%m-%d').tsv

SMALLEST_WEIGHT="5"

getTrainingMax() {
    excersize=$1
    echo "$(grep $excersize $MAXES_FILE | cut -f2) * 0.9" | bc
}

getWeekNum() {
    echo $((($(ls $DATA_FOLDER | wc -l) - 1) / 4))
}

supplementWeights() {
    TRAINING_MAX=$(getTrainingMax $1)
    PERCENTS=$(yes 0.5 | head -n 5 | tr '\r\n' ' ')

    echo "$(GetWeights "$PERCENTS" $1)"
}

GetWeights() {

    TRAINING_MAX=$(getTrainingMax $2)
    PERCENTS=$1
    WEIGHTS=""

    for PERCENT in $PERCENTS
    do
        # https://stackoverflow.com/questions/2395284/round-a-divided-number-in-bash
        prop=$(echo "(($PERCENT * $TRAINING_MAX + ($SMALLEST_WEIGHT / 2))/ $SMALLEST_WEIGHT) " | bc)
        curWeight=$(echo "$prop * $SMALLEST_WEIGHT" | bc)
        WEIGHTS="$WEIGHTS $curWeight"
    done

    echo $WEIGHTS
}

WorkoutWeights() {
    WARMUP_PERCENT="0.4 0.5 0.6"

    WEEK=$(getWeekNum)

    case $WEEK in
        0)
            WORKOUT_PERCENT="0.65 0.75 0.85";;
        1)
            WORKOUT_PERCENT="0.70 0.80 0.90";;
        2)
            WORKOUT_PERCENT="0.75 0.85 0.95";;
        3)
            WORKOUT_PERCENT="0.40 0.50 0.60";;
        *)
            echo "update your maxes" && exit 1;;
    esac

    PERCENTS="$WARMUP_PERCENT $WORKOUT_PERCENT"

    echo $(GetWeights "$PERCENTS" $1)
}

gui() {
    EXCERSIZE="$1"
    REPS="$2"
    WEIGHTS="$3"

    idx="$(seq -s ' ' 1 $(echo $WEIGHTS | wc -w))"

    for i in $idx;
    do
	    EXCER_NAME=$EXCERSIZE-$(echo "$WEIGHTS" | cut -d' ' -f$i)
	    OPTIONS="$(seq $(echo "$REPS" | cut -d' ' -f$i) -1 0)\ncancel"
	    REPS_DONE=$(echo -e "$OPTIONS" | dmenu -p $EXCER_NAME -l 10 -fn "Terminus-30" -wm)
	    [ $REPS_DONE = "cancel" ] && exit 0
	    echo -e "$EXCER_NAME\t$REPS_DONE" >> $TODAY_WORKOUT
	    sleep 1m
    done

}


    PRIMARY="overhead deadlift bench squat"
    SUPPLEMENT="bench squat overhead deadlift"

    ROUTINE_NUM=$(($(($(ls $DATA_FOLDER | wc -l) + 1)) % $(echo $PRIMARY | wc -w)))

    # TODO: Must increase weight automatically
    [ $(getWeekNum) -eq 3 ] && [ $ROUTINE_NUM -eq 4 ] && exit 1

    PRIMARY_EXCERSIZE=$(echo $PRIMARY | cut -d " " -f $ROUTINE_NUM)
    SUPPLEMENT_EXCERSIZE=$(echo $SUPPLEMENT | cut -d " " -f $ROUTINE_NUM)
    echo "$PRIMARY_EXCERSIZE"

    WEIGHTS=$(WorkoutWeights $PRIMARY_EXCERSIZE)
    REPS="5 5 3 5 5 5"

    SUP_REPS="10 10 10 10 10"
    SUP_WEIGHTS=$(supplementWeights $SUPPLEMENT_EXCERSIZE)
    echo "$REPS"
    echo "$PRIMARY_EXCERSIZE"
    echo "$WEIGHTS"

    gui "$PRIMARY_EXCERSIZE" "$REPS" "$WEIGHTS"
    gui "$SUPPLEMENT_EXCERSIZE" "$SUP_REPS" "$SUP_WEIGHTS"