config.phundrak.com/docs/stumpwm/commands.org
Lucien Cartier-Tilet 87b3deeed3
All checks were successful
deploy / build (push) Successful in 2m27s
feat: restore sidebar's table of contents for nested pages
2024-01-28 09:06:40 +01:00

54 lines
1.6 KiB
Org Mode
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#+title: Commands
#+setupfile: ../headers
#+property: header-args:emacs-lisp :tangle no :exports results :cache yes :noweb yes
* Commands
** Commands
:PROPERTIES:
:header-args:lisp: :mkdirp yes :tangle ~/.stumpwm.d/commands.lisp
:END:
The first command I declare in this file is a command that will avoid
me invoking too many Firefox instances. Either Firefox is not already
running and an instance is launched, or one already is, and we are
brought to it. This is done like so:
#+begin_src lisp
(defcommand firefox () ()
"Run or raise Firefox."
(sb-thread:make-thread (lambda () (run-or-raise "firefox" '(:class "Firefox") t nil))))
#+end_src
Next, this command will not only close the current window, but it will
also close the current frame.
#+begin_src lisp
(defcommand delete-window-and-frame () ()
"Delete the current frame with its window."
(delete-window)
(remove-split))
#+end_src
The two following commands will create a new frame to the right and
below the current frame respectively, then focus it.
#+begin_src lisp
(defcommand hsplit-and-focus () ()
"Create a new frame on the right and focus it."
(hsplit)
(move-focus :right))
(defcommand vsplit-and-focus () ()
"Create a new frame below and move focus to it."
(vsplit)
(move-focus :down))
#+end_src
Now, lets create a command for invoking the terminal, optionally with
a program.
#+begin_src lisp
(defcommand term (&optional program) ()
"Invoke a terminal, possibly with a @arg{program}."
(sb-thread:make-thread
(lambda ()
(run-shell-command (if program
(format nil "kitty ~A" program)
"kitty")))))
#+end_src