-
-
Save bashbunni/f6b04fc4703903a71ce9f70c58345106 to your computer and use it in GitHub Desktop.
# I'll be doing another one for Linux, but this one will give you | |
# a pop up notification and sound alert (using the built-in sounds for macOS) | |
# Requires https://github.com/caarlos0/timer to be installed | |
# Mac setup for pomo | |
alias work="timer 60m && terminal-notifier -message 'Pomodoro'\ | |
-title 'Work Timer is up! Take a Break π'\ | |
-appIcon '~/Pictures/pumpkin.png'\ | |
-sound Crystal" | |
alias rest="timer 10m && terminal-notifier -message 'Pomodoro'\ | |
-title 'Break is over! Get back to work π¬'\ | |
-appIcon '~/Pictures/pumpkin.png'\ | |
-sound Crystal" |
I like this configuration π try it
firstly install tool
brew install terminal-notifier
brew install caarlos0/tap/timer
Mac setup for pomodoro
add alias in your ".zshrc" file
alias work="timer 60m && say 'Mola verme zamanΔ± dostum! Kalk ve biraz yΓΌrΓΌyΓΌΕe Γ§Δ±k! Biraz su iΓ§!' \
&& terminal-notifier -message 'Pomodoro'\
-title 'Work Timer is up! Take a Break π'\
-appIcon 'http://vjeantet.fr/images/logo.png' \
-sound Crystal"
alias rest="timer 10m && say 'Mola bitti, hadi ders Γ§alΔ±Εma zamanΔ±' \
&& terminal-notifier -message 'Pomodoro'\
-title 'Break is over! Get back to work π¬'\
-appIcon 'http://vjeantet.fr/images/logo.png' \
-sound Crystal"
then call on your terminal like "work" or "rest"
This is great! How can I make this auto start work and auto start rest?
I test using this code. When I runwork
command, the terminal auto executerest
command. But after the rest timer is up, thework
command isn't execute. Vice versa when I runrest
command first.
alias work="timer 5s && terminal-notifier -message 'Timer is up! Take a Break' && rest -title 'Work Timer is up! Take a Break π' -appIcon '/Pictures/tomato.png' -sound Crystal"/Pictures/tomato.png' -sound Crystal"
alias rest="timer 10s && terminal-notifier -message 'Break is over! Get back to work' && work -title 'Break is over! Get back to work π¬' -appIcon 'Hey i just made a function:
pomo(){ echo "How many rounds you want to do?" read count; for i in {1..$count}; do work; sleep 1; rest; done }hope it solves your problem. just type the function name in the terminal: here -> pomo Oh, and put the code under the two alias!
*Thanks at @nayakayp for finding the lost bracket π
Thank you so much for this, it's just what I needed!
I managed to get the script working, but at the end of the timer, the notification does not show up. I've installed the terminal-notifier using homebrew, but it doesn't appear to be show up. The timer just counts down and displays "finished" on the terminal. Any suggestions on how to fix this?
@kimmy2611 go to Systems Preferences > Notifications > then make sure that terminal-notifier is allowed to send notifications with sounds, banners, etc
@kimmy2611 go to Systems Preferences > Notifications > then make sure that terminal-notifier is allowed to send notifications with sounds, banners, etc
Oh I overlooked that! Thank you for the help!
Also check that macOS is allowing terminal-notifier
to run. At first when I ran terminal-notifier
from iTerm 2, it wouldn't create notifications. I'm not sure exactly how I got it to show notifications but I think I first got it to run in Terminal, and then notifications worked when I ran the command from iTerm 2.
@kimmy2611 go to Systems Preferences > Notifications > then make sure that terminal-notifier is allowed to send notifications with sounds, banners, etc
I'm running into the same problem but I have checked that Notifications have been enabled for terminal-notifier...anything else that could be causing this?
@kimmy2611 go to Systems Preferences > Notifications > then make sure that terminal-notifier is allowed to send notifications with sounds, banners, etc
I'm running into the same problem but I have checked that Notifications have been enabled for terminal-notifier...anything else that could be causing this?
It's a mess. My weird fix was to install via brew (wasn't working correctly like yours even with Notifications enabled), download the binary from the repo and put the app in Applications - which triggered it to work. Then I brew uninstalled it, removed the app, and reinstalled again, now it works .... Made sure the Notifications are enabled after all that - macos might do a banner pop up for you to enable it.
Super helpful, thanks for posting this.
If it's helpful to anyone, I edited the alias to instead run as a bash script so we can turn on/off focus mode easily, including turning it off when exiting the program early. I also added a time arg but it defaults to whatever you time you write in the script (25m and 5m below):
#!/bin/bash
# Function for work mode
work() {
local duration=${1:-25m} # Default to 5 minutes if no argument is provided
macos-focus-mode enable
timer "$duration"
macos-focus-mode disable
osascript -e 'display notification "β" with title "Work Timer is up!" subtitle "Take a Break π" sound name "Crystal"'
}
# Function for rest mode
rest() {
local duration=${1:-5m} # Default to 10 minutes if no argument is provided
timer "$duration"
osascript -e 'display notification "β" with title "Break is over" subtitle "Back to work, loser δ·" sound name "Crystal"'
}
# Trap to disable focus mode when script exits
trap 'macos-focus-mode disable' EXIT
# Main script logic
case "$1" in
work)
work "$2"
;;
rest)
rest "$2"
;;
*)
echo "Usage: $0 {work|rest} [time]"
exit 1
;;
esac
You don't need to install
terminal-notifier
if you don't want to. You can trigger notifications on osx with applescriptosascript -e 'display notification "β" with title "Work Timer is up!" subtitle "Take a Break π" sound name "Crystal"'
but how would i combine this with the alias, cause then there are 3 layers of strings?
You don't need to install
terminal-notifier
if you don't want to. You can trigger notifications on osx with applescriptosascript -e 'display notification "β" with title "Work Timer is up!" subtitle "Take a Break π" sound name "Crystal"'
but how would i combine this with the alias, cause then there are 3 layers of strings?
ok you would have to escape it like this: " -> so in the rc-file it would look like this:
alias work="timer 50m && osascript -e 'display notification \"β\" with title \"Work Timer is up!\" subtitle \"Take a Break π\" sound name \"Crystal\"'"
i've been playing around and attempting to add a time input, but it doesnt recognize an argument. I've looked over my other alias and have no issues with adding an argument.
alias work="timer $1 && osascript -e 'display notification \"β\" with title \"Work Timer is up!\" subtitle \"Take a Break π\" sound name \"Crystal\"' && say \"Phase complete\""
i've been playing around and attempting to add a time input, but it doesnt recognize an argument. I've looked over my other alias and have no issues with adding an argument.
alias work="timer $1 && osascript -e 'display notification \"β\" with title \"Work Timer is up!\" subtitle \"Take a Break π\" sound name \"Crystal\"' && say \"Phase complete\""
alias work='work_alias(){ timer "$1" && osascript -e "display notification \"β\" with title \"Work Timer is up!\" subtitle \"Take a Break π\" sound name \"Crystal\"" && say "Phase complete"; unset -f work_alias; }; work_alias'
this works for me
It worked!
Can you edit the code because it needs a closing bracket. Maybe others will face the problem if you don't edit it
Thank You!