1;; mate.jl -- MATE integration
2
3;; Copyright (C) 2011 Christopher Roy Bratusek <nano@jpberlin.de>
4
5;; This file is part of sawfish.
6
7;; sawfish is free software; you can redistribute it and/or modify it
8;; under the terms of the GNU General Public License as published by
9;; the Free Software Foundation; either version 2, or (at your option)
10;; any later version.
11
12;; sawfish is distributed in the hope that it will be useful, but
13;; WITHOUT ANY WARRANTY; without even the implied warranty of
14;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15;; GNU General Public License for more details.
16
17;; You should have received a copy of the GNU General Public License
18;; along with sawfish; see the file COPYING.  If not, write to
19;; the Free Software Foundation, 51 Franklin Street, Fifth Floor,
20;; Boston, MA 02110-1301 USA.
21
22(define-structure sawfish.wm.integration.mate
23
24    (export detect-mate)
25
26    (open rep
27	  rep.system
28          sawfish.wm.menus
29	  sawfish.wm.misc
30          sawfish.wm.custom
31          sawfish.wm.commands
32          sawfish.wm.commands.launcher)
33
34  (define-structure-alias mate-int sawfish.wm.integration.mate)
35
36  (define (init)
37    (let (menu)
38      (setq desktop-environment "mate")
39      (setq want-poweroff-menu nil)
40
41      ;; invoke the MATE terminal instead of xterm
42      (unless (variable-customized-p 'xterm-program)
43	(setq xterm-program "mate-terminal"))
44
45      ;; use the MATE help browser and url launcher
46      (unless (variable-customized-p 'browser-program)
47	(setq browser-program "mate-www-browser"))
48
49      ;; use the MATE filemanager
50      (unless (variable-customized-p 'filemanager-program)
51	(setq filemanager-program "caja"))
52
53      ;; add some MATE menu-entries
54      (when (setq menu (assoc (_ "_Help") root-menu))
55	(nconc menu `(()
56		      (,(_ "_MATE Help") (system "yelp &"))
57		      (,(_ "MATE _Website") (browser "http://www.matsusoft.com.ar/projects/mate/"))
58		      (,(_ "_About MATE") (system "mate-about &")))))
59
60      ;; add mate-logout and customize menu-entries
61      (when (setq menu (assoc (_ "Sessi_on") root-menu))
62	(nconc menu `(()
63		      (,(_ "_Customize MATE") (system "mate-control-center &"))
64		      (,(_ "_Edit MATE menu") (system "menulibre &"))
65		      ()
66		      (,(_ "L_ock screen from MATE")
67			(system "mate-screensaver-command -l &"))
68		      (,(_ "_Logout from MATE")
69		       (system "mate-session-save --logout-dialog &"))
70		      (,(_ "_Shutdown from MATE")
71		       (system "mate-session-save --shutdown-dialog &")))))))
72
73  ;; Returns nil if mate is not found.
74  ;; If detected, returns t, and do also mate support init.
75  (define (detect-mate)
76    (when (or (equal (getenv "XDG_CURRENT_DESKTOP") "MATE")
77              (equal (getenv "DESKTOP_SESSION") "sawfish-mate")
78              (getenv "MATE_DESKTOP_SESSION_ID"))
79      (init)
80      t)))
81