[sawfish: 2/13] Desktop detection minor cleanup.
- From: Christopher Bratusek <chrisb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sawfish: 2/13] Desktop detection minor cleanup.
- Date: Sat, 9 Oct 2010 13:38:17 +0000 (UTC)
commit 2760de0039aa9ed24f46c49f776a849355285acd
Author: Teika kazura <teika lavabit com>
Date: Sat Oct 9 16:45:57 2010 +0900
Desktop detection minor cleanup.
Detection and inintialization are separated. This makes less likely
to err when further changes are done.
lisp/sawfish/wm/integration/gnome.jl | 62 +++++++++++++++--------------
lisp/sawfish/wm/integration/kde.jl | 73 +++++++++++++++++-----------------
lisp/sawfish/wm/integration/xfce.jl | 66 ++++++++++++++++---------------
lisp/sawfish/wm/user.jl | 5 ++-
4 files changed, 107 insertions(+), 99 deletions(-)
---
diff --git a/lisp/sawfish/wm/integration/gnome.jl b/lisp/sawfish/wm/integration/gnome.jl
index 4cbe5b0..368f182 100644
--- a/lisp/sawfish/wm/integration/gnome.jl
+++ b/lisp/sawfish/wm/integration/gnome.jl
@@ -32,37 +32,39 @@
(define-structure-alias gnome-int sawfish.wm.integration.gnome)
- ;; Returns t or nil. If detected, do also gnome support init.
- (define (detect-gnome)
- (if (getenv "GNOME_DESKTOP_SESSION_ID")
- (let (menu)
- (setq desktop-environment "gnome")
- (setq want-poweroff-menu nil)
+ (define (init)
+ (let (menu)
+ (setq desktop-environment "gnome")
+ (setq want-poweroff-menu nil)
+
+ ;; invoke the GNOME terminal instead of xterm
+ (unless (variable-customized-p 'xterm-program)
+ (setq xterm-program "gnome-terminal.wrapper"))
- ;; invoke the GNOME terminal instead of xterm
- (unless (variable-customized-p 'xterm-program)
- (setq xterm-program "gnome-terminal.wrapper"))
+ ;; use the GNOME help browser and url launcher
+ (unless (variable-customized-p 'browser-program)
+ (setq browser-program "gnome-www-browser"))
- ;; use the GNOME help browser and url launcher
- (unless (variable-customized-p 'browser-program)
- (setq browser-program "gnome-www-browser"))
+ ;; add some GNOME menu-entries
+ (when (setq menu (assoc (_ "_Help") root-menu))
+ (nconc menu `(()
+ (,(_ "_GNOME Help") (system "yelp &"))
+ (,(_ "GNOME _Website") (browser "http://www.gnome.org"))
+ (,(_ "_About GNOME") (system "gnome-about &")))))
- ;; add some GNOME menu-entries
- (when (setq menu (assoc (_ "_Help") root-menu))
- (nconc menu `(()
- (,(_ "_GNOME Help") (system "yelp &"))
- (,(_ "GNOME _Website") (browser "http://www.gnome.org"))
- (,(_ "_About GNOME") (system "gnome-about &")))))
+ ;; add gnome-logout and customize menu-entries
+ (when (setq menu (assoc (_ "Sessi_on") root-menu))
+ (nconc menu `(()
+ (,(_ "_Customize GNOME") (system "gnome-control-center &"))
+ ()
+ (,(_ "_Logout from GNOME")
+ (system "gnome-session-save --logout-dialog &"))
+ (,(_ "_Shutdown from GNOME")
+ (system "gnome-session-save --shutdown-dialog &")))))))
- ;; add gnome-logout and customize menu-entries
- (when (setq menu (assoc (_ "Sessi_on") root-menu))
- (nconc menu `(()
- (,(_ "_Customize GNOME") (system "gnome-control-center &"))
- ()
- (,(_ "_Logout from GNOME")
- (system "gnome-session-save --logout-dialog &"))
- (,(_ "_Shutdown from GNOME")
- (system "gnome-session-save --shutdown-dialog &")))))
- t)
- ;; no, gnome not found
- nil)))
+ ;; Returns nil if gnome is not found.
+ ;; If detected, returns t, and do also gnome support init.
+ (define (detect-gnome)
+ (when (getenv "GNOME_DESKTOP_SESSION_ID")
+ (init)
+ t)))
diff --git a/lisp/sawfish/wm/integration/kde.jl b/lisp/sawfish/wm/integration/kde.jl
index 0c8b515..adce1f5 100644
--- a/lisp/sawfish/wm/integration/kde.jl
+++ b/lisp/sawfish/wm/integration/kde.jl
@@ -37,43 +37,44 @@
'("/usr/share/applications/kde4/")
"KDE specific directories where *.desktop files are stored.")
- ;; Returns t or nil. If detected, do also kde support init.
- (define (detect-kde)
- (if (getenv "KDE_FULL_SESSION")
- (let (menu
- kde-logout-cmd)
- (setq desktop-environment "kde")
- (setq want-poweroff-menu nil)
- (setq desktop-directory
- (append desktop-directory kde-desktop-directories))
+ (define (init)
+ (let (menu
+ kde-logout-cmd)
+ (setq desktop-environment "kde")
+ (setq want-poweroff-menu nil)
+ (setq desktop-directory
+ (append desktop-directory kde-desktop-directories))
- ;; invoke the KDE terminal instead of xterm
- (unless (variable-customized-p 'xterm-program)
- (setq xterm-program "konsole"))
+ ;; invoke the KDE terminal instead of xterm
+ (unless (variable-customized-p 'xterm-program)
+ (setq xterm-program "konsole"))
- ;; use the KDE Browser
- (unless (variable-customized-p 'browser-program)
- (setq browser-program "konqueror"))
+ ;; use the KDE Browser
+ (unless (variable-customized-p 'browser-program)
+ (setq browser-program "konqueror"))
- ;; add some KDE help menus
- (when (setq menu (assoc (_ "_Help") root-menu))
- (nconc menu `(()
- (,(_ "_KDE Help") (system "khelpcenter &"))
- (,(_ "KDE _Website") (browser "http://www.kde.org")))))
+ ;; add some KDE help menus
+ (when (setq menu (assoc (_ "_Help") root-menu))
+ (nconc menu `(()
+ (,(_ "_KDE Help") (system "khelpcenter &"))
+ (,(_ "KDE _Website") (browser "http://www.kde.org")))))
- ;; add kde-logout menu item
- (when (setq menu (assoc (_ "Sessi_on") root-menu))
- (setq kde-logout-cmd "qdbus org.kde.ksmserver /KSMServer org.kde.KSMServerInterface.logout")
- (nconc menu `(()
- (,(_ "_Customize KDE") (system "systemsettings &"))
- ()
- (,(_ "_Logout from KDE")
- (system ,(concat kde-logout-cmd " 1 0 -1 &")))
- (,(_ "_Reboot from KDE")
- (system ,(concat kde-logout-cmd " 1 1 -1 &")))
- (,(_ "_Shutdown from KDE")
- (system ,(concat kde-logout-cmd " 1 2 -1 &"))))))
- t)
- ;; no, kde is not found.
- nil
- )))
+ ;; add kde-logout menu item
+ (when (setq menu (assoc (_ "Sessi_on") root-menu))
+ (setq kde-logout-cmd "qdbus org.kde.ksmserver /KSMServer org.kde.KSMServerInterface.logout")
+ (nconc menu `(()
+ (,(_ "_Customize KDE") (system "systemsettings &"))
+ ()
+ (,(_ "_Logout from KDE")
+ (system ,(concat kde-logout-cmd " 1 0 -1 &")))
+ (,(_ "_Reboot from KDE")
+ (system ,(concat kde-logout-cmd " 1 1 -1 &")))
+ (,(_ "_Shutdown from KDE")
+ (system ,(concat kde-logout-cmd " 1 2 -1 &"))))))))
+
+ ;; Returns nil if kde is not found.
+ ;; If detected, returns t, and do also kde support init.
+ (define (detect-kde)
+ (when (getenv "KDE_FULL_SESSION")
+ (init)
+ t)))
diff --git a/lisp/sawfish/wm/integration/xfce.jl b/lisp/sawfish/wm/integration/xfce.jl
index 7e73487..5b5a2a9 100644
--- a/lisp/sawfish/wm/integration/xfce.jl
+++ b/lisp/sawfish/wm/integration/xfce.jl
@@ -32,39 +32,41 @@
(define-structure-alias xfce-int sawfish.wm.integration.xfce)
- ;; Returns t or nil. If detected, do also xfce support init.
- (define (detect-xfce)
- (if (get-x-property 'root '_DT_SAVE_MODE)
- (let (menu)
- (setq desktop-environment "xfce")
- (setq want-poweroff-menu nil)
+ (define (init)
+ (let (menu)
+ (setq desktop-environment "xfce")
+ (setq want-poweroff-menu nil)
+
+ ;; invoke the GNOME terminal instead of xterm
+ (unless (variable-customized-p 'xterm-program)
+ (setq xterm-program "xfce4-terminal"))
- ;; invoke the GNOME terminal instead of xterm
- (unless (variable-customized-p 'xterm-program)
- (setq xterm-program "xfce4-terminal"))
+ ;; use the GNOME help browser and url launcher
+ (unless (variable-customized-p 'browser-program)
+ (setq browser-program "midori"))
- ;; use the GNOME help browser and url launcher
- (unless (variable-customized-p 'browser-program)
- (setq browser-program "midori"))
+ ;; add some GNOME help menus
+ (when (setq menu (assoc (_ "_Help") root-menu))
+ (nconc menu `(()
+ (,(_ "_XFCE Help") (system "xfhelp4 &"))
+ (,(_ "XFCE _Website") (browser "http://www.xfce.org"))
+ (,(_ "_About XFCE") (system "xfce4-about &")))))
- ;; add some GNOME help menus
- (when (setq menu (assoc (_ "_Help") root-menu))
- (nconc menu `(()
- (,(_ "_XFCE Help") (system "xfhelp4 &"))
- (,(_ "XFCE _Website") (browser "http://www.xfce.org"))
- (,(_ "_About XFCE") (system "xfce4-about &")))))
+ ;; add gnome-logout menu item
+ (when (setq menu (assoc (_ "Sessi_on") root-menu))
+ (nconc menu `(()
+ (,(_ "_Customize XFCE") (system "xfce4-settings-manager &"))
+ ()
+ (,(_ "_Logout from XFCE")
+ (system "xfce4-session-logout --logout &"))
+ (,(_ "_Reboot from XFCE")
+ (system "xfce4-session-logout --reboot &"))
+ (,(_ "_Shutdown from XFCE")
+ (system "xfce4-session-logout --halt &")))))))
- ;; add gnome-logout menu item
- (when (setq menu (assoc (_ "Sessi_on") root-menu))
- (nconc menu `(()
- (,(_ "_Customize XFCE") (system "xfce4-settings-manager &"))
- ()
- (,(_ "_Logout from XFCE")
- (system "xfce4-session-logout --logout &"))
- (,(_ "_Reboot from XFCE")
- (system "xfce4-session-logout --reboot &"))
- (,(_ "_Shutdown from XFCE")
- (system "xfce4-session-logout --halt &")))))
- t)
- ;; No, xfce isn't running
- nil)))
+ ;; Returns nil if xfce is not found.
+ ;; If detected, returns t, and do also xfce support init.
+ (define (detect-xfce)
+ (when (get-x-property 'root '_DT_SAVE_MODE)
+ (init)
+ t)))
diff --git a/lisp/sawfish/wm/user.jl b/lisp/sawfish/wm/user.jl
index b6a7866..1fe1591 100644
--- a/lisp/sawfish/wm/user.jl
+++ b/lisp/sawfish/wm/user.jl
@@ -96,7 +96,10 @@ Possible values are \"kde\", \"gnome\", \"xfce\", or \"none\".")
(message "Renamed file ~/.sawmillrc -> ~/.sawfishrc"))
)
- ;; Detect desktop environment
+ ;; Detect desktop environment.
+ ;; These functions have to non-nil if it detects a DE, otherwise nil.
+ ;; It should also initialize, and set `desktop-environment',
+ ;; and probably `want-poweroff-menu', too.
(define (detect-desktop-environment)
(or (sawfish.wm.integration.gnome#detect-gnome)
(sawfish.wm.integration.kde#detect-kde)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]