prezto/modules/notify/functions/focused_window_id
2013-06-15 13:51:06 -04:00

20 lines
468 B
Text

# Gets the id of the current focused window.
#
# Authors:
# Alex Reece <awreece@gmail.com>
#
case "$OSTYPE" in
(darwin*)
osascript -e 'tell application (path to frontmost application as text) ¬' \
-e ' to get id of front window' 2>/dev/null
;;
(linux-gnu*)
# http://stackoverflow.com/a/8688624/447288
xprop -root -f _NET_ACTIVE_WINDOW 0x ' $0' _NET_ACTIVE_WINDOW \
| awk '{print $2}'
;;
(*)
return 1
;;
esac