aboutsummaryrefslogtreecommitdiffstats
path: root/weechat
diff options
context:
space:
mode:
Diffstat (limited to 'weechat')
-rw-r--r--weechat/plugins.conf8
-rw-r--r--weechat/python/notify.py23
2 files changed, 29 insertions, 2 deletions
diff --git a/weechat/plugins.conf b/weechat/plugins.conf
index b122c14..ec55de3 100644
--- a/weechat/plugins.conf
+++ b/weechat/plugins.conf
@@ -206,6 +206,14 @@ python.listbuffer.modes_min_width = "8"
python.listbuffer.sort_inverted = "on"
python.listbuffer.sort_order = "users"
python.listbuffer.users_min_width = "8"
+python.notify.icon = "/usr/share/pixmaps/weechat.xpm"
+python.notify.ignore_nicks_startwith = "*"
+python.notify.nick_separator = ": "
+python.notify.notify_when_away = "off"
+python.notify.show_hilights = "on"
+python.notify.show_priv_msg = "on"
+python.notify.smart_notification = "off"
+python.notify.urgency = "normal"
python.title.short_name = "on"
python.title.title_priority = "2"
python.whois_on_query.command = "/whois $nick $nick"
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')):