Sound alarm when code finishes

前端 未结 11 823
离开以前
离开以前 2021-01-29 17:42

I am in a situation where my code takes extremely long to run and I don\'t want to be staring at it all the time but want to know when it is done.

How can I make the (Py

11条回答
  •  遇见更好的自我
    2021-01-29 18:10

    Why use python at all? You might forget to remove it and check it into a repository. Just run your python command with && and another command to run to do the alerting.

    python myscript.py && 
        notify-send 'Alert' 'Your task is complete' && 
        paplay /usr/share/sounds/freedesktop/stereo/suspend-error.oga
    

    or drop a function into your .bashrc. I use apython here but you could override 'python'

    function apython() {
        /usr/bin/python $*
        notify-send 'Alert' "python $* is complete"
        paplay /usr/share/sounds/freedesktop/stereo/suspend-error.oga
    }
    

提交回复
热议问题