My latest latest config:
(setf *socket-path* nil)
(asdf:load-system :demeter)
(asdf:load-system :nx-fruit)
(define-configuration browser
((session-restore-prompt :always-restore)))
(define-command-global hello (world)
"Print something"
(echo world))
(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
"M-space" 'execute-command
"C-q" 'quit
"C-1" 'make-window
"C-2" 'delete-current-window
"keypadleft" 'nyxt/web-mode:history-backwards
"keypadright" 'nyxt/web-mode:history-forwards
"keypadbegin" 'reload-current-buffer)
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 (nyxt/blocker-mode:blocker-mode)
((glyph "⦸")))
(define-configuration (nyxt/emacs-mode:emacs-mode)
((glyph "⊹")))
(define-configuration (nyxt/certificate-exception-mode:certificate-exception-mode)
((glyph "⇢")))
(define-configuration (nyxt/web-mode:web-mode)
((glyph "🖧")))
(define-configuration status-buffer
((glyph-mode-presentation-p t)
(style (str:concat
%slot-default%
(cl-css:css
'(("*"
:background-color "rgb(100,100,100) !important")
(".arrow-right"
:clip-path "none")))))))
(define-configuration window
((prompt-buffer-open-height 300)))
(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))
(buffer (make-buffer :url (quri:uri "about:blank"))))
(window-set-buffer window buffer)
;; (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))))))
(define-command-global open-in-firefox ()
"Open the current URL in Firefox"
(uiop:run-program (list "firefox" (render-url (url (current-buffer))))))
(define-bookmarklet-command snake
"Play snake"
"javascript:for(
Q=128,/*maze size*/
m=b=Q*Q,
a=[P=l=u=d=p=S=w=0],/*a=grid,P=playing,l=food-iters left (until tail starts moving),u=food age,d=dir,p=prev-dir,S=score,w=score to be added on,m=the score to be added if food was eaten now*/
u=89,
f=(h=j=t=(b+Q)/2)-1,/*f=food,h=head,j=prev-head,t=tail. set food to left so gets picked up immediately, setting initial snake size*/
(B=(D=document).body).appendChild(x=D.createElement('p')),(X=x.style).position='fixed',X.left=X.top=0,X.background='#FFF',x.innerHTML='<p></p><canvas>',
v=(s=x.childNodes)[0],(s=s[1]).width=s.height=Q*5,c=s.getContext('2d'),
onkeydown=onblur=F=function(e,z){
z? /*calc food*/
a[f]?(
w+=m,/*aging food score calc*/
f=Math.random(l+=8)*(R=Q-2)*R|(u=0),F(f+=Q+1+(f/R|0)*2,z)/*random (re)calc food loc*/
):F(f)/*draw food*/
:e<0?( /*iter*/
l?--l:(y=t,t=a[t]-2,F(y)),/*set tail*/
S+=(w*=.8)/4,/*pretty score up*/
m=999/(u+++10),/*age food a bit*/
a[h+=[-1,-Q,1,Q][d=p]]?/*collision detect*/
B.removeChild(x,alert('Game Over')):
(F(h),/*draw head*/
F(e,j=h),/*calc food*/
v.innerHTML=P?(setTimeout(F,50,e,0),S|0):'Press P')/*next iter*/
):-e?(/*draw (+recalc sqr)*/
y=(a[e]=
e<Q|e>=Q*Q-Q|/*tb walls*/
!(e%Q)|e%Q==Q-1|/*lr walls*/
(e==h)*2)/*snake head*/
+(e==f),
e==h&&(a[j]=2+h),/*snake chain*/
c.fillStyle='hsl('+!a[e]*99+','+m*2+'%,'+y*50+'%)',/*color calc*/
c.fillRect(e%Q*5,(e/Q|0)*5,5,5)
):/*keyinput*/
isNaN(y=e.keyCode-37)|y==43?
(P=y&&!P)&&F(-1)/*pause*/
:p=
!P|y&-4|!(y^2^d)?/*arrow keys&¬ directly opposite*/
p:y;
return!1
};--b;F(b));/*init grid*/
void F(-1)/*dummy update*/")
;; Disable Compositing for Nvidia driver
;; (setf (uiop:getenv "WEBKIT_DISABLE_COMPOSITING_MODE") "1")