diff options
author | Johannes Löthberg <johannes@kyriasis.com> | 2017-06-18 00:54:44 +0200 |
---|---|---|
committer | Johannes Löthberg <johannes@kyriasis.com> | 2017-06-18 00:55:17 +0200 |
commit | 6e78201d6b9da1c5a151ac748c5889a9ebc1da4a (patch) | |
tree | 146df161dcaa870637ffbe28af8728b0972b6a91 /weechat/python | |
parent | f437b522ec47e91e271598a8dba3b2ab160fe8f7 (diff) | |
download | dotfiles-6e78201d6b9da1c5a151ac748c5889a9ebc1da4a.tar.xz |
weechat: add custom notify plugin support for highligthted window support
Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
Diffstat (limited to 'weechat/python')
-rw-r--r-- | weechat/python/notify.py | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/weechat/python/notify.py b/weechat/python/notify.py index 7c583f4..c90b253 100644 --- a/weechat/python/notify.py +++ b/weechat/python/notify.py @@ -42,6 +42,8 @@ SCRIPT_VERSION = "0.0.8" SCRIPT_LICENSE = "GPL" SCRIPT_DESC = "notify: A real time notification system for weechat" +import subprocess + # make sure we're run under weechat. import_ok = True try: @@ -77,12 +79,29 @@ urgencies = { } # Functions +def is_active_window(): + try: + p = subprocess.Popen(['xdotool', 'getwindowfocus', 'getwindowname'], stdout=subprocess.PIPE) + (stdout, _) = p.communicate() + except FileNotFoundError: + # Always notify if xdotool isn't available. + return True + + if p.returncode != 0: + return True + + return b'WeeChat' in stdout + def notify_show(data, bufferp, uber_empty, tagsn, isdisplayed, ishilight, prefix, message): """Sends highlighted message to be printed on notification""" # string for show_notification return snreturn = None - # smart_notification - if (weechat.config_get_plugin('smart_notification') == "on" and bufferp == weechat.current_buffer()): + # Don't notify if the WeeChat window is focused if smart notifications are on + if is_active_window(): + pass + # Don't notify for current buffer if smart notifications are on. + elif (weechat.config_get_plugin('smart_notification') == "on" and bufferp == weechat.current_buffer()): + # smart_notification pass # are we away and want highlights? check: w.infolist_integer(infolist, 'is_away') elif (weechat.config_get_plugin('notify_when_away') == "off" and weechat.buffer_get_string(bufferp, 'localvar_away')): |