Skip to content

Instantly share code, notes, and snippets.

@kfktwo
Last active October 24, 2016 19:38
Show Gist options
  • Select an option

  • Save kfktwo/ec2b30d56b84ac58a0f6c9d3a0a2cd85 to your computer and use it in GitHub Desktop.

Select an option

Save kfktwo/ec2b30d56b84ac58a0f6c9d3a0a2cd85 to your computer and use it in GitHub Desktop.
Set window hint
##Some window managers, including i3wm, the one I use at the moment, highlight
#windows and desktop tabs when the window or one of it’s children sets the X
#urgency hint. irssi, for example, supports that, allowing for nice and silent
#notifications when somebody querys or mentions you. However, even after hours
#of googeling, I couldn’t find any way to make Thunderbird set this flag when
#new mail arrives. This is why I came up with my own solution. I wrote a python
#script that finds the Thunderbird window and set’s the urgency hint using the
#python-xlib (which you would have to install yourself!) bindings. I then
#installed the Thunderbird extension Mailbox Alert, that allows you to specify
#scripts to be executed when new mail arrives – even on a per-folder basis.
#(The extension is pretty awesome, you should definitely check it out!) With
#that, everything works perfectly now.
#The script setting the urgency hint is pretty basic. Here it is:
#!/usr/bin/python2
from Xlib import X, display, Xutil
def find_window(name, w):
for win in w.query_tree().children:
if win.get_wm_class() and win.get_wm_class()[1] == name:
return win
if len(win.query_tree().children) > 0:
a = find_window(name, win)
if a:
return a
def main(disp):
win = find_window("Thunderbird", disp.screen().root)
hints = win.get_wm_hints() or { 'flags': 0 }
hints['flags'] |= Xutil.UrgencyHint
win.set_wm_hints(hints)
disp.flush()
if __name__ == '__main__':
main(display.Display())
#From https://web.archive.org/web/20120623015942/http://www.oelerich.org/how-to-set-the-urgency-hint-for-new-mail-in-thunderbird/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment