From 43916e36c49bbcfac720a88b04ab0bee33f550f5 Mon Sep 17 00:00:00 2001
From: Joshua Branson <jbranso@dismail.de>
Date: Thu, 23 Jan 2020 18:09:39 -0500
Subject: [PATCH] doc: Add sway to the cookbook

* doc/guix-cookbook.texi: Add a guide to install and configure sway.
---
 doc/guix-cookbook.texi | 103 ++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 101 insertions(+), 2 deletions(-)

diff --git a/doc/guix-cookbook.texi b/doc/guix-cookbook.texi
index 477b7e3dff..2b0e4209c5 100644
--- a/doc/guix-cookbook.texi
+++ b/doc/guix-cookbook.texi
@@ -77,8 +77,8 @@ Packaging
 
 System Configuration
 
-* Customizing the Kernel::      Creating and using a custom Linux kernel
-
+* Customizing the Kernel::     Creating and using a custom Linux kernel on Guix System.
+* Setting up Sway::            Using the sway tiling window manager
 
 @end detailmenu
 @end menu
@@ -1320,6 +1320,7 @@ reference.
 
 @menu
 * Customizing the Kernel::     Creating and using a custom Linux kernel on Guix System.
+* Setting up Sway::            Using the sway tiling window manager
 @end menu
 
 @node Customizing the Kernel
@@ -1561,6 +1562,104 @@ Left undiscussed however, is Guix's initrd and its customization.  It is
 likely that you'll need to modify the initrd on a machine using a custom
 kernel, since certain modules which are expected to be built may not be
 available for inclusion into the initrd.
+@c ********************************************************************
+
+@menu
+* Setting up Sway::     Using the sway tiling window manager
+@end menu
+
+@node Setting up Sway
+@section Setting up Sway
+
+Sway is a tiling window manager written for wayland.  Since sway does not
+officially support login managers, some users may need to execute
+"sway" at the virtual console after login.  However, according to Sway's
+developers, the GNOME display manager, usually works to start sway.
+
+To get started using sway, install sway, and the configuration
+file.
+
+@example
+$ guix package -i sway wget
+$ wget https://raw.githubusercontent.com/swaywm/sway/master/config.in
+$ mkdir -p ~/.config/sway/
+$ mv config.ini ~/.config/sway/config
+# optionally remove wget
+$ guix package -r wget
+@end example
+
+Sway supports several configuration options including your default
+terminal and keyboard layout.  Read @code{man sway} for details.
+
+You will need to use @code{%desktop-services} to run sway.  Try to login
+into sway with gdm.  If gdm does not work then try to remove
+@code{gdm-service-type} like so.
+
+@lisp
+  (use-modules (gnu) (guix)
+   (srfi srfi-1))
+
+  (use-service-modules desktop xorg)
+
+  (operating-system
+   (host-name "dobby")
+   (timezone "America/Indiana/Indianapolis")
+   (locale "en_US.utf8")
+   ;; Boot in "legacy" BIOS mode, assuming /dev/sdX is the
+   ;; target hard disk, and "my-root" is the label of the target
+   ;; root file system.
+   (bootloader (bootloader-configuration
+                (bootloader grub-bootloader)
+                (target "/dev/sda")))
+
+   (file-systems
+    (cons* (file-system
+            (mount-point "/")
+            (device "/dev/sda1")
+            (type "btrfs"))
+           %base-file-systems))
+   (users (cons*
+           (user-account
+            (name "username")
+            (comment "user name")
+            (group "users")
+            (home-directory "/home/user")
+            (supplementary-groups
+             '("wheel" "netdev" "audio" "video")))
+           %base-user-accounts))
+
+   ;; Globally-installed packages.
+   (packages (append (map specification->package
+                          '("nss-certs"))
+                     %base-packages))
+
+   (services
+    (cons*
+     (modify-services
+      (remove (lambda (service)
+                (member (service-kind service)
+                        (list
+                         gdm-service-type
+                         )))
+              %desktop-services) ;;end of remove services
+      ))))
+
+@end lisp
+
+You can now login to sway after login to the virtual console by typing
+
+@example
+$ sway
+@end example
+
+You can also set up sway to autostart after you login. Add this to your
+~/.bash_profile
+
+@example
+if [[ -z $DISPLAY ]] && [[ $(tty) = /dev/tty1 ]]; then
+  XKB_DEFAULT_LAYOUT=us exec sway
+fi
+@end example
 
 @c *********************************************************************
 @node Advanced package management
-- 
2.25.0

