Created
December 7, 2011 01:29
-
-
Save aduros/1440990 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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