File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -299,6 +299,7 @@ fn run_app(terminal: &mut Terminal<CrosstermBackend<Stdout>>) -> Result<()> {
299299 }
300300
301301 if pomo. tick_1s ( ) {
302+ pomo. notify ( ) ;
302303 pomo. play_notification ( ) ;
303304 // Restore volume after a delay (notification lasts ~1.5s)
304305 let vol_handle = radio. volume_handle ( ) ;
Original file line number Diff line number Diff line change @@ -82,6 +82,31 @@ impl Pomodoro {
8282 ( secs / 60 , secs % 60 )
8383 }
8484
85+ pub fn notify ( & self ) {
86+ let ( title, body) = match self . mode {
87+ Mode :: Focus => ( "Time to focus" , "Focus session started. Let's go." ) ,
88+ Mode :: Break => ( "Take a break" , "Break time. Step away for a bit." ) ,
89+ } ;
90+ thread:: spawn ( move || {
91+ #[ cfg( target_os = "macos" ) ]
92+ {
93+ let script = format ! (
94+ "display notification \" {}\" with title \" {}\" " ,
95+ body, title
96+ ) ;
97+ let _ = std:: process:: Command :: new ( "osascript" )
98+ . args ( [ "-e" , & script] )
99+ . output ( ) ;
100+ }
101+ #[ cfg( target_os = "linux" ) ]
102+ {
103+ let _ = std:: process:: Command :: new ( "notify-send" )
104+ . args ( [ title, body] )
105+ . output ( ) ;
106+ }
107+ } ) ;
108+ }
109+
85110 pub fn play_notification ( & self ) {
86111 let is_focus = matches ! ( self . mode, Mode :: Focus ) ;
87112 thread:: spawn ( move || {
You can’t perform that action at this time.
0 commit comments