display-0.lisp 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. (in-package :stumpwm)
  2. (setf *maxsize-border-width* 0)
  3. (setf *message-window-y-padding* 0)
  4. (setf *normal-border-width* 0)
  5. (setf *transient-border-width* 0)
  6. (setq *suppress-frame-indicator* nil)
  7. (setf *float-window-border* 0)
  8. (setf *float-window-title-height* 0)
  9. (bind-super)
  10. (rename-group *default-group-name* "1")
  11. (setq *default-group-name* "1")
  12. ;; TODO: Fix VNC
  13. ;; (restore-from-file (concat (getenv "HOME") "/.stumpwm.d/desktop-0.lisp"))
  14. (mapcar #'(lambda (x)
  15. (add-group (current-screen) (write-to-string x) :background t))
  16. (range 10 :min 2 :step 1))
  17. (add-group (current-screen) "0" :background t :type 'float-group)
  18. (run-commands "gselect 1")
  19. (define-frame-preference "1" (0 NIL T :CLASS "firefox-default" :TITLE "YouTube"))
  20. (define-frame-preference "1" (1 NIL T :CLASS "firefox-default" :TITLE "Picture-in-Picture"))
  21. (when (string-equal (screen-display-string (current-screen)) "DISPLAY=:0.0")
  22. (mode-line)
  23. (setf *mouse-focus-policy* :sloppy))
  24. ;; XXX: pam-gnupg race condition
  25. ;;
  26. ;; (let ((uptime-seconds (parse-integer (car (split-string (car (split-string (uiop:read-file-string "/proc/uptime") " ")) ".")))))
  27. ;; (when (< uptime-seconds 60)
  28. ;; (term-shell-command "sh -c 'sleep 5; if gpg-unlock; then exit 0; else read; fi'"
  29. ;; :terminal 'st
  30. ;; :color "dark")))
  31. (defun run-frame (group-number &key
  32. (restart? nil)
  33. (frame-0-command nil)
  34. (frame-1-command nil)
  35. (frame-2-command nil))
  36. (if (string= (group-name (current-group))
  37. (write-to-string group-number))
  38. (let ((screen (current-screen))
  39. (group (current-group)))
  40. (cond
  41. ;; Two monitors.
  42. ((and (> (screen-width screen) 1920)
  43. (= (length (group-frames group)) 2))
  44. (if (and (current-window) (not restart?))
  45. (run-commands "fnext")
  46. (case (frame-number (tile-group-current-frame group))
  47. ((0) (funcall frame-0-command))
  48. ((1) (funcall frame-1-command)))))
  49. ;; Two monitor with frames: big, small, medium
  50. ((and (> (screen-width screen) 1920)
  51. (>= (length (group-frames group)) 2))
  52. (if (and (current-window) (not restart?))
  53. (run-commands "fnext")
  54. (case (frame-number (tile-group-current-frame group))
  55. ((0) (funcall frame-0-command))
  56. ((1) (funcall frame-2-command))
  57. ((2) (funcall frame-1-command)))))
  58. ;; Single monitor.
  59. (t
  60. (case (length (group-windows group))
  61. ((0) (funcall frame-0-command))
  62. ((1) (funcall frame-1-command))))))
  63. (run-commands (format nil "gselect ~a" group-number))))
  64. (defcommand group-1-start-programs () ()
  65. (run-frame 1 :frame-0-command (lambda ()
  66. (run-shell-command "firefox"))
  67. :frame-1-command (lambda ()
  68. (run-shell-command "run-emacs"))
  69. :frame-2-command (lambda ()
  70. (emacs-todo-new-window))))
  71. (defcommand group-1-restart-programs () ()
  72. (run-frame 1 :restart? t
  73. :frame-0-command (lambda ()
  74. (run-shell-command "pkill emacs; run-emacs"))
  75. :frame-1-command (lambda ()
  76. (run-shell-command "pkill firefox; firefox"))
  77. :frame-2-command (lambda ()
  78. (emacs-todo-new-window))))
  79. (defcommand group-2-start-programs () ()
  80. (run-frame 2
  81. :frame-0-command
  82. (lambda ()
  83. (run-shell-command "vnc client guix"))))
  84. (defcommand group-3-start-programs () ()
  85. (run-frame 3 :frame-0-command
  86. (lambda ()
  87. (run-shell-command "vnc client windows"))))
  88. (defvar *windows-novnc*
  89. "http://novnc.windows.home.wugi.info/vnc.html")
  90. (defcommand group-4-start-programs () ()
  91. (run-frame 4
  92. :frame-0-command
  93. (lambda ()
  94. (run-shell-command (firefox-temp-profile nil *windows-novnc*)))))
  95. (defcommand group-5-start-programs () ()
  96. (run-frame 5 :frame-0-command
  97. (lambda ()
  98. (let (;; (window (current-window))
  99. )
  100. (run-shell-command
  101. (join
  102. (list
  103. "xfreerdp"
  104. (concat "/w:" "1920" ;; (window-width window)
  105. )
  106. (concat "/h:" "1052" ;; (window-height window)
  107. )
  108. (concat "/u:" "oleg")
  109. (concat "/p:" (string-trim '(#\Newline)
  110. (password-store-show "windows.local/oleg")))
  111. "/v:windows.local")))))))
  112. (defcommand group-6-start-programs () ()
  113. (run-frame 6 :frame-0-command (lambda ()
  114. (run-commands "trans-en-ru"))
  115. :frame-1-command (lambda ()
  116. (run-commands "trans-ru-en"))))
  117. (defcommand group-7-start-programs () ()
  118. (run-frame 7 :frame-0-command (lambda ()
  119. (run-commands "looking-glass-client"))))
  120. (defcommand group-8-start-programs () ()
  121. (run-frame 8 :frame-0-command (lambda ()
  122. (if (free-time?)
  123. (run-commands "pulsemixer")
  124. (run-commands "emacs-anywhere")))
  125. :frame-1-command (lambda ()
  126. (if (free-time?)
  127. (run-shell-command "chromium --app=https://habitica.com/")
  128. (run-shell-command "firefox --new-window https://cerberus.intr/")))))
  129. (defcommand group-9-start-programs () ()
  130. (run-frame 9 :frame-0-command (lambda ()
  131. (run-commands "mjru-office-shedule-eng"))
  132. :frame-1-command (lambda ()
  133. (run-commands "mjru-office-shedule-sup"))))
  134. ;; (define-frame-preference "1" (1 NIL NIL :CLASS "mpv"))
  135. ;; (add-hook *new-window-hook* (lambda (window) ||#
  136. ;; (when (string= (window-class window) "mpv") ||#
  137. ;; (update-fullscreen window 2) ||#
  138. ;; (run-commands "move-focus left")))) ||#
  139. ;; (add-hook *new-window-hook*
  140. ;; (lambda (window)
  141. ;; (when (string= (window-role window) "PictureInPicture")
  142. ;; (let* ((screen (current-screen))
  143. ;; (head (current-head))
  144. ;; (ml (head-mode-line head)))
  145. ;; (setf (mode-line-mode ml) :hidden)
  146. ;; (xlib:unmap-window (mode-line-window ml))
  147. ;; (dolist (group (screen-groups screen))
  148. ;; (group-sync-head group head))))))