Skip to content

Instantly share code, notes, and snippets.

# 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"