My lightweight configuration

Hello everyone,

here is my configuration, hopefully serves as a good inspiration :slight_smile:

(setf *socket-path* nil) ;; allow multiple instances of Nyxt

(define-configuration browser
    ((session-restore-prompt :never-restore)
     (startup-function (make-startup-function :buffer-fn (lambda () (make-buffer :url "about:blank"))))))

(define-configuration web-buffer
    ((default-modes (append '(auto-mode emacs-mode) %slot-default))
     (override-map (let ((map (make-keymap "my-override-map")))
                     (define-key map
                       "C-q" 'quit
                       "C-1" 'make-window
                       "C-2" 'delete-current-window)
                     map))))

(define-configuration buffer
    ((default-modes (append '(emacs-mode) %slot-default))
     (override-map (let ((map (make-keymap "my-override-map")))
                     (define-key map
                       "C-q" 'quit
                       "C-1" 'make-window
                       "C-2" 'delete-current-window)
                     map))))

 (define-configuration nyxt/auto-mode:auto-mode
   ((nyxt/auto-mode:prompt-on-mode-toggle t)))

(defvar +dev-data-profile+ (make-instance 'data-profile :name "dev")
  "Development profile.")

(defmethod nyxt:expand-data-path ((profile (eql +dev-data-profile+)) (path data-path))
  "Persist data to /tmp/nyxt/."
  (expand-default-path (make-instance (class-name (class-of path))
                                      :basename (basename path)
                                      :dirname "/tmp/nyxt/")))

#+darwin
(define-command cpu-sleep ()
  "Put the computer to sleep."
  (uiop:run-program "/Users/jmercouris/User/cpu_sleep"))

#+darwin
(define-command cpu-battery ()
  "Show the battery status."
  (echo (uiop:run-program "/Users/jmercouris/User/cpu_battery" :output :string)))

#+darwin
(define-command open-in-safari ()
  "Open the current URL in Safari"
  (uiop:run-program (list "open" "-a" "Safari" (object-string (url (current-buffer))))))

4 Likes

Addendum (auto-config.lisp):

(DEFINE-CONFIGURATION BUFFER
  ((HINTS-ALPHABET "asfdghjkl")))
1 Like

Here is my latest configuration:

(define-configuration browser
  ((session-restore-prompt :never-restore)
   (autofills (list (make-autofill :key "Current time"
                                   :fill (lambda () (format nil "~a" (local-time:now))))))))

(define-configuration nyxt/auto-mode:auto-mode
  ((nyxt/auto-mode:prompt-on-mode-toggle t)))

(define-configuration buffer
  ((default-modes (append '(emacs-mode) %slot-default%))
   (override-map (let ((map (make-keymap "my-override-map")))
                   (define-key map
                     "C-q" 'quit
                     "C-1" 'make-window
                     "C-2" 'delete-current-window
                     "keypadleft" 'nyxt/web-mode:history-backwards
                     "keypadright" 'nyxt/web-mode:history-forwards)
                   map))))

(define-configuration web-buffer
  ((default-modes (append '(emacs-mode blocker-mode) %slot-default%))
   (password-interface (make-instance 'password:password-store-interface))))

(define-configuration (prompt-buffer)
    ((default-modes (append '(emacs-mode) %slot-default%))
     (hide-suggestion-count-p t)))

(define-configuration status-buffer
    ((style (str:concat 
             %slot-default%
             (cl-css:css
              '(("#container"
                 ;; Columns: controls, arrow, url
                 :grid-template-columns "115px 10px 1fr")))))))

(define-configuration nyxt/web-mode::web-mode
  ((nyxt/web-mode::hints-alphabet "asdfghjklqwertyuiop")))

(define-command-global current-time ()
  "Show the current time."
  (echo "~a" (local-time:now)))

(defmethod nyxt::startup ((browser browser) urls)
  "Make a blank buffer."
  (window-make browser)
  (let ((window (current-window)))
    (window-set-buffer window (make-buffer :url (quri:uri "about:blank")))
    (toggle-fullscreen window)))

#+darwin
(define-command cpu-sleep ()
  "Put the computer to sleep."
  (uiop:run-program "/Users/jmercouris/User/cpu_sleep"))

#+darwin
(define-command cpu-battery ()
  "Show the battery status."
  (echo (uiop:run-program "/Users/jmercouris/User/cpu_battery" :output :string)))

#+darwin
(define-command open-in-safari ()
  "Open the current URL in Safari"
  (uiop:run-program (list "open" "-a" "Safari" (object-string (url (current-buffer))))))

Again updated to reflect the latest changes:

(define-configuration browser
  ((session-restore-prompt :never-restore)
   (autofills (list (make-autofill :key "Current time"
                                   :fill (lambda () (format nil "~a" (local-time:now))))))))

(define-configuration nyxt/auto-mode:auto-mode
  ((nyxt/auto-mode:prompt-on-mode-toggle t)))

(define-configuration buffer
  ((default-modes (append '(emacs-mode) %slot-default%))
   (override-map (let ((map (make-keymap "my-override-map")))
                   (define-key map
                     "C-q" 'quit
                     "C-1" 'make-window
                     "C-2" 'delete-current-window
                     "keypadleft" 'nyxt/web-mode:history-backwards
                     "keypadright" 'nyxt/web-mode:history-forwards)
                   map))))

(define-configuration web-buffer
  ((default-modes (append '(emacs-mode blocker-mode) %slot-default%))
   (password-interface (make-instance 'password:password-store-interface))))

(define-configuration (prompt-buffer)
    ((default-modes (append '(emacs-mode) %slot-default%))
     (hide-suggestion-count-p t)))

(define-configuration status-buffer
    ((style (str:concat 
             %slot-default%
             (cl-css:css
              '(("#container"
                 ;; Columns: controls, url
                 :grid-template-columns "120px 2fr")))))))

(defun my-format-status (window)
  (let ((buffer (current-buffer window)))
    (markup:markup
     (:div :id "container"
           (:div :id "controls" :class "arrow-right"
                 (markup:raw (format-status-buttons)))
           (:div :id "url"
                 (markup:raw
                  (format-status-load-status buffer)
                  (format-status-url buffer)))))))

(define-configuration window
  ((status-formatter #'my-format-status)))

(define-configuration nyxt/web-mode::web-mode
  ((nyxt/web-mode::hints-alphabet "asdfghjklqwertyuiop")))

(define-command-global current-time ()
  "Show the current time."
  (echo "~a" (local-time:now)))

(defmethod nyxt::startup ((browser browser) urls)
  "Make a blank buffer."
  (window-make browser)
  (let ((window (current-window)))
    (window-set-buffer window (make-buffer :url (quri:uri "about:blank")))
    (toggle-fullscreen window)))

#+darwin
(define-command cpu-sleep ()
  "Put the computer to sleep."
  (uiop:run-program "/Users/jmercouris/User/cpu_sleep"))

#+darwin
(define-command cpu-battery ()
  "Show the battery status."
  (echo (uiop:run-program "/Users/jmercouris/User/cpu_battery" :output :string)))

#+darwin
(define-command open-in-safari ()
  "Open the current URL in Safari"
  (uiop:run-program (list "open" "-a" "Safari" (object-string (url (current-buffer))))))
2 Likes

object-string doesn’t work anymore, replace with quri:render-uri ?

Ah, you mean for the safari directive, you are correct. However on macOS I have an older version of Nyxt!