Opinionated Nyxt Base Config

@ambrevar @jmercouris I know you’ll both see this at some point anyway but tagging you as I mentioned it in other threads.

So it took me a little bit to get this going and it probably isn’t finished by any stretch but this came out of necessity almost as I was spreading the word about Nyxt. It seemed like with everything I did and all I told people about it they still need a solid jumping off point. So I made a repo that has my very opinonated settings for Nyxt that will stay mostly in line with what I use personally. Everything is commented (hopefully well enough) and serves as a good jumping off point as it includes a decent amount of concepts from the beginning.

Repo - GitHub - ericdrgn/drgn.nyxt: Base configuration for nyxt with opinionated theme(s) and organization.

I haven’t seen many configurations or organization of those at this point so I made my own organization and decided where I thought things should be (again opinionated haha). As can probably be seen I did also put a decent emphasis on theming Nyxt so that is there with four “themes” I created.

There is also an update.sh script in there that I made so that Linux users can just run that and it will pull my latest release and put everything in the correct places whether or not the .config/nyxt directory had already been created. Again more of an initialization piece to get people on the boat, not necessarily meant to continue running that.

But that is about it, since this is based on my personal config (I have more experiments and other things going on there) I can’t commit to fixing any and everything that might come up because it works for me and time might not allow for much else. That said I do welcome any comments, suggestions, improvements and all that either here or in the repo as I am sure I didn’t do everything right or in the best way.

This is literally just my attempt at trying to stitch it all together. Thanks to everyone that has helped me get this far!

2 Likes

Wow! I am really impressed! You’ve gone to great lengths to make it approachable! I personally really like the presence of several themes. Very cool. Hopefully we will soon make it a little bit easier to publish and distribute themes, we have some ideas on our issue tracker!

I am very excited to see where this goes. Thanks for sharing! Also, please consider putting a link to your config in the Nyxt config expose (on this forum).

1 Like

Done Nyxt Starter - drgn.nyxt

On styling of things @jmercouris… First I would like to style about:blank but can’t figure out how to do that. I just want it black, of course haha. But also pretty consistently my screen flashes to a blank white screen when navigating to a url or something. Is this flash actually from about:blank? Or is it something else? Either way how could I get that styled black as well. Especially at night that white flash can be really jarring…

nyxtflash

Yes, that should be about:blank. To style it, you can leverage WebKit. This feels like a browser-level thing, rather than personal config one, though.

I am sure that is the better way, but there should still be a way to just easily calling it up and making it black instead of having to develop the whole thing just to change it, right? I can easily change it for Firefox via CSS.

Artyom is correct. We’ll have to leverage webkit. I think we could definitely make it a browser slot though. Or at least a gtk-browser slot.

More of me just knowing nothing about it all then haha.

Thanks a lot for your configuration files and structure proposal @ericdrgn. I’m using it as a base config that I hope I’ll be able to further customize when I understand Lisp and Nyxt variables a little bit better.

So far I just added a base/domainrules.lisp where I set a rule to replace all “reddit.com” URLs with “old.reddit.com”. Stolen from someone else’s dotfiles:

;; HANDLERS
(defparameter old-reddit-handler
  (url-dispatching-handler
   'old-reddit-dispatcher
   (match-host "www.reddit.com")
   (lambda (url)
     (quri:copy-uri url :host "old.reddit.com"))))

(defvar *my-request-resource-handlers* (list old-reddit-handler))

(define-configuration buffer
  ((request-resource-hook
    (reduce #'hooks:add-hook
            *my-request-resource-handlers*
            :initial-value %slot-default%))))

More minor edits: I removed the fullscreen option and set the restore prompt to “always-ask” (but it doesn’t work, I must have done something wrong). [Edit] I think this was due to your “Setting new buffer url” block in init.lisp. Can I safely remove the whole 5-line block without breaking something else?

Apart from fixing the above, what I would like to do now is:

  • hide the toolbar/powerbar/bufferbar/modebar when the minibuffer is hidden, or maybe add a keybind to toggle just those bars on and off
  • keep the I/N indicators for vi mode (those are quite convenient, thanks)
  • change the statusbar (where warnings are shown and URLs are shown when hovering a link) into a translucent overlay, so that Nyxt uses full vertical space when there is no status message, and when there’s one, it just shows on top of the content
  • change all “black” values of the drgn-dark.lisp file into a variable so that the minibuffer colour can be changed into any other dark colour with just one change, and possibly make it reflect the background colour of my ~/.config/kitty.conf.

I suppose only the last feature is reasonably easy to achieve, while the rest should keep me busy for a bunch of months. :> Help welcome of course!

Thanks again!

1 Like

Wow! Awesome, glad you like what I’ve attempted to do. I think I’ll do that theme variable bit myself as well! Let me know if you do anything cool down the line and I’ll add it and give you credit. Or however you would like to do it. Obviously this is my config and I want people to branch from it like you have but if something adds functionality that is a good to have and doesn’t interfere with my use then I’ll add it.

Oh I need no credits, I did nothing and it’s going to take decades before I know how to achieve what I want to do in common lisp!

There is no repository for it yet, but I continued customizing a bit to my own preferences based on your nice base. It looks like that for now:

This is the current diff:

diff --git a/tmp/drgn.nyxt/auto-config.lisp b/home/user/.config/nyxt/auto-config.lisp
index 139597f..5e259c1 100644
--- a/tmp/drgn.nyxt/auto-config.lisp
+++ b/home/user/.config/nyxt/auto-config.lisp
@@ -1,2 +1,11 @@
 
 
+(DEFINE-CONFIGURATION BUFFER
+  ((DEFAULT-MODES (APPEND '(NYXT::EMACS-MODE) %SLOT-DEFAULT%))))
+(DEFINE-CONFIGURATION BUFFER
+  ((DEFAULT-MODES %SLOT-DEFAULT%)))
+(DEFINE-CONFIGURATION BUFFER
+  ((DEFAULT-MODES (APPEND '(NYXT::VI-NORMAL-MODE) %SLOT-DEFAULT%))))
+(DEFINE-CONFIGURATION PROMPT-BUFFER
+  ((DEFAULT-MODES (APPEND '(NYXT::VI-INSERT-MODE) %SLOT-DEFAULT%))))
+
diff --git a/tmp/drgn.nyxt/base/commands.lisp b/home/user/.config/nyxt/base/commands.lisp
index c1d3bc3..cc1c923 100644
--- a/tmp/drgn.nyxt/base/commands.lisp
+++ b/home/user/.config/nyxt/base/commands.lisp
@@ -1,10 +1,5 @@
 (in-package #:nyxt-user)
 
-;;runs shutdown -h now
-(define-command-global no-mercy ()
-  "shutdown, with no mercy."
-  (uiop:run-program "~/.config/nyxt/scripts/shutdown.sh"))
-
 ;;shows current time
 (define-command-global current-time ()
   "Show the current time."
@@ -15,11 +10,6 @@
   "Show the weather for current location in message area."
   (echo (uiop:run-program "~/.config/nyxt/scripts/weather.sh" :output :string)))
 
-;;runs script to open spotify and set the window
-(define-command-global open-spotify ()
-  "Open Spotify."
-  (uiop:run-program "~/.config/nyxt/scripts/spotify.sh"))
-
 ;;command to close nyxt and delete history file | investigating below issues
 ;;currently cannot be last command in this list and won't show in commands list so setting a keybinding is necessary
 (define-command-global quit-history ()
@@ -27,7 +17,27 @@
                                           (history-path (current-buffer))))
   (quit))
 
-;;opens current url in different browser replace firefox with your browser/path
-(define-command-global open-external-browser ()
-  "Open the current url in external browser"
+;;use kakoune as external-editor
+(define-configuration browser
+  ((external-editor-program (list "/usr/bin/kitty" "--name" "floating" "/usr/local/bin/kak"))))
+
+;;opens current url in different programs
+(define-command-global open-in-firefox ()
+  "Open the current URL in Firefox"
   (uiop:run-program (list "firefox" (render-url (url (current-buffer))))))
+
+(define-command-global open-in-chromium ()
+  "Open the current URL in Chromium"
+  (uiop:run-program (list "chromium" (render-url (url (current-buffer))))))
+
+(define-command-global open-in-w3m ()
+  "Open the current URL in w3m"
+  (uiop:run-program (list "kitty" "w3m" (render-url (url (current-buffer))))))
+
+(define-command-global open-in-lynx ()
+  "Open the current URL in lynx"
+  (uiop:run-program (list "kitty" "lynx" (render-url (url (current-buffer))))))
+
+(define-command-global open-in-kakoune ()
+  "Edit the current text field in kakoune"
+  (uiop:run-program (list "kitty" "--name" "floating" "kak" (render-url (url (current-buffer))))))
diff --git a/home/user/.config/nyxt/base/domainrules.lisp b/home/user/.config/nyxt/base/domainrules.lisp
new file mode 100644
index 0000000..6fd3763
--- /dev/null
+++ b/home/user/.config/nyxt/base/domainrules.lisp
@@ -0,0 +1,16 @@
+;; HANDLERS
+(defparameter old-reddit-handler
+  (url-dispatching-handler
+   'old-reddit-dispatcher
+   (match-host "www.reddit.com")
+   (lambda (url)
+     (quri:copy-uri url :host "old.reddit.com"))))
+
+(defvar *my-request-resource-handlers* (list old-reddit-handler))
+
+(define-configuration buffer
+  ((request-resource-hook
+    (reduce #'hooks:add-hook
+            *my-request-resource-handlers*
+            :initial-value %slot-default%))))
+
diff --git a/tmp/drgn.nyxt/base/glyphs.lisp b/home/user/.config/nyxt/base/glyphs.lisp
index cc85881..00a3d9d 100644
--- a/tmp/drgn.nyxt/base/glyphs.lisp
+++ b/home/user/.config/nyxt/base/glyphs.lisp
@@ -13,9 +13,9 @@
 (define-configuration nyxt/style-mode:style-mode ((glyph "s")))
 (define-configuration nyxt/help-mode:help-mode ((glyph "?")))
 
-;;configure web mode hints to home row fore colemak and set glyph
+;;configure web mode hints to home row and set glyph
 (define-configuration nyxt/web-mode:web-mode
-  ((nyxt/web-mode:hints-alphabet "ARSTGMNEIO")
+  ((nyxt/web-mode:hints-alphabet "ASDFGHJKL")
     (glyph "ω")))
 
 ;;auto-mode config and set glyph
diff --git a/tmp/drgn.nyxt/base/keybindings.lisp b/home/user/.config/nyxt/base/keybindings.lisp
index 84f0cef..1a7758e 100644
--- a/tmp/drgn.nyxt/base/keybindings.lisp
+++ b/home/user/.config/nyxt/base/keybindings.lisp
@@ -4,12 +4,12 @@
 (define-configuration buffer
   ((override-map (let ((map (make-keymap "my-override-map")))
                    (define-key map
-                     "M-i" 'show-weather
-                     "C-t" 'set-url-new-buffer
-                     "C-2" 'open-external-browser
-                     "C-0" 'no-mercy
-                     "M-x" 'execute-command
-                     "C-s" 'query-selection-in-search-engine
-                     "C-c" 'nyxt/web-mode::copy ;;currently an override because C-c not working without it
-                     "C-q" 'quit-history)
+                     "M-i"  'show-weather
+                     "M-x"  'execute-command
+                     "C-o"  'query-selection-in-search-engine
+                     "C-c"  'nyxt/web-mode::copy ;;currently an override because C-c not working without it
+                     "C-q"  'quit-history
+                     "C-t"  'toggle-toolbars
+                     "C-e"  'edit-with-external-editor
+                     "C-x"  'edit-user-file-with-external-editor)
                    map))))
diff --git a/tmp/drgn.nyxt/base/urlprompt.lisp b/home/user/.config/nyxt/base/urlprompt.lisp
index bb7f0c1..7a34742 100644
--- a/tmp/drgn.nyxt/base/urlprompt.lisp
+++ b/home/user/.config/nyxt/base/urlprompt.lisp
@@ -4,10 +4,11 @@
 ;;order: "shortcut" "url for search, ~a determines where query is placed" "fallback url when query fails or an empty search"
 (defvar *my-search-engines*
   (list
-   '("az" "https://amazon.com/s?k=~a" "https://amazon.com/") ;;amazon
+   '("az" "https://amazon.fr/s?k=~a" "https://amazon.fr/") ;;amazon
    '("hns" "https://hns.to/~a" "https://hns.to/") ;;handshake addresses
-   '("git" "https://github.com/search?q=~a" "https://github.com/") ;;git repos
+   '("gh" "https://github.com/search?q=~a" "https://github.com/") ;;git repos
    '("wiki" "https://en.wikipedia.org/w/index.php?search=~a" "https://en.wikipedia.org/") ;;wikipedia
+   '("sp" "https://www.startpage.com/do/dsearch?query=~a" "https://www.startpage.com/") ;;startpage
    '("ddg" "https://duckduckgo.com/?q=~a" "https://duckduckgo.com/") ;;duckduckgo
 
 (define-configuration buffer
diff --git a/home/user/.config/nyxt/ex/bookmarklets.lisp b/home/user/.config/nyxt/ex/bookmarklets.lisp
new file mode 100644
index 0000000..3ee036c
--- /dev/null
+++ b/home/user/.config/nyxt/ex/bookmarklets.lisp
@@ -0,0 +1,3 @@
+(define-bookmarklet-command mouse-over-image-preview
+    "Description"
+    "insert JS here")
diff --git a/tmp/drgn.nyxt/ex/specificurl.lisp b/home/user/.config/nyxt/ex/specificurl.lisp
index 25443c6..21cb4d4 100644
--- a/tmp/drgn.nyxt/ex/specificurl.lisp
+++ b/home/user/.config/nyxt/ex/specificurl.lisp
@@ -2,6 +2,22 @@
 
 ;;extra .lisp file for the configs of various search engines/url prompts to get straight to them via command/binding
 
+;;command to start running a search from sp directly
+(define-command-global search-sp (&key (prefill-current-url-p t))
+  "Set sp in the url prompt to search straight from startpage."
+  (let ((actions (list (make-command buffer-load* (suggestion-values)
+                         "Load first selected URL in current buffer and the rest in new buffer(s)."
+                         (mapc (lambda (suggestion) (make-buffer :url (url suggestion))) (rest suggestion-values))
+                         (buffer-load (url (first suggestion-values))))
+                       (make-command new-buffer-load (suggestion-values)
+                         "Load URL(s) in new buffer(s)."
+                         (mapc (lambda (suggestion) (make-buffer :url (url suggestion))) (rest suggestion-values))
+                         (make-buffer-focus :url (url (first suggestion-values)))))))
+    (prompt
+     :prompt "Startpage"
+     :input "sp "
+     :sources (list (make-instance 'user-new-url-or-search-source :actions actions)))))
+ 
 ;;command to start running a search from ddg directly
 (define-command-global search-ddg (&key (prefill-current-url-p t))
   "Set ddg in the url prompt to search straight from duckduckgo."
@@ -18,9 +34,9 @@
      :input "ddg "
      :sources (list (make-instance 'user-new-url-or-search-source :actions actions)))))
  
- ;;command to start running a search from git directly    
-(define-command-global search-git (&key (prefill-current-url-p t))
-  "Set git in the url prompt to search straight from github."
+ ;;command to start running a search from gh directly    
+(define-command-global search-gh (&key (prefill-current-url-p t))
+  "Set gh in the url prompt to search straight from github."
   (let ((actions (list (make-command buffer-load* (suggestion-values)
                          "Load first selected URL in current buffer and the rest in new buffer(s)."
                          (mapc (lambda (suggestion) (make-buffer :url (url suggestion))) (rest suggestion-values))
@@ -31,7 +47,7 @@
                          (make-buffer-focus :url (url (first suggestion-values)))))))
     (prompt
      :prompt "GitHub"
-     :input "git "
+     :input "gh "
      :sources (list (make-instance 'user-new-url-or-search-source :actions actions)))))
  
  ;;command to start running a search from wiki directly    
diff --git a/home/user/.config/nyxt/icon.png b/home/user/.config/nyxt/icon.png
new file mode 100644
index 0000000..e962ff5
Binary files /dev/null and b/home/user/.config/nyxt/icon.png differ
diff --git a/tmp/drgn.nyxt/init.lisp b/home/user/.config/nyxt/init.lisp
index 526762c..7e8e6de 100644
--- a/tmp/drgn.nyxt/init.lisp
+++ b/home/user/.config/nyxt/init.lisp
@@ -2,31 +2,28 @@
 
 ;;loading of config files
 ;;add theme here
-(nyxt::load-lisp "~/.config/nyxt/themes/standard-dark.lisp")
+(nyxt::load-lisp "~/.config/nyxt/themes/kabouik-standard-dark.lisp")
 ;;base
 (nyxt::load-lisp "~/.config/nyxt/base/keybindings.lisp")
 (nyxt::load-lisp "~/.config/nyxt/base/urlprompt.lisp")
 (nyxt::load-lisp "~/.config/nyxt/base/commands.lisp")
 (nyxt::load-lisp "~/.config/nyxt/base/glyphs.lisp")
+(nyxt::load-lisp "~/.config/nyxt/base/domainrules.lisp")
 ;;extending
 (nyxt::load-lisp "~/.config/nyxt/ex/specificurl.lisp")
+(nyxt::load-lisp "~/.config/nyxt/ex/bookmarklets.lisp")
 
 ;;configuration for browser
 (define-configuration browser
-  ((session-restore-prompt :never-restore)))
+  ((session-restore-prompt :always-ask)))
 
 ;;configuration for buffer and nosave buffer to have reduce tracking by default
 (define-configuration (web-buffer nosave-buffer)
-  ((default-modes `(reduce-tracking-mode
+  ((default-modes `(reduce-tracking-mode blocker-mode
                     ,@%slot-default%))))
 
-;;setting new buffer url and having nyxt start full screen
-(defmethod nyxt::startup ((browser browser) urls)
-  "Home"
-  (window-make browser)
-  (let ((window (current-window)))
-    (window-set-buffer window (make-buffer :url (quri:uri "https://nyxt.atlas.engineer/")))
-    (toggle-fullscreen window)))
+;;disable smooth-scrolling
+(define-configuration buffer  ((smooth-scrolling nil)))
 
 ;;when reloading init.lisp file shows in message bar once finished
 (echo "Loaded config.")
diff --git a/tmp/drgn.nyxt/scripts/shutdown.sh b/tmp/drgn.nyxt/scripts/shutdown.sh
deleted file mode 100644
index 4cf3d42..0000000
--- a/tmp/drgn.nyxt/scripts/shutdown.sh
+++ /dev/null
@@ -1 +0,0 @@
-shutdown -h now
diff --git a/tmp/drgn.nyxt/scripts/spotify.sh b/tmp/drgn.nyxt/scripts/spotify.sh
deleted file mode 100644
index 548aaf0..0000000
--- a/tmp/drgn.nyxt/scripts/spotify.sh
+++ /dev/null
@@ -1,13 +0,0 @@
-xdotool search --classname spotify windowkill %@ &
-
-sleep 2s
-
-/usr/share/spotify/spotify &
-'''
-sleep 10s
-
-xdotool search --classname spotify set_desktop_for_window %@ 0 &
-
-
-
-
diff --git a/tmp/drgn.nyxt/scripts/weather.sh b/home/user/.config/nyxt/scripts/weather.sh
old mode 100644
new mode 100755
diff --git a/home/user/.config/nyxt/themes/kabouik-standard-dark.lisp b/home/user/.config/nyxt/themes/kabouik-standard-dark.lisp
new file mode 100644
index 0000000..e2901a2
--- /dev/null
+++ b/home/user/.config/nyxt/themes/kabouik-standard-dark.lisp
@@ -0,0 +1,139 @@
+(in-package #:nyxt-user)
+  
+;;configuration window
+(define-configuration window
+  ((message-buffer-style
+    (str:concat
+     %slot-default%
+     (cl-css:css
+      '((body
+         :background-color "#292d3e"
+         :color "#bfc7e5")))))))
+
+;prompt buffer
+(define-configuration prompt-buffer
+  ((style (str:concat
+           %slot-default%
+           (cl-css:css
+            '((*
+               :font-family "monospace,monospace"
+               :font-size "12px"
+               :line-height "12px")
+              (body
+               :background-color "#292d3e"
+               :color "#bfc7e5")
+              ("#vi-mode"
+               :line-height "18px")
+              ("#prompt-area"
+               :background-color "#292d3e")
+              ("#prompt-area-vi"
+               :background-color "#292d3e")
+              ("#input"
+               :background-color "#3D425A"
+               :color "#cccccc")
+              (".source-name"
+               :background-color "#141724"
+               :color "#cccccc")
+              (".source-content"
+               :width "100%"
+               :background-color "#292d3e")
+              (".source-content th"
+               :background-color "292d3e"
+               :font-weight "bold")
+              (".source-content th:nth-child(1)"
+               :width "20%")
+              (".source-content th:nth-child(2)"
+               :width "9%")
+              (".source-content th:nth-child(3)"
+               :width "54%")
+              (".source-content th:nth-child(4)"
+               :width "17%")
+              ("#selection"
+               :background-color "#141724")
+              (.marked :background-color "black"
+                       :font-weight "bold"
+                       :color "#cccccc")
+              (.selected :background-color "black"
+                         :color "#cccccc")))))))
+
+;internal buffer
+(define-configuration internal-buffer
+  ((style
+    (str:concat
+     %slot-default%
+     (cl-css:css
+      '((title
+         :color "#bfc7e5")
+        (body
+         :background-color "#292d3e"
+         :color "#bfc7e5")
+        (hr
+         :color "#bfc7e5")
+        (a
+         :color "#bfc7e5")
+        (.button
+         :color "#292d3e"
+         :background-color "#bfc7e5")))))))
+
+;;history tree
+(define-configuration nyxt/history-tree-mode:history-tree-mode
+  ((nyxt/history-tree-mode::style
+    (str:concat
+     %slot-default%
+     (cl-css:css
+      '((body
+         :background-color "#292d3e"
+         :color "#bfc7e5")
+        (hr
+         :color "#3d425a")
+        (a
+         :color "#bfc7e5")
+        ("ul li::before"
+         :background-color "#bfc7e5")
+        ("ul li::after"
+         :background-color "#bfc7e5")
+        ("ul li:only-child::before"
+         :background-color "#bfc7e5")))))))
+
+;;highlight boxes
+(define-configuration nyxt/web-mode:web-mode
+  ((nyxt/web-mode:highlighted-box-style
+    (cl-css:css
+     '((".nyxt-hint.nyxt-highlight-hint"
+        :background "#292d3e")))
+    :documentation "The style of highlighted boxes, e.g. link hints.")))
+
+;;styling status buffer black and setting size of tabs and modes. Can uncomment url and controls section for theming those.
+(define-configuration status-buffer
+  ((style (str:concat
+           %slot-default%
+           (cl-css:css
+            '((*
+               :font-family "monospace,monospace")
+              ("#controls"
+               :background-color "#292d3e"
+               :border-top "1px solid black")
+              ("#url"
+               :background-color "#292d3e"
+               :border-top "1px solid black"
+               :font-size "11px")
+              ("#modes"
+               :background-color "#292d3e"
+               :border-top "1px solid black"
+               :font-size "11px")
+              ("#tabs"
+               :background-color "#292d3e"
+               :color "#bfc7e5"
+               :font-size "11px"
+               :border-top "1px solid black")
+              (".controls:hover"
+               :color "#bfc7e5")
+              (".modes:hover"
+               :color "#bfc7e5")
+              (".button:hover"
+               :color "#bfc7e5")
+              (".url:hover"
+               :color "#bfc7e5")
+              (".tab:hover"
+               :color "#bfc7e5")))))))
+

Mostly changes on the dark theme. Still other things I would like to implement (e.g., the list in my previous post, but there are others things on my list). The search engines set in base/urlprompt.lisp also don’t seem to work for me, they always just end in Duckduckgo instead of searching directly on corresponding sits, But I think they are a bit redundant with Duckduckgo !bang commands anyway so I might remove them eventually and just use !bang like !imdb, !sp, !gi, as those won’t need any Nyxt config. Maybe I just didn’t understand how to use them.

2 Likes