Subject: Add emacs-switch-window and emacs-exwm-x

From: "Feng Shu" <[email-masked]>
Date: Sun, 18 Jun 2017 11:42:11 +0800

>From 15acb2ed8e4570a7fe44cb3350083209fe12ec03 Mon Sep 17 00:00:00 2001
From: Feng Shu <[email-masked]>
Date: Sat, 17 Jun 2017 15:58:05 +0800
Subject: [PATCH 1/2] gnu: Add emacs-switch-window

* gnu/packages/emacs.scm (emacs-switch-window): New variable.
---
 gnu/packages/emacs.scm | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/gnu/packages/emacs.scm b/gnu/packages/emacs.scm
index 99b9b0601..58688b9a8 100644
--- a/gnu/packages/emacs.scm
+++ b/gnu/packages/emacs.scm
@@ -4602,6 +4602,27 @@ It should enable you to implement low-level X11 applications.")
 built on top of XELB.")
     (license license:gpl3+)))
 
+(define-public emacs-switch-window
+  (package
+    (name "emacs-switch-window")
+    (version "1.5.0-1.8d37f56")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (commit "8d37f5660666516ab6c9e6ec1da748ea1669ed4b")
+                    (url "https://github.com/dimitri/switch-window.git")))
+              (file-name (string-append name "-" version "-checkout"))
+              (sha256
+               (base32
+                "19bszzslzz8rprch0z3h6xa6pjhrwik7j53i4kj33w306d58gi3f"))))
+    (build-system emacs-build-system)
+    (home-page "https://github.com/dimitri/switch-window")
+    (synopsis "Emacs window switch tool")
+    (description "Switch-window is an emacs window switch tool, which
+offer a visual way to choose a window to switch to, delete, split or
+other operations.")
+    (license license:wtfpl2)))
+
 (define-public emacs-gnuplot
   (package
     (name "emacs-gnuplot")
-- 
2.12.2

>From ad804179af5f44a3ca0bf0cedc566954b7fa4acb Mon Sep 17 00:00:00 2001
From: Feng Shu <[email-masked]>
Date: Sun, 18 Jun 2017 08:18:39 +0800
Subject: [PATCH 2/2] gnu: Add emacs-exwm-x

* gnu/packages/emacs.scm (emacs-exwm-x): New variable.
---
 gnu/packages/emacs.scm | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 67 insertions(+)

diff --git a/gnu/packages/emacs.scm b/gnu/packages/emacs.scm
index 58688b9a8..b6867cd1e 100644
--- a/gnu/packages/emacs.scm
+++ b/gnu/packages/emacs.scm
@@ -4623,6 +4623,73 @@ offer a visual way to choose a window to switch to, delete, split or
 other operations.")
     (license license:wtfpl2)))
 
+(define-public emacs-exwm-x
+  (package
+    (name "emacs-exwm-x")
+    (version "1.0-2.2099138")
+    (synopsis "Derivative window manager based on EXWM")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (commit "20991380f4b62f7203348841f9bf36ad1ed5dfc5")
+                    (url "https://github.com/tumashu/exwm-x.git")))
+              (file-name (string-append name "-" version "-checkout"))
+              (sha256
+               (base32
+                "0yx2v9ms0l2pxjrcmlaqs41b4482zfsljdg5ml7yi3r0l6mkpwg8"))))
+    (build-system emacs-build-system)
+    (propagated-inputs
+     `(("emacs-exwm" ,emacs-exwm)
+       ("emacs-switch-window" ,emacs-switch-window)
+       ("emacs-ivy" ,emacs-ivy)))
+    (inputs
+     `(("xhost" ,xhost)
+       ("dbus" ,dbus)))
+    ;; Need emacs instead of emacs-minimal,
+    ;; for emacs's bin path will be inserted into bin/exwm-x file.
+    (arguments
+     `(#:emacs ,emacs
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'build 'install-xsession
+           (lambda* (#:key inputs outputs #:allow-other-keys)
+             (let* ((out (assoc-ref outputs "out"))
+                    (xsessions (string-append out "/share/xsessions"))
+                    (bin (string-append out "/bin"))
+                    (exwm-executable (string-append bin "/exwm-x")))
+               ;; Add a .desktop file to xsessions
+               (mkdir-p xsessions)
+               (mkdir-p bin)
+               (with-output-to-file
+                   (string-append xsessions "/exwm-x.desktop")
+                 (lambda _
+                   (format #t "[Desktop Entry]~@
+                     Name=~a~@
+                     Comment=~a~@
+                     Exec=~a~@
+                     TryExec=~@*~a~@
+                     Type=Application~%" ,name ,synopsis exwm-executable)))
+               ;; Add a shell wrapper to bin
+               ;; Set DISPLAY variable to work around
+               ;; https://github.com/ch11ng/exwm/issues/213
+               (with-output-to-file exwm-executable
+                 (lambda _
+                   (format #t "#!~a ~@
+                     export DISPLAY=:0 ~@
+                     ~a +SI:localuser:$USER ~@
+                     exec ~a --exit-with-session ~a \"$@\" --eval '~s' ~%"
+                           (string-append (assoc-ref inputs "bash") "/bin/sh")
+                           (string-append (assoc-ref inputs "xhost") "/bin/xhost")
+                           (string-append (assoc-ref inputs "dbus") "/bin/dbus-launch")
+                           (string-append (assoc-ref inputs "emacs") "/bin/emacs")
+                           '(require 'exwmx-loader))))
+               (chmod exwm-executable #o555)
+               #t))))))
+    (home-page "https://github.com/tumashu/exwm-x")
+    (description "EXWM-X is a derivative window manager based on EXWM, which focus
+on mouse-control-people.")
+    (license license:gpl3+)))
+
 (define-public emacs-gnuplot
   (package
     (name "emacs-gnuplot")
-- 
2.12.2

--