visual.lisp 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. ;;; visual.lisp --- Visual appearance: colors, fonts, mode line, ...
  2. ;; Copyright © 2013–2016, 2018–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. ;;; Colors
  18. ;; Yellow and magenta are swapped to show keys in yellow.
  19. (setf *colors*
  20. '("black" ; 0
  21. "red" ; 1
  22. "green" ; 2
  23. "magenta" ; 3
  24. "#44d0ff" ; 4
  25. "yellow" ; 5
  26. "cyan" ; 6
  27. "white" ; 7
  28. "AntiqueWhite3"
  29. "khaki3")
  30. *bar-hi-color* "^B^5*")
  31. (update-color-map (current-screen))
  32. (defmacro al/set-color (val color)
  33. "Similar to `set-any-color', but without updating colors."
  34. `(dolist (s *screen-list*)
  35. (setf (,val s) (alloc-color s ,color))))
  36. (al/set-color screen-fg-color (hex-to-xlib-color "#e5e8ef"))
  37. (al/set-color screen-bg-color "gray15")
  38. (al/set-color screen-focus-color "DeepSkyBlue")
  39. (al/set-color screen-border-color "ForestGreen")
  40. (al/set-color screen-float-focus-color "DeepSkyBlue")
  41. (al/set-color screen-float-unfocus-color "gray15")
  42. (update-colors-all-screens)
  43. ;;; Grabbed pointer
  44. (setq
  45. *grab-pointer-character* 40
  46. *grab-pointer-character-mask* 41
  47. *grab-pointer-foreground* (hex-to-xlib-color "#3db270")
  48. *grab-pointer-background* (hex-to-xlib-color "#2c53ca"))
  49. ;;; mode-line auxiliary code
  50. (defvar al/ml-separator " | ")
  51. (defun al/ml-separate (str)
  52. "Concatenate `al/ml-separator' and STR."
  53. (concat al/ml-separator str))
  54. ;;; mode-line cpu
  55. (al/load "mode-line-cpu")
  56. (defvar al/cpu-refresh-time 3)
  57. (al/defun-with-delay
  58. al/cpu-refresh-time al/ml-cpu ()
  59. (al/ml-separate (al/stumpwm-cpu:cpu-mode-line-string)))
  60. ;;; mode-line thermal
  61. (al/load "mode-line-thermal")
  62. (defvar al/thermal-zone
  63. (car (al/stumpwm-thermal:all-thermal-zones)))
  64. (defvar al/thermal-zones-refresh-time 6)
  65. (al/defun-with-delay
  66. al/thermal-zones-refresh-time al/ml-thermal-zones ()
  67. (al/ml-separate
  68. (al/stumpwm-thermal:thermal-zones-mode-line-string al/thermal-zone)))
  69. (defun al/ml-thermal-zones-maybe ()
  70. (if al/thermal-zone
  71. (al/ml-thermal-zones)
  72. ""))
  73. ;;; mode-line net
  74. (al/load "mode-line-net")
  75. (defvar al/net-refresh-time 6)
  76. (al/defun-with-delay
  77. al/net-refresh-time al/ml-net ()
  78. (al/ml-separate (al/stumpwm-net:net-mode-line-string)))
  79. ;;; mode-line battery
  80. (al/load "mode-line-battery")
  81. (defvar al/battery (car (al/stumpwm-battery:all-batteries)))
  82. (defvar al/battery-refresh-time 60)
  83. (al/defun-with-delay
  84. al/battery-refresh-time al/ml-battery ()
  85. (al/ml-separate
  86. (al/stumpwm-battery:battery-mode-line-string al/battery)))
  87. (defun al/ml-battery-maybe ()
  88. (if al/battery
  89. (al/ml-battery)
  90. ""))
  91. ;;; mode-line keyboard
  92. (defun al/ml-locks ()
  93. (defun bool->color (bool)
  94. (if bool "^B^2" ""))
  95. (let ((mods (xlib:device-state-locked-mods
  96. (xlib:get-state *display*))))
  97. (al/ml-separate
  98. (format nil "^[~ACaps^] ^[~ANum^]"
  99. (bool->color (al/mod-lock-state +caps-lock+ mods))
  100. (bool->color (al/mod-lock-state +num-lock+ mods))))))
  101. (defun al/ml-layout ()
  102. (al/ml-separate
  103. (format nil "^[^7*~A^]"
  104. (al/layout-string (al/current-layout)))))
  105. ;;; Visual appearance and mode-line settings
  106. (setf
  107. *window-info-format*
  108. (format nil "^>^B^5*%c ^b^6*%w^7*x^6*%h^7*~%%t")
  109. *time-format-string-default*
  110. (format nil "^5*%H:%M:%S~%^2*%A~%^7*%d %B")
  111. *time-modeline-string* "%k:%M"
  112. *mode-line-timeout* 3
  113. *screen-mode-line-format*
  114. '("^[^5*%d^]" ; time
  115. " ^[^2*%n^]" ; group name
  116. (:eval (al/ml-cpu))
  117. (:eval (al/ml-thermal-zones-maybe))
  118. (:eval (al/ml-net))
  119. (:eval (al/ml-battery-maybe))
  120. "^>"
  121. (:eval (al/ml-layout))
  122. (:eval (al/ml-locks))))
  123. (al/mode-line-on)
  124. ;; (set-font "-*-dejavu sans mono-medium-r-normal-*-*-115-*-*-*-*-*-1")
  125. (set-font "9x15bold")
  126. ;;; visual.lisp ends here