2024-01-28 08:06:40 +00:00
|
|
|
|
#+title: Commands
|
2024-01-28 04:31:58 +00:00
|
|
|
|
#+setupfile: ../headers
|
|
|
|
|
#+property: header-args:emacs-lisp :tangle no :exports results :cache yes :noweb yes
|
|
|
|
|
|
2024-01-28 08:06:40 +00:00
|
|
|
|
* Commands
|
2024-01-28 04:31:58 +00:00
|
|
|
|
** 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, let’s 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
|