aboutsummaryrefslogtreecommitdiffstats
path: root/weechat
diff options
context:
space:
mode:
authorJohannes Löthberg <johannes@kyriasis.com>2017-06-18 00:54:44 +0200
committerJohannes Löthberg <johannes@kyriasis.com>2017-06-18 00:55:17 +0200
commit6e78201d6b9da1c5a151ac748c5889a9ebc1da4a (patch)
tree146df161dcaa870637ffbe28af8728b0972b6a91 /weechat
parentf437b522ec47e91e271598a8dba3b2ab160fe8f7 (diff)
downloaddotfiles-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')
-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')):