linux - воспроизводить звук при входе в систему?

439
mpy

Я установил Gentoo без графического интерфейса и добавил aplay /usr/shar/sounds/startup3.wav &> /dev/null &в мой файл / etc / bash / bashrc. Это прекрасно работает при воспроизведении звукового файла, но как только звук заканчивается, и я нажимаю Enter, он говорит мне, что процесс завершен. Когда я запускаю звук на переднем плане, у меня нет возможности что-либо делать в своем терминале, пока звук не закончится.

Можно ли как-нибудь воспроизвести звук без каких-либо выходных или сбоев после входа в систему?

0

1 ответ на вопрос

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$ 
В bash `(sleep 10 &)` - это часто используемый обходной путь. `setsid sleep 10` - другой, в зависимости от требований (он отличается от` & `тем, что он также отсоединяется от управляющего tty). grawity 11 лет назад 2
Спасибо за ваш подробный ответ. Я закончил тем, что выполнил `(command &)` из приведенного выше комментария, но лучше узнать о disown, а также `&!` В zsh. 11 лет назад 0

Похожие вопросы