1;; xfce.jl -- XFCE integration
2
3;; Copyright (C) 2010 Christopher 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.xfce
23
24    (export detect-xfce)
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 xfce-int sawfish.wm.integration.xfce)
35
36  (define (init)
37    (let (menu)
38      (setq desktop-environment "xfce")
39      (setq want-poweroff-menu nil)
40
41      ;; invoke the XFCE terminal instead of xterm
42      (unless (variable-customized-p 'xterm-program)
43	(setq xterm-program "xfce4-terminal"))
44
45      ;; use the XFCE help browser and url launcher
46      (unless (variable-customized-p 'browser-program)
47	(setq browser-program "midori"))
48
49      ;; use the XFCE filemanager
50      (unless (variable-customized-p 'filemanager-program)
51	(setq filemanager-program "thunar"))
52
53      ;; add some XFCE help menus
54      (when (setq menu (assoc (_ "_Help") root-menu))
55	(nconc menu `(()
56		      (,(_ "_XFCE Help") (system "xfhelp4 &"))
57		      (,(_ "XFCE _Website") (browser "http://www.xfce.org"))
58		      (,(_ "_About XFCE") (system "xfce4-about &")))))
59
60      ;; add xfce-logout menu item
61      (when (setq menu (assoc (_ "Sessi_on") root-menu))
62	(nconc menu `(()
63		      (,(_ "_Customize XFCE") (system "xfce4-settings-manager &"))
64		      (,(_ "_Edit XFCE Menu") (system "menulibre &"))
65		      ()
66		      (,(_ "L_ock from XFCE")
67			(system "xflock4 &"))
68		      (,(_ "_Logout from XFCE")
69		       (system "xfce4-session-logout --logout -f &"))
70		      (,(_ "_Reboot from XFCE")
71		       (system "xfce4-session-logout --reboot -f &"))
72		      (,(_ "_Shutdown from XFCE")
73		       (system "xfce4-session-logout --halt -f &"))
74		      (,(_ "_Hibernate from XFCE")
75			(system "xfce4-session-logout --hibernate -f &"))
76		      (,(_ "S_uspend from XFCE")
77			(system "xfce4-session-logout --suspend -f &")))))))
78
79  ;; Returns nil if xfce is not found.
80  ;; If detected, returns t, and do also xfce support init.
81  (define (detect-xfce)
82    (when (or (get-x-property 'root '_DT_SAVE_MODE)
83              (equal (getenv "DESKTOP_SESSION") "sawfish-xfce")
84              (equal (getenv "XDG_CURRENT_DESKTOP") "XFCE"))
85      (init)
86      t)))
87