Linux - Ton beim Anmelden abspielen?

545
mpy

Ich habe Gentoo ohne GUI installiert und an aplay /usr/shar/sounds/startup3.wav &> /dev/null &meine Datei / etc / bash / bashrc angehängt . Das funktioniert gut beim Abspielen der Sounddatei, aber sobald der Sound zu Ende ist und ich die Eingabetaste drücke, wird der Vorgang abgeschlossen. Wenn ich den Sound im Vordergrund abspielen lasse, kann ich nichts in meinem Terminal tun, bis der Sound vollständig abgespielt ist.

Gibt es eine Möglichkeit, den Sound nach dem Einloggen ohne Ausgabe oder Unterbrechung wiederzugeben?

0

1 Antwort auf die Frage

0
mpy

That "Done" message is because the shell has the command still under its job control:

$ sleep 10 & [1] 660 $ jobs [1]+ Running sleep 10 & (time passes) $ [1]+ Done sleep 10 

You can simply remove all jobs from job control with disown(a)

$ sleep 100 & [1] 3804 $ jobs [1]+ Running sleep 100 & $ disown $ jobs $ 

I don't know a method to disown a job right with its start(b), so I propose that you simply put a disown to your bashrc, right after the sound command. However this will disown all jobs -- I don't know if this is wanted. Otherwise you can use disown %aplay.


(a) man bash

disown [-ar] [-h] [jobspec ...] Without options, each jobspec is removed from the table of active jobs. If jobspec is not present, and neither -a nor -r is supplied, the shell's notion of the current job is used. If the -h option is given, each jobspec is not removed from the table, but is marked so that SIGHUP is not sent to the job if the shell receives a SIGHUP. If no jobspec is present, and neither the -a nor the -r option is supplied, the current job is used. If no jobspec is supplied, the -a option means to remove or mark all jobs; the -r option without a jobspec argument restricts operation to running jobs. The return value is 0 unless a jobspec does not specify a valid job.

(b) However, in the Z Shell zshthis is easy:

zsh$ sleep 10 &! zsh$ jobs zsh$ 
In bash, `(sleep 10 &)` is a frequently used workaround. `setsid sleep 10` is another, depending on the requirements (it's different from `&` in that it also detaches from the controlling tty). grawity vor 11 Jahren 2
Vielen Dank für Ihre ausführliche Antwort. Letztendlich habe ich `(command &) 'aus dem Kommentar oben gemacht, aber es ist gut über disown zu wissen, sowie' &! 'In zsh. vor 11 Jahren 0