Compare commits

...

5 Commits

Author SHA1 Message Date
Dianne Skoll
62030719bb Set app name to tkremind.
All checks were successful
Remind unit tests / tests (push) Successful in 30s
2024-10-02 11:08:17 -04:00
Dianne Skoll
985816dc32 Document that system notifications work if notify-send is installed. 2024-10-02 11:05:38 -04:00
Dianne Skoll
a131a53132 Fix typos. 2024-10-02 11:05:27 -04:00
Dianne Skoll
c5e723b6ac Use "notify-send" if Tk < 9.0 2024-10-02 11:00:28 -04:00
Dianne Skoll
3fe2b88e65 Document "Use system notifications when issuing a reminder" 2024-10-02 09:26:11 -04:00
2 changed files with 30 additions and 5 deletions

View File

@@ -224,6 +224,14 @@ If this is selected, pop-up reminder boxes will be closed after one minute
has elapsed. Otherwise, they remain on your screen forever until you
explicitly dismiss them.
.TP
.B Use system notifications when issuing a reminder
This option is available only for Tcl/Tk version 9.0 or later, or if
you have the \fBnotify-send\fR program installed; it will be greyed
out if neither condition is true. If selected, then when a reminder
is popped up, it will also be sent to the desktop notification system,
causing a notification to appear.
.TP
.B Beep terminal when popping up a reminder
If selected, \fBTkRemind\fR beeps the terminal bell when a queued reminder

View File

@@ -15,6 +15,8 @@
# the next line restarts using wish \
exec wish "$0" "$@"
tk appname tkremind
# We need at least version 8.5 because of {*} list expansion operator
if {[catch {package require Tcl 8.5-}]} {
puts stderr "This program requires Tcl 8.5 or higher."
@@ -30,9 +32,18 @@ set HOME $env(HOME)
# Check if we have "tk sysnotify"
set HAVE_SYSNOTIFY 0
set NOTIFY_SEND_PATH ""
catch { tk sysnotify } err opt
if { [dict get $opt -errorcode] == "TCL WRONGARGS" } {
set HAVE_SYSNOTIFY 1
} else {
set path [split $env(PATH) :]
foreach d $path {
if { [file executable [file join $d "notify-send"]] } {
set NOTIFY_SEND_PATH [file join $d "notify-send"]
break
}
}
}
proc home { f } {
@@ -751,7 +762,7 @@ proc CreateCalWindow { dayNames } {
# Lets user edit options
#***********************************************************************
proc EditOptions {} {
global Option tmpOpt HAVE_SYSNOTIFY
global Option tmpOpt HAVE_SYSNOTIFY NOTIFY_SEND_PATH
# Make a working copy of current option set
foreach name [array names Option] {
@@ -788,11 +799,13 @@ proc EditOptions {} {
-anchor w -justify left -variable tmpOpt(AutoClose)
checkbutton $w.sysNotify \
-text "Use system notifications when issuing a reminder (Tk >= 9.0)" \
-text "Use system notifications when issuing a reminder" \
-anchor w -justify left -variable tmpOpt(SysNotify)
if { ! $HAVE_SYSNOTIFY } {
$w.sysNotify configure -state disabled -takefocus 0
if { "$NOTIFY_SEND_PATH" == "" } {
$w.sysNotify configure -state disabled -takefocus 0
}
}
# Ring bell when popping up reminder
@@ -2894,7 +2907,7 @@ proc DaemonReadable { file } {
# Reads a background reminder from daemon and pops up window.
#---------------------------------------------------------------------------
proc IssueBackgroundReminder { body time now tag qid } {
global BgCounter Option Ignore DaemonFile HAVE_SYSNOTIFY
global BgCounter Option Ignore DaemonFile HAVE_SYSNOTIFY NOTIFY_SEND_PATH
if {$Option(Deiconify)} {
wm deiconify .
}
@@ -2955,8 +2968,12 @@ proc IssueBackgroundReminder { body time now tag qid } {
bell
}
if {$Option(SysNotify)} {
if ($HAVE_SYSNOTIFY) {
if {$HAVE_SYSNOTIFY} {
tk sysnotify "Reminder for $time" $body
} elseif {"$NOTIFY_SEND_PATH" != "" } {
catch {
exec $NOTIFY_SEND_PATH -a tkremind -i dialog-information "Reminder for $time" "$body"
}
}
}
if {$Option(RunCmd) != ""} {