diff --git a/modules/desktop.org b/modules/desktop.org index 301b8df..d5a6d9b 100644 --- a/modules/desktop.org +++ b/modules/desktop.org @@ -10,42 +10,7 @@ I use Emacs as a Desktop Environment with the *EXWM*[fn:1] package. It allows Emacs to function as a complete tiling window manager for *X11*[fn:2]. -* Profile -:PROPERTIES: -:header-args: :tangle ../config/profile :comments org -:END: - -Setup the default shell profile to run Emacs as a desktop environment. - -** Append to the $PATH - -Ensure that ~~/.local/bin~ added to the =$PATH= variable. - -#+begin_src shell -PATH=$PATH:~/.local/bin -export PATH -#+end_src - -** Launch on TTY1 - -When launching into a new session on ~TTY1~, if the display server is not running, run *StartX*[fn:3]. This will launch the window manager. - -#+begin_src shell -if [ -z "${DISPLAY}" ] && [ "${XDG_VTNR}" -eq 1 ]; then - exec startx -fi -#+end_src - -** Create symbolic link - -The system will look for the default shell profile at ~~/.profile~. Create a symbolic link from this location to the configuration file defined. - -#+begin_src emacs-lisp -(dotfiles/symlink "~/.emacs.d/config/profile" - "~/.profile") -#+end_src - -* Window manager +* Initialization :PROPERTIES: :header-args: :tangle ../config/xinitrc :comments org :END: @@ -73,6 +38,22 @@ Write out the ~$BROWSER~ variable so other applications can pick up the custom b (setenv "BROWSER" dotfiles/browser) #+end_src +** Browse URL keybindings + +Create a custom keybinding for browsing the urls behind =SPC u=: + ++ URL with =u= ++ Point with =p= ++ Cursor with =c= + +#+begin_src emacs-lisp +(dotfiles/leader + "u" '(:ignore t :which-key "Browse") + "uu" '(browse-url :which-key "URL") + "up" '(browse-url-at-point :which-key "Point") + "uc" '(browse-url-at-cursor :which-key "Cursor")) +#+end_src + * Displays detection When the window manager first launches the ~init-hook~ executes, allowing us to define some custom logic. @@ -98,40 +79,9 @@ Using =autorandr= with pre configured profiles, switching screens (AKA hot plugg (dotfiles/run-in-background "autorandr --change --force")) #+end_src -* Shell interaction - -Define a method to run an external process, allowing us to launch any application on a new process without interferring with Emacs. - -#+begin_src emacs-lisp -(defun dotfiles/run (cmd) - "Run an external process." - (interactive (list (read-shell-command "λ "))) - (start-process-shell-command cmd nil cmd)) -#+end_src - -Apply methods to the current call process to avoid issues with hooks. - -#+begin_src emacs-lisp -(defun dotfiles/run-in-background (cmd) - (let ((command-parts (split-string cmd "[ ]+"))) - (apply #'call-process `(,(car command-parts) nil 0 nil ,@(cdr command-parts))))) -#+end_src - -Place keybindings for executing shell commands behind =SPC x=. - -+ Run shell commands with =x= -+ Run async shell commands with =z= - -#+begin_src emacs-lisp -(dotfiles/leader - "x" '(:ignore t :which-key "Run") - "xx" '(dotfiles/run :which-key "Run") - "xz" '(async-shell-command :which-key "Async")) -#+end_src - -* Configuration +* Window manager - Connect our custom hooks and configure the input keys, a custom layer for key capture layers. +Connect our custom hooks and configure the input keys, a custom layer for key capture layers. + Enable =randr= support + Pass through to Emacs diff --git a/modules/shell.org b/modules/shell.org new file mode 100644 index 0000000..6c843ba --- /dev/null +++ b/modules/shell.org @@ -0,0 +1,85 @@ +#+TITLE: Shell +#+AUTHOR: Christopher James Hayward +#+EMAIL: chris@chrishayward.xyz + +#+PROPERTY: header-args:emacs-lisp :tangle shell.el :comments org +#+PROPERTY: header-args :results silent :eval no-export :comments org + +#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil +#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil + +Override the default behaviour of the Shell environment to integrate with Emacs. + +* Profile +:PROPERTIES: +:header-args: :tangle ../config/profile :comments org +:END: + +Override the default shell profile under *Bash*. + +** Setting up the $PATH + + Ensure ~~/.local/bin~ added to the =$PATH= environment variable. + +#+begin_src shell +PATH=$PATH:~/.local/bin +export PATH +#+end_src + +** Starting Emacs by default on TTY1 + +When launching into a new session on ~TTY1~, if the display server is not running, run *StartX*[fn:3]. This will launch the window manager. + +#+begin_src shell +if [ -z "${DISPLAY}" ] && [ "${XDG_VTNR}" -eq 1 ]; then + exec startx +fi +#+end_src + +** Creating symbolic links + +The system looks for the default shell profile under *Bash* at ~~/.profile~. Creating a symbolic link from this location to our configuration will override the startup behaviour. + +#+begin_src emacs-lisp +(dotfiles/symlink "~/.emacs.d/config/profile" + "~/.profile") +#+end_src + +* Methods + +Define methods for interaction between Emacs and the underlying shell environment. + +** Run an external process + +Define a method to run an external process, launching any application on a new process without interferring with Emacs. + +#+begin_src emacs-lisp +(defun dotfiles/run (cmd) + "Run an external process." + (interactive (list (read-shell-command "λ "))) + (start-process-shell-command cmd nil cmd)) +#+end_src + +** Apply command to call process + +Define a method to apply commands to the current call process, this is to avoid issues with hooks but can impact the performance of Emacs. + +#+begin_src emacs-lisp +(defun dotfiles/run-in-background (cmd) + (let ((command-parts (split-string cmd "[ ]+"))) + (apply #'call-process `(,(car command-parts) nil 0 nil ,@(cdr command-parts))))) +#+end_src + +** Keybindings + +Place keybindings for executing shell commands behind =SPC x=: + ++ Run shell commands with =x= ++ Run async shell commands with =z= + +#+begin_src emacs-lisp +(dotfiles/leader + "x" '(:ignore t :which-key "Run") + "xx" '(dotfiles/run :which-key "Run") + "xz" '(async-shell-command :which-key "Async")) +#+end_src