Skip to content

Commit

Permalink
remove problemtic ignore_windows support from lnotify plugin
Browse files Browse the repository at this point in the history
The python "lnotify" plugin had some problematic code that would
suppress notifications if the active window was named "tilda",
"xterm", or "gnome-terminal". This list was not user-configurable, and
the code implementing this feature was broken due to weechat#339
(incompatible with common versions of ps) and weechat#334 (python3
bytes-vs-string incompatibility).

This commit removes the problematic code.

Closes: weechat#334
Closes: weechat#339
  • Loading branch information
larsks committed May 31, 2019
1 parent a3eccda commit 669c75f
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions python/lnotify.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,14 @@
#
# 0.3.3
# Fix undefined ignore_windows_list.
#
# 0.3.5 Lars Kellogg-Stedman <lars@oddbit.com>
# Remove problematic ignore_windows support

import weechat as weechat
import subprocess
from os import environ, path
import weechat

lnotify_name = "lnotify"
lnotify_version = "0.3.4"
lnotify_version = "0.3.5"
lnotify_license = "GPL3"

# convenient table checking for bools
Expand Down Expand Up @@ -94,20 +95,8 @@ def handle_msg(data, pbuffer, date, tags, displayed, highlight, prefix, message)
buffer_type = weechat.buffer_get_string(pbuffer, "localvar_type")
away = weechat.buffer_get_string(pbuffer, "localvar_away")
x_focus = False
window_name = ""
my_nickname = "nick_" + weechat.buffer_get_string(pbuffer, "localvar_nick")

# Check if active window is in the ignore_windows_list and skip notification
if (environ.get('DISPLAY') != None) and path.isfile("/bin/xdotool"):
cmd_pid="xdotool getactivewindow getwindowpid".split()
window_pid = subprocess.check_output(cmd_pid)
cmd_name=("ps -ho comm -p %s"%(window_pid)).split()
window_name = subprocess.check_output(cmd_name)
ignore_windows_list = ["tilda", "gnome-terminal", "xterm"]
if window_name in ignore_windows_list:
x_focus = True
return weechat.WEECHAT_RC_OK

if pbuffer == weechat.current_buffer() and x_focus:
return weechat.WEECHAT_RC_OK

Expand Down

0 comments on commit 669c75f

Please sign in to comment.