Skip to content

Instantly share code, notes, and snippets.

@tennox
Last active October 3, 2019 23:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tennox/e027e5daabe4997093a49873411f5c0e to your computer and use it in GitHub Desktop.
Save tennox/e027e5daabe4997093a49873411f5c0e to your computer and use it in GitHub Desktop.
Elementary OS Loki Task complete notification for fish shell
# ! install xdotool first - it is needed to check if the terminal is in foreground (or disable that if you don't want)
# then append this to ~/.config/fish/config.fish (create it if not existent)
function alert_cmd_done --on-event fish_postexec
set status_code $status # save for later
set active_window (ps -p (xdotool getwindowpid (xdotool getactivewindow)) -o comm=) # get the process name of the currently active window
if status --is-interactive # Check for interactive session (keyboard attached)
if [ $active_window != "pantheon-termin" -a \
$CMD_DURATION -a \
$CMD_DURATION -gt (math "1000 * 5") ] # in background, after a job longer than 5 seconds
set secs (math "$CMD_DURATION / 1000")
if [ $status_code = 0 ]
notify-send -i "terminal" "Done (after "$secs"s)" "$argv[1]"
else # increase timeout to 4s, and use error icon
notify-send -t 4000 -i "dialog-error" "Exit code $status_code (after "$secs"s)" "$argv[1]"
end
end
end
end
@deyvisonrocha
Copy link

Works fine!

@tennox
Copy link
Author

tennox commented Oct 3, 2019

Works in Elementary Juno now out of the box 😎
So no need anymore 🤷‍♂️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment