profanity-im / profanity

Ncurses based XMPP client
https://profanity-im.github.io/
Other
1.32k stars 187 forks source link

/notify on mac imprecise #352

Closed madc closed 10 years ago

madc commented 10 years ago

Trying profanity the first day and on OS X (10.9) the Notifications look like this: profanity

I think, they could contain more information, like part of the message. Also, if this is possible, it would be awesome to only send notification, when the chat window is not focused.

best, /m

boothj5 commented 10 years ago

Sounds reasonable, I'll extend notification options to allow users to choose to show more message information if desired, since some may still want to hide message text.

The second point has been raised before, also makes sense to add an option.

I've tagged this issue for the 0.5.0 release.

Thanks.

madc commented 10 years ago

I started writing a bash-script for mcabber to handle notifications some time ago. I just post it here, maybe it helps.

#!/bin/sh

TYPE="$1"
DIR="$2"
JID="$3"
FILE="$4"

if [ -e $FILE ]; then
    MSG=$(<$FILE)
fi

rm $FILE

#if TYPE == "MSG" then
#   growlnotify -t "[$2] $3" -m "message"
#end

case $TYPE in
    "MSG")
        if [ $DIR == "IN" ] ; then
            terminal-notifier -message "$MSG" -title "⇥ $JID" -group "XMPP-IN-$JID"
            tput bel
#       elif [ $DIR == "OUT" ] ; then
#           terminal-notifier -message "$MSG" -title "⇤ $JID"
        elif [ $DIR == "MUC" ] ; then
            #@TODO: load message content
            #@TODO: Filter own messages!?
            terminal-notifier -message "$MSG" -title "⇉ $JID" -group "XMPP-IN-MUC"
            tput bel
        fi
    ;;
#   "STATUS")
#       if [ $DIR == "_" ] ; then
#           terminal-notifier -message "... went offline." -title "⇋ $JID" -group "XMPP-STATUS"
#       else
#           terminal-notifier -message "... changed status to $DIR." -title "⇋ $JID" -group "XMPP-STATUS"
#       fi
#   ;;
esac
boothj5 commented 10 years ago

Thanks for the script, I'm using a similar mechanism so it will be useful.

madc commented 10 years ago

Just saw, that the terminal-notifier evolved quite a bit since i wrote this. Its now also possible to set an image, play a sound and stuff.

Usage: terminal-notifier -[message|list|remove] [VALUE|ID|ID] [options]

   Either of these is required (unless message data is piped to the tool):

       -help              Display this help banner.
       -message VALUE     The notification message.
       -remove ID         Removes a notification with the specified ‘group’ ID.
       -list ID           If the specified ‘group’ ID exists show when it was delivered,
                          or use ‘ALL’ as ID to see all notifications.
                          The output is a tab-separated list.

   Optional:

       -title VALUE       The notification title. Defaults to ‘Terminal’.
       -subtitle VALUE    The notification subtitle.
       -sound NAME        The name of a sound to play when the notification appears. The names are listed
                          in Sound Preferences. Use 'default' for the default notification sound.
       -group ID          A string which identifies the group the notifications belong to.
                          Old notifications with the same ID will be removed.
       -activate ID       The bundle identifier of the application to activate when the user clicks the notification.
       -sender ID         The bundle identifier of the application that should be shown as the sender, including its icon.
       -appIcon URL       The URL of a image to display instead of the application icon (Mavericks+ only)
       -contentImage URL  The URL of a image to display attached to the notification (Mavericks+ only)
       -open URL          The URL of a resource to open when the user clicks the notification.
       -execute COMMAND   A shell command to perform when the user clicks the notification.

Let me know, if i can help you by composing the message.

boothj5 commented 10 years ago

The master branch now has extra notification options.

The current setting determines whether a notification is sent for when the window is focused. The text setting determines whether to show the message text in the notification.

The mention setting for rooms will only send notifications when a message contains your nickname (case insensitive).

Relevant settings:

/notify message on|off
/notify message current on|off
/notify message text on|off

/notify room on|off|mention
/notify room current on|off
/notify room text on|off

/notify typing on|off
/notify typing current on|off
madc commented 10 years ago

Hm, can't compile anymore:

me@MeBook:profanity$ ./bootstrap.sh 
me@MeBook:profanity$ LDFLAGS=-L/opt/local/lib ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... build-aux/install-sh -c -d
[...]
checking for wget_wch support in ncursesw... yes
checking for glib... yes
checking for curl... yes
./configure: line 5369: syntax error near unexpected token `yes'
./configure: line 5369: `AX_LIB_GCRYPT(yes)'
kmwhite commented 10 years ago

@madc Have you installed the gcrypt dev headers? I don't know the exact package, but I would assume brew install has something for you...

kmwhite commented 10 years ago

Lame. I can't edit comments on mobile GitHub.

@madc I also ran into that on a Linux box. I also had to upgrade libtool. HTH.

madc commented 10 years ago

I'm using macports (don't want to mix these things and install homebrew). Got libgcrypt (@1.5.3) and libtool (@2.4.2) installed.

boothj5 commented 10 years ago

A couple of new dependencies have been added:

autoconf-archive
libgcrypt-devel

And the dependency on gnutls-devel removed.

The dependencies don't change very often. But when they do I usually update install-all.sh which is a good guide.

madc commented 10 years ago

Can't find libgcrypt-devel for OS X, but thats another issue. Thanks for the info...

boothj5 commented 10 years ago

I'll close this issue as the feature has been added to profanity.

Don't know if you found it in the end, but libgcrypt is no longer required as I'm now using public domain code for generating SHA1 hashes.

autoconf-archive is currently not needed either (for the same reason), but probably will be again, once the plugins code is merged into master.