settings.lisp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. ;;; settings.lisp --- General settings: variables, hooks, ...
  2. ;; Copyright © 2013–2019 Alex Kost <alezost@gmail.com>
  3. ;; This program is free software; you can redistribute it and/or modify
  4. ;; it under the terms of the GNU General Public License as published by
  5. ;; the Free Software Foundation, either version 3 of the License, or
  6. ;; (at your option) any later version.
  7. ;;
  8. ;; This program is distributed in the hope that it will be useful,
  9. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. ;; GNU General Public License for more details.
  12. ;;
  13. ;; You should have received a copy of the GNU General Public License
  14. ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. ;;; Code:
  16. (in-package :stumpwm)
  17. ;;; Windows, frames and groups
  18. ;; Name the default group.
  19. (setf (group-name (car (screen-groups (current-screen))))
  20. "tile1")
  21. (gnewbg "tile2")
  22. (gnewbg-float "float")
  23. (set-normal-gravity :bottom)
  24. (setf
  25. *message-window-gravity* :bottom-right
  26. *input-window-gravity* :center
  27. *mouse-focus-policy* :click)
  28. (defvar al/frames1 nil)
  29. (defun al/make-frames1 ()
  30. "Return a frame layout (list of frames) for `al/frames1'."
  31. (let* ((screen (current-screen))
  32. (s-width (screen-width screen))
  33. (s-height (screen-height screen))
  34. (f0-width (/ s-width 2))
  35. (f0-height (* 3 (/ f0-width 4)))
  36. (f0 (make-frame
  37. :number 0
  38. :x 0 :y 0
  39. :width f0-width
  40. :height f0-height))
  41. (f1 (make-frame
  42. :number 1
  43. :x 0 :y f0-height
  44. :width f0-width
  45. :height (- s-height f0-height)))
  46. (f2 (make-frame
  47. :number 2
  48. :x f0-width :y 0
  49. :width (- s-width f0-width)
  50. :height s-height)))
  51. (list f0 f2 f1)))
  52. (defcommand al/frames1 (&optional (populatep t)) ()
  53. "Show layout of 3 frames with one frame having 4/3 ratio."
  54. (al/set-frames (or al/frames1
  55. (setf al/frames1 (al/make-frames1)))
  56. populatep))
  57. ;;; Keyboard layouts
  58. ;; This is needed because stumpwm opens display before extension
  59. ;; definition.
  60. (xlib::initialize-extensions *display*)
  61. (xlib:enable-xkeyboard *display*)
  62. (al/set-display-layout 0)
  63. (al/enable-per-window-layout)
  64. ;;; Message after a part of key sequence
  65. ;; Idea from <https://github.com/stumpwm/stumpwm/wiki/FAQ#how-do-i-make-keypresses-show-up-in-a-message-window-as-i-press-them>.
  66. (defun al/key-seq-msg (_key key-seq cmd)
  67. "Show a message with current incomplete key sequence."
  68. (declare (ignore _key))
  69. (or (eq *top-map* *resize-map*)
  70. (stringp cmd)
  71. (let ((*message-window-gravity* :bottom-left))
  72. (message "~A" (print-key-seq (reverse key-seq))))))
  73. (add-hook *key-press-hook* 'al/key-seq-msg)
  74. ;;; Misc
  75. (setf *top-level-error-action* :message)
  76. ;; Original `send-fake-key' sends only "press" event.
  77. (setf (symbol-function 'send-fake-key)
  78. (lambda (win key) (al/send-key key win)))
  79. (setf *deny-raise-request*
  80. '((:class "Conkeror")
  81. (:class "Firefox")
  82. (:class "IceCat")
  83. (:class "FLTK") ; xcas
  84. (:class "libreoffice-writer")))
  85. (al/banish-pointer)
  86. ;; (setf *debug-level* 10) ; show all debug info
  87. ;;; settings.lisp ends here