Giter VIP home page Giter VIP logo

Comments (15)

nmaggioni avatar nmaggioni commented on August 16, 2024

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.

from ntfy.

nmaggioni avatar nmaggioni commented on August 16, 2024

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.

from ntfy.

dschep avatar dschep commented on August 16, 2024

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.

from ntfy.

dschep avatar dschep commented on August 16, 2024

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 😢

from ntfy.

nmaggioni avatar nmaggioni commented on August 16, 2024

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.

from ntfy.

zamber avatar zamber commented on August 16, 2024

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.

from ntfy.

nmaggioni avatar nmaggioni commented on August 16, 2024

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

from ntfy.

dschep avatar dschep commented on August 16, 2024

@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.

from ntfy.

sethwoodworth avatar sethwoodworth commented on August 16, 2024

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

from ntfy.

pmav99 avatar pmav99 commented on August 16, 2024

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

from ntfy.

dschep avatar dschep commented on August 16, 2024

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

from ntfy.

dschep avatar dschep commented on August 16, 2024

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

from ntfy.

dschep avatar dschep commented on August 16, 2024

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

from ntfy.

pmav99 avatar pmav99 commented on August 16, 2024

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

from ntfy.

dschep avatar dschep commented on August 16, 2024

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.

from ntfy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.