Last active
October 3, 2019 23:39
-
-
Save tennox/e027e5daabe4997093a49873411f5c0e to your computer and use it in GitHub Desktop.
Elementary OS Loki Task complete notification for fish shell
This file contains hidden or 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
# ! 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 |
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
Works fine!