-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
check if window is not the same as the one where the command started … #35
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,6 +53,14 @@ function _auto_notify_message() { | |
fi | ||
} | ||
|
||
function _auto_notify_active_window_id () { | ||
if [[ -n $DISPLAY ]] ; then | ||
xprop -root _NET_ACTIVE_WINDOW | awk '{print $5}' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this work on Mac? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure. Only tested on linux. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We would need this to work on Mac or at the very least gracefully ignore this feature in order for this to get merged. Wouldnt want this to not work for non-linux users. The same question also applies to those using wayland, does xprop work there? For example on my machine I get:
which doesnt look right. |
||
return | ||
fi | ||
echo nowindowid | ||
} | ||
|
||
function _is_auto_notify_ignored() { | ||
local command="$1" | ||
# split the command if its been piped one or more times | ||
|
@@ -101,8 +109,12 @@ function _auto_notify_send() { | |
if [[ "$(_is_auto_notify_ignored "$AUTO_COMMAND_FULL")" == "no" ]]; then | ||
local current="$(date +"%s")" | ||
let "elapsed = current - AUTO_COMMAND_START" | ||
local current_window="$(_auto_notify_active_window_id)" | ||
|
||
if [[ $elapsed -gt $AUTO_NOTIFY_THRESHOLD ]]; then | ||
if [[ $current_window != $AUTO_NOTIFY_ACTIVE_WINDOW_ID ]] || | ||
[[ ! -z "$AUTO_NOTIFY_IGNORE_WINDOW_CHECK" ]] || | ||
[[ $current_window == "nowindowid" ]] && | ||
[[ $elapsed -gt $AUTO_NOTIFY_THRESHOLD ]]; then | ||
_auto_notify_message "$AUTO_COMMAND" "$elapsed" "$exit_code" | ||
fi | ||
fi | ||
|
@@ -119,6 +131,7 @@ function _auto_notify_track() { | |
AUTO_COMMAND="${1:-$2}" | ||
AUTO_COMMAND_FULL="$3" | ||
AUTO_COMMAND_START="$(date +"%s")" | ||
AUTO_NOTIFY_ACTIVE_WINDOW_ID="$(_auto_notify_active_window_id)" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks like it won't work if multiple commands are running at once? |
||
} | ||
|
||
function _auto_notify_reset_tracking() { | ||
|
@@ -128,6 +141,8 @@ function _auto_notify_reset_tracking() { | |
unset AUTO_COMMAND_FULL | ||
# Command that the user has executed | ||
unset AUTO_COMMAND | ||
# window id of where the command was executed | ||
unset AUTO_NOTIFY_ACTIVE_WINDOW_ID | ||
} | ||
|
||
function disable_auto_notify() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would probably make this the non default for backwards compatibility purposes. I'll give it some thought