;;; -*- mode: stumpwm -*-
;;; StumpWmRC: 
;;; $Author: tv.raman.tv $
;;; Keywords: StumpWM, Emacspeak, Audio Desktop
(in-package :stumpwm)
;;{{{Variables:
;;; Avoid focus getting stolen due to activity.

(setq *deny-raise-request* t)
(defvar *emacspeak-dir* "/home/raman/emacs/lisp/emacspeak"
  "Root directory of Emacspeak installation.")
(defvar *tts-window-icon*
  (concatenate 'string
               *emacspeak-dir*
               "/"
               "sounds/chimes/window-resize.ogg")
  "Window change icon.")

(defvar *tts-off-icon*
  (concatenate 'string
               *emacspeak-dir*
               "/"
               "sounds/chimes/off.ogg")
  "Off icon.")

(defvar *tts-on-icon*
  (concatenate 'string
               *emacspeak-dir*
               "/"
               "sounds/chimes/on.ogg")
  "On icon.")

;;}}}
;;{{{Prefix key matches my screen setup:

(set-prefix-key (kbd "C-\\"))

;;}}}
;;{{{TTS

(load
 (concatenate 'string
              *emacspeak-dir*
              "/"
              "stumpwm/tts.lisp"))

(setq *tts-engine*
(concatenate 'string   *emacspeak-dir* "/servers/dtk-soft"))

(tts-say "TTS: Ready to talk! ")
(tts-rate 300)
;;}}}
;;{{{Speak Actions:
(defun speak-window-change (new old)
  "Speak current window  information."
  (declare (special *tts-window-icon*))
  (when new
  (stumpwm:run-shell-command "/usr/local/bin/emstop")
    (tts-serve-icon *tts-window-icon*)
    (tts-speak
     (concatenate 'string
                  (window-name new)
                  (time-format " %l %M%p")))))



(defun speak-this-window (window)
  "Speak this window  information."
  (tts-speak (window-name window)))

(defun speak-current-window ()
  "Speak current window  information."
  (tts-speak (window-name (current-window))))

(defvar *tts-speak-messages* t
  "Switch messages on and off.")

(defcommand  tts-toggle-speak-messages ()
  ()
  "Toggle state of speak messages switch."
  (setq *tts-speak-messages* (not *tts-speak-messages*))
  (tts-serve-icon
   (if *tts-speak-messages*
       *tts-on-icon*
       *tts-off-icon*)))

(define-key *root-map* (kbd "t") "tts-toggle-speak-messages")

(defun speak-messages (&rest messages)
  "Speak messages, a list of lines."
  (declare (special *tts-speak-messages*))
  (when *tts-speak-messages*
    (tts-speak
     (apply
      #'concatenate  'string
      (mapcar #'stumpwm::uncolorify messages)))))

;;}}}
;;{{{Attach Handlers:

(setq  *focus-window-hook* (list 'speak-window-change))
(setq *new-window-hook* (list 'speak-this-window))
(setq *message-hook* (list 'speak-messages))

;;}}}
;;{{{Chrome:

(defcommand chrome ()
  ()
  "Start  or switch to Chrome."
  (run-or-raise "$HOME/bin/g" '(:class "chrome" :title "Chrome")))

(define-key *root-map* (kbd "g") "chrome")


;;}}}
;;{{{ end-session:
(add-to-load-path #p "/home/raman/sourceforge/stumpwm/contrib/util/end-session/")
(load-module "end-session")
(define-key *root-map* (kbd "L") "logout")
;;}}}
;;{{{orca if you need it:
(defvar *orca-running-p* nil
  "Is orca running?")

(defcommand  toggle-orca ()
             ()
             "Toggle state of orca."
             (cond
              (*orca-running-p*
               (stumpwm:run-shell-command "pkill orca&")
               (setq *orca-running-p* nil))
              (t  (stumpwm:run-shell-command "orca -r &")
                  (setq *orca-running-p* t)))
             (tts-serve-icon
              (if *orca-running-p*
                  *tts-on-icon*
                *tts-off-icon*)))

(define-key *root-map* (kbd "O") "toggle-orca")

;;}}}
;;{{{wallpaper:

(stumpwm:run-shell-command  
    " feh --no-fehbg --bg-center '/home/raman/emacs/lisp/emacspeak/etc/tilden-face.jpg' ")

;;}}}
;;{{{Emacs local variables

;;; local variables:
;;; mode: stumpwm
;;; mode: folding
;;; folded-file: t
;;; end:

;;}}}

