How can I play a sound when script execution is ready?
Clash Royale CLAN TAG#URR8PPP
up vote
37
down vote
favorite
I am executing every now and then some python scripts which take quite long to execute.
I execute them like this:$ time python MyScript.py
How can I play a sound as soon as the execution of the script is done?
I use Ubuntu 10.10 (Gnome desktop).
shell ubuntu audio
add a comment |Â
up vote
37
down vote
favorite
I am executing every now and then some python scripts which take quite long to execute.
I execute them like this:$ time python MyScript.py
How can I play a sound as soon as the execution of the script is done?
I use Ubuntu 10.10 (Gnome desktop).
shell ubuntu audio
Are you usingbash
orzsh
? There are actually some ways of making this happen automatically, but they're quite involved and depend on which shell you are using.
â Mikel
Mar 4 '11 at 23:06
$ echo $SHELL returns "/bin/bash"
â Martin Thoma
Mar 5 '11 at 20:39
add a comment |Â
up vote
37
down vote
favorite
up vote
37
down vote
favorite
I am executing every now and then some python scripts which take quite long to execute.
I execute them like this:$ time python MyScript.py
How can I play a sound as soon as the execution of the script is done?
I use Ubuntu 10.10 (Gnome desktop).
shell ubuntu audio
I am executing every now and then some python scripts which take quite long to execute.
I execute them like this:$ time python MyScript.py
How can I play a sound as soon as the execution of the script is done?
I use Ubuntu 10.10 (Gnome desktop).
shell ubuntu audio
shell ubuntu audio
edited Mar 4 '11 at 23:00
Gilles
514k12110211550
514k12110211550
asked Mar 4 '11 at 22:44
Martin Thoma
1,13231842
1,13231842
Are you usingbash
orzsh
? There are actually some ways of making this happen automatically, but they're quite involved and depend on which shell you are using.
â Mikel
Mar 4 '11 at 23:06
$ echo $SHELL returns "/bin/bash"
â Martin Thoma
Mar 5 '11 at 20:39
add a comment |Â
Are you usingbash
orzsh
? There are actually some ways of making this happen automatically, but they're quite involved and depend on which shell you are using.
â Mikel
Mar 4 '11 at 23:06
$ echo $SHELL returns "/bin/bash"
â Martin Thoma
Mar 5 '11 at 20:39
Are you using
bash
or zsh
? There are actually some ways of making this happen automatically, but they're quite involved and depend on which shell you are using.â Mikel
Mar 4 '11 at 23:06
Are you using
bash
or zsh
? There are actually some ways of making this happen automatically, but they're quite involved and depend on which shell you are using.â Mikel
Mar 4 '11 at 23:06
$ echo $SHELL returns "/bin/bash"
â Martin Thoma
Mar 5 '11 at 20:39
$ echo $SHELL returns "/bin/bash"
â Martin Thoma
Mar 5 '11 at 20:39
add a comment |Â
7 Answers
7
active
oldest
votes
up vote
34
down vote
accepted
Append any command that plays a sound; this could be as simple as
$ time mycommand; printf '7'
or as complex as
$ time mycommand && paplay itworked.ogg || paplay bombed.ogg
(Commands assume pulseaudio is installed; substitute your sound player, which will depend on your desktop environment.)
5
+1paplay
is probably the best command to use to play a sound on a "modern" Linux system.
â Mikel
Mar 4 '11 at 23:21
3
printf '7' doesn't work for me, but this command worked as I wanted ittime python MyScript.py -n 40 && paplay /usr/share/sounds/ubuntu/stereo/desktop-login.ogg || paplay /usr/share/sounds/ubuntu/stereo/phone-outgoing-busy.ogg
â Martin Thoma
Mar 5 '11 at 20:43
printf '7'
works for me (paplay doesn't; (git shell)) but it's just a very small bip. Are there more codes that make other sounds? I tried6
,8
but they are some characters.
â laggingreflex
Sep 17 '14 at 23:20
@laggingreflex No,7
(BEL) is usually the only character that possibly triggers a sound (see the Wikipedia article Control character); note that it may not always make a sound, either.
â musiphil
Nov 20 '14 at 18:31
2
@laggingreflex You probably don't need this any more but just for laughs ;)for i in 1..30; do for j in 1..3; do printf '7'; sleep 0.12; done; sleep 0.4; done
â cprn
Aug 24 '15 at 20:49
 |Â
show 1 more comment
up vote
9
down vote
Just pick a sound on your hard drive, and put a command to play it right after the command you're waiting on; they'll happen sequentially:
$ time python MyScript.py; mplayer ~/ScriptDone.wav
(You can use any player, naturally). I have a script called alertdone
that plays a tone and shows an libnotify alert when run; I use it for exactly this occasion:
$ time python MyScript.py; alertdone "Done timing"
It's really simple, so if you want to make your own you can base it on this (mine requires notify-more
, mplayer
, and ~/tones/alert_1.wav
though):
#!/bin/bash
message=$1:-"Finished working"
notify-more -t 10000 -i /usr/share/icons/gnome/32x32/actions/insert-object.png "Process Finished" "$message"
mplayer ~/tones/alert_1.wav
2
notify-more
ornotify-send
could indeed be useful alternatives to playing a sound.
â Mikel
Mar 4 '11 at 23:19
@Mikel I'm completely addicted to libnotify; everything on my system pops up notifications
â Michael Mrozekâ¦
Mar 4 '11 at 23:31
add a comment |Â
up vote
8
down vote
time python MyScript.py; play /path/so/sound.ogg
play
is a very basic (no UI) sound player from the sox Install sox http://bit.ly/software-small package. You can replace it by any other command-line-driven sound player.
Yep,play
,aplay
, orpaplay
. (My Ubuntu system hasaplay
andpaplay
by default.)
â Mikel
Mar 4 '11 at 23:20
1
time python MyScript.py -n 40; paplay /usr/share/sounds/ubuntu/stereo/desktop-login.ogg
worked, thanks.
â Martin Thoma
Mar 5 '11 at 20:46
add a comment |Â
up vote
8
down vote
spd-say
sleep 2; spd-say 'get back to work'
Infinite loop with -w
if you need extra motivation:
sleep 2; while true; do spd-say -w 'get back to work'; done
Pre-installed on 14.04 via package speech-dispatcher
: http://releases.ubuntu.com/trusty/ubuntu-14.04.4-desktop-amd64.manifest for blind people I suppose?
Also add a popup
This combo is a life saver:
b() ( spd-say 'done'; zenity --info --text "$(date);$(pwd)" & )
and then:
super-slow-command;b
If I'm somewhere in the room, I'll hear it and know that the long job is done.
Otherwise, I'll see the popup when I get back to my computer.
Related: https://stackoverflow.com/questions/7035/how-to-show-a-gui-message-box-from-a-bash-script-in-linux
To get thespd-say
tool associated withspeech-dispatcher
, you may need to install a subpackage likespeech-dispatcher-utils
(Fedora 24).
â dfarrell07
Dec 13 '16 at 18:27
add a comment |Â
up vote
3
down vote
You can also make this happen automatically.
I will show you how in zsh
, then add info about bash
.
The essence looks like this:
preexec()
starttime=$SECONDS
precmd()
if ((SECONDS - starttime >= 5)); then
aplay "sound.wav"
# or printf "b", or notify-send, or whatever
fi
You can also make it only do it if the program was Python, e.g.
preexec()
starttime=$SECONDS
case $3 in python*)
command_is_python=true;;
*)
command_is_python=false;;
esac
precmd()
if $command_is_python && ((SECONDS - starttime >= 5)); then
aplay "sound.wav"
# or printf "b", or notify-send, or whatever
fi
In bash
, the best way is to download preexec.bash.txt and source it (e.g. . ~/preexec.bash.txt
at the top of your ~/.bashrc
, then the above (or something close to it) should work. (Not sure about the $3
bit to check if the command is Python.)
If you're using GNOME Terminal, I would also point you to Flashing GNOME Terminal. It's a patch I wrote that makes the terminal blink when a command is done, so you can Alt-Tab to something else, then it lets you know when it's done.
add a comment |Â
up vote
0
down vote
Personally, I use my-script && notify-send "done"
. This sends a desktop notification, which on Linux Mint looks like this:
New contributor
add a comment |Â
up vote
-1
down vote
Any player can be used. I'm adding cvlc
for completeness.
add a comment |Â
7 Answers
7
active
oldest
votes
7 Answers
7
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
34
down vote
accepted
Append any command that plays a sound; this could be as simple as
$ time mycommand; printf '7'
or as complex as
$ time mycommand && paplay itworked.ogg || paplay bombed.ogg
(Commands assume pulseaudio is installed; substitute your sound player, which will depend on your desktop environment.)
5
+1paplay
is probably the best command to use to play a sound on a "modern" Linux system.
â Mikel
Mar 4 '11 at 23:21
3
printf '7' doesn't work for me, but this command worked as I wanted ittime python MyScript.py -n 40 && paplay /usr/share/sounds/ubuntu/stereo/desktop-login.ogg || paplay /usr/share/sounds/ubuntu/stereo/phone-outgoing-busy.ogg
â Martin Thoma
Mar 5 '11 at 20:43
printf '7'
works for me (paplay doesn't; (git shell)) but it's just a very small bip. Are there more codes that make other sounds? I tried6
,8
but they are some characters.
â laggingreflex
Sep 17 '14 at 23:20
@laggingreflex No,7
(BEL) is usually the only character that possibly triggers a sound (see the Wikipedia article Control character); note that it may not always make a sound, either.
â musiphil
Nov 20 '14 at 18:31
2
@laggingreflex You probably don't need this any more but just for laughs ;)for i in 1..30; do for j in 1..3; do printf '7'; sleep 0.12; done; sleep 0.4; done
â cprn
Aug 24 '15 at 20:49
 |Â
show 1 more comment
up vote
34
down vote
accepted
Append any command that plays a sound; this could be as simple as
$ time mycommand; printf '7'
or as complex as
$ time mycommand && paplay itworked.ogg || paplay bombed.ogg
(Commands assume pulseaudio is installed; substitute your sound player, which will depend on your desktop environment.)
5
+1paplay
is probably the best command to use to play a sound on a "modern" Linux system.
â Mikel
Mar 4 '11 at 23:21
3
printf '7' doesn't work for me, but this command worked as I wanted ittime python MyScript.py -n 40 && paplay /usr/share/sounds/ubuntu/stereo/desktop-login.ogg || paplay /usr/share/sounds/ubuntu/stereo/phone-outgoing-busy.ogg
â Martin Thoma
Mar 5 '11 at 20:43
printf '7'
works for me (paplay doesn't; (git shell)) but it's just a very small bip. Are there more codes that make other sounds? I tried6
,8
but they are some characters.
â laggingreflex
Sep 17 '14 at 23:20
@laggingreflex No,7
(BEL) is usually the only character that possibly triggers a sound (see the Wikipedia article Control character); note that it may not always make a sound, either.
â musiphil
Nov 20 '14 at 18:31
2
@laggingreflex You probably don't need this any more but just for laughs ;)for i in 1..30; do for j in 1..3; do printf '7'; sleep 0.12; done; sleep 0.4; done
â cprn
Aug 24 '15 at 20:49
 |Â
show 1 more comment
up vote
34
down vote
accepted
up vote
34
down vote
accepted
Append any command that plays a sound; this could be as simple as
$ time mycommand; printf '7'
or as complex as
$ time mycommand && paplay itworked.ogg || paplay bombed.ogg
(Commands assume pulseaudio is installed; substitute your sound player, which will depend on your desktop environment.)
Append any command that plays a sound; this could be as simple as
$ time mycommand; printf '7'
or as complex as
$ time mycommand && paplay itworked.ogg || paplay bombed.ogg
(Commands assume pulseaudio is installed; substitute your sound player, which will depend on your desktop environment.)
edited Mar 5 '11 at 0:06
answered Mar 4 '11 at 23:05
geekosaur
22k25853
22k25853
5
+1paplay
is probably the best command to use to play a sound on a "modern" Linux system.
â Mikel
Mar 4 '11 at 23:21
3
printf '7' doesn't work for me, but this command worked as I wanted ittime python MyScript.py -n 40 && paplay /usr/share/sounds/ubuntu/stereo/desktop-login.ogg || paplay /usr/share/sounds/ubuntu/stereo/phone-outgoing-busy.ogg
â Martin Thoma
Mar 5 '11 at 20:43
printf '7'
works for me (paplay doesn't; (git shell)) but it's just a very small bip. Are there more codes that make other sounds? I tried6
,8
but they are some characters.
â laggingreflex
Sep 17 '14 at 23:20
@laggingreflex No,7
(BEL) is usually the only character that possibly triggers a sound (see the Wikipedia article Control character); note that it may not always make a sound, either.
â musiphil
Nov 20 '14 at 18:31
2
@laggingreflex You probably don't need this any more but just for laughs ;)for i in 1..30; do for j in 1..3; do printf '7'; sleep 0.12; done; sleep 0.4; done
â cprn
Aug 24 '15 at 20:49
 |Â
show 1 more comment
5
+1paplay
is probably the best command to use to play a sound on a "modern" Linux system.
â Mikel
Mar 4 '11 at 23:21
3
printf '7' doesn't work for me, but this command worked as I wanted ittime python MyScript.py -n 40 && paplay /usr/share/sounds/ubuntu/stereo/desktop-login.ogg || paplay /usr/share/sounds/ubuntu/stereo/phone-outgoing-busy.ogg
â Martin Thoma
Mar 5 '11 at 20:43
printf '7'
works for me (paplay doesn't; (git shell)) but it's just a very small bip. Are there more codes that make other sounds? I tried6
,8
but they are some characters.
â laggingreflex
Sep 17 '14 at 23:20
@laggingreflex No,7
(BEL) is usually the only character that possibly triggers a sound (see the Wikipedia article Control character); note that it may not always make a sound, either.
â musiphil
Nov 20 '14 at 18:31
2
@laggingreflex You probably don't need this any more but just for laughs ;)for i in 1..30; do for j in 1..3; do printf '7'; sleep 0.12; done; sleep 0.4; done
â cprn
Aug 24 '15 at 20:49
5
5
+1
paplay
is probably the best command to use to play a sound on a "modern" Linux system.â Mikel
Mar 4 '11 at 23:21
+1
paplay
is probably the best command to use to play a sound on a "modern" Linux system.â Mikel
Mar 4 '11 at 23:21
3
3
printf '7' doesn't work for me, but this command worked as I wanted it
time python MyScript.py -n 40 && paplay /usr/share/sounds/ubuntu/stereo/desktop-login.ogg || paplay /usr/share/sounds/ubuntu/stereo/phone-outgoing-busy.ogg
â Martin Thoma
Mar 5 '11 at 20:43
printf '7' doesn't work for me, but this command worked as I wanted it
time python MyScript.py -n 40 && paplay /usr/share/sounds/ubuntu/stereo/desktop-login.ogg || paplay /usr/share/sounds/ubuntu/stereo/phone-outgoing-busy.ogg
â Martin Thoma
Mar 5 '11 at 20:43
printf '7'
works for me (paplay doesn't; (git shell)) but it's just a very small bip. Are there more codes that make other sounds? I tried 6
, 8
but they are some characters.â laggingreflex
Sep 17 '14 at 23:20
printf '7'
works for me (paplay doesn't; (git shell)) but it's just a very small bip. Are there more codes that make other sounds? I tried 6
, 8
but they are some characters.â laggingreflex
Sep 17 '14 at 23:20
@laggingreflex No,
7
(BEL) is usually the only character that possibly triggers a sound (see the Wikipedia article Control character); note that it may not always make a sound, either.â musiphil
Nov 20 '14 at 18:31
@laggingreflex No,
7
(BEL) is usually the only character that possibly triggers a sound (see the Wikipedia article Control character); note that it may not always make a sound, either.â musiphil
Nov 20 '14 at 18:31
2
2
@laggingreflex You probably don't need this any more but just for laughs ;)
for i in 1..30; do for j in 1..3; do printf '7'; sleep 0.12; done; sleep 0.4; done
â cprn
Aug 24 '15 at 20:49
@laggingreflex You probably don't need this any more but just for laughs ;)
for i in 1..30; do for j in 1..3; do printf '7'; sleep 0.12; done; sleep 0.4; done
â cprn
Aug 24 '15 at 20:49
 |Â
show 1 more comment
up vote
9
down vote
Just pick a sound on your hard drive, and put a command to play it right after the command you're waiting on; they'll happen sequentially:
$ time python MyScript.py; mplayer ~/ScriptDone.wav
(You can use any player, naturally). I have a script called alertdone
that plays a tone and shows an libnotify alert when run; I use it for exactly this occasion:
$ time python MyScript.py; alertdone "Done timing"
It's really simple, so if you want to make your own you can base it on this (mine requires notify-more
, mplayer
, and ~/tones/alert_1.wav
though):
#!/bin/bash
message=$1:-"Finished working"
notify-more -t 10000 -i /usr/share/icons/gnome/32x32/actions/insert-object.png "Process Finished" "$message"
mplayer ~/tones/alert_1.wav
2
notify-more
ornotify-send
could indeed be useful alternatives to playing a sound.
â Mikel
Mar 4 '11 at 23:19
@Mikel I'm completely addicted to libnotify; everything on my system pops up notifications
â Michael Mrozekâ¦
Mar 4 '11 at 23:31
add a comment |Â
up vote
9
down vote
Just pick a sound on your hard drive, and put a command to play it right after the command you're waiting on; they'll happen sequentially:
$ time python MyScript.py; mplayer ~/ScriptDone.wav
(You can use any player, naturally). I have a script called alertdone
that plays a tone and shows an libnotify alert when run; I use it for exactly this occasion:
$ time python MyScript.py; alertdone "Done timing"
It's really simple, so if you want to make your own you can base it on this (mine requires notify-more
, mplayer
, and ~/tones/alert_1.wav
though):
#!/bin/bash
message=$1:-"Finished working"
notify-more -t 10000 -i /usr/share/icons/gnome/32x32/actions/insert-object.png "Process Finished" "$message"
mplayer ~/tones/alert_1.wav
2
notify-more
ornotify-send
could indeed be useful alternatives to playing a sound.
â Mikel
Mar 4 '11 at 23:19
@Mikel I'm completely addicted to libnotify; everything on my system pops up notifications
â Michael Mrozekâ¦
Mar 4 '11 at 23:31
add a comment |Â
up vote
9
down vote
up vote
9
down vote
Just pick a sound on your hard drive, and put a command to play it right after the command you're waiting on; they'll happen sequentially:
$ time python MyScript.py; mplayer ~/ScriptDone.wav
(You can use any player, naturally). I have a script called alertdone
that plays a tone and shows an libnotify alert when run; I use it for exactly this occasion:
$ time python MyScript.py; alertdone "Done timing"
It's really simple, so if you want to make your own you can base it on this (mine requires notify-more
, mplayer
, and ~/tones/alert_1.wav
though):
#!/bin/bash
message=$1:-"Finished working"
notify-more -t 10000 -i /usr/share/icons/gnome/32x32/actions/insert-object.png "Process Finished" "$message"
mplayer ~/tones/alert_1.wav
Just pick a sound on your hard drive, and put a command to play it right after the command you're waiting on; they'll happen sequentially:
$ time python MyScript.py; mplayer ~/ScriptDone.wav
(You can use any player, naturally). I have a script called alertdone
that plays a tone and shows an libnotify alert when run; I use it for exactly this occasion:
$ time python MyScript.py; alertdone "Done timing"
It's really simple, so if you want to make your own you can base it on this (mine requires notify-more
, mplayer
, and ~/tones/alert_1.wav
though):
#!/bin/bash
message=$1:-"Finished working"
notify-more -t 10000 -i /usr/share/icons/gnome/32x32/actions/insert-object.png "Process Finished" "$message"
mplayer ~/tones/alert_1.wav
answered Mar 4 '11 at 23:03
Michael Mrozekâ¦
59.1k27186207
59.1k27186207
2
notify-more
ornotify-send
could indeed be useful alternatives to playing a sound.
â Mikel
Mar 4 '11 at 23:19
@Mikel I'm completely addicted to libnotify; everything on my system pops up notifications
â Michael Mrozekâ¦
Mar 4 '11 at 23:31
add a comment |Â
2
notify-more
ornotify-send
could indeed be useful alternatives to playing a sound.
â Mikel
Mar 4 '11 at 23:19
@Mikel I'm completely addicted to libnotify; everything on my system pops up notifications
â Michael Mrozekâ¦
Mar 4 '11 at 23:31
2
2
notify-more
or notify-send
could indeed be useful alternatives to playing a sound.â Mikel
Mar 4 '11 at 23:19
notify-more
or notify-send
could indeed be useful alternatives to playing a sound.â Mikel
Mar 4 '11 at 23:19
@Mikel I'm completely addicted to libnotify; everything on my system pops up notifications
â Michael Mrozekâ¦
Mar 4 '11 at 23:31
@Mikel I'm completely addicted to libnotify; everything on my system pops up notifications
â Michael Mrozekâ¦
Mar 4 '11 at 23:31
add a comment |Â
up vote
8
down vote
time python MyScript.py; play /path/so/sound.ogg
play
is a very basic (no UI) sound player from the sox Install sox http://bit.ly/software-small package. You can replace it by any other command-line-driven sound player.
Yep,play
,aplay
, orpaplay
. (My Ubuntu system hasaplay
andpaplay
by default.)
â Mikel
Mar 4 '11 at 23:20
1
time python MyScript.py -n 40; paplay /usr/share/sounds/ubuntu/stereo/desktop-login.ogg
worked, thanks.
â Martin Thoma
Mar 5 '11 at 20:46
add a comment |Â
up vote
8
down vote
time python MyScript.py; play /path/so/sound.ogg
play
is a very basic (no UI) sound player from the sox Install sox http://bit.ly/software-small package. You can replace it by any other command-line-driven sound player.
Yep,play
,aplay
, orpaplay
. (My Ubuntu system hasaplay
andpaplay
by default.)
â Mikel
Mar 4 '11 at 23:20
1
time python MyScript.py -n 40; paplay /usr/share/sounds/ubuntu/stereo/desktop-login.ogg
worked, thanks.
â Martin Thoma
Mar 5 '11 at 20:46
add a comment |Â
up vote
8
down vote
up vote
8
down vote
time python MyScript.py; play /path/so/sound.ogg
play
is a very basic (no UI) sound player from the sox Install sox http://bit.ly/software-small package. You can replace it by any other command-line-driven sound player.
time python MyScript.py; play /path/so/sound.ogg
play
is a very basic (no UI) sound player from the sox Install sox http://bit.ly/software-small package. You can replace it by any other command-line-driven sound player.
answered Mar 4 '11 at 23:00
Gilles
514k12110211550
514k12110211550
Yep,play
,aplay
, orpaplay
. (My Ubuntu system hasaplay
andpaplay
by default.)
â Mikel
Mar 4 '11 at 23:20
1
time python MyScript.py -n 40; paplay /usr/share/sounds/ubuntu/stereo/desktop-login.ogg
worked, thanks.
â Martin Thoma
Mar 5 '11 at 20:46
add a comment |Â
Yep,play
,aplay
, orpaplay
. (My Ubuntu system hasaplay
andpaplay
by default.)
â Mikel
Mar 4 '11 at 23:20
1
time python MyScript.py -n 40; paplay /usr/share/sounds/ubuntu/stereo/desktop-login.ogg
worked, thanks.
â Martin Thoma
Mar 5 '11 at 20:46
Yep,
play
, aplay
, or paplay
. (My Ubuntu system has aplay
and paplay
by default.)â Mikel
Mar 4 '11 at 23:20
Yep,
play
, aplay
, or paplay
. (My Ubuntu system has aplay
and paplay
by default.)â Mikel
Mar 4 '11 at 23:20
1
1
time python MyScript.py -n 40; paplay /usr/share/sounds/ubuntu/stereo/desktop-login.ogg
worked, thanks.â Martin Thoma
Mar 5 '11 at 20:46
time python MyScript.py -n 40; paplay /usr/share/sounds/ubuntu/stereo/desktop-login.ogg
worked, thanks.â Martin Thoma
Mar 5 '11 at 20:46
add a comment |Â
up vote
8
down vote
spd-say
sleep 2; spd-say 'get back to work'
Infinite loop with -w
if you need extra motivation:
sleep 2; while true; do spd-say -w 'get back to work'; done
Pre-installed on 14.04 via package speech-dispatcher
: http://releases.ubuntu.com/trusty/ubuntu-14.04.4-desktop-amd64.manifest for blind people I suppose?
Also add a popup
This combo is a life saver:
b() ( spd-say 'done'; zenity --info --text "$(date);$(pwd)" & )
and then:
super-slow-command;b
If I'm somewhere in the room, I'll hear it and know that the long job is done.
Otherwise, I'll see the popup when I get back to my computer.
Related: https://stackoverflow.com/questions/7035/how-to-show-a-gui-message-box-from-a-bash-script-in-linux
To get thespd-say
tool associated withspeech-dispatcher
, you may need to install a subpackage likespeech-dispatcher-utils
(Fedora 24).
â dfarrell07
Dec 13 '16 at 18:27
add a comment |Â
up vote
8
down vote
spd-say
sleep 2; spd-say 'get back to work'
Infinite loop with -w
if you need extra motivation:
sleep 2; while true; do spd-say -w 'get back to work'; done
Pre-installed on 14.04 via package speech-dispatcher
: http://releases.ubuntu.com/trusty/ubuntu-14.04.4-desktop-amd64.manifest for blind people I suppose?
Also add a popup
This combo is a life saver:
b() ( spd-say 'done'; zenity --info --text "$(date);$(pwd)" & )
and then:
super-slow-command;b
If I'm somewhere in the room, I'll hear it and know that the long job is done.
Otherwise, I'll see the popup when I get back to my computer.
Related: https://stackoverflow.com/questions/7035/how-to-show-a-gui-message-box-from-a-bash-script-in-linux
To get thespd-say
tool associated withspeech-dispatcher
, you may need to install a subpackage likespeech-dispatcher-utils
(Fedora 24).
â dfarrell07
Dec 13 '16 at 18:27
add a comment |Â
up vote
8
down vote
up vote
8
down vote
spd-say
sleep 2; spd-say 'get back to work'
Infinite loop with -w
if you need extra motivation:
sleep 2; while true; do spd-say -w 'get back to work'; done
Pre-installed on 14.04 via package speech-dispatcher
: http://releases.ubuntu.com/trusty/ubuntu-14.04.4-desktop-amd64.manifest for blind people I suppose?
Also add a popup
This combo is a life saver:
b() ( spd-say 'done'; zenity --info --text "$(date);$(pwd)" & )
and then:
super-slow-command;b
If I'm somewhere in the room, I'll hear it and know that the long job is done.
Otherwise, I'll see the popup when I get back to my computer.
Related: https://stackoverflow.com/questions/7035/how-to-show-a-gui-message-box-from-a-bash-script-in-linux
spd-say
sleep 2; spd-say 'get back to work'
Infinite loop with -w
if you need extra motivation:
sleep 2; while true; do spd-say -w 'get back to work'; done
Pre-installed on 14.04 via package speech-dispatcher
: http://releases.ubuntu.com/trusty/ubuntu-14.04.4-desktop-amd64.manifest for blind people I suppose?
Also add a popup
This combo is a life saver:
b() ( spd-say 'done'; zenity --info --text "$(date);$(pwd)" & )
and then:
super-slow-command;b
If I'm somewhere in the room, I'll hear it and know that the long job is done.
Otherwise, I'll see the popup when I get back to my computer.
Related: https://stackoverflow.com/questions/7035/how-to-show-a-gui-message-box-from-a-bash-script-in-linux
edited Jun 13 at 9:29
answered Jul 28 '16 at 11:55
Ciro Santilli æ°çÂÂæ¹é ä¸Âå¿ å ÂÃ¥ÂÂäºÂ件 æ³Âè½®åÂÂ
4,46123938
4,46123938
To get thespd-say
tool associated withspeech-dispatcher
, you may need to install a subpackage likespeech-dispatcher-utils
(Fedora 24).
â dfarrell07
Dec 13 '16 at 18:27
add a comment |Â
To get thespd-say
tool associated withspeech-dispatcher
, you may need to install a subpackage likespeech-dispatcher-utils
(Fedora 24).
â dfarrell07
Dec 13 '16 at 18:27
To get the
spd-say
tool associated with speech-dispatcher
, you may need to install a subpackage like speech-dispatcher-utils
(Fedora 24).â dfarrell07
Dec 13 '16 at 18:27
To get the
spd-say
tool associated with speech-dispatcher
, you may need to install a subpackage like speech-dispatcher-utils
(Fedora 24).â dfarrell07
Dec 13 '16 at 18:27
add a comment |Â
up vote
3
down vote
You can also make this happen automatically.
I will show you how in zsh
, then add info about bash
.
The essence looks like this:
preexec()
starttime=$SECONDS
precmd()
if ((SECONDS - starttime >= 5)); then
aplay "sound.wav"
# or printf "b", or notify-send, or whatever
fi
You can also make it only do it if the program was Python, e.g.
preexec()
starttime=$SECONDS
case $3 in python*)
command_is_python=true;;
*)
command_is_python=false;;
esac
precmd()
if $command_is_python && ((SECONDS - starttime >= 5)); then
aplay "sound.wav"
# or printf "b", or notify-send, or whatever
fi
In bash
, the best way is to download preexec.bash.txt and source it (e.g. . ~/preexec.bash.txt
at the top of your ~/.bashrc
, then the above (or something close to it) should work. (Not sure about the $3
bit to check if the command is Python.)
If you're using GNOME Terminal, I would also point you to Flashing GNOME Terminal. It's a patch I wrote that makes the terminal blink when a command is done, so you can Alt-Tab to something else, then it lets you know when it's done.
add a comment |Â
up vote
3
down vote
You can also make this happen automatically.
I will show you how in zsh
, then add info about bash
.
The essence looks like this:
preexec()
starttime=$SECONDS
precmd()
if ((SECONDS - starttime >= 5)); then
aplay "sound.wav"
# or printf "b", or notify-send, or whatever
fi
You can also make it only do it if the program was Python, e.g.
preexec()
starttime=$SECONDS
case $3 in python*)
command_is_python=true;;
*)
command_is_python=false;;
esac
precmd()
if $command_is_python && ((SECONDS - starttime >= 5)); then
aplay "sound.wav"
# or printf "b", or notify-send, or whatever
fi
In bash
, the best way is to download preexec.bash.txt and source it (e.g. . ~/preexec.bash.txt
at the top of your ~/.bashrc
, then the above (or something close to it) should work. (Not sure about the $3
bit to check if the command is Python.)
If you're using GNOME Terminal, I would also point you to Flashing GNOME Terminal. It's a patch I wrote that makes the terminal blink when a command is done, so you can Alt-Tab to something else, then it lets you know when it's done.
add a comment |Â
up vote
3
down vote
up vote
3
down vote
You can also make this happen automatically.
I will show you how in zsh
, then add info about bash
.
The essence looks like this:
preexec()
starttime=$SECONDS
precmd()
if ((SECONDS - starttime >= 5)); then
aplay "sound.wav"
# or printf "b", or notify-send, or whatever
fi
You can also make it only do it if the program was Python, e.g.
preexec()
starttime=$SECONDS
case $3 in python*)
command_is_python=true;;
*)
command_is_python=false;;
esac
precmd()
if $command_is_python && ((SECONDS - starttime >= 5)); then
aplay "sound.wav"
# or printf "b", or notify-send, or whatever
fi
In bash
, the best way is to download preexec.bash.txt and source it (e.g. . ~/preexec.bash.txt
at the top of your ~/.bashrc
, then the above (or something close to it) should work. (Not sure about the $3
bit to check if the command is Python.)
If you're using GNOME Terminal, I would also point you to Flashing GNOME Terminal. It's a patch I wrote that makes the terminal blink when a command is done, so you can Alt-Tab to something else, then it lets you know when it's done.
You can also make this happen automatically.
I will show you how in zsh
, then add info about bash
.
The essence looks like this:
preexec()
starttime=$SECONDS
precmd()
if ((SECONDS - starttime >= 5)); then
aplay "sound.wav"
# or printf "b", or notify-send, or whatever
fi
You can also make it only do it if the program was Python, e.g.
preexec()
starttime=$SECONDS
case $3 in python*)
command_is_python=true;;
*)
command_is_python=false;;
esac
precmd()
if $command_is_python && ((SECONDS - starttime >= 5)); then
aplay "sound.wav"
# or printf "b", or notify-send, or whatever
fi
In bash
, the best way is to download preexec.bash.txt and source it (e.g. . ~/preexec.bash.txt
at the top of your ~/.bashrc
, then the above (or something close to it) should work. (Not sure about the $3
bit to check if the command is Python.)
If you're using GNOME Terminal, I would also point you to Flashing GNOME Terminal. It's a patch I wrote that makes the terminal blink when a command is done, so you can Alt-Tab to something else, then it lets you know when it's done.
edited Mar 4 '11 at 23:17
answered Mar 4 '11 at 23:12
Mikel
38.1k997123
38.1k997123
add a comment |Â
add a comment |Â
up vote
0
down vote
Personally, I use my-script && notify-send "done"
. This sends a desktop notification, which on Linux Mint looks like this:
New contributor
add a comment |Â
up vote
0
down vote
Personally, I use my-script && notify-send "done"
. This sends a desktop notification, which on Linux Mint looks like this:
New contributor
add a comment |Â
up vote
0
down vote
up vote
0
down vote
Personally, I use my-script && notify-send "done"
. This sends a desktop notification, which on Linux Mint looks like this:
New contributor
Personally, I use my-script && notify-send "done"
. This sends a desktop notification, which on Linux Mint looks like this:
New contributor
New contributor
answered 8 mins ago
Cee
1
1
New contributor
New contributor
add a comment |Â
add a comment |Â
up vote
-1
down vote
Any player can be used. I'm adding cvlc
for completeness.
add a comment |Â
up vote
-1
down vote
Any player can be used. I'm adding cvlc
for completeness.
add a comment |Â
up vote
-1
down vote
up vote
-1
down vote
Any player can be used. I'm adding cvlc
for completeness.
Any player can be used. I'm adding cvlc
for completeness.
answered Dec 26 '14 at 7:52
nponeccop
1668
1668
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f8607%2fhow-can-i-play-a-sound-when-script-execution-is-ready%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Are you using
bash
orzsh
? There are actually some ways of making this happen automatically, but they're quite involved and depend on which shell you are using.â Mikel
Mar 4 '11 at 23:06
$ echo $SHELL returns "/bin/bash"
â Martin Thoma
Mar 5 '11 at 20:39