1 ;; 17-emchat-sy.el --- EMchat Settings -*- Emacs-Lisp -*-
3 ;; Copyright (C) 2007 - 2013 Steve Youngs
5 ;; Author: Steve Youngs <steve@sxemacs.org>
6 ;; Maintainer: Steve Youngs <steve@sxemacs.org>
7 ;; Created: <2007-12-02>
8 ;; Time-stamp: <Thursday Aug 22, 2013 23:56:57 steve>
9 ;; Download: <http://bastard.steveyoungs.com/~steve/SXEmacs/inits/>
10 ;; HTMLised: <http://bastard.steveyoungs.com/~steve/SXEmacs/htmlinits/17-emchat-sy.html>
11 ;; Git Repo: git clone http://git.sxemacs.org/syinit
12 ;; Keywords: init, compile
14 ;; This file is part of SYinit
16 ;; Redistribution and use in source and binary forms, with or without
17 ;; modification, are permitted provided that the following conditions
20 ;; 1. Redistributions of source code must retain the above copyright
21 ;; notice, this list of conditions and the following disclaimer.
23 ;; 2. Redistributions in binary form must reproduce the above copyright
24 ;; notice, this list of conditions and the following disclaimer in the
25 ;; documentation and/or other materials provided with the distribution.
27 ;; 3. Neither the name of the author nor the names of any contributors
28 ;; may be used to endorse or promote products derived from this
29 ;; software without specific prior written permission.
31 ;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
32 ;; IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
33 ;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
34 ;; DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
35 ;; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
36 ;; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
37 ;; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
38 ;; BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
39 ;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
40 ;; OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
41 ;; IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
45 ;; My EMchat settings.
50 ;; The HTML version of this file was created with Hrvoje Niksic's
51 ;; htmlize.el which is part of the XEmacs "text-modes" package.
59 ;:*=======================
63 ;;; Experimental stuff
66 ;; EMchat works great in a tty, but some settings I use are best
67 ;; suited for X, so this just turns them off.
68 (defun tty-im-setup ()
69 "Set some things so I can use EMchat/Riece in tty."
71 (setq emchat-status-use-gutter nil
72 emchat-start-in-new-frame nil
73 emchat-wharf-frame-use-p nil))
76 (when (device-on-window-system-p)
77 (setq emchat-status-use-gutter t
78 emchat-start-in-new-frame t))
81 emchat-doctor-enabled-flag t
82 emchat-emphasis-enabled-flag t
83 emchat-history-enabled-flag t
84 emchat-log-fill-column 72
87 emchat-track-indicator-type 'char
88 emchat-user-alias "JackaLX"
89 emchat-user-password (getenv "ICQPASSWD")
90 emchat-user-meta-nickname "JackaLX"
91 emchat-user-meta-firstname "Steve"
92 emchat-user-meta-lastname "Youngs"
93 emchat-user-meta-primary-email "steve@sxemacs.org"
94 emchat-user-meta-secondary-email "steve@steveyoungs.com"
95 emchat-user-meta-city "Brisbane"
96 emchat-user-meta-state "DOA"
97 emchat-user-meta-hide-ip t
98 emchat-user-meta-authorization t
99 emchat-user-meta-about
100 "EMchat Maintainer.\n
101 If you'd like to help out with the EMchat project,
102 please send me a message. Or go to:
103 <http://www.emchat.org/>\n
104 SXEmacs - It's not just an editor.
106 <http://www.sxemacs.org/>"
107 emchat-user-meta-homepage "http://www.sxemacs.org/"
108 emchat-user-meta-sex 'male
109 emchat-user-meta-language-1 12
110 emchat-user-meta-language-2 12
111 emchat-user-meta-language-3 12
112 emchat-user-meta-web-aware t
113 emchat-user-initial-status "online"
114 emchat-user-meta-age 38
115 emchat-user-meta-birth-day 19
116 emchat-user-meta-birth-month 6
117 emchat-user-meta-birth-year 66
118 emchat-user-meta-cell-phone "6666 6666"
119 emchat-user-meta-country 61
120 emchat-user-meta-fax "7777 7777"
121 emchat-user-meta-phone "8888 8888"
122 emchat-user-meta-street "1 Linux Lane"
123 emchat-user-meta-work-homepage "http://www.sxemacs.org/"
124 emchat-user-meta-work-address "What me, work?"
125 emchat-user-meta-work-city "Penguinville"
126 emchat-user-meta-work-company "SlackBiz"
127 emchat-user-meta-work-department "Slackers"
128 emchat-user-meta-work-fax "9999 9999"
129 emchat-user-meta-work-phone "5555 5555"
130 emchat-user-meta-work-position "Seated"
131 emchat-user-meta-work-state "DOA"
132 emchat-user-meta-zipcode "9999"
133 emchat-buddy-view 'emchat-all-aliases
134 emchat-use-sound-flag nil
135 emchat-save-log-on-exit-p nil
136 emchat-log-debug-flag t
137 emchat-user-meta-invisible nil
138 emchat-buddy-show-xface t)
140 ;; PulseAudio only seems to work if X is running
141 (when (getenv "DISPLAY")
142 (setq emchat-use-sound-flag t))
144 ;; Lets not auto-away.
145 (customize-set-variable 'emchat-auto-away-timeout 0)
147 (emchat-world-update)
149 (when emchat-use-sound-flag
150 (setq emchat-audio-device
151 ;(make-audio-device 'alsa))
152 (make-audio-device 'pulse
153 :client "SXEmacs::EMchat"
154 :stream "EMchat::Stream"
156 ;; SXEmacs doesn't like current ffmpeg, and SoX is dodgy ATM too
157 (setq emchat-media-driver 'sndfile)
158 (setq default-media-stream-volume 50)
159 (setq emchat-sound-alist
160 '((auth-sound . "Auth.wav")
161 (buddy-sound . "Online.wav")
162 (chat-sound . "Chat.wav")
163 (emailx-sound . "System.wav")
164 (message-sound . "Message.wav")
165 (pager-sound . "System.wav")
166 (system-sound . "System.wav")
167 (url-sound . "URL.wav"))))
170 ;:*=======================
171 ;:* Addons/extensions
173 (defun sy-emchat-now-playing ()
174 "Return title/artist of current song."
176 (format "NP: %s" (mpd-now-playing)))
178 (defun sy-emchat-send-now-playing ()
179 "Send title/artist of current song."
181 (let ((song (sy-emchat-now-playing))
182 (alias (emchat-alias-around)))
183 (emchat-send-message song alias)))
185 (defun sy-emchat-yow ()
186 "When you can't think of what to say..."
188 (let ((message (yow))
189 (alias (emchat-alias-around)))
190 (emchat-send-message message alias)))
193 (require 'emchat-menu)
194 (define-key emchat-log-mode-map (kbd "C-c p") #'sy-emchat-send-now-playing)
195 (define-key emchat-log-mode-map (kbd "C-c y") #'sy-emchat-yow)
197 ;:*=======================
203 ;;(defun sy-emchat-temp (&optional fahrenheit)
204 ;; "Returns a string to send to a ICQ user saying the current temp.
206 ;;With optional arg, FAHRENHEIT, don't send the temp in celsius."
208 ;; (let ((xwem-weather-temperature-format 'fahrenheit))
209 ;; (format "The current temperature here is: %s°F"
210 ;; (substring (xwem-weather-get-temp) 0 -2)))
211 ;; (let ((xwem-weather-temperature-format 'celsius))
212 ;; (format "The current temperature here is: %s°C"
213 ;; (substring (xwem-weather-get-temp) 0 -2)))))
215 (defconst sy-beer-love
216 ["when you realise, 24 beers in a case, 24 hours in a day. Coincidence?"
217 "when you wake up with `CRS'... Can't Remember Shit."
218 "when, to you, it's not a six-pack, it's a support group."
219 "when it is the reason you get up every afternoon."
220 "when you favour the 2 party system... party on Friday, party on Saturday."
221 "when getting f#@ked up is your hobby."]
222 "Proof you love beer.")
224 (defun sy-emchat-beer-love ()
225 (let ((prefix "You know you love beer... ")
226 (love (aref sy-beer-love
227 (% (+ (% (random t) 1000) 1000)
228 (length sy-beer-love)))))
229 (concat prefix love)))
231 (defun sy-emchat-incoming-msg-hook ()
232 (when (or (member alias emchat-visible-contacts)
233 (not (member alias emchat-invisible-contacts)))
234 (let ((repo "The main EMchat git repo is:
235 git clone http://git.emchat.org/emchat")
236 (download "EMchat source tarballs and (S)XEmacs pkg tarballs
237 can be downloaded from: Offline ATM, sorry")
238 (latest (shell-command-to-string
239 "cd ~/programming/EMchat/emchat && git describe"))
240 (lastlog (shell-command-to-string
241 "cd ~/programming/EMchat/emchat && git log -1"))
242 (time (format-time-string "The local time here is: %c"))
243 (beer (sy-emchat-beer-love))
244 (song (sy-emchat-now-playing))
245 (help "Cmds are prefixed with `,,' (ie, ,,cmd). Only the first
246 valid cmd in a msg is accepted. The cmd can appear anywhere in
249 Accepted cmds: version, latest, lastlog, emchat-repo, download, yow,
250 time, beer, song, help."))
251 (cond ((string-match ",,version" message)
252 (emchat-send-message-helper
253 (format "I am using %s" (emchat-version)) (list alias)
254 'automatic "Version sent"))
255 ((string-match ",,latest" message)
256 (emchat-send-message-helper latest (list alias) 'automatic "Latest sent"))
257 ((string-match ",,lastlog" message)
258 (emchat-send-message-helper lastlog (list alias) 'automatic "Lastlog sent"))
259 ((string-match ",,emchat-repo" message)
260 (emchat-send-message-helper repo (list alias) 'automatic "Repo sent"))
261 ((string-match ",,download" message)
262 (emchat-send-message-helper download (list alias) 'automatic "Download sent"))
263 ((string-match ",,yow" message)
264 (emchat-send-message-helper (format "%s" (yow)) (list alias)
265 'automatic "Yow sent"))
266 ((string-match ",,time" message)
267 (emchat-send-message-helper time (list alias) 'automatic "Time sent"))
268 ;((string-match ",,temp-f" message)
269 ; (emchat-send-message (sy-emchat-temp 'fahrenheit) alias))
270 ;((string-match ",,temp" message)
271 ; (emchat-send-message (sy-emchat-temp) alias))
272 ((string-match ",,beer" message)
273 (emchat-send-message-helper beer (list alias) 'automatic "Beer sent"))
274 ((string-match ",,song" message)
275 (emchat-send-message-helper song (list alias) 'automatic "Song sent"))
276 ((string-match ",,help" message)
277 (emchat-send-message-helper help (list alias) 'automatic "Help sent"))))))
279 (add-hook 'emchat-new-message-hook #'sy-emchat-incoming-msg-hook)
281 (defun sy-emchat-zero-wharf ()
282 "Helper func to zero wharf counters."
284 (emchat-wharf-change-messages "New" -9999)
285 (emchat-wharf-change-messages "Sys" -9999))
287 ;; Use the Wharf if not using XWEM
288 (unless (or (string= "notyet" (getenv "XWEM_RUNNING"))
289 (string= "yes" (getenv "XWEM_RUNNING"))
290 (not (device-on-window-system-p)))
291 (require 'emchat-wharf)
292 (setq emchat-wharf-frame-use-p t)
293 (setq emchat-wharf-notice-riece-flag t)
294 (push (cons 'left 1690) emchat-wharf-frame-props)
295 (push (cons 'top 5) emchat-wharf-frame-props)
296 (push (cons 'internal-border-width 4) emchat-wharf-frame-props)
297 ;; `override-redirect' means no WM decorations, and you also get
298 ;; sticky and always on top and skip pagers and task lists etc.
299 (push (cons 'override-redirect t) emchat-wharf-frame-props)
300 (push (cons 'border-width 1) emchat-wharf-frame-props)
301 (push (cons 'border-color "red") emchat-wharf-frame-props)
302 (add-hook 'emchat-new-message-hook #'emchat-wharf-inc-messages)
303 (add-hook 'emchat-system-message-hook #'emchat-wharf-inc-system)
304 (add-hook 'emchat-read-message-hook #'emchat-wharf-dec-messages)
305 (add-hook 'riece-biff-activity-hook #'emchat-wharf-riece-active)
306 (add-hook 'riece-biff-clear-hook #'emchat-wharf-riece-inactive)
307 (add-hook 'emchat-track-clear-hook #'sy-emchat-zero-wharf)
308 (define-key emchat-log-mode-map [?C] #'sy-emchat-zero-wharf))
310 ;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*
311 (message "EMchat settings loaded")