* playing sounds from Emacs
@ 2017-08-14 0:16 Emanuel Berg
2017-08-14 21:49 ` Emanuel Berg
0 siblings, 1 reply; 3+ messages in thread
From: Emanuel Berg @ 2017-08-14 0:16 UTC (permalink / raw)
To: help-gnu-emacs
PS. Don't forget to download the sound
file! DS.
Remember the discussion where I said the computer
should be silent? Only the huge fan of the
nearby industrial plant, or the lazy buzz of
the starship engine, should make for a pleasant
trip to the oldest galaxies of the universe...
Anyway, I think it was I that came up with the
rule, that there isn't a rule without an
exception, so I decided to play a sound from
Emacs whenever I use a function to check the
integrity of the system, if the check turns
out OK!
So far, what happens is, it calls a shell
function. I actually happen to know, that that
is a fine way of doing it. Even so, it would be
interesting to hear of other ways and/or
interfaces that you are familiar with!
Here is the code:
(shell-command "omx-play-sound ~/bo/up.mp3")
;; Here is the sound file (89K) - bonus points
;; if you can identify the two parts :)
;;
;; http://user.it.uu.se/~embe8573/sounds/up.mp3
;; Here is the zsh function, in a file that is
;; 'source'd from ~/.zshenv to be visible from
;; Emacs:
;; omx-play-sound () {
;; local -a files
;; files=($@)
;;
;; check-files $files # error checking, never mind it
;; (( $? == 1 )) && return 1
;;
;; local vol=200
;;
;; for f in $files; do
;; sudo omxplayer \
;; --adev local \
;; --vol $vol \
;; $f \
;; > /dev/null # no verbose option in omxplayer(1)
;; done
;; }
;; Original files:
;;
;; http://user.it.uu.se/~embe8573/conf/.zshenv
;;
;; http://user.it.uu.se/~embe8573/conf/.zsh/omx
--
underground experts united
http://user.it.uu.se/~embe8573
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: playing sounds from Emacs
2017-08-14 0:16 playing sounds from Emacs Emanuel Berg
@ 2017-08-14 21:49 ` Emanuel Berg
2017-08-15 10:29 ` Marcin Borkowski
0 siblings, 1 reply; 3+ messages in thread
From: Emanuel Berg @ 2017-08-14 21:49 UTC (permalink / raw)
To: help-gnu-emacs
> (shell-command "omx-play-sound ~/bo/up.mp3")
To use `shell-command' like that means
everything halts until the command has been
executed, which we can't have, but simply
putting an "&" after - to make it
"asynchronous" which is a nice way of saying
the command will be executed in yet another
shell, a subshell - that won't work. I get ugly
output in buffer "*Async Shell Command*".
and an error message:
exited abnormally with code 1.
Perhaps some shell color codes are, well,
"async"! (So yes, in principle it should work.)
Anyway without digging into that, I have
another function that will do the job if an
ampersand (&) is appended the command. Here it
is:
(defun shell-command-silent (command)
"Execute a shell COMMAND.
Use & after the command to execute it in the background,
without output to the echo area."
(process-file shell-file-name
nil ; INFILE
nil ; BUFFER
nil ; DISPLAY
shell-command-switch command) )
--
underground experts united
http://user.it.uu.se/~embe8573
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: playing sounds from Emacs
2017-08-14 21:49 ` Emanuel Berg
@ 2017-08-15 10:29 ` Marcin Borkowski
0 siblings, 0 replies; 3+ messages in thread
From: Marcin Borkowski @ 2017-08-15 10:29 UTC (permalink / raw)
To: Emanuel Berg; +Cc: help-gnu-emacs
On 2017-08-14, at 23:49, Emanuel Berg <moasen@zoho.com> wrote:
>> (shell-command "omx-play-sound ~/bo/up.mp3")
>
> To use `shell-command' like that means
> everything halts until the command has been
> executed, which we can't have, but simply
> putting an "&" after - to make it
> "asynchronous" which is a nice way of saying
> the command will be executed in yet another
> shell, a subshell - that won't work. I get ugly
> output in buffer "*Async Shell Command*".
> and an error message:
>
> exited abnormally with code 1.
>
> Perhaps some shell color codes are, well,
> "async"! (So yes, in principle it should work.)
Dunno about the non-zero exit code, but did you see this:
http://mbork.pl/2016-04-07_Hiding_those_annoying_Async_Shell_Command_buffers
?
Also - for the record - this:
http://mbork.pl/2016-04-12_Showing_some_of_those_Async_Shell_Command_buffers
and that:
http://git.savannah.gnu.org/cgit/emacs.git/commit/etc/NEWS?id=85512e752191091d38cd5e34e7bed80eac1e9013
And also, `call-process-shell-command' and `shell-command-to-string'.
Hth,
--
Marcin Borkowski
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-08-15 10:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-14 0:16 playing sounds from Emacs Emanuel Berg
2017-08-14 21:49 ` Emanuel Berg
2017-08-15 10:29 ` Marcin Borkowski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).