| 1 | #title Scheme Your Windows |
| 2 | |
| 3 | * Installing SCWM |
| 4 | |
| 5 | ** Dependencies |
| 6 | |
| 7 | *** Required |
| 8 | |
| 9 | - [[http://www.gnu.org/software/guile][Guile]] 1.8.0+ |
| 10 | - IMLib 1.x (in Debian imlib11-dev) |
| 11 | |
| 12 | *** Optional |
| 13 | |
| 14 | - [[ftp://ftp.gnu.org/gnu/guile-gtk/guile-gtk-0.60.tar.gz][Guile-GTK]] 0.60 for dialog support. Guile-GTK 2.x and scwm are not |
| 15 | compatible yet |
| 16 | |
| 17 | ** Downloading and Building |
| 18 | |
| 19 | A working version of SCWM can be obtained from |
| 20 | [[http://sourceforge.net/cvs/?group_id=225][sourceforge CVS]]. Compilation is much more straightforward than one |
| 21 | would suspect from a project so old (thanks to dsmith for doing the |
| 22 | painful parts of unbitrotting). The standard autoconf sequence of |
| 23 | commands should work. |
| 24 | |
| 25 | <example> |
| 26 | ./autogen.sh |
| 27 | ./configure |
| 28 | make |
| 29 | sudo make install |
| 30 | </example> |
| 31 | |
| 32 | ** Running |
| 33 | |
| 34 | The directory =sample.scwmrc= has a few sample SCWM |
| 35 | configurations. =system.scwmrc= and =sample.scwmrc= both work fairly well; |
| 36 | I have yet to test the others. If not using =system.scwmrc= it is useful |
| 37 | to at least include the bits that enable debugging. |
| 38 | |
| 39 | <src lang="scheme"> |
| 40 | (define debug #t) |
| 41 | |
| 42 | (if debug |
| 43 | (begin |
| 44 | (add-hook! module-loaded-hook display-module-loaded) |
| 45 | (set! %load-verbosely #t) |
| 46 | (debug-enable 'debug 'backtrace) |
| 47 | (read-enable 'positions))) |
| 48 | </src> |
| 49 | |
| 50 | SCWM will attempt to load =system.scwmrc= by default, but this can be |
| 51 | overridden with the =-f= option. The default =system.scwmrc= loads user |
| 52 | config from a series of files in =~/.scwm/=. |
| 53 | |
| 54 | ** Hacking |
| 55 | |
| 56 | *** XNested Setup |
| 57 | |
| 58 | The easiest way to hack on SCWM is to run it inside of Xnest. |
| 59 | |
| 60 | <example> |
| 61 | Xnest :1 & |
| 62 | scwm --display :1 --debug # --debug makes X requests synchronous |
| 63 | </example> |
| 64 | |
| 65 | *** GDS for Interaction |
| 66 | |
| 67 | SCWM has an emacs interaction mode that communicates with the window |
| 68 | manager using X window properties, but the emacs side of the code |
| 69 | doesn't quite work, and GDS is featureful enough now to be used to |
| 70 | interact with scwm. Using GDS makes hacking scwm quite a bit |
| 71 | easier. **GDS requires a Guile built with threads to work properly |
| 72 | (the version in Debian is built *without* threading).** |
| 73 | |
| 74 | **** scwmrc code |
| 75 | |
| 76 | The following code should be in your scwmrc somewhere. |
| 77 | |
| 78 | <src lang="scheme"> |
| 79 | (use-modules (ice-9 gds-client) |
| 80 | (ice-9 threads)) |
| 81 | |
| 82 | ;;; GDS thread (in case it must be killed during debugging, ...) |
| 83 | (define cke-gds-thread #f) |
| 84 | |
| 85 | (define (connect-to-debugging-server) |
| 86 | (set! cke-gds-thread |
| 87 | (call-with-new-thread (lambda () (run-utility)))) |
| 88 | cke-gds-thread) |
| 89 | </src> |
| 90 | |
| 91 | After defining you can either use =scwmrepl= to run |
| 92 | =(connect-to-debugging-server)= after starting a GDS server, or simply |
| 93 | add =(connect-to-debugging-server)= to the config if one will always be |
| 94 | running. |
| 95 | |
| 96 | **** Emacs config |
| 97 | |
| 98 | I wrote [[http://darcs.unknownlamer.org/site-emacs/init.d/guile-debug.el][a bit of elisp]] to simplify setting up a scratch buffer for |
| 99 | interaction with guile. |
| 100 | |
| 101 | <src lang="emacs-lisp"> |
| 102 | (require 'gds) |
| 103 | (require 'gds-server) |
| 104 | (require 'gds-scheme) |
| 105 | |
| 106 | (defvar guile-scratch-buffer-name "*guile-scratch*" |
| 107 | "Name of the Guile evaluation scratch buffer") |
| 108 | |
| 109 | (defun make-guile-scratch-buffer () |
| 110 | (interactive) |
| 111 | (let ((scratch-buf (generate-new-buffer guile-scratch-buffer-name))) |
| 112 | (switch-to-buffer scratch-buf) |
| 113 | (scheme-mode) |
| 114 | (gds-auto-associate-buffer))) |
| 115 | </src> |
| 116 | |
| 117 | If you were already running a debugging client process you will need |
| 118 | to choose the process to associate the buffer with; =ps= will tell you |
| 119 | the PID of scwm. |
| 120 | |
| 121 | **** Known Issues |
| 122 | |
| 123 | Occasionally evaluating an expression or viewing a backtrace will make |
| 124 | scwm lockup. My understanding is that scwm is not threadsafe, and |
| 125 | there are some evil issues that will take a while to solve. GDS works |
| 126 | well enough for now; if I can't make GDS completely reliable I shall |
| 127 | unbitrot the scwm emacs interaction mode (unless someone else beats me |
| 128 | to it, *hint hint*). |