Lucas
1 year ago
5 changed files with 263 additions and 2 deletions
@ -1,3 +1,20 @@ |
|||||
# remind |
# Remind |
||||
|
|
||||
A simple bash script to remind something by stipulated time. |
A simple bash script to remind something by stipulated time. |
||||
|
|
||||
|
## Install |
||||
|
|
||||
|
```bash |
||||
|
sh <(curl -s https://git.lucasf.dev/public/remind/raw/branch/master/install.sh) |
||||
|
``` |
||||
|
|
||||
|
## Usage |
||||
|
|
||||
|
Example of usage: |
||||
|
|
||||
|
```bash |
||||
|
remind do something cool |
||||
|
> Time to delay: 15m |
||||
|
``` |
||||
|
|
||||
|
The time can be (s|m|h) |
||||
|
Binary file not shown.
After Width: | Height: | Size: 184 KiB |
@ -0,0 +1,31 @@ |
|||||
|
#!/bin/sh |
||||
|
|
||||
|
main() { |
||||
|
local SOUNDDIR="$HOME/.local/share/sounds" |
||||
|
local ICONDIR="$HOME/.local/share/icons" |
||||
|
local CMDDIR="$HOME/.local/bin/" |
||||
|
|
||||
|
|
||||
|
if [[ ! -d "./remind" ]]; then |
||||
|
git clone https://git.lucasf.dev/public/remind > /dev/null 2>&1 |
||||
|
if [[ ! -d "$SOUNDDIR" ]]; then |
||||
|
mkdir -p "$SOUNDDIR" |
||||
|
fi |
||||
|
if [[ ! -d "$ICONDIR" ]]; then |
||||
|
mkdir -p "$ICONDIR" |
||||
|
fi |
||||
|
mv $(pwd)/remind/remind $CMDDIR |
||||
|
mv $(pwd)/remind/clock.svg $ICONDIR |
||||
|
mv $(pwd)/remind/beep.mp3 $SOUNDDIR |
||||
|
rm -rf $(pwd)/remind |
||||
|
else |
||||
|
echo -e "\033[31m[error]\nRemove the remind folder first.\n\033[0m" |
||||
|
exit 1 |
||||
|
fi |
||||
|
|
||||
|
} |
||||
|
|
||||
|
main |
||||
|
if [[ $? -eq 0 ]];then echo "Remind installed"; fi |
||||
|
|
||||
|
# vim: ft=bash:ts=4:sts=4:sw=4 |
@ -0,0 +1,64 @@ |
|||||
|
#!/bin/bash |
||||
|
|
||||
|
|
||||
|
CMD="cancel" |
||||
|
SOUND_LOCATION="$HOME/.local/share/sounds" |
||||
|
ICON_LOCATION="$HOME/.local/share/icons/clock.svg" |
||||
|
|
||||
|
_execute() { |
||||
|
if [[ $TIMECHOOSEN =~ ^[1-9]?[0-9](s|m|h)$ ]]; then |
||||
|
sleep $TIMECHOOSEN |
||||
|
notify-send -i $ICON_LOCATION "Reminder" "$MSG" |
||||
|
ffplay -nodisp -autoexit -hide_banner -loglevel error $SOUND_LOCATION/beep.mp3 |
||||
|
else |
||||
|
echo -e "\033[31m[error]\nThe time must be provided as the example: 10(s|m|h).\n\033[0m" |
||||
|
fi |
||||
|
} |
||||
|
|
||||
|
_parse() { |
||||
|
if [[ $@ == "$CMD" ]]; then |
||||
|
_pre_cancel |
||||
|
else |
||||
|
_remind $@ |
||||
|
fi |
||||
|
} |
||||
|
|
||||
|
_remind() { |
||||
|
MSG="$@" |
||||
|
|
||||
|
if [[ -z "$@" ]]; then |
||||
|
echo -e "\033[31m[error]\nProvide a remind text first.\n\033[0m" |
||||
|
else |
||||
|
read -p 'Time to delay: ' TIMECHOOSEN |
||||
|
if [[ -z "$TIMECHOOSEN" ]]; then |
||||
|
echo -e "\033[31m[error]\nProvide a time.\n\033[0m" |
||||
|
else |
||||
|
_execute $@ $TIMECHOOSEN & |
||||
|
fi |
||||
|
fi |
||||
|
} |
||||
|
|
||||
|
_pre_cancel() { |
||||
|
NUMOFLINES=$(pgrep -a remind | wc -l) |
||||
|
if [[ $NUMOFLINES -le 2 ]]; then |
||||
|
echo "No reminders to cancel" |
||||
|
else |
||||
|
_cancel |
||||
|
fi |
||||
|
} |
||||
|
|
||||
|
_cancel() { |
||||
|
pgrep -a remind | awk -F "remind" -v nl="$NUMOFLINES" '{ if (NR < (nl - 1)) { print "[" NR "]" $NF}}' |
||||
|
read -p "Please choose a number to cancel [1-$(($NUMOFLINES - 2))]: " CHOOSE |
||||
|
if [[ $CHOOSE =~ ^[1-9]?[0-9] ]]; then |
||||
|
if [[ $CHOOSE -le $(($NUMOFLINES - 2)) ]]; then |
||||
|
kill $(pgrep -a remind | awk -F " " -v op="$CHOOSE" '{ if (NR == op) { print $1}}') |
||||
|
else |
||||
|
echo -e "\033[31m[error]\nInvalid option.\n\033[0m" |
||||
|
fi |
||||
|
else |
||||
|
echo -e "\033[31m[error]\nInvalid option.\n\033[0m" |
||||
|
fi |
||||
|
} |
||||
|
|
||||
|
_parse $@ |
Loading…
Reference in new issue