1
;; audio-events.jl -- map wm actions to audio samples
2
;; $Id: audio-events.jl,v 1.12 2001/01/08 00:37:28 jsh Exp $
4
;; Copyright (C) 2000 John Harper <john@dcs.warwick.ac.uk>
6
;; This file is part of sawmill.
8
;; sawmill is free software; you can redistribute it and/or modify it
9
;; under the terms of the GNU General Public License as published by
10
;; the Free Software Foundation; either version 2, or (at your option)
13
;; sawmill is distributed in the hope that it will be useful, but
14
;; 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.
18
;; You should have received a copy of the GNU General Public License
19
;; along with sawmill; see the file COPYING. If not, write to
20
;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
22
;;;###autoload (defgroup audio "Sound" :require sawfish.wm.ext.audio-events)
24
(define-structure sawfish.wm.ext.audio-events
26
(export audio-event-handler)
32
sawfish.wm.state.maximize)
34
(define-structure-alias audio-events sawfish.wm.ext.audio-events)
36
(defgroup audio "Sound"
37
:require sawfish.wm.ext.audio-events)
39
;; XXX it would be cool to merge the customization with the GNOME sound prefs
41
(defcustom audio-events-enabled nil
42
"Play sound effects for window events."
45
:require sawfish.wm.ext.audio-events
48
(defcustom audio-for-ignored-windows nil
49
"Play sound effects for unmanaged windows."
51
:depends audio-events-enabled
54
;; standard events are: iconified, uniconified, shaded, unshaded,
55
;; maximized, unmaximized, mapped, unmapped, mapped-transient,
56
;; unmapped-transient, switch-workspace, move-viewport, focused,
59
(defcustom audio-events-alist '((iconified . "slide.wav")
60
(uniconified . "slide.wav")
61
(shaded . "slide.wav")
62
(unshaded . "slide.wav")
63
(maximized . "slide.wav")
64
(unmaximized . "slide.wav")
65
(mapped . "activate.wav")
66
(unmapped . "gameover.wav")
67
(mapped-transient . "activate.wav")
68
(unmapped-transient . "toggled.wav")
69
;(focused . "clicked.wav")
70
(switch-workspace . "toggled.wav")
71
(move-viewport . "toggled.wav"))
73
:type* `(alist ((symbol iconified uniconified
77
mapped-transient unmapped-transient
78
switch-workspace move-viewport
79
focused unfocused) ,(_ "Event"))
80
(file ,(_ "Audio file")))
81
:widget-flags (expand-vertically)
82
:depends audio-events-enabled
85
(defun audio-event-handler (event #!optional w)
86
"Possibly play a sound sample for EVENT (a symbol) occurring on window W."
87
(when (and audio-events-enabled
89
(not (window-get w 'ignored))
90
audio-for-ignored-windows))
92
((sample (cdr (assq event audio-events-alist))))
94
(require 'sawfish.wm.util.play-audio)
95
(play-sample sample)))))
99
(defun audio-state-change-fun (w states)
100
(mapc (lambda (state)
103
(audio-event-handler (if (window-get w 'iconified)
104
'iconified 'uniconified) w))
106
(audio-event-handler (if (window-get w 'shaded)
107
'shaded 'unshaded) w))
109
(audio-event-handler (if (window-maximized-p w)
110
'maximized 'unmaximized) w)))) states))
112
(call-after-state-changed '(iconified shaded maximized)
113
audio-state-change-fun)
115
(defun audio-focus-in-fun (w)
116
(audio-event-handler 'focused w))
118
(add-hook 'focus-in-hook audio-focus-in-fun)
120
(defun audio-focus-out-fun (w)
121
(audio-event-handler 'unfocused w))
123
(add-hook 'focus-out-hook audio-focus-out-fun)
125
(defun audio-mapped-fun (w)
126
(audio-event-handler (if (window-transient-p w)
127
'mapped-transient 'mapped) w))
129
(add-hook 'map-notify-hook audio-mapped-fun)
131
(defun audio-unmapped-fun (w)
132
(audio-event-handler (if (window-transient-p w)
133
'unmapped-transient 'unmapped) w))
135
(add-hook 'unmap-notify-hook audio-unmapped-fun)
137
(defun audio-enter-ws-fun ()
138
(audio-event-handler 'switch-workspace))
140
(add-hook 'enter-workspace-hook audio-enter-ws-fun)
142
(defun audio-move-vp-fun ()
143
(audio-event-handler 'move-viewport))
145
(add-hook 'viewport-moved-hook audio-move-vp-fun))