*** empty log message ***
[gnus] / lisp / gnus-audio.el
1 ;;; gnus-audio.el --- Sound effects for Gnus
2 ;; Copyright (C) 1996 Free Software Foundation
3
4 ;; Author: Steven L. Baur <steve@miranova.com>
5
6 ;; This file is part of GNU Emacs.
7
8 ;; GNU Emacs is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation; either version 2, or (at your option)
11 ;; any later version.
12
13 ;; GNU Emacs is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 ;; GNU General Public License for more details.
17
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
20 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 ;; Boston, MA 02111-1307, USA.
22
23 ;;; Commentary:
24 ;; This file provides access to sound effects in Gnus.
25 ;; Prerelease:  This file is partially stripped to support earcons.el
26 ;; You can safely ignore most of it until Red Gnus.  **Evil Laugh**
27 ;;; Code:
28
29 (when (null (boundp 'running-xemacs))
30   (defvar running-xemacs (string-match "XEmacs\\|Lucid" emacs-version)))
31
32 (require 'nnheader)
33 (eval-when-compile (require 'cl))
34
35 (defvar gnus-audio-inline-sound
36   (and (fboundp 'device-sound-enabled-p)
37        (device-sound-enabled-p))
38   "When t, we will not spawn a subprocess to play sounds.")
39
40 (defvar gnus-audio-directory (nnheader-find-etc-directory "sounds")
41   "The directory containing the Sound Files.")
42
43 (defvar gnus-audio-au-player "/usr/bin/showaudio"
44   "Executable program for playing sun AU format sound files.")
45
46 (defvar gnus-audio-wav-player "/usr/local/bin/play"
47   "Executable program for playing WAV files.")
48
49 ;;; The following isn't implemented yet.  Wait for Millennium Gnus.
50 ;(defvar gnus-audio-effects-enabled t
51 ;  "When t, Gnus will use sound effects.")
52 ;(defvar gnus-audio-enable-hooks nil
53 ;  "Functions run when enabling sound effects.")
54 ;(defvar gnus-audio-disable-hooks nil
55 ;  "Functions run when disabling sound effects.")
56 ;(defvar gnus-audio-theme-song nil
57 ;  "Theme song for Gnus.")
58 ;(defvar gnus-audio-enter-group nil
59 ;  "Sound effect played when selecting a group.")
60 ;(defvar gnus-audio-exit-group nil
61 ;  "Sound effect played when exiting a group.")
62 ;(defvar gnus-audio-score-group nil
63 ;  "Sound effect played when scoring a group.")
64 ;(defvar gnus-audio-busy-sound nil
65 ;  "Sound effect played when going into a ... sequence.")
66
67
68 ;;;###autoload
69                                         ;(defun gnus-audio-enable-sound ()
70 ;  "Enable Sound Effects for Gnus."
71 ;  (interactive)
72 ;  (setq gnus-audio-effects-enabled t)
73 ;  (gnus-run-hooks gnus-audio-enable-hooks))
74
75 ;;;###autoload
76                                         ;(defun gnus-audio-disable-sound ()
77 ;  "Disable Sound Effects for Gnus."
78 ;  (interactive)
79 ;  (setq gnus-audio-effects-enabled nil)
80 ;  (gnus-run-hooks gnus-audio-disable-hooks))
81
82 ;;;###autoload
83 (defun gnus-audio-play (file)
84   "Play a sound through the speaker."
85   (interactive)
86   (let ((sound-file (if (file-exists-p file)
87                         file
88                       (concat gnus-audio-directory file))))
89     (when (file-exists-p sound-file)
90       (if gnus-audio-inline-sound
91           (play-sound-file sound-file)
92         (cond ((string-match "\\.wav$" sound-file)
93                (call-process gnus-audio-wav-player
94                              sound-file
95                              0
96                              nil
97                              sound-file))
98               ((string-match "\\.au$" sound-file)
99                (call-process gnus-audio-au-player
100                              sound-file
101                              0
102                              nil
103                              sound-file)))))))
104
105
106 ;;; The following isn't implemented yet, wait for Red Gnus
107                                         ;(defun gnus-audio-startrek-sounds ()
108 ;  "Enable sounds from Star Trek the original series."
109 ;  (interactive)
110 ;  (setq gnus-audio-busy-sound "working.au")
111 ;  (setq gnus-audio-enter-group "bulkhead_door.au")
112 ;  (setq gnus-audio-exit-group "bulkhead_door.au")
113 ;  (setq gnus-audio-score-group "ST_laser.au")
114 ;  (setq gnus-audio-theme-song "startrek.au")
115 ;  (add-hook 'gnus-select-group-hook 'gnus-audio-startrek-select-group)
116 ;  (add-hook 'gnus-exit-group-hook 'gnus-audio-startrek-exit-group))
117 ;;;***
118
119 (defvar gnus-startup-jingle "Tuxedomoon.Jingle4.au"
120   "Name of the Gnus startup jingle file.")
121
122 (defun gnus-play-jingle ()
123   "Play the Gnus startup jingle, unless that's inhibited."
124   (interactive)
125   (gnus-audio-play gnus-startup-jingle))
126
127 (provide 'gnus-audio)
128
129 (run-hooks 'gnus-audio-load-hook)
130
131 ;;; gnus-audio.el ends here