Tuesday, May 14, 2024
104
rated 0 times [  104] [ 0]  / answers: 1 / hits: 128755  / 2 Years ago, mon, december 6, 2021, 1:00:05

I have started a long process through a terminal. Is it possible to make the Ubuntu terminal make a sound once the process is complete? This way, I don’t need to keep checking, but will instead be notified through a sound.


More From » command-line

 Answers
0

There are at least three command line ways to accomplish this by putting the suiting command at the end of your script you may invoke for your lengthy process:



  1. The "classical" way to play a sound is to use beep.


    Beep will make a tone through the PC speaker. However this will not work in all cases (e.g. in my system PC speakers are completely disabled) You may have to remove pcspkr from /etc/modprobe/blacklist.conf and load the pcspkr kernel module:


    sudo sed -i 's/blacklist pcspkr/#blacklist pcspkr/g' /etc/modprobe.d/blacklist.conf
    sudo modprobe pcspkr
    beep [optional parameters]


  2. We can also play any sound file in wav format using aplay (installed by default):


     aplay /usr/share/sounds/alsa/Side_Right.wav


  3. Another way is to use the pulseaudio command line interface to enable playback of any sound files your system (in libsndfile) recognizes on the default audio output:


      paplay /usr/share/sounds/freedesktop/stereo/complete.oga



We can use default sound files from /usr/share/sounds/, or any other sound file we may have in a different location.




Just to have mentioned it, there is another nice way to achieve this by misusing espeak, which is installed by default in Ubuntu <= 12.04. See, or rather hear the following example:


#! /bin/bash

c=10; while [ $c -ge 0 ]; do espeak $c; let c--; done; sleep 1 ## here lengthy code
espeak "We are done with counting"

In Ubuntu >= 12.10 Orca uses speak-dispatcher. We can then install espeak, or alternatively use spd-say "Text".


[#31915] Tuesday, December 7, 2021, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
laceanz

Total Points: 86
Total Questions: 113
Total Answers: 104

Location: Australia
Member since Thu, Jan 26, 2023
1 Year ago
laceanz questions
Tue, Apr 26, 22, 07:43, 2 Years ago
Sat, Oct 23, 21, 09:40, 3 Years ago
Sat, Nov 5, 22, 08:24, 2 Years ago
Sat, Mar 12, 22, 07:56, 2 Years ago
;