Skip to content

Instantly share code, notes, and snippets.

@fdevibe
Created October 20, 2016 11:58
Show Gist options
  • Save fdevibe/4206d6098b5c698bdf5462efff23e55c to your computer and use it in GitHub Desktop.
Save fdevibe/4206d6098b5c698bdf5462efff23e55c to your computer and use it in GitHub Desktop.
Send desktop notifications on window urgency hints on i3
#! /usr/bin/env python
import i3ipc
import pgi
pgi.require_version('Notify', '0.7')
from pgi.repository import Notify
i3conn = i3ipc.Connection()
Notify.init('Urgent!')
def on_urgent(i3, event):
urgent = find_urgent(i3.get_tree().descendents())
if urgent:
n = Notify.Notification.new(
'Window %s:%s on workspace %s requires your attention' % (
urgent.window_instance,
urgent.name,
urgent.workspace().name),
None,
"dialog-information")
n.show()
def find_urgent(descendents):
try:
return next(c for c in descendents if c.urgent and c.type == 'con')
except StopIteration:
return None
i3conn.on('window::urgent', on_urgent)
i3conn.main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment