dschep / ntfy

🖥️📱🔔 A utility for sending notifications, on demand and when commands finish.
http://ntfy.rtfd.io
GNU General Public License v3.0
4.84k stars 213 forks source link

Does not work with guake terminal #77

Open ojhaujjwal opened 8 years ago

ojhaujjwal commented 8 years ago

It works very nicely on normal terminal but, I get an error on guake terminal. image

nmaggioni commented 8 years ago

It appears that not every terminal sets the WINDOWID environment variable. Terminator and gnome-terminal, for example, set it correctly, while Guake and Terminix do not.

nmaggioni commented 8 years ago

I came up with a raw solution based on xdotool, but I don't know if it is in line with @dschep's thoughts; relying on external binaries is not always a welcome choice, especially if such binaries are not installed by default on most systems.

xdotool_patch.txt

Also extensive testing is required, as this is more of a temporary hack rather than a solution.

dschep commented 8 years ago

Hmm, yeah I've seen other tools that do this sort of thing using xdotool. I'd prefer not having additional dependencies, but I wouldn't be opposed to using it if available, and falling back to $WINDOWID.

dschep commented 8 years ago

Hrmm.. actually, isn't xdotoo getactivewindow the same as the xprop command ntfy uses? WINDOWID is the ID of the window the command is running in, regardless of focus. Good to know that there's an issue with Guake & Gnome-Terminal, but I'm afraid xdotool isn't the answer 😢

nmaggioni commented 8 years ago

In theory both refer to the same attribute, but with the said terminals I've only managed to get a WindowID by using xdotool... There's probably another attribute hidden somewhere in /proc.

zamber commented 8 years ago

Hit the same issue. Solved it by returning False from is_focused(). Will see how that turns out for me ;). On a side note, having that configurable in .config would make things easier for other potentially deficient terminals.

nmaggioni commented 8 years ago

@zamber But won't you get notified even if the terminal is focused, that way?

dschep commented 8 years ago

@zamber hmm yeah, I should make the ntfy done --background-only and ntfy shell-integration --foreground-too options configurable via the config file.

@nmaggioni yup.

sethwoodworth commented 8 years ago

I switched to Terminology recently and it appears to not set WINDOWID either.

pmav99 commented 7 years ago

The last version of terminator does not set $WINDOWID either

$ pacman -Qi terminator
Name            : terminator
Version         : 1.90-1

Perhaps, this could be of help? http://stackoverflow.com/questions/2250757/is-there-a-linux-command-to-determine-the-window-ids-associated-with-a-given-pro

dschep commented 6 years ago

Welp. seems Gnome terminal no longer sets WINDOWID either. gonna play with the xdotool solution.

dschep commented 6 years ago

Doh. per my previous comment xdotool doesn't work. Not sure how to do this :cry:

dschep commented 6 years ago

Potential fix for getting the terminals WINDOWID

wmctrl -lp | grep $PPID # but in python and recursively since ntfy/python's ppid is bash

still not great bc gnome-terminal for example has many windows for the same pid

pmav99 commented 6 years ago

I just installed guake

$ guake
Guake not running, starting it
Guake Terminal 3.2.1
VTE 0.50.2
Gtk 3.22.29
System doesn't support transparency
can't bind show-focus key

and xdotool seems to work...

$ xdotool getactivewindow
33554447

$ xdotool getmouselocation --shell | grep WINDOW
WINDOW=33554447
dschep commented 6 years ago

Right. but isn't xdotool getactivewindow the equivalent of xprop -root '\t$0' _NET_ACTIVE_WINDOW? Ie: it gets the current active window. WINDOWID is window ID of the terminal that ntfy is running in. Its needed because to determine focus you have to compare the current window id with ntfy's terminal's window id.