Skip to content

Instantly share code, notes, and snippets.

@aduros
Created December 7, 2011 01:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aduros/1440990 to your computer and use it in GitHub Desktop.
Save aduros/1440990 to your computer and use it in GitHub Desktop.
# If we're running in X, automatically alert when a command ends on another workspace
if [ -n "$WINDOWID" ]; then
function maybeAlert {
local icon=`[ $? = 0 ] && echo terminal || echo error`
local lastCommand=`history 1 | sed -e 's/^\s*[0-9]\+\s*//'`
local desktop=`xprop -id $WINDOWID _NET_WM_DESKTOP | cut -d ' ' -f 3`
local current=`xprop -root _NET_CURRENT_DESKTOP | cut -d ' ' -f 3`
if [ "$desktop" != "$current" ]; then
local message="On workspace $(($desktop+1))"
notify-send --urgency=low -i "$icon" "$lastCommand" "$message"
fi
}
# maybeAlert needs to be the first prompt command to get the exit code of the last command
export PROMPT_COMMAND="maybeAlert;$PROMPT_COMMAND"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment