parent
856b3ff614
commit
f99f480eee
@ -0,0 +1,26 @@
|
|||||||
|
# Gets the id of the current focused window.
|
||||||
|
#
|
||||||
|
# Authors:
|
||||||
|
# Alex Reece <awreece@gmail.com>
|
||||||
|
#
|
||||||
|
|
||||||
|
function focused_window_id {
|
||||||
|
case "$OSTYPE" in
|
||||||
|
(darwin*)
|
||||||
|
osascript -e 'tell application "System Events" to ¬' \
|
||||||
|
-e ' set focus_app_name to ¬' \
|
||||||
|
-e ' name of first application process ¬' \
|
||||||
|
-e ' whose frontmost is true' \
|
||||||
|
-e 'tell application focus_app_name to ¬' \
|
||||||
|
-e ' get id of front window'
|
||||||
|
;;
|
||||||
|
(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
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
# Check if it makes sense to load the notify module.
|
||||||
|
#
|
||||||
|
# Checks for requirements, that it is an xsession, etc.
|
||||||
|
#
|
||||||
|
# Authors:
|
||||||
|
# Alex Reece <awreece@gmail.com>
|
||||||
|
#
|
||||||
|
|
||||||
|
function should_load_notify_module {
|
||||||
|
case "$OSTYPE" in
|
||||||
|
(darwin*)
|
||||||
|
# For now, always enable on mac osx.
|
||||||
|
# TODO(awreece) Disable if ssh with no windows?
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
(linux-gnu*)
|
||||||
|
# Disable if don't have X.
|
||||||
|
if [[ -z $XAUTHORITY ]]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# We need both of these functions to operate.
|
||||||
|
if (( ! $+commands[notify-send] || ! $+commands[xprop] )); then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
(*)
|
||||||
|
# If we don't know, then just disable.
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
Loading…
Reference in new issue