diff --git a/.drone.yml b/.drone.yml
deleted file mode 100644
index 65caccc..0000000
--- a/.drone.yml
+++ /dev/null
@@ -1,37 +0,0 @@
-kind: pipeline
-name: default
-
-steps:
-- name: build
- image: silex/emacs:master-alpine-ci
- commands:
- - emacs -Q --script export.el
- when:
- branch:
- - master
- event:
- exclude:
- - pull_request
-
-- name: deploy
- image: appleboy/drone-scp
- settings:
- host:
- from_secret: ssh_host
- target:
- from_secret: ssh_target
- source:
- - org/config/*
- strip_components: 2
- username:
- from_secret: ssh_username
- password:
- from_secret: ssh_password
- port:
- from_secret: ssh_port
- when:
- branch:
- - master
- event:
- exclude:
- - pull_request
diff --git a/README.org b/README.org
index 0a79929..97ddb71 100644
--- a/README.org
+++ b/README.org
@@ -3,49 +3,31 @@
#+EMAIL: lucien@phundrak.com
#+CREATOR: Lucien Cartier-Tilet
#+LANGUAGE: en
-#+OPTIONS: auto-id:t H:4 broken_links:mark email:t ^:{}
+#+OPTIONS: H:4 broken_links:mark email:t ^:{}
#+KEYWORDS: dotfiles linux emacs configuration phundrak drakpa
-#+html:
-#+html:
#+html:
-#+html:
* Presentation
- :PROPERTIES:
- :CUSTOM_ID: Presentation-e5605995
- :END:
- This repository is where I keep most of my configuration files. With what is
- stored here, anyone can recreate a working desktop configuration similar to my
- daily one.
+This repository is where I keep most of my configuration files. With
+what is stored here, anyone can recreate a working desktop
+configuration similar to my daily one.
- My dotfiles are managed by [[https://yadm.io/][yadm]], and although I don’t use its alternate files
- features (which is pretty neat btw), it allows me to painlessly manage my
- dotfiles right where they are and not in a separate Git repository somewhere
- with everything symlinked. Another advantage of yadm is it will automatically
- execute (with your authorization, of course) my homemade bootstrap when my
- dotfiles are cloned through yadm.
+My dotfiles are managed by [[https://yadm.io/][yadm]], and although I don’t use its
+alternate files features (which is pretty neat btw), it allows me to
+painlessly manage my dotfiles right where they are and not in a
+separate Git repository somewhere with everything symlinked. Another
+advantage of yadm is it will automatically execute (with your
+authorization, of course) my homemade bootstrap when my dotfiles are
+cloned through yadm.
-* Where’s the config file for X?
- :PROPERTIES:
- :CUSTOM_ID: Where’s_the_config_file_for_X?-7b214c4a
- :END:
- As you may have noticed, I am striving for a 100% amount of configuration
- files exported from Org files, that is, through literary programming. This is
- still very much a work in progress though. Most of what you need can be found
- in my [[file:org/config/index.org][index.org]] file and in its folder.
-
-* Some more info please?
- :PROPERTIES:
- :CUSTOM_ID: Some_more_info_please?-f54ae73a
- :END:
- Everything you need to know is in my [[file:org/config/]] folder, and my Org files
- are also available in web format on my website [[https://config.phundrak.com/][config.phundrak.com]].
+* A lot of things are missing!
+Yep, a lot of things are not in this repository but over at
+[[https://config.phundrak.com][config.phundrak.com]]. This is where I store all my litterate config.
+You can check out its own repo over at
+[[https://labs.phundrak.com/phundrak/config.phundrak.com][labs.phundrak.com/phundrak/config.phundrak.com]].
* Neat, what’s the license?
- :PROPERTIES:
- :CUSTOM_ID: Neat,_what’s_the_license?-399aa236
- :END:
All of my dotfiles (and my dotfiles only) are available under the GNU GPLv3
Licence. Please consult [[file:LICENCE.md]] for more information. In short: you
are free to access, edit and redistribute all of my dotfiles under the same
diff --git a/export.el b/export.el
deleted file mode 100755
index fa840d6..0000000
--- a/export.el
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/usr/bin/env -S emacs -Q --script
-
-(require 'package)
-(require 'org)
-(require 'ox-html)
-
-(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
-(package-initialize)
-(package-refresh-contents)
-(package-install 'htmlize)
-
-(setq org-confirm-babel-evaluate nil
- org-html-validation-link nil
- make-backup-files nil)
-
-(defun export-and-clean (directory)
- (progn (mapc (lambda (file)
- (progn (message (concat "=====================\n"
- "Exporting "
- file
- "\n"
- "=====================\n"))
- (with-current-buffer (find-file file)
- (org-html-export-to-html))))
- (directory-files directory t (regexp-quote ".org")))))
-
-(dolist (dir '("org/config/" "org/config/Deprecated/" "org/config/WIP"))
- (export-and-clean dir))
diff --git a/org/config/.dir-locals.el b/org/config/.dir-locals.el
deleted file mode 100644
index faa8462..0000000
--- a/org/config/.dir-locals.el
+++ /dev/null
@@ -1,2 +0,0 @@
-((org-mode . ((org-confirm-babel-evaluate . nil)
- (org-latex-reference-command . "\\ref{%s}"))))
diff --git a/org/config/Deprecated/awesome.org b/org/config/Deprecated/awesome.org
deleted file mode 100644
index f5d52c1..0000000
--- a/org/config/Deprecated/awesome.org
+++ /dev/null
@@ -1,1513 +0,0 @@
-#+title: AwesomeWM configuration
-#+setupfile: ../headers
-#+OPTIONS: unique-id:t
-#+HTML_HEAD_EXTRA:
-#+HTML_HEAD_EXTRA:
-#+HTML_HEAD_EXTRA:
-#+PROPERTY: header-args :noweb yes :tangle no :exports none
-#+PROPERTY: header-args:lua :tangle ~/.config/awesome/rc.lua :exports code :noweb yes :mkdirp yes
-
-* Introduction
-:PROPERTIES:
-:CUSTOM_ID: Introduction-4c41360e
-:END:
-From the Arch Wiki: awesome is a highly configurable, next generation framework
-window manager for Xorg. It is very fast and extensible. It is primarily
-targeted at power users, developers and any people dealing with every day
-computing tasks and who want to have fine-grained control on its graphical
-environment.
-
-Personally, what really made me want to try Awesome is the fact its
-configuration file is written with an actual programming language and not just a
-configuration language like with i3, and by the fact it works with tags and not
-workspaces which makes window management much more flexible.
-
-This document was written in Emacs with Org-mode and is both the documentation
-and source code of my configuration file which can be extracted to
-~$HOME/.config/awesome/rc.lua~ through a call to ~org-babel-tangle~.
-
-* Launching Awesome
-:PROPERTIES:
-:CUSTOM_ID: Launching-Awesome-lavgvvz00bj0
-:END:
-In order to launch Awesome with ~startx~, I need a ~xinit~-compatible
-script. Here is my ~$HOME/.xinitrc.awesome~ file:
-#+begin_src sh :tangle ~/.xinitrc.awesome
-xhost +
-exec awesome
-#+end_src
-
-* Loading libraries
-:PROPERTIES:
-:CUSTOM_ID: Loading_libraries-4df76999
-:END:
-First of all, some initialization is needed, and this initialization is about
-math randomness. So, let’s initialize the ~random~ method of the ~math~ library:
-#+BEGIN_SRC lua
-math.randomseed(os.time())
-#+END_SRC
-
-In order to be able to load libraries properly, I first need to make sure
-LuaRocks is installed, so I can also make sure the packages our configuration
-depends on installed through it can be found. If LuaRocks is not installed, then
-do nothing.
-#+BEGIN_SRC lua
-pcall(require, "luarocks.loader")
-#+END_SRC
-
-Next, we’ll also load the following libraries
-#+NAME: table-imported-libraries
-| Library | Import as | What it is |
-|---------------------+---------------+---------------------------|
-| gears | gears | Standard Awesome library |
-| awful | awful | Standard Awesome library |
-| wibox | wibox | Widget and layout library |
-| beautiful | beautiful | Theme handling library |
-| naughty | naughty | Notification library |
-| menubar | menubar | Create menus |
-| awful.hotkeys_popup | hotkeys_popup | Help window for hotkeys |
-
-#+NAME: imported-libraries
-#+BEGIN_SRC emacs-lisp :var libs=table-imported-libraries :cache yes
-(mapconcat (lambda (x) (format "local %s = require(\"%s\")"
- (cadr x)
- (car x)))
- libs
- "\n")
-#+END_SRC
-
-#+RESULTS[a66d7b66dbd4b4001dc3f649840b66761cc915b5]: imported-libraries
-: local gears = require("gears")
-: local awful = require("awful")
-: local wibox = require("wibox")
-: local beautiful = require("beautiful")
-: local naughty = require("naughty")
-: local menubar = require("menubar")
-: local hotkeys_popup = require("awful.hotkeys_popup")
-
-Here is the actual code in the config file:
-#+BEGIN_SRC lua
-<>
-#+END_SRC
-
-I also want to be able to autofocus the first window when I go to another workspace, so let’s require that:
-#+BEGIN_SRC lua
-require("awful.autofocus")
-#+END_SRC
-
-And finally, I want to be able to declare some shortcuts specific to some apps
-thanks to the hotkeys help widget.
-#+BEGIN_SRC lua
-require("awful.hotkeys_popup.keys")
-#+END_SRC
-By the way, let’s initialize the ~random~ method of the ~math~ library:
-#+BEGIN_SRC lua
-math.randomseed(os.time())
-#+END_SRC
-
-* Error handling
-:PROPERTIES:
-:CUSTOM_ID: Error_handling-f6a6668f
-:END:
-This code checks if Awesome encountered an error during startup and fell back to
-another config. This code will only ever execute for the fallback config.
-#+BEGIN_SRC lua
-if awesome.startup_errors then
- naughty.notify({ preset = naughty.config.presets.critical,
- title = "Oops, there were errors during startup!",
- text = awesome.startup_errors })
-end
-#+END_SRC
-
-And this code handles runtime errors after startup thanks to signals.
-#+BEGIN_SRC lua
-do
- local in_error = false
- awesome.connect_signal("debug::error", function (err)
- -- Make sure we don't go into an endless error loop
- if in_error then return end
- in_error = true
-
- naughty.notify({ preset = naughty.config.presets.critical,
- title = "Oops, an error happened!",
- text = tostring(err) })
- in_error = false
- end)
-end
-#+END_SRC
-
-* Variable definitions
-:PROPERTIES:
-:CUSTOM_ID: Variable_definitions-06b2bcbf
-:END:
-** Themes
-:PROPERTIES:
-:CUSTOM_ID: Variable_definitions-Themes-591886b4
-:END:
-With Awesome, it is possible to load or write custom themes in order to give
-Awesome a special look that fits the user. I am currently using a custom theme
-that is not yet included in my dotfiles. I will add it later, along with the
-images used for the theme.
-#+BEGIN_SRC lua
-beautiful.init("/home/phundrak/.config/awesome/nord/theme.lua")
-#+END_SRC
-
-** Default terminal and text editor
-:PROPERTIES:
-:CUSTOM_ID: Variable_definitions-Default_terminal_and_text_editor-44b84e20
-:END:
-The two following variables are set so that I don’t need to go over my whole
-config file in order to modify which terminal or text editor I use, not that I
-do it often though.
-#+BEGIN_SRC lua
-terminal = "kitty"
-editor = os.getenv("EDITOR") or "emacsclient -c -a emacs"
-#+END_SRC
-
-** Keys
-:PROPERTIES:
-:CUSTOM_ID: Variable_definitions-Keys-b8def4ac
-:END:
-The following declares the default Modkey. Usually, ~Mod4~ is the Super key,
-situated between the Ctrl key and the Alt key with a logo (usually Windows’).
-Another usual value for this is ~Mod1~, which is the Alt key, but it has greater
-chances of interfering with other software. I also defined some other obvious
-variables in order to make my code cleaner later on.
-#+BEGIN_SRC lua
-modkey = "Mod4"
-shift = "Shift"
-control = "Control"
-meta = "Mod1"
-alt = "Mod1" -- Just in case
-#+END_SRC
-
-* Custom functions
-:PROPERTIES:
-:CUSTOM_ID: Custom_functions-ed54dbe2
-:END:
-** Wallpaper-related functions
-:PROPERTIES:
-:CUSTOM_ID: Custom_functions-Wallpaper-related_functions-5912f7dd
-:END:
-*** Set a random wallpaper
-:PROPERTIES:
-:CUSTOM_ID: Custom_functions-Wallpaper-related_functions-Set_a_random_wallpaper-104bbeec
-:END:
-This function sets a random wallpaper from the directory
-=~/Pictures/Wallpapers=, see [[file:bin.org::#pape-update-bdecbadf][pape-update]] in my custom scripts.
-#+BEGIN_SRC lua
-local function set_random_pape()
- awful.spawn.with_shell("pape-update")
- naughty.notify({ preset = naughty.config.presets.normal,
- title = "Wallpaper change",
- text = "Done!"})
-end
-#+END_SRC
-
-*** Restore previous wallpaper
-:PROPERTIES:
-:CUSTOM_ID: Custom_functions-Wallpaper-related_functions-Restore_previous_wallpaper-8b5bc08c
-:END:
-I also wrote the following function that will restore the previously set
-wallpaper:
-#+BEGIN_SRC lua
-local function set_wallpaper(_)
- awful.spawn.with_shell("nitrogen --restore")
-end
-#+END_SRC
-
-** Layout manipulation
-:PROPERTIES:
-:CUSTOM_ID: Custom_functions-Layout_manipulation-6bc7db06
-:END:
-The following function is used by a shortcut described below in
-[[#Keybindings-Clients-f9f96d60]].
-#+BEGIN_SRC lua
-local function client_go_back()
- awful.client.focus.history.previous()
- if client.focus then
- client.focus:raise()
- end
-end
-#+END_SRC
-
-** Clients manipulation
-:PROPERTIES:
-:CUSTOM_ID: Custom_functions-Clients_manipulation-7e958fed
-:END:
-#+BEGIN_SRC lua
-local function restore_minimized_clients()
- local c = awful.client.restore()
- -- Focus restored client
- if c then
- c:emit_signal(
- "request::activate", "key.unminimize", {raise = true}
- )
- end
-end
-#+END_SRC
-
-#+BEGIN_SRC lua
-local function toggle_fullscreen_client(c)
- c.fullscreen = not c.fullscreen
- c:raise()
-end
-#+END_SRC
-
-#+BEGIN_SRC lua
-local function toggle_maximized(c)
- c.maximized = not c.maximized
- c:raise()
-end
-#+END_SRC
-
-#+BEGIN_SRC lua
-local function toggle_vertical_maximized(c)
- c.maximized_vertical = not c.maximized_vertical
- c:raise()
-end
-#+END_SRC
-
-#+BEGIN_SRC lua
-local function toggle_horizontal_maximized(c)
- c.maximized_horizontal = not c.maximized_horizontal
- c:raise()
-end
-#+END_SRC
-
-** Tag manipulation
-:PROPERTIES:
-:CUSTOM_ID: Custom_functions-Tag_manipulation-5fc67669
-:END:
-#+BEGIN_SRC lua
-local function view_tag_n(i)
- local screen = awful.screen.focused()
- local tag = screen.tags[i]
- if tag then
- tag:view_only()
- end
-end
-#+END_SRC
-
-#+BEGIN_SRC lua
-local function toggle_tag_n(i)
- local screen = awful.screen.focused()
- local tag = screen.tags[i]
- if tag then
- awful.tag.viewtoggle(tag)
- end
-end
-#+END_SRC
-
-#+BEGIN_SRC lua
-local function move_focused_to_tag_n(i)
- if client.focus then
- local tag = client.focus.screen.tags[i]
- if tag then
- client.focus:move_to_tag(tag)
- end
- end
-end
-#+END_SRC
-
-#+BEGIN_SRC lua
-local function toggle_focused_client_to_tag_n(i)
- if client.focus then
- local tag = client.focus.screen.tags[i]
- if tag then
- client.focus:toggle_tag(tag)
- end
- end
-end
-#+END_SRC
-
-** Awesome prompt
-:PROPERTIES:
-:CUSTOM_ID: Custom_functions-Awesome_prompt-de4fde50
-:END:
-#+BEGIN_SRC lua
-local function invoke_lua_execute_prompt()
- awful.prompt.run {
- prompt = "Run Lua code: ",
- textbox = awful.screen.focused().promptbox.widget,
- exe_callback = awful.util.eval,
- history_path = awful.util.get_cache_dir() .. "/history_eval"
- }
-end
-#+END_SRC
-
-* Layouts
-:PROPERTIES:
-:CUSTOM_ID: Layouts-be55a7fd
-:END:
-The following is a list of available windows layouts. I only enable some of
-them, and their order in the table is their order in Awesome.
-#+NAME: table-layouts
-| Layout | Enabled? |
-|-----------------+----------|
-| magnifier | yes |
-| tile.left | yes |
-| tile | yes |
-| tile.bottom | yes |
-| tile.top | yes |
-| max | yes |
-| max.fullscreen | yes |
-| floating | yes |
-| fair | yes |
-| fair.horizontal | yes |
-| spiral | yes |
-| spiral.dwindle | yes |
-| corner.nw | no |
-| corner.ne | no |
-| corner.sw | no |
-| corner.se | no |
-
-#+NAME: list-layouts
-#+BEGIN_SRC emacs-lisp :var layouts=table-layouts :cache yes
-(mapconcat (lambda (layout)
- (let ((enabled-p (string= (cadr layout) "yes"))
- (layout (car layout)))
- (when enabled-p
- (format "awful.layout.suit.%s,\n" layout))))
- layouts
- "")
-#+END_SRC
-
-#+RESULTS[bf3bbbd40ecc04ec19d9660abff2080b4f68196a]: list-layouts
-#+begin_example
-awful.layout.suit.magnifier,
-awful.layout.suit.tile.left,
-awful.layout.suit.tile,
-awful.layout.suit.tile.bottom,
-awful.layout.suit.tile.top,
-awful.layout.suit.max,
-awful.layout.suit.max.fullscreen,
-awful.layout.suit.floating,
-awful.layout.suit.fair,
-awful.layout.suit.fair.horizontal,
-awful.layout.suit.spiral,
-awful.layout.suit.spiral.dwindle,
-#+end_example
-
-Here is the code that activates these layouts:
-#+BEGIN_SRC lua
-awful.layout.layouts = {
- <>
-}
-#+END_SRC
-
-* Top bar
-:PROPERTIES:
-:CUSTOM_ID: Top_bar-d3117294
-:END:
-The top bar in Awesome is declared thanks to a ~wibar~ widget fro the ~awful~
-library. It is comprised of several buttons and widgets that will be declared
-below.
-
-** Menus
-:PROPERTIES:
-:CUSTOM_ID: Top_bar-Menus-cf468ca8
-:END:
-#+NAME: make-menu
-#+BEGIN_SRC emacs-lisp :var menu=table-main-menu
-(mapconcat (lambda (item)
- (format "{ \"%s\", %s }"
- (car item)
- (mapconcat #'identity (cdr item) ", ")))
- menu
- ",\n")
-#+END_SRC
-
-#+RESULTS: make-menu
-: { "awesome", awesomewm_menu, beautiful.awesome_icon },
-: { "open terminal", terminal, nil }
-
-It is possible to create actual menus in Awesome, including the one available at
-the top-left corner of the screen. First, let’s declare a menu related to
-Awesome:
-#+NAME: table-awesome-menu
-| Name | Command |
-|-------------+---------------------------------------------------------------------|
-| hotkeys | function() hotkeys_popup.show_help(nil, awful.screen.focused()) end |
-| edit config | editor .. " " .. awesome.conffile |
-| restart | awesome.restart |
-| quit | function() awesome.quit() end |
-
-And here is the actual code:
-#+BEGIN_SRC lua
-awesomewm_menu = {
- <>
-}
-#+END_SRC
-
-Next, let’s create the main menu that will be used on ~S-w~ and at the top left
-of the window:
-#+NAME: table-main-menu
-| Name | Command | Icon |
-|---------------+----------------+------------------------|
-| awesome | awesomewm_menu | beautiful.awesome_icon |
-| open terminal | terminal | nil |
-
-Here is the actual code:
-#+BEGIN_SRC lua
-mainmenu = awful.menu({ items = {
- <>
- }})
-#+END_SRC
-
-For now it only has two entries: the Awesome menu and opening a terminal, I will
-add some more later probably. Let’s specify it as being our main launcher:
-#+BEGIN_SRC lua
-launcher = awful.widget.launcher({ image = beautiful.awesome_icon,
- menu = mainmenu })
-#+END_SRC
-
-Finally, let’s declare the menubar’s terminal for applications that require it.
-#+BEGIN_SRC lua
-menubar.utils.terminal = terminal
-#+END_SRC
-
-** Widgets
-:PROPERTIES:
-:CUSTOM_ID: Top_bar-Widgets-0b255378
-:END:
-Let’s declare the keyboard map indicator and switcher for the top bar:
-#+BEGIN_SRC lua
-keyboardlayout = awful.widget.keyboardlayout()
-#+END_SRC
-
-Let’s also create a clock widget:
-#+BEGIN_SRC lua
-textclock = wibox.widget.textclock()
-#+END_SRC
-
-** Tag list
-:PROPERTIES:
-:CUSTOM_ID: Top_bar-Tag_list-d43dbb62
-:END:
-In order to create the taglist (an equivalent to workspaces, but better), we
-need to create first a local variable that will hold the widget. It will be
-declared as you can see below:
-#+BEGIN_SRC lua :tangle no
-local tasklist_buttons = gears.table.join(
- -- configuration goes here
-)
-#+END_SRC
-
-~gears.table.join()~ joins several tables together, as described [[https://awesomewm.org/doc/api/libraries/gears.table.html][here]], which
-will be useful since all its arguments will be tables generated by the
-~awful.button~ method which will be useful in order to manage what clicks on the
-tags should do. First, let’s manage left clicks.
-
-Left clicks in general are dedicated to tag visibility. A simple left click on a
-tag should switch this tag as the only visible tag, no matter how many of them
-were visible beforehand.
-#+NAME: tag-simple-left-click
-#+BEGIN_SRC lua :tangle no
-awful.button({ }, 1, function(t) t:view_only() end)
-#+END_SRC
-
-However, left clicks combined with the modkey will add the clicked tag to the
-list of visible tags, which allows the user to see windows from several tags at
-once.
-#+NAME: tag-mod-left-click
-#+BEGIN_SRC lua :tangle no
-awful.button({ modkey }, 1, awful.tag.viewtoggle)
-#+END_SRC
-
-Right clicks are dedicated to window tagging. A simple right click will untag
-the currently focused window and tag it again with the clicked tag, moving it
-effectively from one tag to another.
-#+NAME: tag-simple-right-click
-#+BEGIN_SRC lua :tangle no
-awful.button({ }, 3, function(t)
- if client.focus then
- client.focus:move_to_tag(t)
- end
-end)
-#+END_SRC
-
-However, a right click combined with the modkey will add the clicked tag to the
-currently focused window, making it visible to both tags.
-#+NAME: tag-mod-right-click
-#+BEGIN_SRC lua :tangle no
-awful.button({ modkey }, 3, function(t)
- if client.focus then
- client.focus:toggle_tag(t)
- end
-end)
-#+END_SRC
-
-The scroll wheel is treated as clicks just as any right or left clicks and can
-be interpreted by Awesome. They can prove useful when it comes to tags. If a
-scroll up is detected over tags, then Awesome will display the previous tag.
-#+NAME: tag-simple-scroll-up
-#+BEGIN_SRC lua :tangle no
-awful.button({ }, 4, function(t) awful.tag.viewprev(t.screen) end)
-#+END_SRC
-
-Otherwise, if a scroll down is detected, the next tag will be displayed.
-#+NAME: tag-simple-scroll-down
-#+BEGIN_SRC lua :tangle no
-awful.button({ }, 5, function(t) awful.tag.viewnext(t.screen) end)
-#+END_SRC
-
-So, here’s the actual configuration code for the taglist:
-#+BEGIN_SRC lua
-local taglist_buttons = gears.table.join(
- <>,
- <>,
- <>,
- <>,
- <>,
- <>
-)
-#+END_SRC
-
-** Tasks list
-:PROPERTIES:
-:CUSTOM_ID: Top_bar-Tasks_list-fb7c9b20
-:END:
-Similarly to the tag list, the task list can display some special behavior
-depending on the clicks it receives. These clicks are set like so:
-#+BEGIN_SRC lua :tangle no
-local tasklist_buttons = gears.table.join(
- -- List of clicks
-)
-#+END_SRC
-
-A left click on a task in the taskbar will simply focus and raise the window
-linked to it if it is not focused. Otherwise, if the window is focused, the
-window will be minimized.
-#+NAME: task-simple-left-click
-#+BEGIN_SRC lua :tangle no
-awful.button({ }, 1, function (c)
- if c == client.focus then
- c.minimized = true
- else
- c:emit_signal(
- "request::activate",
- "tasklist",
- {raise = true}
- )
- end
-end)
-#+END_SRC
-
-If the right click is detected, then a list of all the opened clients is invoked
-so we can switch to another (and if needed switch visible tag). The width of
-this list will be 250px.
-#+NAME: task-simple-right-click
-#+BEGIN_SRC lua :tangle no
-awful.button({ }, 3, function()
- awful.menu.client_list({ theme = { width = 250 } })
-end)
-#+END_SRC
-
-If a scroll up is detected, then let’s select the previous client in the
-tasklist.
-#+NAME: task-simple-scroll-up
-#+BEGIN_SRC lua :tangle no
-awful.button({ }, 4, function ()
- awful.client.focus.byidx(1)
-end)
-#+END_SRC
-
-If a scroll down is detected, then let’s select the next client in the tasklist.
-#+NAME: task-simple-scroll-down
-#+BEGIN_SRC lua :tangle no
-awful.button({ }, 5, function ()
- awful.client.focus.byidx(-1)
-end)
-#+END_SRC
-
-So, here’s the actual code for the tasklist:
-#+BEGIN_SRC lua
-local tasklist_buttons = gears.table.join(
- <>,
- <>,
- <>,
- <>
-)
-#+END_SRC
-
-* Theme and display
-:PROPERTIES:
-:CUSTOM_ID: Theme_and_display-6f94bad4
-:END:
-** Screen update
-:PROPERTIES:
-:CUSTOM_ID: Theme_and_display-Screen_update-e162a27a
-:END:
-When a screen’s geometry changes (e.g. when a different resolution is applied),
-the signal ~property::geometry~ is sent. When this is the case, the wallpaper
-should be redisplayed since it won’t necessarily fit the new geometry of the
-screen. And remember, I have a [[#Custom_functions-Wallpaper-related_functions-Restore_previous_wallpaper-8b5bc08c][function that does exactly that]]! Let’s connect
-this function to the geometry change signal:
-#+BEGIN_SRC lua
-screen.connect_signal("property::geometry", set_wallpaper)
-#+END_SRC
-
-If a new screen gets connected, it will need to get a new wallpaper. A lot needs
-to be done, and all the following lines of code will be inside a block like
-this:
-#+BEGIN_SRC lua :tangle no
-awful.screen.connect_for_each_screen(function(s)
- -- Code to be executed goes here
-end)
-#+END_SRC
-
-So, due the code block above, if you see any reference to ~s~ in the code blocks
-below, it will refer to the screen being set up by the function.
-
-First, let’s set its wallpaper:
-#+NAME: screen-set-pape
-#+BEGIN_SRC lua :tangle no
-set_wallpaper()
-#+END_SRC
-
-Next, let’s build a list of tags for the screen. *Be aware that each screen has
-its own tag table!* The default layout will be the first refered to in the
-layouts list described above.
-#+NAME: screen-taglist
-#+BEGIN_SRC lua :tangle no
-awful.tag({ "1", "2", "3", "4", "5", "6", "7", "8", "9", "0" }, s, awful.layout.layouts[1])
-#+END_SRC
-
-Next, let’s create the taglist widget. It will use the ~taglist_buttons~
-[[#Top_bar-Tag_list-d43dbb62][declared above]] in order to handle clicks on tags, and due to the filter, all
-tags will be displayed in the tagbar ([[https://awesomewm.org/apidoc/widgets/awful.widget.taglist.html#List_filters][more about tag filters]]).
-#+NAME: screen-taglist-widget
-#+BEGIN_SRC lua :tangle no
-s.taglist = awful.widget.taglist {
- screen = s,
- filter = awful.widget.taglist.filter.all,
- buttons = taglist_buttons
-}
-#+END_SRC
-
-A tasklist widget will also get created thanks with the ~tasklist_button~
-[[#Top_bar-Tag_list-d43dbb62][declared above]] that will handle clicks on tasks. Contrarily to the taglist
-widget above, the tasklist will only display the screen’s current tags thanks to
-its filter.
-#+NAME: screen-tasklist-widget
-#+BEGIN_SRC lua :tangle no
-s.tasklist = awful.widget.tasklist {
- screen = s,
- filter = awful.widget.tasklist.filter.currenttags,
- buttons = tasklist_buttons
-}
-#+END_SRC
-
-A promptbox will also be created for the screen:
-#+NAME: screen-promptbox
-#+BEGIN_SRC lua :tangle no
-s.promptbox = awful.widget.prompt()
-#+END_SRC
-
-Then, Let’s create an imagebox widget in which will be contained an icon
-indicating which layout is being used. We need one per screen. We will also make
-it clickable: if there is a left click or a scroll up detected above it, the
-next layout will be loaded; otherwise if a right click or a scroll down is
-detected, the previous layout will be loaded.
-#+NAME: screen-layout-indicator
-#+BEGIN_SRC lua :tangle no
-s.layoutbox = awful.widget.layoutbox(s)
-s.layoutbox:buttons(gears.table.join(
- awful.button({ }, 1, function () awful.layout.inc( 1) end),
- awful.button({ }, 3, function () awful.layout.inc(-1) end),
- awful.button({ }, 4, function () awful.layout.inc( 1) end),
- awful.button({ }, 5, function () awful.layout.inc(-1) end)))
-#+END_SRC
-
-Now it is time to create the widget, a ~wibox~ that will contain our bar.
-#+NAME: screen-wibox-widget
-#+BEGIN_SRC lua :tangle no
-s.wibox = awful.wibar({ position = "top", screen = s })
-#+END_SRC
-
-Finally, let’s set up our bar. Since it is a horizontal bar, its layout will be
-horizontal too. Our launcher, taglist and promptbox will be part of the left
-widgets, while the tasklist will be at the center, and the keyboard indicator,
-the system tray, the clock and the layout indicator will be on the right.
-#+NAME: screen-wibox-setup
-#+BEGIN_SRC lua :tangle no
-s.wibox:setup {
- layout = wibox.layout.align.horizontal,
- { -- Left widgets
- layout = wibox.layout.fixed.horizontal,
- launcher,
- s.taglist,
- s.promptbox,
- },
- s.tasklist, -- Middle widget
- { -- Right widgets
- layout = wibox.layout.fixed.horizontal,
- keyboardlayout,
- wibox.widget.systray(),
- textclock,
- s.layoutbox,
- },
-}
-#+END_SRC
-
-In the end, our code looks like this:
-#+BEGIN_SRC lua
-awful.screen.connect_for_each_screen(function(s)
- <>
- <>
- <>
- <>
- <>
- <>
- <>
- <>
-end)
-#+END_SRC
-
-* Mouse bindings
-:PROPERTIES:
-:CUSTOM_ID: Mouse_bindings-eb4a69a8
-:END:
-It is possible with Awesome to bind some shortcuts to mouse events when the
-mouse is above Awesome itself (not above some client). Only one is set: the
-right click opens the Awesome menu.
-#+BEGIN_SRC lua
-root.buttons(gears.table.join(
- awful.button({}, 3, function() mainmenu:toggle() end)
-))
-#+END_SRC
-
-I will also set three mouse bindings for when the mouse is above a client:
-- A simple click on a client will focus and raise it.
-- A click on a client combined with a modkey press will allow the user to move a
- client after focusing it and making it floating.
-- A middle click on a client combined with a modkey press will toggle the
- floating status of the client.
-- A right click combined with the modkey will allow the user to resize a after
- focusing it and making it a floating client.
-
-#+BEGIN_SRC lua
-clientbuttons = gears.table.join(
- awful.button({ }, 1, function (c)
- c:emit_signal("request::activate", "mouse_click", {raise = true})
- end),
- awful.button({ modkey }, 1, function (c)
- c:emit_signal("request::activate", "mouse_click", {raise = true})
- c.floating = true
- awful.mouse.client.move(c)
- end),
- awful.button({ modkey }, 2, function (c)
- awful.client.floating.toggle(c)
- end),
- awful.button({ modkey }, 3, function (c)
- c:emit_signal("request::activate", "mouse_click", {raise = true})
- c.floating = true
- awful.mouse.client.resize(c)
- end)
-)
-#+END_SRC
-
-* Keybindings
-:PROPERTIES:
-:CUSTOM_ID: Keybindings-a4e415b3
-:END:
-Keybindings allow the user to execute some Lua code all across Awesome. They all
-bear at least a list of modifier keys, the actual key to be pressed, the action
-they keybinding should yield, a description, and a group. The latter two will be
-useful for the keybindings help window which will display them all, sorted by
-group and with the description displayed next to the keybinding itself.
-
-Here are some keybindings related to Awesome itself. Most of them will be
-described in tables, but due to some limitations from Org-mode (the Emacs mode
-used to write this document and generate my Awesome configuration), a few of
-them will be directly written as Lua code.
-
-Here is a description of the tables displayed below:
-- Key :: key which toggles the shortcut
-- Modifiers :: modifier keys that are required to toggle the shortcut
-- Lambda? :: whether or not the ~Action~ should be nested in a lambda function.
- Possible values are:
- - ~no~ :: The value is a Lua function to be executed as is
- - ~yes~ :: The value is to be inserted into a lambda
- - ~spawn~ :: The value is to be inserted in an ~awful.spawn~ call in a lambda
- - ~shell~ :: The value is to be inserted in an ~awful.spawn.with_shell~ call
- in a lambda
-- Action :: code to be executed by the shortcut
-- What it does :: short description of the shortcut’s action
-- Group :: group in which the shortcut will appear in Awesome’s help window
-- Clientkey? :: whether this should be a global shortcut or a shortcut only
- aimed at clients (value is ~yes~ or ~no~)
-
-#+NAME: gen-sc-text
-#+BEGIN_SRC emacs-lisp
-(lambda (x)
- (let ((key (nth 0 x))
- (modifiers (nth 1 x))
- (lambda-p (pcase (nth 2 x)
- ("yes" 'lambda)
- ("shell" 'shell)
- ("terminal" 'terminal)
- ("spawn" 'spawn)
- (otherwise nil)))
- (action (nth 3 x))
- (description (nth 4 x))
- (group (nth 5 x))
- (clientkey (if (string= (nth 6 x) "yes") "c" "")))
- (format "awful.key({%s},\"%s\",%s,\n\t{description=\"%s\",group=\"%s\"})"
- modifiers
- key
- (if (not lambda-p)
- action
- (format "function(%s) %s end" clientkey
- (pcase lambda-p
- ('lambda action)
- ('shell
- (format "awful.spawn.with_shell(\"%s\")" action))
- ('terminal
- (format "awful.spawn(terminal..\" -e %s\")" action))
- ('spawn
- (format "awful.spawn(\"%s\")" action)))))
- description
- group)))
-#+END_SRC
-
-#+NAME: gen-sc-glob
-#+BEGIN_SRC emacs-lisp :var table=sc-client
-(mapconcat
- <>
- (seq-filter (lambda (x)
- (let ((clientkey-p (nth 6 x)))
- (or (not clientkey-p)
- (string= "no" clientkey-p))))
- table)
- ",\n")
-#+END_SRC
-
-#+NAME: gen-sc-client
-#+BEGIN_SRC emacs-lisp :var table=sc-client :cache yes
-(mapconcat
- <>
- (seq-filter (lambda (keybind)
- (string= "yes" (nth 6 keybind)))
- table)
- ",\n")
-#+END_SRC
-
-#+NAME: sc-tag-num-gen
-#+BEGIN_SRC emacs-lisp :var input=sc-tag-num :results drawer :wrap src lua
-(let (result)
- (dotimes (i 10 result)
- (let* ((j (+ 1 i)))
- (setq result
- (cons
- (mapconcat
- (lambda (line)
- (format
- "awful.key({%s},\"#%d\",function() %s%d) end,
-\t{description=\"%s%d\",group=\"%s\"})"
- (nth 1 line) (+ j 9) (nth 2 line) j
- (nth 3 line) j (nth 4 line)))
- input
- ",\n") result))))
- (mapconcat (lambda (x) x)
- result
- ",\n\n"))
-#+END_SRC
-
-Most of these keybindings are available at root-level of Awesome and will be
-declared in the ~globalkeys~ variable, which will be added then to ~root.keys~
-(see [[https://awesomewm.org/doc/api/libraries/root.html#keys]]).
-#+BEGIN_SRC lua :cache yes
-globalkeys = gears.table.join(
- -- Awesome
- <>,
- -- App
- <>,
- <>,
- <>,
- <>,
- <>,
- -- Client
- <>,
- -- Layout
- <>,
- -- Media
- <>,
- -- Screen
- <>,
- -- Tags
- <>,
- -- Misc
- <>,
- <>
-)
-root.keys(globalkeys)
-
-clientkeys = gears.table.join(
- -- Client
- <>
-)
-#+END_SRC
-
-** Applications
-:PROPERTIES:
-:CUSTOM_ID: Keybindings-Applications-8321c6c9
-:END:
-#+NAME: sc-app
-| Key | Modifiers | Lambda? | Action | What it does | Group |
-|--------+-----------+---------+-----------------------+-------------------+-------|
-| Return | modkey | yes | awful.spawn(terminal) | open a terminal | app |
-| n | modkey | spawn | nemo | open file manager | app |
-| g | modkey | spawn | gimp | open GIMP | app |
-
-*** Internet apps
-:PROPERTIES:
-:CUSTOM_ID: Keybindings-Applications-Internet_apps-87e80705
-:END:
-#+NAME: sc-app-internet
-| Key | Modifiers | Lambda? | Action | What it does | Group |
-|-----+----------------+---------+-----------------------------------+--------------------+----------|
-| b | modkey | yes | awful.spawn(os.getenv("BROWSER")) | invoke web browser | internet |
-| d | control, shift | spawn | lightcord | launch Discord | internet |
-
-*** Screenshots
-:PROPERTIES:
-:CUSTOM_ID: Keybindings-Applications-Screenshots-fa63a5a5
-:END:
-#+NAME: sc-app-screenshot
-| Key | Modifiers | Lambda? | Action | What it does | Group |
-|-------+-----------+---------+----------------------------------------------+-----------------------------+------------|
-| Print | | spawn | scrot -e 'mv $f ~/Pictures/Screenshots' | Screenshot | screenshot |
-| Print | control | spawn | scrot -s -e 'mv $f ~/Pictures/Screenshots' | Screenshot (area selection) | screenshot |
-| Print | shift | spawn | scrot -d 3 -e 'mv $f ~/Pictures/Screenshots' | Screenshot (3s delay) | screenshot |
-
-*** Emacs
-:PROPERTIES:
-:CUSTOM_ID: Keybindings-Applications-Emacs-95f8f6a4
-:END:
-#+NAME: sc-app-emacs
-| Key | Modifiers | Lambda? | Action | What it does | Group |
-|-----+---------------+---------+-------------------+----------------------+-------|
-| e | modkey | spawn | emacsclient -c -n | invoke Spacemacs | emacs |
-| e | modkey, shift | spawn | emacs | invoke Vanilla Emacs | emacs |
-
-*** Rofi
-:PROPERTIES:
-:CUSTOM_ID: Keybindings-Applications-Rofi-ca998c87
-:END:
-#+NAME: sc-app-rofi
-| Key | Modifiers | Lambda? | Action | What it does | Group |
-|-----+------------------------+---------+------------------------------------------+---------------------------------+-------|
-| a | modkey | shell | awiki | find and open an ArchWiki page | rofi |
-| d | modkey | spawn | rofi -combi-modi drun,window -show combi | rofi for drun and windows | rofi |
-| d | modkey, meta | spawn | rofi -show ssh | rofi for SSH | rofi |
-| p | modkey, shift | shell | rofi-pass -t | types password from ~pass~ | rofi |
-| p | modkey, control, shift | shell | rofi-pass | copy password from ~pass~ | rofi |
-| e | modkey, meta | shell | rofi-emoji | select and copy emoji from list | rofi |
-| m | modkey, meta | shell | rofi-mount | volume mounting helper | rofi |
-| u | modkey, meta | shell | rofi-umount | volume unmounting helper | rofi |
-| w | modkey, control | shell | wacom-setup | set up my wacom tablet | rofi |
-| y | modkey | shell | ytplay | play web video in mpv | rofi |
-| y | modkey, shift | shell | rofi-ytdl | download video from web | rofi |
-
-** Awesome
-:PROPERTIES:
-:CUSTOM_ID: Keybindings-Awesome-7b691e10
-:END:
-Here will be declared some shortcuts directly related to Awesome itself.
-#+NAME: sc-awesome
-| Key | Modifiers | Lambda? | Action | What it does | Group |
-|-----+------------------------+---------+---------------------------+-------------------------+---------|
-| h | modkey | no | hotkeys_popup.show_help | show help | awesome |
-| h | modkey, shift | yes | mainmenu:show() | show main menu | awesome |
-| l | modkey | spawn | plock | lock screen | awesome |
-| q | modkey, shift | no | awesome.quit | quit awesome | awesome |
-| r | modkey, shift, control | no | awesome.restart | reload awesome | awesome |
-| w | modkey | no | set_random_pape | set random wallpaper | awesome |
-| w | modkey, shift | spawn | select-pape | set wallpaper | awesome |
-| x | modkey | no | invoke_lua_execute_prompt | lua execute prompt | awesome |
-| F4 | modkey, control | spawn | systemctl hibernate | hibernate computer | awesome |
-| F4 | modkey, shift | spawn | systemctl suspend | suspend to RAM computer | awesome |
-| F4 | modkey, shift, control | spawn | poweroff | power off computer | awesome |
-
-** Clients
-:PROPERTIES:
-:CUSTOM_ID: Keybindings-Clients-f9f96d60
-:END:
-These shortcuts are related to clients (aka windows) management.
-#+NAME: sc-client
-| Key | Modifiers | Lambda? | Action | What it does | Group | Clientkey? |
-|-----+------------------------+---------+----------------------------------+-------------------------------+--------+------------|
-| c | modkey, meta | yes | awful.placement.centered(c) | center client | client | yes |
-| f | modkey | yes | toggle_fullscreen_client(c) | toggle fullscreen | client | yes |
-| m | modkey | yes | toggle_maximized(c) | toggle maximized | client | yes |
-| m | modkey, shift | yes | toggle_horizontal_maximized(c) | toggle horizontally maximized | client | yes |
-| m | modkey, control | yes | toggle_vertical_maximized(c) | toggle vertically maximized | client | yes |
-| n | modkey, shift | yes | c.minimized = true | minimize | client | yes |
-| n | modkey, control | no | restore_minimized_clients | restore minimized | client | no |
-| o | modkey, shift | yes | c:move_to_screen() | move to screen | client | yes |
-| q | modkey | yes | c:kill() | close client | client | yes |
-| s | modkey | yes | awful.client.focus.byidx(-1) | focus previous client | client | no |
-| t | modkey | yes | awful.client.focus.byidx(1) | focus next client | client | no |
-| s | modkey, shift | yes | awful.client.swap.byidx(-1) | swap with previous client | client | no |
-| t | modkey, shift | yes | awful.client.swap.byidx(1) | swap with next client | client | no |
-| m | modkey, shift, control | yes | c:swap(awful.client.getmaster()) | swap with master client | client | yes |
-| u | modkey | no | awful.client.urgent.jumpto | jump to urgent client | client | no |
-| v | modkey | yes | c.ontop = not c.ontop | toggle keep on top | client | yes |
-| f | modkey, control | no | awful.client.floating.toggle | toggle floating | client | yes |
-| Tab | modkey | no | client_go_back | go back | client | no |
-
-** Layout manipulation
-:PROPERTIES:
-:CUSTOM_ID: Keybindings-Layout_manipulation-648b4581
-:END:
-#+NAME: sc-layout
-| Key | Modifiers | Lambda? | Action | What it does | Group |
-|-------+-----------------+---------+-------------------------------------+-----------------------------------+--------|
-| r | modkey | yes | awful.tag.incmwfact(0.05) | increase master width factor | layout |
-| c | modkey | yes | awful.tag.incmwfact(-0.05) | decrease master width factor | layout |
-| r | modkey, shift | yes | awful.tag.incnmaster(1, nil, true) | increase number of master clients | layout |
-| c | modkey, shift | yes | awful.tag.incnmaster(-1, nil, true) | decrease number of master clients | layout |
-| r | modkey, control | yes | awful.tag.incncol(1, nil, true) | increase number of colums | layout |
-| c | modkey, control | yes | awful.tag.incncol(-1, nil, true) | decrease number of colums | layout |
-| space | modkey | yes | awful.layout.inc(1) | next layout | layout |
-| space | modkey, meta | yes | awful.layout.inc(-1) | previous layout | layout |
-
-** Media
-:PROPERTIES:
-:CUSTOM_ID: Keybindings-Media-f2cc1324
-:END:
-#+NAME: sc-media
-| Key | Modifiers | Lambda? | Action | What it does | Group |
-|----------------------+-----------------+----------+---------------------------------+--------------------------+-------|
-| + | modkey, meta | shell | mpc volume +2 | increase mpd volume | media |
-| - | modkey, meta | shell | mpc volume -2 | decrease mpd volume | media |
-| n | modkey, meta | terminal | ncmpcpp -q | spawn ncmpcpp | media |
-| v | modkey, meta | terminal | ncmpcpp -qs visualizer | spawn ncmpcpp visualizer | media |
-| XF86AudioLowerVolume | | shell | amixer -q set Master 2%- unmute | lower volume | media |
-| Prior | modkey, control | shell | amixer -q set Master 2%- unmute | lower volume | media |
-| XF86AudioRaiseVolume | | shell | amixer -q set Master 2%+ unmute | raise volume | media |
-| Next | modkey, control | shell | amixer -q set Master 2%+ unmute | lower volume | media |
-| XF86AudioMute | | shell | amixer -q set master 1+ toggle | toggle mute audio | media |
-| Prior | modkey, control | shell | amixer -q set master 1+ toggle | toggle mute audio | media |
-| XF86AudioPrev | | shell | mpc prev | previous mpd track | media |
-| XF86AudioLowerVolume | meta | shell | mpc prev | prevous mpd track | media |
-| Prior | modkey | shell | mpc prev | previous mpd track | media |
-| XF86AudioNext | | shell | mpc next | next mpd track | media |
-| XF86AudioRaiseVolume | meta | shell | mpc next | next mpd track | media |
-| Next | modkey | shell | mpc next | next mpd track | media |
-| XF86AudioPlay | | shell | mpc toggle | toggle mpd playback | media |
-| p | modkey | shell | mpc toggle | toggle mpd playback | media |
-| XF86AudioStop | | shell | mpc stop | stop playback | media |
-| XF86AudioPlay | meta | shell | mpc stop | stop playback | media |
-| p | modkey, meta | shell | mpc stop | stop playback | media |
-
-** Screen
-:PROPERTIES:
-:CUSTOM_ID: Keybindings-Screen-b73991f0
-:END:
-#+NAME: sc-screen
-| Key | Modifiers | Lambda? | Action | What it does | Group |
-|-----------------------+--------------+---------+---------------------------------+----------------------------+--------|
-| t | modkey, meta | yes | awful.screen.focus_relative(1) | focus next screen | screen |
-| s | modkey, meta | yes | awful.screen.focus_relative(-1) | focus previous screen | screen |
-| XF86MonBrightnessDown | | shell | xbacklight -dec 1 | decrease screen brightness | screen |
-| Next | modkey, meta | shell | xbacklight -dec 1 | decrease screen brightness | screen |
-| XF86MonBrightnessUp | | shell | xbacklight -inc 1 | increase screen brightness | screen |
-| Prev | modkey, meta | shell | xbacklight -inc 1 | increase screen brightness | screen |
-| F3 | modkey | spawn | arandr | randr graphical frontend | screen |
-| o | modkey | yes | awful.screen.focus_relative(1) | focus next screen | screen |
-
-** Tags
-:PROPERTIES:
-:CUSTOM_ID: Keybindings-Tags-3424b757
-:END:
-#+NAME: sc-tag
-| Key | Modifiers | Lambda? | Action | What it does | Group |
-|--------+-----------------+---------+---------------------------+--------------+-------|
-| Escape | modkey | no | awful.tag.history.restore | go back | tag |
-| t | modkey, control | no | awful.tag.viewprev | view prev | tag |
-| s | modkey, control | no | awful.tag.viewnext | view next | tag |
-
-Another set of shortcuts is linked to the number row on the keyboard that allow
-the manipulation of the default tags that range from ~1~ to ~10~ (the latter is
-displayed as ~0~). Here is what the possible actions are:
-#+NAME: sc-tag-num
-| Key | Modifiers | Action | What it does | Group |
-|--------+------------------------+---------------------------------+--------------------------------+-------|
-| Number | modkey | view_tag_n( | view tag # | tag |
-| Number | modkey, control | toggle_tag_n( | toggle tag # | tag |
-| Number | modkey, shift | move_focused_to_tag_n( | move focused client to tag # | tag |
-| Number | modkey, control, shift | toggle_focused_client_to_tag_n( | Toggle focused client on tag # | tag |
-
-** Misc
-:PROPERTIES:
-:CUSTOM_ID: Keybindings-Misc-0b45ce02
-:END:
-In this category you will find other keybindings that do not fit in other
-categories. For now, the only keybinding that is in this category is for
-toggling the touchpad’s tapping ability. This is linked to a special script I
-wrote [[file:bin.org::#Toggle_touchpad_tapping-23348b00][here]].
-#+NAME: sc-misc
-| Key | Modifiers | Lambda? | Action | What it does | Group |
-|--------------------+-----------+---------+-----------+-------------------------+-------|
-| XF86TouchpadToggle | | shell | tttapping | toggle touchpad tapping | misc |
-
-* Rules
-:PROPERTIES:
-:CUSTOM_ID: Rules-c6142cdf
-:END:
-With ~awful.rules~, users are able to describe some rules for window clients
-when the latter spawn, such as their placement, their properties or even execute
-a script. A rule can be applied through the ~manage~ signal, and they are all
-stored in ~awful.rules.rules~, the global rules table, as follows:
-#+BEGIN_SRC lua :tangle no
-awful.rules.rules = {
- -- Rules here
-}
-#+END_SRC
-
-# Block for exporting rules from below
-#+BEGIN_SRC lua :exports none
-awful.rules.rules = {
- <>,
- <>,
- <>,
- <>
-}
-#+END_SRC
-
-For more documentation on rules and their syntax, you can read the [[https://awesomewm.org/doc/api/libraries/awful.rules.html][official
-documentation]].
-
-** Universal rules
-:PROPERTIES:
-:CUSTOM_ID: Rules-Universal_rules-50aad2ce
-:END:
-The first rule is a universal rule which will match all clients, as you can see
-with its syntax below:
-#+BEGIN_SRC lua :tangle no
-{ rule = {},
- properties = {
- -- List of properties
- }
-}
-#+END_SRC
-
-Here is the list of properties with their value to apply to all clients, and a
-short explanation as to what they do.
-#+NAME: rules-universal-properties-table
-| Property | Value | What it does |
-|---------------+---------------------------------------------------------+-------------------------------------------------------------------------|
-| border_width | beautiful.border_width | Set the width of the window’s border |
-| border_color | beautiful.border_normal | Set the color of the window’s border |
-| focus | awful.client.focus.filter | Set focus on the new window, except filtered out windows |
-| raise | true | Set it as raised window |
-| keys | clientkeys | Set the client’s shortcuts set in [[*Clients][Shortcuts/Clients]] |
-| buttons | clientbuttons | Set the client’s mouse shortcuts from [[#Mouse_bindings-eb4a69a8][Mouse bindings]] |
-| screen | awful.screen.preferred | Spawn the client on the main screen |
-| placement | awful.placement.no_overlap+awful.placement.no_offscreen | Avoid the client to appear off the screen and overlaping another client |
-| round_corners | true | Enable rounded corners for client |
-
-#+NAME: rules-universal-properties
-#+BEGIN_SRC emacs-lisp :tangle no :exports none :var properties=rules-universal-properties-table :cache yes
-(mapconcat (lambda (x)
- (format "%s = %s"
- (car x)
- (cadr x)))
- properties
- ",\n")
-#+END_SRC
-
-#+RESULTS[5ddcb42f901ac56237de5ed102800b588f462100]: rules-universal-properties
-: border_width = beautiful.border_width,
-: border_color = beautiful.border_normal,
-: focus = awful.client.focus.filter,
-: raise = true,
-: keys = clientkeys,
-: buttons = clientbuttons,
-: screen = awful.screen.preferred,
-: placement = awful.placement.no_overlap+awful.placement.no_offscreen,
-: round_corners = true
-
-This is what my universal rules look like:
-#+NAME: rules-universal
-#+BEGIN_SRC lua :tangle no
- { rule = {},
- properties = {
- <>
- }
- }
-#+END_SRC
-
-** Floating clients
-:PROPERTIES:
-:CUSTOM_ID: Rules-Floating_clients-49ab582e
-:END:
-Some clients will be declared by default as floating windows. For this, we will
-declare a rule that will match any of the provided conditions:
-#+NAME: rules-floating-conditions-table
-| Property | Matches | Comment |
-|----------+--------------+----------------------------------------------------------------|
-| instance | pinentry | Matches any Polkit |
-| class | Arandr | Visual frontend for Randr |
-| class | Sxiv | Simple X Image Viewer |
-| class | Tor Browser | Needs a fixed window size to avoid fingerprinting |
-| name | Event Tester | xev |
-| role | pop-up | Any pop-up window, such as Chromium’s detached Developer Tools |
-
-#+NAME: rules-floating-conditions
-#+BEGIN_SRC emacs-lisp :exports none :tangle no :var conditions=rules-floating-conditions-table :cache yes
-(mapconcat (lambda (x)
- (format "%s = { \"%s\" }" (car x) (cadr x)))
- conditions
- ",\n")
-#+END_SRC
-
-#+RESULTS[1fbe7dc1e85b5170957c9583e39c4cbec9a7d7ca]: rules-floating-conditions
-: instance = { "pinentry" },
-: class = { "Arandr" },
-: class = { "Sxiv" },
-: class = { "Tor Browser" },
-: name = { "Event Tester" },
-: role = { "pop-up" }
-
-If any of these conditions is matched, then the client will be set as floating,
-as you can see below:
-#+NAME: rules-floating
-#+BEGIN_SRC lua :tangle no
-{ rule_any = {
- <>
-}, properties = { floating = true }}
-#+END_SRC
-
-** Titlebars
-:PROPERTIES:
-:CUSTOM_ID: Rules-Titlebars-b532fdba
-:END:
-Any normal or dialog client will get a titlebar. This is enabled like so:
-#+NAME: rules-titlebars
-#+BEGIN_SRC lua :tangle no
-{ rule_any = {type = { "normal", "dialog" }
- }, properties = { titlebars_enabled = true }
-}
-#+END_SRC
-
-** Default tag for clients
-:PROPERTIES:
-:CUSTOM_ID: Rules-Default_tag_for_clients-6ded2a47
-:END:
-With the use of some rules, it is possible to define which client are assigned
-to which tag by default.
-#+NAME: rules-default-tags-table
-| Client Property | Value | Tag |
-|-----------------+------------+-----|
-| class | Emacs | 2 |
-| class | firefox | 3 |
-| class | Nemo | 4 |
-| class | Gimp* | 5 |
-| class | Signal | 8 |
-| class | Steam | 9 |
-| class | Mattermost | 0 |
-| class | discord | 0 |
-| class | lightcord | 0 |
-
-#+NAME: rules-default-tags-generate
-#+BEGIN_SRC emacs-lisp :tangle no :exports none :cache yes :var tags=rules-default-tags-table
-(mapconcat (lambda (x)
- (format "{rule = {%s = \"%s\"}, properties = {screen = 1, tag = \"%d\"} }"
- (nth 0 x) (nth 1 x) (nth 2 x)))
- tags
- ",\n")
-#+END_SRC
-
-#+RESULTS[b1e188e8810460c2f84b6d9cb819430af300d9d0]: rules-default-tags-generate
-: {rule = {class = "Emacs"}, properties = {screen = 1, tag = "2"} },
-: {rule = {class = "firefox"}, properties = {screen = 1, tag = "3"} },
-: {rule = {class = "Nemo"}, properties = {screen = 1, tag = "4"} },
-: {rule = {class = "Gimp*"}, properties = {screen = 1, tag = "5"} },
-: {rule = {class = "Signal"}, properties = {screen = 1, tag = "8"} },
-: {rule = {class = "Steam"}, properties = {screen = 1, tag = "9"} },
-: {rule = {class = "Mattermost"}, properties = {screen = 1, tag = "0"} },
-: {rule = {class = "discord"}, properties = {screen = 1, tag = "0"} },
-: {rule = {class = "lightcord"}, properties = {screen = 1, tag = "0"} }
-
-This is what these rules look like:
-#+NAME: rules-default-tags
-#+BEGIN_SRC lua :tangle no
-<>
-#+END_SRC
-
-* Signals
-:PROPERTIES:
-:CUSTOM_ID: Signals-e32971d6
-:END:
-Signals are a way for Awesome to handle events, such as client creation or
-deletion.
-
-** Client creation
-:PROPERTIES:
-:CUSTOM_ID: Signals-Client_creation-8048ac12
-:END:
-When a new client is created, the ~manage~ signal is emited. When so, the
-following snippet ensures this new client is not off the screen, unless its
-position was deliberately set by a program or by the user. It will also spawn
-the new client where the mouse currently is.
-#+BEGIN_SRC lua
-client.connect_signal("manage", function (c)
- awful.client.movetoscreen(c, mouse.screen)
- if awesome.startup
- and not c.size_hints.user_position
- and not c.size_hints.program_position then
- awful.placement.no_offscreen(c)
- end
-end)
-#+END_SRC
-
-** Titlebar creation
-:PROPERTIES:
-:CUSTOM_ID: Signals-Titlebar_creation-3b1aaa14
-:END:
-It is possible for Awesome to send request signals, such as the request to
-create titlebar (generally for new clients). The following snippet handles this
-titlebar creation if titlebar creation was set to ~true~ in the [[#Rules-c6142cdf][rules]]. For a
-detailed explanation of the code, see below.
-#+BEGIN_SRC lua
-client.connect_signal("request::titlebars", function(c)
- local buttons = gears.table.join(
- <>,
- <>
- )
- <>
-end)
-#+END_SRC
-
-The function has two main parts: the creation of the titlebar buttons (mouse
-handling on the titlebar), and the creation of the titlebar itself. The creation
-of the button is done by creating a local variable ~buttons~ which will be a
-table created by the library ~gears~, in which will be buttons created by the
-user.
-#+BEGIN_SRC lua :tangle no
-local buttons = gears.table.join(
- -- Buttons declared here
-)
-#+END_SRC
-
-You can see a left click will enable the user to raise the window, but also it
-will enable the user to move the window (if it is floating of course).
-#+NAME: signal-titlebar-button1
-#+BEGIN_SRC lua :tangle no
-awful.button({ }, 1, function()
- c:emit_signal("request::activate", "titlebar", {raise = true})
- awful.mouse.client.move(c)
-end)
-#+END_SRC
-
-A right click on the titlebar will also raise the window, but will instead allow
-the user to resize the client.
-#+NAME: signal-titlebar-button3
-#+BEGIN_SRC lua :tangle no
-awful.button({ }, 3, function()
- c:emit_signal("request::activate", "titlebar", {raise = true})
- awful.mouse.client.resize(c)
-end)
-#+END_SRC
-
-Next comes the actual creation of the titlebar for the client ~c~. For that, we
-call ~awful.titlebar()~, tell it where the titlebar should be relative to the
-client and what its setup should be. The full call should look like so:
-#+NAME: signal-titlebar-create
-#+BEGIN_SRC lua :tangle no
-awful.titlebar(c, {position="left", size = 22}) : setup {
- <>
-}
-#+END_SRC
-
-In the setup, I need to repeat to Awesome the titlebar should be on the left of
-the client, and I also tell it the layout alignment of the titlebar will be
-vertical, because I like vertial titlebars. I also first send it three tables:
-- The top or left elements of the titlebar (here the top)
-- The middle elements of the titlebar
-- The bottom or right elements of the titlebar (here the bottom)
-You can notice in the setup’s code below that I haven’t included anything in the
-middle elements, the only elements I am interested in are the top and bottom
-elements. In the top elements, I have (top to bottom):
-- A close button
-- A maximize button
-- A minimize button
-- And an indication to Awesome these elements should be vertically aligned
-To make Awesome happy, I also must indicate that the middle elements are
-vertically aligned, and then I can declare my bottom elements:
-- A button for toggling client floating
-- And again the indication to Awesome these elements should be vertically
- aligned
-#+NAME: signal-titlebar-setup
-#+BEGIN_SRC lua :tangle no
-{ -- Top
- awful.titlebar.widget.closebutton(c),
- awful.titlebar.widget.minimizebutton(c),
- awful.titlebar.widget.maximizedbutton(c),
- layout = wibox.layout.fixed.vertical()
-},
-{
- layout = wibox.layout.fixed.vertical()
-}, -- Middle
-{ -- Bottom
- awful.titlebar.widget.floatingbutton(c),
- layout = wibox.layout.fixed.vertical()
-},
-layout = wibox.layout.align.vertical,
-position = "left"
-#+END_SRC
-
-** Changes of focus
-:PROPERTIES:
-:CUSTOM_ID: Signals-Changes_of_focus-1b73902c
-:END:
-The default Awesome configuration enables the following snippet of code that
-makes windows hovered by the user’s mouse focused. Just for completeness’ sake,
-I included it in this document, but be aware this won’t be tangled into my
-configuration file and focus will not follow my mouse.
-#+BEGIN_SRC lua :tangle no
-client.connect_signal("mouse::enter", function(c)
- c:emit_signal("request::activate", "mouse_enter", {raise = false})
-end)
-#+END_SRC
-
-It is also possible to change the color of the borders based on client focus.
-While my clients don’t have any border, they do have a titlebar which color
-changes based on the client’s focus. This is handled by the following code
-snippet:
-#+BEGIN_SRC lua
-client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end)
-client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
-#+end_SRC
-
-* Autostart
-:PROPERTIES:
-:CUSTOM_ID: Autostart-f2cf42fe
-:END:
-By simply adding a line requesting to spawn a command, it is possible to create
-some autolaunch. All of my autolaunched apps are launch through a custom script
-which you can [[file:~/org/config/bin.org::#Autostart-a99e99e7][find here]]. The command gets called with
-~awful.spawn.with_shell()~, as you can see below.
-#+BEGIN_SRC lua
-awful.spawn.with_shell("autostart")
-#+END_SRC
-
-* What to do now :noexport:
-:PROPERTIES:
-:CUSTOM_ID: What_to_do_now-bce61fe1
-:END:
-** DONE Error on S-q
- CLOSED: [2020-04-12 dim. 15:47]
-:PROPERTIES:
-:CUSTOM_ID: What_to_do_now-Error_on_S-q-beea9b99
-:END:
-~attempt to index a nil value (global 'c')~
-
-** TODO Make custom theme
-:PROPERTIES:
-:CUSTOM_ID: What_to_do_now-Make_custom_theme-5837307e
-:END:
diff --git a/org/config/Deprecated/i3.org b/org/config/Deprecated/i3.org
deleted file mode 100644
index 1c368f8..0000000
--- a/org/config/Deprecated/i3.org
+++ /dev/null
@@ -1,827 +0,0 @@
-#+TITLE: i3 config
-#+setupfile: ../headers
-#+OPTIONS: unique-id:t
-#+HTML_HEAD_EXTRA:
-#+HTML_HEAD_EXTRA:
-#+HTML_HEAD_EXTRA:
-#+PROPERTY: header-args :noweb yes :exports code :tangle ~/.config/i3/config
-#+PROPERTY: header-args:emacs-lisp :exports none :tangle no
-
-* Presentation
-:PROPERTIES:
-:CUSTOM_ID: Presentation-9c7a53bf
-:END:
-#+begin_center
-*Before proceeding, be aware that I deprecated this i3 config on August 22nd, 2020, meaning I won’t update it anymore unless I use it again some day in the future. I will keep it on my website though.*
-#+end_center
-
-=i3= is a window manager for GNU/Linux which automatically tiles windows in workspaces. This configuration was ade to automatically handle some tasks such as which software allowed where, autostart, and launching software with shortcuts.
-
-It is to be noted I am using [[https://github.com/Airblader/i3][Airblader’s fork of i3]], =i3-gaps=. Some configuration will not work with =i3=.
-
-#+BEGIN_SRC conf :exports none
- # -*- mode: conf -*-
-#+END_SRC
-
-* Screenshots
-:PROPERTIES:
-:CUSTOM_ID: Screenshots-51f1cef3
-:END:
-#+CAPTION: Desktop with Neofetch in the terminal
-[[./img/neofetch.png.webp]]
-
-#+CAPTION: Desktop with Emacs opened
-[[./img/emacs.png.webp]]
-
-#+CAPTION: Desktop with Rofi
-[[./img/rofi.png.webp]]
-
-* Variables declaration
-:PROPERTIES:
-:CUSTOM_ID: Variables_declaration-0ebc9a21
-:END:
-** Global
-:PROPERTIES:
-:CUSTOM_ID: Variables_declaration-Global-1cf1bfe4
-:END:
-The first I do is declaring the modifier key and the alt key —I don’t find the names =Mod1= and =Mod4= to be explicit enough. This will map =$mod= to the Super key (or as some people unfortunately call it, the /Windows/ key) and =$alt= to the Alt key.
-
-Let’s also bind the =$up=, =$down=, =$left= and =$right= variables to respectively the up, down, left, and right arrows on the keyboard. Why bind them to variables? If I ever want to modify the arrow keys to some other keys, like =é=, =a=, =u=, and =i= (the equivalent of =wqsd= on the bépo layout) or =c=, =t=, =s=, and =r= (the equivalent of =hjkl= on the bépo layout), I will just have to modify these four lines.
-
-I’ll also set the =$term= variable. A lot of shortcuts in my i3 config rely on the terminal emulator itself to launch commands in the terminal, and thus call the terminal itself. If I ever need to move from my current terminal, I will just have to change the name of the executable here.
-
-#+NAME: variable-table
-| variable | value |
-|----------+-------|
-| $mod | Mod4 |
-| $alt | Mod1 |
-| $up | Up |
-| $down | Down |
-| $left | Left |
-| $right | Right |
-| $term | st |
-
-#+NAME: variable-sh
-| variable | value |
-|-------------+--------------------------------------------------------------------------|
-| $exiti3 | i3-nagbar -t warning -m 'Leave i3?' -b 'Yes' 'i3-msg exit' |
-| $lockscreen | Lucien Cartier-Tilet\n(Phuntsok Drak-pa)\n+33 (0)6 83 90 56 89 |
-| $rofiexec | rofi -combi-modi 'window,drun' -show combi -mohh combi -m -1 -show-icons |
-| $mail | emacsclient -c -e '(mu4e)' -n |
-| $ec | emacsclient -c -n |
-| $walset | wal -i ~/Pictures/Wallpapers -o wal-set |
-
-Variables will be set like so.
-#+BEGIN_SRC conf :tangle no
-set $term st
-#+END_SRC
-
-#+NAME: generate-variables
-#+BEGIN_SRC emacs-lisp :var variables=variable-table :cache yes
- (mapconcat (lambda (x) (format "set %s %s" (car x) (cadr x)))
- variables
- "\n")
-#+END_SRC
-
-#+RESULTS[48079cbd7e6dbf2003fe5ae87216bd38f638b6f8]: generate-variables
-: set $mod Mod4
-: set $alt Mod1
-: set $up Up
-: set $down Down
-: set $left Left
-: set $right Right
-: set $term st
-
-Finally, some variables hold some long strings for commands I don’t want to have to type multiple times.
-#+NAME: generate-variables2
-#+BEGIN_SRC emacs-lisp :var variables=variable-sh :cache yes
- (mapconcat (lambda (x) (format "set %s \"%s\"" (car x) (cadr x)))
- variables
- "\n")
-#+END_SRC
-
-#+RESULTS[c901e3e31c500859661650e86a6b63aef286acbe]: generate-variables2
-: set $exiti3 "i3-nagbar -t warning -m 'Leave i3?' -b 'Yes' 'i3-msg exit'"
-: set $lockscreen "Lucien Cartier-Tilet\n(Phuntsok Drak-pa)\n+33 (0)6 83 90 56 89"
-: set $rofiexec "rofi -combi-modi 'window,drun' -show combi -mohh combi -m -1 -show-icons"
-: set $mail "emacsclient -c -e '(mu4e)' -n"
-: set $ec "emacsclient -c -n"
-: set $walset "wal -i ~/Pictures/Wallpapers -o wal-set"
-
-Here is the configuration:
-#+BEGIN_SRC conf :noweb yes
- <>
- <>
-#+END_SRC
-
-Now comes the font for the window tiles. Honestly, this setting is useless since we do not see it, but let’s set it anyway.
-#+BEGIN_SRC conf
- font Fira Sans Book:style=Book:pixelsize=10
-#+END_SRC
-
-** Floating windows
-:PROPERTIES:
-:CUSTOM_ID: Variables_declaration-Floating_windows-897d0c3b
-:END:
-Floating windows are windows that are not tiled with other windows, but rather are free to go anywhere on your screen, with any size. A bit like what you would get with any other non-tiling window manager or desktop environment (though most of them support minimal tiling features).
-
-Let’s declare our floading modyfier. With floating windows, you can move them around by clicking on the window’s borders; but since we don’t have any with this config, we will have instead to press the floating modifier while clicking on the window (anywhere on the window is fine) to move them around.
-
-Here is the configuration:
-#+BEGIN_SRC conf
-floating_modifier $mod
-#+END_SRC
-
-* i3 global settings
-:PROPERTIES:
-:CUSTOM_ID: i3_global_settings-1b863d93
-:END:
-Some settings affect i3 globally, such as its aspect or how it handles the mouse. Hence, here are some settings I set in my configuration.
-
-** Mouse settings
-:PROPERTIES:
-:CUSTOM_ID: i3_global_settings-Mouse_settings-4630241d
-:END:
-First of all, I do not want i3 to warp my mouse each time I change windows; my mouse stays where it is.
-#+BEGIN_SRC conf
-mouse_warping none
-#+END_SRC
-
-I also to not want the window focus to follow my mouse, because sometimes I will just knock my physical mouse out of the way of my hand, and when I do that the software mouse will most likely end up in another window I do not want to focus.
-#+BEGIN_SRC conf
- focus_follows_mouse no
-#+END_SRC
-
-** Popup handling
-:PROPERTIES:
-:CUSTOM_ID: i3_global_settings-Popup_handling-51b6ed8d
-:END:
-While in fullscreen, some software might generate a popup. In that case, I want to be aware of that, and any popup will make me leave fullscreen in order to be presented with said popup.
-#+BEGIN_SRC conf
-popup_during_fullscreen leave_fullscreen
-#+END_SRC
-
-** Behavior of workspace changes
-:PROPERTIES:
-:CUSTOM_ID: i3_global_settings-Behavior_of_workspace_changes-00202985
-:END:
-When changing workspace as described below, we often want to go back to the previous workspace we were working on, but we might not remember immediately which one it was, or we might still have our fingers ready to fire the shortcut which made us make the first workspace change. Hence, if we type the same workspace change shortcut, instead of doing nothing it will bring us back to the previous workspace we were on.
-#+BEGIN_SRC conf
-workspace_auto_back_and_forth yes
-#+END_SRC
-
-** Gaps and window appearance
-:PROPERTIES:
-:CUSTOM_ID: i3_global_settings-Gaps_and_window_appearance-749e9f7b
-:END:
-As mentioned in at the beginning of this document, I am using i3-gaps, which brings spacing (gaps) between windows to i3.
-
-First, I want space around my windows only when there are several containers on the same screen, otherwise they will be maximized.
-#+BEGIN_SRC conf
- smart_gaps on
-#+END_SRC
-
-I also do not want to see any window border, so I will be turning this setting off.
-#+BEGIN_SRC conf
- smart_borders on
-#+END_SRC
-
-By the way, the default border is invisible, since it is zero pixels wide.
-#+BEGIN_SRC conf
-default_border pixel 0
-#+END_SRC
-
-Then comes the size of these gaps. I made the outer gap negative so the space between my windows and the border of my screens is smaller than the gap between my containers.
-#+BEGIN_SRC conf
- gaps inner 20
- gaps outer -10
-#+END_SRC
-
-Some parameters are also available when it comes to the colors i3 uses. Honestly, we won’t see these colors much, so let’s simply keep the default values.
-#+BEGIN_SRC conf
- set_from_resource $fg i3wm.color7 #f0f0f0
- set_from_resource $bg i3wm.color2 #f0f0f0
-
- # class border backgr. text indicator child_border
- client.focused $bg $bg $fg $bg $bg
- client.focused_inactive $bg $bg $fg $bg $bg
- client.unfocused $bg $bg $fg $bg $bg
- client.urgent $bg $bg $fg $bg $bg
- client.placeholder $bg $bg $fg $bg $bg
-#+END_SRC
-
-* Assigning windows to workspaces
-:PROPERTIES:
-:CUSTOM_ID: Assigning_windows_to_workspaces-e59f61e5
-:END:
-I decided to bind some windows to some workspaces in order to have a better organization of my desktop.
-#+NAME: assignment-table
-| Application | Class | Workspace |
-|-------------+-------------+-----------|
-| Emacs | Emacs | 2 |
-| Chromium | Chromium | 3 |
-| Firefox | firefox | 3 |
-| Nemo | Nemo | 4 |
-| Wonderdraft | Godot | 5 |
-| Gimp | Gimp* | 6 |
-| Gnome Boxes | gnome-boxes | 8 |
-| Steam | Steam | 9 |
-| Discord | discord | 10 |
-
-The class table is used in the assignment in the i3 config file. For instance, Gimp’s assignment will look like this:
-#+BEGIN_SRC conf :tangle no
- assign [class="Gimp*"] 6
-#+END_SRC
-
-#+NAME: generate-workspaces
-#+BEGIN_SRC emacs-lisp :var workspaces=assignment-table :cache yes
- (mapconcat (lambda (x) (format "assign [class=\"%s\"] %s" (cadr x) (caddr x)))
- workspaces
- "\n")
-#+END_SRC
-
-#+RESULTS[0995341b013e50227edf78257ab502e46a30bc9a]: generate-workspaces
-: assign [class="Emacs"] 2
-: assign [class="Chromium"] 3
-: assign [class="firefox"] 3
-: assign [class="Nemo"] 4
-: assign [class="Godot"] 5
-: assign [class="Gimp*"] 6
-: assign [class="gnome-boxes"] 8
-: assign [class="Steam"] 9
-: assign [class="discord"] 10
-
-Here is the configuration:
-#+BEGIN_SRC conf :noweb yes
-<>
-#+END_SRC
-
-And although this is not specifically assigning a window to a workspace, I also want to have the tenth workspace assigned to a specific output in case I have two screens — and since this is the case when I am using only one computer, Marpa, I will be using some EmacsLisp in order to generate a different configuration file from this org file depending on the name of the machine.
-#+NAME: ws10-output-edp1
-#+BEGIN_SRC emacs-lisp
- (if (string= system-name "Marpa")
- "workspace 10 output eDP-1"
- "")
-#+END_SRC
-
-Now I’ll call the above code as a noweb reference that should be executed.
-#+BEGIN_SRC conf
- <>
-#+END_SRC
-
-* Shortcuts
-:PROPERTIES:
-:CUSTOM_ID: Shortcuts-9c7074d3
-:END:
-I use *A LOT* of shortcuts when it comes to my workflow. Like, all the time. So, expect this chapter to be a bit long, and I’ll try to make it readable still.
-
-Shortcuts are set like so:
-#+BEGIN_SRC conf :tangle no
-bindsym shortcut command
-#+END_SRC
-
-#+NAME: generate-shortcuts
-#+BEGIN_SRC emacs-lisp :exports none :var table=[] :tangle no
- (mapconcat (lambda (x) (format "bindsym %s %s" (car x) (cadr x)))
- table
- "\n")
-#+END_SRC
-
-** Terminal shortcuts
-:PROPERTIES:
-:CUSTOM_ID: Shortcuts-Terminal_shortcuts-514ecdbe
-:END:
-I have a couple of shortcuts which are related to my terminal. For instance, ~$mod+Return~ opens a regular terminal instance while ~$mod+$alt+M~ opens an SSH instance on my Mila host.
-#+NAME: terminal-shortcuts
-| shortcut | command | What it does |
-|-------------------+----------------------+--------------------------------------------------|
-| $mod+Return | exec $term | Opens a regular terminal console |
-| $mod+$alt+Return | split h;; exec $term | Opens a terminal console below the current one |
-| $mod+Shift+Return | split v;; exec $term | Opens a terminal on the right of the current one |
-| $mod+$alt+m | exec $term ssh Mila | Opens an SSH instance in my Mila host |
-| $mod+$alt+n | exec $term ssh Naro | Opens an SSH instance in my Naro host |
-| $mod+Shift+h | exec $term htop | Opens a terminal with ~htop~ |
-
-Here is the configuration:
-#+BEGIN_SRC conf
-<>
-#+END_SRC
-
-** i3 shortcuts
-:PROPERTIES:
-:CUSTOM_ID: Shortcuts-i3_shortcuts-369039ae
-:END:
-A couple of shortcuts are dedicated to i3 itself.
-#+NAME: i3-sh
-| shortcut | command | what it does |
-|--------------+---------------------------------+----------------------------------|
-| $mod+Shift+c | exec yadm alt && i3-msg reload | Reload the i3 configuration file |
-| $mod+Shift+r | exec yadm alt && i3-msg restart | Restart i3 inplace |
-| $mod+Shift+e | exec $exiti3 | Quit i3 |
-
-And although this is not really an i3 shortcut per se, I add here the shortcut for launching pywal, which will set one of my wallpapers as the wallpaper and will generate my system’s color configuration from it.
-#+NAME: wal-sh
-| shortcut | command | what it does |
-|----------+--------------+--------------------------------------------------------------|
-| $mod+w | exec $walset | Set a random wallpaper and generates a color profile from it |
-
-We also have some shortcuts to lock our screen, sleep, hibernate and shut down our computer.
-#+NAME: computer-sh
-| shortcut | command | what it does |
-|---------------+----------------------------+------------------------|
-| $mod+l | exec i3lock -fol | Lock the screen |
-| $mod+$alt+h | exec "systemctl suspend" | Suspend the computer |
-| $mod+Ctrl+h | exec "systemctl hibernate" | Hibernate the computer |
-| $mod+Shift+F4 | exec poweroff | Power off the computer |
-
-Here is the configuration:
-#+BEGIN_SRC conf
-<>
-<>
-<>
-#+END_SRC
-
-** Window and workspace management
-:PROPERTIES:
-:CUSTOM_ID: Shortcuts-Window_and_workspace_management-a384b8f8
-:END:
-*** Managing how windows will split
-:PROPERTIES:
-:CUSTOM_ID: Shortcuts-Window_and_workspace_management-Managing_how_windows_will_split-5a22ae31
-:END:
-It is possible to indicate to i3 how windows interact with one another, and especially how they are organized by spawning new windows either to the right or below the current window.
-#+NAME: split-win-sh
-| shortcuts | command | what it does |
-|-----------+---------+--------------------------------------------------------|
-| $mod+h | split h | Next window to spawn will spawn below the current one |
-| $mod+v | split v | Next window to spawn will spawn beside the current one |
-
-Here is the configuration:
-#+BEGIN_SRC conf
-<>
-#+END_SRC
-
-*** Focus windows
-:PROPERTIES:
-:CUSTOM_ID: Shortcuts-Window_and_workspace_management-Focus_windows-69a00ae9
-:END:
-To change window focus, you can use one of the following shortcuts:
-#+NAME: window-focus-sh
-| shortcut | command | what it does |
-|-------------+-------------+-------------------------------------------|
-| $mod+$left | focus left | Focus the window left of the current one |
-| $mod+$down | focus down | Focus the window down of the current one |
-| $mod+$up | focus up | Focus the window up of the current one |
-| $mod+$right | focus right | Focus the windof right of the current one |
-
-Here is the configuration:
-#+BEGIN_SRC conf
-<>
-#+END_SRC
-
-*** Focus workspaces
-:PROPERTIES:
-:CUSTOM_ID: Shortcuts-Window_and_workspace_management-Focus_workspaces-9f4bee74
-:END:
-Just like windows, it is also possible to change focus between workspaces, because let’s be honest, most people won’t have ten screens to display all ten workspaces at the same time, and frankly that would be impractical.
-#+NAME: ws-focus-sh
-| shortcut | window | what it does |
-|----------+--------------+-------------------------|
-| $mod+1 | workspace 1 | Focus first workspace |
-| $mod+2 | workspace 2 | Focus second workspace |
-| $mod+3 | workspace 3 | Focus third workspace |
-| $mod+4 | workspace 4 | Focus fourth workspace |
-| $mod+5 | workspace 5 | Focus fifth workspace |
-| $mod+6 | workspace 6 | Focus sixth workspace |
-| $mod+7 | workspace 7 | Focus seventh workspace |
-| $mod+8 | workspace 8 | Focus eighth workspace |
-| $mod+9 | workspace 9 | Focus ninth workspace |
-| $mod+0 | workspace 10 | Focus tenth workspace |
-
-Here is the configuration:
-#+BEGIN_SRC conf
-<>
-#+END_SRC
-
-*** Moving windows
-:PROPERTIES:
-:CUSTOM_ID: Shortcuts-Window_and_workspace_management-Moving_windows-d8c90ac2
-:END:
-To move windows, a couple of shortcuts are available:
-#+NAME: window-move-sh
-| shortcut | command | what it does |
-|-------------------+------------+-------------------------------|
-| $mod+Shift+$left | move left | Move the focused window left |
-| $mod+Shift+$down | move down | Move the focused window down |
-| $mod+Shift+$up | move up | Move the focused window up |
-| $mod+Shift+$right | move right | Move the focused window right |
-
-Here is the configuration:
-#+BEGIN_SRC conf
-<>
-#+END_SRC
-
-*** Moving containers
-:PROPERTIES:
-:CUSTOM_ID: Shortcuts-Window_and_workspace_management-Moving_containers-b97cf4ae
-:END:
-To move containers between the available screens, you have the following shortcuts:
-#+NAME: containers-move-sh
-| shortcut | command | what it does |
-|------------------+--------------------------------+------------------------------------------------------------|
-| $mod+Ctrl+$left | move container to output left | Moves the container to the screen left of the current one |
-| $mod+Ctrl+$down | move container to output down | Moves the container to the screen down of the current one |
-| $mod+Ctrl+$up | move container to output up | Moves the container to the screen above the current one |
-| $mod+Ctrl+$right | move container to output right | Moves the container to the screen right of the current one |
-
-You can also send containers to other workspaces by their number.
-#+NAME: containers-ws-sh
-| shortcut | command | what it does |
-|--------------+--------------------------------+--------------------------------------------|
-| $mod+Shift+1 | move container to workspace 1 | Move current container to the workspace 1 |
-| $mod+Shift+2 | move container to workspace 2 | Move current container to the workspace 2 |
-| $mod+Shift+3 | move container to workspace 3 | Move current container to the workspace 3 |
-| $mod+Shift+4 | move container to workspace 4 | Move current container to the workspace 4 |
-| $mod+Shift+5 | move container to workspace 5 | Move current container to the workspace 5 |
-| $mod+Shift+6 | move container to workspace 6 | Move current container to the workspace 6 |
-| $mod+Shift+7 | move container to workspace 7 | Move current container to the workspace 7 |
-| $mod+Shift+8 | move container to workspace 8 | Move current container to the workspace 8 |
-| $mod+Shift+9 | move container to workspace 9 | Move current container to the workspace 9 |
-| $mod+Shift+0 | move container to workspace 10 | Move current container to the workspace 10 |
-
-Here is the configuration:
-#+BEGIN_SRC conf
-<>
-<>
-#+END_SRC
-
-*** Moving workspaces
-:PROPERTIES:
-:CUSTOM_ID: Shortcuts-Window_and_workspace_management-Moving_workspaces-a71d7b54
-:END:
-
-It is also possible to move workspaces. The related shortcuts available are the following:
-
-#+NAME: workspace-move-sh
-| shortcut | command | what it does |
-|------------------------+--------------------------------+------------------------------------------------------------|
-| $mod+Ctrl+Shift+$left | move workspace to output left | Moves the workspace to the screen left of the current one |
-| $mod+Ctrl+Shift+$down | move workspace to output down | Moves the workspace to the screen down of the current one |
-| $mod+Ctrl+Shift+$up | move workspace to output up | Moves the workspace to the screen above the current one |
-| $mod+Ctrl+Shift+$right | move workspace to output right | Moves the workspace to the screen right of the current one |
-
-Here is the configuration:
-#+BEGIN_SRC conf
-<>
-#+END_SRC
-
-*** Close windows
-:PROPERTIES:
-:CUSTOM_ID: Shortcuts-Window_and_workspace_management-Close_windows-5e521a48
-:END:
-To close windows, we have two main shortcuts: Alt+F4 and mod+q. The first one is here due to habits, but I don’t really use it anymore due to my main keyboard which doesn’t have any easy access to the functions keys, hence mod+q.
-#+NAME: close-win-sh
-| shortcut | command | what it does |
-|----------+---------+-------------------------|
-| $mod+q | kill | kill the current window |
-| $alt+F4 | kill | kill the current window |
-
-Here is the configuration:
-#+BEGIN_SRC conf
-<>
-#+END_SRC
-
-*** Manage the size of the current window
-:PROPERTIES:
-:CUSTOM_ID: Shortcuts-Window_and_workspace_management-Manage_the_size_of_the_current_window-11afa914
-:END:
-It is possible to change the size of the current window, even if it is a floating one. The first shortcut that might interest you is $mod+f which switches your current window to fullscreen. But to resize a window, you will need to enter the ~resize~ mode.
-#+NAME: size-win-sh
-| shortcut | command | what it does |
-|----------+-------------------+---------------------------------------------------|
-| $mod+f | fullscreen toggle | Puts the current window in fullscreen or exits it |
-| $mod+r | mode "resize" | Enter resize mode |
-
-When it comes to modes, they are defined as follows:
-#+BEGIN_SRC conf :tangle no
- mode "nameofyourmode" {
- here go your shortcuts
- }
-#+END_SRC
-
-So, all the following shortcuts will be inserted in a mode called ~resize~. Note that not only are the resizing shortcuts bound to the arrow keys, they are also bound to ~ctsr~, which is the bépo equivalent of ~hjkl~.
-#+NAME: resize-win-sh
-| shortcut | command | what it does |
-|----------+-------------------------------------+-------------------------------------------|
-| $right | resize grow width 20 px or 10 ppt | Increase the width of the current window |
-| r | resize grow width 20 px or 10 ppt | Increase the width of the current window |
-| $left | resize shrink width 10 px or 5 ppt | Decrease the width of the current window |
-| c | resize shrink width 10 px or 5 ppt | Decrease the width of the current window |
-| $down | resize grow height 10 px or 5 ppt | Increase the height of the current window |
-| t | resize grow height 10 px or 5 ppt | Increase the height of the current window |
-| $up | resize shrink height 10 px or 5 ppt | Decrease the height of the current window |
-| s | resize shrink height 10 px or 5 ppt | Decrease the height of the current window |
-| Return | mode "default" | Return to the default mode |
-| Escape | mode "default" | Return to the default mode |
-If you prefer, you can think of these shortcuts not as increasing or decreasing the width or height of the current window, but rather as how the bottom or right limit of the windows will be moved relative to the top left corner.
-
-Here is the configuration:
-#+BEGIN_SRC conf
- <>
- mode "resize" {
- <>
- }
-#+END_SRC
-
-*** Manage floating windows
-:PROPERTIES:
-:CUSTOM_ID: Shortcuts-Window_and_workspace_management-Manage_floating_windows-9206f4da
-:END:
-As said above, your windows can be floating windows instead of being tiled like they are by default. For this too we have a couple of shortcuts:
-#+NAME: float-win-sh
-| shortcut | command | what it does |
-|------------------+----------------------+------------------------------------------------------|
-| $mod+Shift+space | floating toggle | Toggles the window between tiled and floating mode |
-| $mod+space | focus mode_toggle | Toggles the focus between tiled and floating windows |
-| $mod+Ctrl+c | move position center | Centers the focused floating window |
-If you want to move around your floating window, you can do it with your mouse while holding down the floating modifier declared [[#Variables_declaration-Floating_windows-897d0c3b][here]].
-
-Here is the configuration:
-#+BEGIN_SRC conf
-<>
-#+END_SRC
-
-*** Scratchpad and window display
-:PROPERTIES:
-:CUSTOM_ID: Shortcuts-Window_and_workspace_management-Scratchpad_and_window_display-10d8d1f4
-:END:
-You can think of i3’s scratchpad as some sort of extra workspace in which you can hide your windows you are not using, or as if you want to reduce a window to the taskbar of other window managers or desktop environments. You have basically two shortcuts for the scratchpad: one that sends the current window to the scratchpad, and one that cicles through the windows sent to the scratchpad and shows them to you sequencially. If you go through all of them, they will be hidden again. You can get a window out of the scratchpad by tiling it to the current workspace with the shortcut described above.
-
-You also have the possibility of making a floating window a sticky window. This means not only will it show on all workspaces, it will also be on top of every other window. It can be useful if you have some notes you want to keep an eye on for instance.
-#+NAME: scratchpad-sh
-| shortcut | command | what it does |
-|--------------+-----------------+------------------------------------------------------|
-| $mod+Shift+s | move scratchpad | Sends the current window to the scratchpad |
-| $mod+s | scratchpad show | Shows and cycles through windows from the scratchpad |
-| $mod+Ctrl+s | sticky toggle | Toggles sticky mode on current window |
-
-Here is the configuration:
-#+BEGIN_SRC conf
-<>
-#+END_SRC
-
-*** Gaps management
-:PROPERTIES:
-:CUSTOM_ID: Shortcuts-Window_and_workspace_management-Gaps_management-33979213
-:END:
-It is possible to dynamically change the gaps between containers if we want to change a bit the appearance of i3. For that, we obviously have some shortcuts.
-#+NAME: gaps-resize-sh
-| shortcut | command | what it does |
-|-------------------+-----------------------------------------------+-----------------------------|
-| $mod+g | gaps inner current plus 5 | Increase the inner gap size |
-| $mod+Shift+g | gaps inner current minus 5 | Decrease the inner gap size |
-| $mod+Ctrl+g | gaps outer current plus 5 | Increase the outer gap size |
-| $mod+Ctrl+Shift+g | gaps outer current minus 5 | Decrease the outer gap size |
-| $mod+$alt+g | gaps inner all set 20; gaps outer all set -10 | Reset gaps |
-
-Here is the corresponding configuration:
-#+BEGIN_SRC conf
-<>
-#+END_SRC
-
-** Launching software
-:PROPERTIES:
-:CUSTOM_ID: Shortcuts-Launching_software-0e088e69
-:END:
-A big part of my i3 shortcuts though are related to launching various software. I’ll try to sort them by category here, but do take a look even at categories which you might not be interested in, they might actually have something useful for you.
-
-*** Software and command launcher
-:PROPERTIES:
-:CUSTOM_ID: Shortcuts-Launching_software-Software_and_command_launcher-a3f5863e
-:END:
-These commands will allow the user to launch applications which provide ~.desktop~ files or user-defined ~.desktop~ files, as well as commands with the help of rofi.
-#+NAME: launcher-sh
-| shortcut | command | what it does |
-|--------------+---------------------------------------+-------------------------------------------------------|
-| $mod+Shift+d | exec --no-startup-id j4-dmenu-desktop | Launch a registered application |
-| $mod+d | exec --no-startup-id $rofiexec | Launch a terminal command or a registered application |
-
-Here is the configuration:
-#+BEGIN_SRC conf
-<>
-#+END_SRC
-
-*** Internet software
-:PROPERTIES:
-:CUSTOM_ID: Shortcuts-Launching_software-Internet_software-a0524cd8
-:END:
-I have a couple of Internet-related software I can launch easily.
-#+NAME: internet-sh
-| shortcut | command | what it does |
-|--------------+---------------------+-----------------------------|
-| $mod+b | exec firefox | Launch browser |
-| $mod+m | exec $mail | Launch Gnus, my mail client |
-| Ctrl+Shift+d | exec discord-canary | Launch Discord |
-
-Hence this configuration:
-#+BEGIN_SRC conf
-<>
-#+END_SRC
-
-*** Screenshots
-:PROPERTIES:
-:CUSTOM_ID: Shortcuts-Launching_software-Screenshots-41e41c88
-:END:
-A couple of shortcuts are available for taking screenshots.
-#+NAME: screenshot-sh
-| shortcut | command | what it does |
-|-------------+-----------------------------------+----------------------------------------------------------|
-| Print | exec --no-startup-id scrot | Takes a screenshot of the entire desktop |
-| Ctrl+Print | exec --no-startup-id "scrot -s" | Takes a screenshot of a region or the selected window |
-| Shift+Print | exec --no-startup-id "scrot -d 3" | takes a screenshot of the desktop three in three seconds |
-
-This gives us this configuration:
-#+BEGIN_SRC conf
-<>
-#+END_SRC
-
-*** Screen brightness
-:PROPERTIES:
-:CUSTOM_ID: Shortcuts-Launching_software-Screen_brightness-6855d53f
-:END:
-Here we have four commands for managing our screen’s brightness (this is useful for laptops, not so much with desktops), and two of them are actually duplicates of the other two in case a laptop doesn’t have dedicated keys or we are using a keyboard which doesn’t provide them.
-#+NAME: brightness-sh
-| shortcut | command | what it does |
-|-----------------------+------------------------+---------------------------------------|
-| XF86MonBrightnessUp | exec xbacklight -inc 5 | Increase the brightness of the screen |
-| $mod+$alt+Next | exec xbacklight -inc 5 | Increase the brightness of the screen |
-| XF86MonBrightnessDown | exec xbacklight -dec 5 | Decrease the brightness of the screen |
-| $mod+$alt+Prev | exec xbacklight -dec 5 | Decrease the brightness of the screen |
-
-This gives us this configuration:
-#+BEGIN_SRC conf
-<>
-#+END_SRC
-
-*** Media control
-:PROPERTIES:
-:CUSTOM_ID: Shortcuts-Launching_software-Media_control-18ad2815
-:END:
-Some shortcuts are dedicated to media control, especially when it comes to controlling music. All of these media control shortcuts will be calls to ~mpc~ which will in turn send commands to ~mpd~, which is the music server I use on my computers.
-#+NAME: media-sh
-| shortcut | command | what it does |
-|---------------------------+--------------------+--------------------------------|
-| XF86AudioNext | exec mpc next | Forward to the next track |
-| $alt+XF86AudioRaiseVolume | exec mpc next | Forward to the next track |
-| $mod+Next | exec mpc next | Forward to the next track |
-| XF86AudioPrev | exec mpc prev | Backward to the previous track |
-| $alt+XF86AudioLowerVolume | exec mpc prev | Backward to the previous track |
-| $mod+Prior | exec mpc prev | Backward to the previous track |
-| XF86AudioPlay | exec mpc toggle | Play or pause the music |
-| $mod+p | exec mpc toggle | Play or pause the music |
-| $mod+$alt+p | exec mpc stop | Completely stop the music |
-| XF86AudioStop | exec mpc stop | Completely stop the music |
-| $alt+XF86AudioPlay | exec mpc stop | Completely stop the music |
-| $mod+$alt+7 | exec mpc volume +5 | Increase the volume from mpd |
-| $mod+$alt+8 | exec mpc volume -5 | Decrease the volume from mpd |
-
-We also have two shortcuts for launching ncmpcpp, my mpd frontend, either with the playlist open by default, or the visualizes open.
-#+NAME: ncmpcpp-sh
-| shortcut | command | what it does |
-|--------------+-----------------------------------+----------------------------------|
-| $mod+Shift+n | exec $term ncmpcpp -q | Launch ncmpcpp’s playlist editor |
-| $mod+Shift+v | exec $term ncmpcpp -qs visualizer | Launch ncmpcpp’s visualizer |
-
-We also have more general shortcuts, like how to manipulate the general volume level.
-#+NAME: volume-sh
-| shortcut | command | what it does |
-|----------------------+----------------------------------------+----------------------|
-| XF86AudioMute | exec "amixer set Master 1+ toggle" | Mute or unmute audio |
-| Ctrl+$mod+Prior | exec "amixer -q set Master 2%+ unmute" | Raise volume |
-| XF86AudioRaiseVolume | exec "amixer -q set Master 2%+ unmute" | Raise volume |
-| Ctrl+$mod+Next | exec "amixer -q set Master 2%- unmute" | Reduce volume |
-| XF86AudioLowerVolume | exec "amixer -q set Master 2%- unmute" | Reduce volume |
-
-This gives us this configuration:
-#+BEGIN_SRC conf
-<>
-<>
-<>
-#+END_SRC
-
-*** Rofi utilities
-:PROPERTIES:
-:CUSTOM_ID: Shortcuts-Launching_software-Rofi_utilities-b8eb5b95
-:END:
-We also have some utilities I’ve written and which are interfaced with rofi. Here are said shortcuts.
-#+NAME: rofi-sh
-| shortcut | command | what it does |
-|-------------------+-----------------------+-----------------------------------------------------------------------|
-| $mod+Shift+p | exec rofi-pass --type | Types the selected password available from ~pass~ where the cursor is |
-| $mod+Ctrl+Shift+p | exec rofi-pass | Copies in the clipboard the selected password from ~pass~ for 45 sec |
-| $mod+Ctrl+m | exec rofi-mount | Volume mounting helper |
-| $mod+Ctrl+u | exec rofi-umount | Volume unmounting helper |
-| $mod+$alt+e | exec rofi-emoji | Emoji picker, copies it in the clipboard |
-| $mod+Ctrl+w | exec wacom-setup | Sets my Wacom Bamboo tablet as being active on the selected screen |
-| $mod+Shift+w | exec connect-wifi | Connect to an available WiFi network |
-
-This gives us the following configuration:
-#+BEGIN_SRC conf
-<>
-#+END_SRC
-
-*** Miscellaneous
-:PROPERTIES:
-:CUSTOM_ID: Shortcuts-Launching_software-Miscellaneous-7ec80fea
-:END:
-And last but not least, I have some other shortcuts for various software, some of them which I use quite a lot like the shortcut for launching Emacs.
-#+NAME: misc-sh
-| shortcut | command | what it does |
-|-------------+------------------+---------------------------------|
-| $mod+e | exec $ec | Launch Emacs client |
-| $mod+n | exec nemo | Launch Nemo (file manager) |
-| $mod+$alt+c | exec speedcrunch | Launch Speedcrunch (calculator) |
-| $mod+F3 | exec arandr | Launch arandr |
-
-This gives us the following configuration:
-#+BEGIN_SRC conf
-<>
-#+END_SRC
-
-*** Screen management
-:PROPERTIES:
-:CUSTOM_ID: Shortcuts-Launching_software-Screen_management-f9b35bf2
-:END:
-Additionally, we have a shortcut for entering presentation mode on the additional screen of the computer; on my main computer, Mila, the additional screen is HDMI-1, while it is VGA1 on my travel laptop. We’ll use some Emacs Lisp to determine on the configuration file export which screens names to use.
-#+NAME: hostname-screen-management
-#+BEGIN_SRC emacs-lisp
- (cond ((string= system-name "Marpa") "bindsym $mod+Ctrl+p xrandr --output HDMI-1 --mode 1024x768 --right-of eDP-1")
- ((string= system-name "gampo") "bindsym $mod+Ctrl+p xrandr --output VGA1 --mode 1024x768 --right-of LVDS1"))
-#+END_SRC
-
-Now, we just have to call this Emacs Lisp code as a noweb reference and execute it.
-#+BEGIN_SRC conf :noweb yes
- <>
-#+END_SRC
-
-* Software autolaunch
-:PROPERTIES:
-:CUSTOM_ID: Software_autolaunch-ccee82f6
-:END:
-When i3 is launched, I want it to also launch some software automatically. Here is what we will launch:
-#+NAME: autolaunch
-| always execute it? | command | what it is |
-|--------------------+-------------------------------------------+----------------------------------------|
-| no | /usr/lib/xfce-polkit/xfce-polkit | Launch the XFCE Polkit |
-| no | picom --experimental-backends -e 1 | Launch picom |
-| no | xss-lock -- lock | Launch power management |
-| no | numlockx on | Activate NumLock |
-| no | dunst -config ~/.config/dunst/dunstrc | Launch notification manager |
-| no | nm-applet | NetworkManager system tray |
-| yes | wal -i "$(< "${HOME}/.cache/wal/wal")" | Sets the wallpaper from last session |
-| no | xrdb $HOME/.Xresources | Load Xresources files |
-| yes | polybar-launch | Launch polybar |
-| no | mpc stop | Stop music from mpd |
-| no | mpd_discord_richpresence --no-idle --fork | Launch mpd status sharing with Discord |
-
-#+NAME: generate-autolaunch
-#+BEGIN_SRC emacs-lisp :exports none :cache yes :var table=autolaunch
- (mapconcat (lambda (x)
- (format (concat (if (string= (car x)
- "yes")
- "exec_always"
- "exec")
- " --no-startup-id %s")
- (cadr x)))
- table
- "\n")
-#+END_SRC
-
-#+RESULTS[283577fe2e66b30c936b7fcf142713d285db8da6]: generate-autolaunch
-#+begin_example
-exec_always --no-startup-id wal -i "$(< "${HOME}/.cache/wal/wal")"
-exec --no-startup-id xss-lock -- i3lock -fol
-exec --no-startup-id dunst -config ~/.config/dunst/dunstrc
-exec --no-startup-id xrdb $HOME/.Xresources
-exec --no-startup-id compton -F --opengl --config ~/.config/compton.conf -e 1
-exec_always --no-startup-id polybar-launch
-exec_always --no-startup-id enable_touch
-exec --no-startup-id syndaemon -i 1.0 -t -k
-exec --no-startup-id mpc stop
-exec --no-startup-id mpd_discord_richpresence --no-idle --fork
-exec --no-startup-id nm-applet
-exec --no-startup-id numlockx on
-#+end_example
-
-My travel laptop has a fingerprint reader which can be used as an authentification method when the root password is asked. Let’s launch our policy kit manager if that is the case:
-#+NAME: fingerprint-thinkpad
-#+BEGIN_SRC emacs-lisp
- (if (string= system-name "gampo")
- "exec --no-startup-id /usr/lib/mate-polkit/polkit-mate-authentication-agent-1"
- "")
-#+END_SRC
-
-#+BEGIN_SRC conf
- <>
- <>
-#+END_SRC
diff --git a/org/config/Deprecated/img/emacs.png b/org/config/Deprecated/img/emacs.png
deleted file mode 100644
index 9ba0d05..0000000
Binary files a/org/config/Deprecated/img/emacs.png and /dev/null differ
diff --git a/org/config/Deprecated/img/emacs.png.webp b/org/config/Deprecated/img/emacs.png.webp
deleted file mode 100644
index c928aee..0000000
Binary files a/org/config/Deprecated/img/emacs.png.webp and /dev/null differ
diff --git a/org/config/Deprecated/img/neofetch.png b/org/config/Deprecated/img/neofetch.png
deleted file mode 100644
index 5fadf64..0000000
Binary files a/org/config/Deprecated/img/neofetch.png and /dev/null differ
diff --git a/org/config/Deprecated/img/neofetch.png.webp b/org/config/Deprecated/img/neofetch.png.webp
deleted file mode 100644
index 0e41313..0000000
Binary files a/org/config/Deprecated/img/neofetch.png.webp and /dev/null differ
diff --git a/org/config/Deprecated/img/rofi.png b/org/config/Deprecated/img/rofi.png
deleted file mode 100644
index d5d9066..0000000
Binary files a/org/config/Deprecated/img/rofi.png and /dev/null differ
diff --git a/org/config/Deprecated/img/rofi.png.webp b/org/config/Deprecated/img/rofi.png.webp
deleted file mode 100644
index a59ccd4..0000000
Binary files a/org/config/Deprecated/img/rofi.png.webp and /dev/null differ
diff --git a/org/config/Deprecated/nano.org b/org/config/Deprecated/nano.org
deleted file mode 100644
index 7231519..0000000
--- a/org/config/Deprecated/nano.org
+++ /dev/null
@@ -1,117 +0,0 @@
-#+TITLE: Nano configuration
-#+setupfile: ../headers
-#+OPTIONS: unique-id:t
-#+HTML_HEAD_EXTRA:
-#+HTML_HEAD_EXTRA:
-#+HTML_HEAD_EXTRA:
-#+PROPERTY: header-args :tangle ~/.config/nano/nanorc
-
-* Introduction
-:PROPERTIES:
-:CUSTOM_ID: Introduction-7e535842
-:END:
-#+begin_center
-*Before proceeding, be aware that I deprecated this nano config on August 28th, 2020, meaning I won’t update it anymore unless I use it again some day in the future. I will keep it on my website though.*
-#+end_center
-
-I nowadays rarely use Nano as a text editor, since I mainly rely on Emacs for all sorts of tasks, including quick file editing. However, at times, Emacs won’t work or won’t be available, and I therefore need a lightweight, fast and reliable text editor: Nano. And despite Nano being a simple piece of software, it does offer some customization I cannot refuse. Here is how I configured it:
-
-* Configuration
-:PROPERTIES:
-:CUSTOM_ID: Configuration-b55668a7
-:END:
-When saving a file, create a backup file by adding a tilde (=~=) to the file's name. And make and keep not just one backup file, but make and keep a uniquely numbered one every time a file is saved — when backups are enabled with =set backup= or =--backup= or =-B=. The uniquely numbered files are stored in the directory =~/.cache/nano/backups/=.
-#+BEGIN_SRC conf
- set backup
- set backupdir /home/phundrak/.cache/nano/backups/
-#+END_SRC
-
-Save a file by default in Unix format. This overrides nano's default behavior of saving a file in the format that it had. (This option has no effect when you also use =set noconvert=.)
-#+BEGIN_SRC conf
- set unix
-#+END_SRC
-
-** Keys behavior
-:PROPERTIES:
-:CUSTOM_ID: Configuration-Keys_behavior-c665fa36
-:END:
-Make the Home key smarter. When Home is pressed anywhere but at the very beginning of non-whitespace characters on a line, the cursor will jump to that beginning (either forwards or backwards). If the cursor is already at that position, it will jump to the true beginning of the line.
-#+BEGIN_SRC conf
- set smarthome
-#+END_SRC
-
-** Search
-:PROPERTIES:
-:CUSTOM_ID: Configuration-Search-6e458076
-:END:
-Do case-unsensitive searches by default.
-#+BEGIN_SRC conf
- unset casesensitive
-#+END_SRC
-
-Do regular-expression searches by default. Regular expressions in =nano= are of the extended type (ERE).
-#+BEGIN_SRC conf
- set regexp
-#+END_SRC
-
-** Visual settings
-:PROPERTIES:
-:CUSTOM_ID: Configuration-Visual_settings-9952f2ae
-:END:
-Use bold instead of reverse video for the title bar, status bar, key combos, function tags, line numbers, and selected text. This can be overridden by setting the options =titlecolor=, =statuscolor=, =keycolor=, =functioncolor=, =numbercolor=, and =selectedcolor=.
-#+BEGIN_SRC conf
- set boldtext
-#+END_SRC
-
-Enable soft line wrapping for easier viewing of very long lines.
-#+BEGIN_SRC conf
- set softwrap
-#+END_SRC
-
-When soft line wrapping is enabled, make it wrap lines at blank characters (tabs and spaces) instead of always at the edge of the screen.
-#+BEGIN_SRC conf
- set atblanks
-#+END_SRC
-
-Display line numbers to the left of the text area.
-#+BEGIN_SRC conf
- set linenumbers
-#+END_SRC
-
-Constantly display the cursor position in the status bar. This overrides the option =quickblank=.
-#+BEGIN_SRC conf
- set constantshow
-#+END_SRC
-
-** Whitespace settings
-:PROPERTIES:
-:CUSTOM_ID: Configuration-Whitespace_settings-8cef9cd7
-:END:
-Convert typed tabs to spaces. Sue me.
-#+BEGIN_SRC conf
- set tabstospaces
-#+END_SRC
-
-Use a tab size of a certain amount of columns. The value of number must be greater than 0. The default value is 8.
-#+BEGIN_SRC conf
-set tabsize 2
-#+END_SRC
-
-Automatically indent a newly created line to the same number of tabs and/or spaces as the previous line (or as the next line if the previous line is the beginning of a paragraph).
-#+BEGIN_SRC conf
- set autoindent
-#+END_SRC
-
-Remove trailing whitespace from wrapped lines when automatic hard-wrapping occurs or when text is justified.
-#+BEGIN_SRC conf
-set trimblanks
-#+END_SRC
-
-** Included configuration file
-:PROPERTIES:
-:CUSTOM_ID: Configuration-Included_configuration_file-70b0f35b
-:END:
-Nano gives the opportunity to include some files located elsewhere. This is why I added [[https://github.com/scopatz/nanorc][this repo]] as a submodule of my dotfiles so I can access a lot of them at the same time. Since the submodule is cloned in =~/.config/nanorc=, we can add only one line to include all of the =.nanorc= files.
-#+BEGIN_SRC conf
- include ~/.config/nano/nano-syntax/*.nanorc
-#+END_SRC
diff --git a/org/config/Deprecated/polybar.org b/org/config/Deprecated/polybar.org
deleted file mode 100644
index a028fe2..0000000
--- a/org/config/Deprecated/polybar.org
+++ /dev/null
@@ -1,858 +0,0 @@
-#+TITLE: Polybar config
-#+setupfile: ../headers
-#+OPTIONS: unique-id:t
-#+HTML_HEAD_EXTRA:
-#+HTML_HEAD_EXTRA:
-#+HTML_HEAD_EXTRA:
-#+PROPERTY: header-args :exports none
-#+PROPERTY: header-args:emacs-lisp :tangle no :exports none
-#+PROPERTY: header-args:conf-windows :tangle ~/.config/polybar/config :noweb yes :exports code :mkdirp yes
-
-* Presentation
-:PROPERTIES:
-:CUSTOM_ID: Presentation-4e723f32
-:END:
-#+begin_center
-*Before proceeding, be aware that I deprecated this polybar config on August 22nd, 2020, meaning I won’t update it anymore unless I use it again some day in the future. I will keep it on my website though.*
-#+end_center
-
-Polybar is a desktop utility for displaying various information in form of bars for GNU/Linux systems. It is often used as a replacement for native bars available in window managers, such as i3. In my case, I use two instances of polybar in order to get two bars displayed on each screen. The information displayed is either related to i3 itself, or it is system information, such as CPU or disk usage. More information will be given and explained below.
-
-If you want to learn more about how to configure Polybar, you can go to its [[https://github.com/jaagr/polybar][official repository on Github]].
-
-#+BEGIN_EXPORT latex
-Be aware that this PDF documents suffers from a couple of issues with some characters such as emojis. If you wish to see everything correctly, I would suggest you to take a look at the online HTML version of this document.
-#+END_EXPORT
-
-* General settings
-:PROPERTIES:
-:CUSTOM_ID: General_settings-e02fb78c
-:END:
- Some general settings are available for Polybar, and they are declared under
- the ~[settings]~ section.
- #+BEGIN_SRC conf-windows
- [settings]
- #+END_SRC
- Only one setting is used in this configuration though: the ability to relauch
- polybar on a configuration file rewrite.
- #+BEGIN_SRC conf-windows
- screenchange-reload = true
- #+END_SRC
-
- Some global settings are also available in order to adjust the
- ~_NET_WM_STRUT_PARTIAL~ top and bottom values:
- #+BEGIN_SRC conf-windows
- [global/wm]
- margin-top = 32
- margin-bottom = 22
- #+END_SRC
-
-* Colors declaration for polybar
-:PROPERTIES:
-:CUSTOM_ID: Colors_declaration_for_polybar-75ee0b65
-:END:
-#+BEGIN_SRC conf-windows :exports none
- ; -*- mode: conf-windows -*-
-#+END_SRC
-Like most status bars available, we can declare custom colors to be used in polybar. This part of the configuration file is declared with the following header:
-#+BEGIN_SRC conf-windows
- [colors]
-#+END_SRC
-As I use pywal as a color scheme generator based on the color of my wallpaper, I need to tell polybar to fetch the colors it will use from xrdb. If such color cannot be used, other colors will be used as fallback colors. First, let’s declare our default background and foreground colors with their alternative option.
-#+BEGIN_SRC conf-windows
- background = ${xrdb:color1:#50000000}
- background-alt = ${xrdb:color2:#444}
- foreground = ${xrdb:color7:#dfdfdf}
- foreground-alt = ${xrdb:color6:#555}
-#+END_SRC
-Now, we can also declare our primary and secondary colors.
-#+BEGIN_SRC conf-windows
- primary = #ffb52a
- secondary = #e60053
-#+END_SRC
-Polybar is also aware of alerts sent by window managers such as i3 when a window opens in an unfocused workspace. For that, let’s declare an alert color.
-#+BEGIN_SRC conf-windows
- alert = #bd2c40
-#+END_SRC
-
-* Declaration of the bars
-:PROPERTIES:
-:CUSTOM_ID: Declaration_of_the_bars-a95135a3
-:END:
-It is possible in i3 to declare as many bars as we wish, and each of these bars will be named. Naming the bar is done in its module declaration like so:
-#+BEGIN_SRC conf-windows :tangle no
- [bar/nameofthebar]
-#+END_SRC
-In my configuration, I use two of such bars, one atop of my screen, and one at the bottom.
-
-** Top bar declaration
-:PROPERTIES:
-:CUSTOM_ID: Declaration_of_the_bars-Top_bar_declaration-fc0cd977
-:END:
-As unimaginative as it might seem, I went for a rather explicit name for my bars. The top one is simply named ~top~, as shown below.
-#+BEGIN_SRC conf-windows
-[bar/top]
-#+END_SRC
-
-*** Positioning
-:PROPERTIES:
-:CUSTOM_ID: Declaration_of_the_bars-Top_bar_declaration-Positioning-2505760c
-:END:
-We need to set on which screen the bar is to be displayed. Indeed, it is possible to display a bar on only one specific screen if we wish to. Actually, it is even the default behavior of polybar, but as we will see later with the launching script, it is possible to launch bars on multiple outputs at the same time. Here, we simply get the value of the variable ~monitor~ from the launch environment.
-#+NAME: monitor-bar
-#+BEGIN_SRC conf-windows
-monitor = ${env:MONITOR}
-#+END_SRC
-We have a few position-related variables that need to be set. We can specify whether or not we want our bar at the bottom of the screen —which is the default behavior of polybar—, its width, its height, the radius for the rounding of its corners and whether the bar should be centered or not. In my case, my bars are rather small height-wise, and it occupies most of the width of my screens. There is some gaps between this bar and the border of the screen, but this is due to a border around the bar itself which acts not only on the width of the bar itself, but also on its height.
-#+BEGIN_SRC conf-windows
- bottom = false
- border-size = 5
- <>
-#+END_SRC
-#+NAME: position-bar-top
-#+BEGIN_SRC conf-windows :exports none :tangle no
- width = 100%
- height = 22
- radius = 10.0
- fixed-center = true
-#+END_SRC
-We also want to add some padding to our bar so our modules are not too close to its edges, especially due to the rounding of the top bar.
-#+NAME: padding-bar
-#+BEGIN_SRC conf-windows
- padding-left = 2
- padding-right = 4
-#+END_SRC
-Each module will have some padding around it, so that modules aren’t glued together and instead have some room to breathe. The padding on the left is a bit less than the padding on the right for aesthetic reasons.
-#+NAME: module-margin-bar
-#+BEGIN_SRC conf-windows
- module-margin-left = 1
- module-margin-right = 2
-#+END_SRC
-The top bar doesn’t include any system tray, so let’s disable that.
-#+BEGIN_SRC conf-windows
- tray-position = none
-#+END_SRC
-
-*** Colors and display
-:PROPERTIES:
-:CUSTOM_ID: Declaration_of_the_bars-Top_bar_declaration-Colors_and_display-30f12652
-:END:
-As explained above, we declared some global variables when it comes to colors, and this is where they will be used. The bar’s background will be of the same color as the main background color declared earlier, and the same goes for the foreground.
-#+NAME: bar-colors
-#+BEGIN_SRC conf-windows
- background = ${colors.background}
- foreground = ${colors.foreground}
-#+END_SRC
-
-If we wanted, we could also declare a default color for the underlines under the various modules that will be included in the bar, but in our case this variable is unused. So we will simply add this commented line as a memento this is possible, but it won’t have any effect with this current configuration of polybar. Same goes for the border around the bar, it is a useless variable in this configuration since we want the border to be transparent.
-#+NAME: line-border-color
-#+BEGIN_SRC conf-windows
- line-color = #f00
- ; border-color = #00000000
-#+END_SRC
-
-Although the variable for the default line color is not used, we still have to set the default width of the underline of our modules. By default, their underline will be three pixels thick.
-#+NAME: line-size-bar
-#+BEGIN_SRC conf-windows
- line-size = 3
-#+END_SRC
-
-*** Fonts and locale
-:PROPERTIES:
-:CUSTOM_ID: Declaration_of_the_bars-Top_bar_declaration-Fonts_and_locale-70a25466
-:END:
-Now we can chose which font fill be used in order to display text in this bar, as well as the locale we want. The locale will be useful for displaying information such as date and time, which is a module we will have in this top bar. First, the declaration of the locale is done like so:
-#+NAME: locale-bar
-#+BEGIN_SRC conf-windows
- locale = ja_JP.UTF-8
-#+END_SRC
-Now, we can declare the fonts we want to use in Polybar. It is possible to declare several of them, the first one is the one which gets the absolute priority, and the next ones with a larger index are fallback fonts. Font declaration accepts the fontconfig format as well as possible offset[fn:1]. Five fonts are used in my polybar config:
-#+NAME: fonts-polybar
-| Font | fontconfig | Vertical offset | Why it’s used |
-|--------------+----------------------------------------------------+-----------------+-----------------------|
-| Fira Sans | Fira Sans Book:style=Book:pixelsize=10 | 1 | Text display |
-| IPA Mincho | IPAMincho:style=regular:pixelsize=6 | 0 | Japanese text display |
-| Unifont | unifont:fontformat=truetype:size=6:antialias=false | 0 | Fallback font |
-| NotoEmoji | NotoEmoji:style=Book:scale=16 | 0 | Emoji display |
-| Siji | Siji:pixelsize=8 | 0 | Symbol display |
-| Default font | fixed:pixelsize=8 | 0 | Fallback font |
-#+NAME: font-ws-config
-#+HEADER: :var text="font"
-#+BEGIN_SRC emacs-lisp :var table=fonts-polybar[,1:2] :cache yes
- (setq counter 0)
- (mapconcat (lambda (font)
- (setq counter (+ 1 counter))
- (format "%s-%d = %s;%s"
- text
- (- counter 1)
- (nth 0 font)
- (nth 1 font)))
- table
- "\n")
-#+END_SRC
-
-#+RESULTS[53fd99d75f6b08e96288fd2a62b455d7ef8b1754]: font-ws-config
-: font-0 = Fira Sans Book:style=Book:pixelsize=10;1
-: font-1 = IPAMincho:style=regular:pixelsize=6;0
-: font-2 = unifont:fontformat=truetype:size=6:antialias=false;0
-: font-3 = NotoEmoji:style=Book:scale=16;0
-: font-4 = Siji:pixelsize=8;0
-: font-5 = fixed:pixelsize=8;0
-
-Here’s the font configuration:
-#+BEGIN_SRC conf-windows
- <>
-#+END_SRC
-Note that only Fira Sans get a small offset due to the size of the font and the height of the bar itself.
-
-*** Modules
-:PROPERTIES:
-:CUSTOM_ID: Declaration_of_the_bars-Top_bar_declaration-Modules-18979638
-:END:
-Finally, arguably one of the most important parts of our bar configuration: the module selection. Modules can be positioned in three different parts of our bar: to the right, in middle or to the left. On the left, we want our workspace indicator for i3. In the middle, we’ll get the title of the focused window, and to the left we’ll have the date and time.
-#+NAME: modules-generate
-#+BEGIN_SRC emacs-lisp :var table=top-modules :results value :cache yes
- (setq right '()
- center '()
- left '())
- (dolist (module table)
- (let* ((module-name (nth 0 module))
- (module-layout (nth 1 module)))
- (message "%S" module-layout)
- (add-to-list (cond
- ((string= "left" module-layout) 'left)
- ((string= "center" module-layout) 'center)
- (t 'right))
- module-name)))
- (concat (concat "modules-left = "
- (mapconcat #'identity left " ")
- "\n")
- (concat "modules-center = "
- (mapconcat #'identity center " ")
- "\n")
- (concat "modules-right = "
- (mapconcat #'identity right " ")
- "\n"))
-#+END_SRC
-
-#+RESULTS[90b932dc0fd32501e1513f14059b92de09a7b59e]: modules-generate
-: modules-left = i3
-: modules-center = xwindow
-: modules-right = date
-
-Here is the list of modules used:
-#+NAME: top-modules
-| Module name | Position | Brief description |
-|-------------+----------+----------------------------|
-| i3 | left | i3 workspace indicator |
-| xwindow | center | Name of the focused window |
-| date | right | Date and time |
-
-#+BEGIN_SRC conf-windows :cache yes
- <>
-#+END_SRC
-
-Each module will be described in details later in this document.
-
-** Bottom bar declaration
-:PROPERTIES:
-:CUSTOM_ID: Declaration_of_the_bars-Bottom_bar_declaration-8504b5ec
-:END:
-As described above, we will once again have to declare our bar with an equally unimaginative but explicit name.
-#+BEGIN_SRC conf-windows
- [bar/bottom]
-#+END_SRC
-
-*** Positioning
-:PROPERTIES:
-:CUSTOM_ID: Declaration_of_the_bars-Bottom_bar_declaration-Positioning-b1883756
-:END:
-The variables are the same as above, but two of them will be slightly modified:
-#+BEGIN_SRC conf-windows
- bottom = true
- border-size = 0
- <>
-#+END_SRC
-
-#+NAME: position-bar-bottom
-#+BEGIN_SRC conf-windows :exports none :tangle no
- width = 100%
- height = 22
- radius = 0.0
- fixed-center = true
-#+END_SRC
-When it comes to the bottom bar, I prefer to have it fit my outputs, without any margin around it. And of course, I have to declare it as being at the bottom of the screen, hence these modifications. As regards the padding of our modules, their own margins, and the screen output, they aren’t modified.
-#+BEGIN_SRC conf-windows
- <>
- <>
- <>
-#+END_SRC
-However, we do display the system tray on this bottom bar at its right. It has no padding and it is not detached from the bar (this allows the bar to be displayed under the icons of the system tray), and their maximum size was chosen so they are well visible without being too big.
-#+BEGIN_SRC conf-windows
- tray-position = right
- tray-padding = 0
- tray-detached = false
- tray-maxsize = 15
-#+END_SRC
-
-*** Colors and display
-:PROPERTIES:
-:CUSTOM_ID: Declaration_of_the_bars-Bottom_bar_declaration-Colors_and_display-854aae82
-:END:
-Nothing changes from the top bar, all the variables stay with the same values. See [[#Declaration_of_the_bars-Bottom_bar_declaration-Colors_and_display-854aae82][Colors and display]] of the top bar for more information.
-#+BEGIN_SRC conf-windows
- <>
- <>
- <>
-#+END_SRC
-
-*** Fonts and locale
-:PROPERTIES:
-:CUSTOM_ID: Declaration_of_the_bars-Bottom_bar_declaration-Fonts_and_locale-67459d62
-:END:
-Again, nothing changes from the top bar, so for more info on what’s going on, see [[#Declaration_of_the_bars-Top_bar_declaration-Fonts_and_locale-70a25466][Fonts and locale]] of the top bar.
-#+BEGIN_SRC conf-windows
- <>
- <>
-#+END_SRC
-
-*** Modules
-:PROPERTIES:
-:CUSTOM_ID: Declaration_of_the_bars-Bottom_bar_declaration-Modules-702b21fc
-:END:
-Now, we can get to something interesting again: modules. This bar has a lot more modules than the top bar. Here is the list of the modules we have on the bottom bar:
-#+NAME: table-modules-bottom
-| Module name | Position | Brief description |
-|----------------+----------+---------------------------------|
-| mpd | left | MPD status indicator |
-| filesystem | right | Free storage in our filesystem |
-| wlan | right | Name of the active WiFi network |
-| eth | right | Local address on Ethernet |
-| volume | right | System volume |
-| backlight-acpi | right | Screen backlight |
-| cpu | right | CPU usage |
-| memory | right | RAM usage |
-| temperature | right | CPU temperature |
-| custom-battery | right | Battery usage |
-Here’s the corresponding configuration:
-#+ATTR_LATEX: :options breaklines
-#+BEGIN_SRC conf-windows
- <>
-#+END_SRC
-All these modules will be explained below.
-
-As you may have noticed, no modules will be displayed in the middle of this bar.
-
-* Modules
-:PROPERTIES:
-:CUSTOM_ID: Modules-2e1a51bc
-:END:
-Before we begin to describe the different modules, I would like to point out something that will be repeated multiple times if I don’t talk about it right now: for each module, it is possible to declare the foreground and background color of the prefix of the modules, as well as the underline color and the padding of the module. I like these parameters to be rather consistent, so the code block you will see below will often be reused. The colors refer to the colors declared earlier, and the padding is minimal.
-#+NAME: mod-prefix-col
-#+BEGIN_SRC conf-windows :tangle no
- format-prefix-foreground = ${colors.foreground-alt}
- format-prefix-underline = ${colors.secondary}
- format-underline = ${colors.secondary}
- format-padding = 1
-#+END_SRC
-
-** Hardware
-:PROPERTIES:
-:CUSTOM_ID: Modules-Hardware-26426ebd
-:END:
-*** Battery
-:PROPERTIES:
-:CUSTOM_ID: Modules-Hardware-Battery-299f2e42
-:END:
-This module allows the user to get a battery widget among the polybar modules that will also send a notification to the user if the battery level drops below a certain value. This module relies on ~polybar-another-battery~ ([[https://github.com/drdeimos/polybar_another_battery][link]]) and its generated binary ~polybar-ab~ which should be in the ~$PATH~.
-
-The first line of the module declaration lets the user name the module however they want. In this case, the name is ~custom-battery~.
-#+BEGIN_SRC conf-windows
- [module/custom-battery]
-#+END_SRC
-Since it is not a core module, we have to declare it as a custom script so polybar knows what to do with it.
-#+BEGIN_SRC conf-windows
- type = custom/script
-#+END_SRC
-We now can specify the script execution, and whether or not the script will be continuously outputting something. In our case, the answer to this last question is yes.
-#+BEGIN_SRC conf-windows
- exec = polybar-ab -polybar -thr 10
- tail = true
-#+END_SRC
-The ~-thr 10~ specifies the threshold for polybar-ab at which it should warn the user about the battery level of the computer.
-
-Of course, users on desktop computers won’t need this module which is aimed at laptop users. Feel free to remove it if you do not need it.
-
-*** Filesystem
-:PROPERTIES:
-:CUSTOM_ID: Modules-Hardware-Filesystem-26f0a3c6
-:END:
-This module allows to display information about our filesystem, including (and this is what I use this module for) displaying the used space and remaining space on different mount points. This module is an internal module to polybar, so let’s declare it as such:
-#+BEGIN_SRC conf-windows
- [module/filesystem]
- type = internal/fs
-#+END_SRC
-We can specify how often the filesystem is to be checked with the variable ~interval~. I prefer it not to check it too often in order to not ping too often my drives, but I want it to be often enough so it is somewhat responsive. This is why I settled on a 20 seconds interval.
-#+BEGIN_SRC conf-windows
- interval = 20
-#+END_SRC
-We now have to indicate where our different filesystems are mounted. In the case of my main computer /Marpa/, I have two partitions, the root partition and the home partition. But on my travel laptop, I only have the root partition, hence the usage of the below Elisp code that determines based on the computer it is running whether or not the second mount point to my home partition should be included.
-#+NAME: include-home-partition
-#+BEGIN_SRC emacs-lisp :tangle no :exports code
- (if (string= system-name "Marpa")
- "mount-1 = /home")
-#+END_SRC
-
-#+BEGIN_SRC conf-windows
- mount-0 = /
- <>
-#+END_SRC
-Now we can set the format of our module. There are two mains formats, one for mounted and one for unmounted mountpoints. For both, we’ll simply use their label.
-#+BEGIN_SRC conf-windows
- format-mounted =
- format-unmounted =
-#+END_SRC
-When it comes to the mounted partition, we want to display the name of the mountpoint and how used it is, both in terms of gigabytes and percentage.
-#+BEGIN_SRC conf-windows
- label-mounted = 💽 %mountpoint%: %used%/%total% (%percentage_used%%)
- label-mounted-foreground = ${colors.foreground}
- label-mounted-underline = ${colors.secondary}
-#+END_SRC
-If the volume is unmounted (which should be worrying considering the mountpoints chosen), then we’ll simply have a message telling us about that, and the foreground color will use the alternative foreground color described earlier.
-#+BEGIN_SRC conf-windows
- label-unmounted = %mountpoint% not mounted
- label-unmounted-foreground = ${colors.foreground-alt}
-#+END_SRC
-
-*** Xbacklight
-:PROPERTIES:
-:CUSTOM_ID: Modules-Hardware-Xbacklight-2901c504
-:END:
-This module is used in order to display the level of brightness of a screen. It is not used by itself, but rather by other modules, such as [[#Modules-Hardware-ACPI_backlight-9eaeaa79][ACPI backlight]]. First of all, this module is an internal module for xbacklight. It will also display the brightness percentage, prefixed by a sun emoji. Lastly, it will be underlined by a green line.
-#+BEGIN_SRC conf-windows
- [module/xbacklight]
- type = internal/xbacklight
- format =
- label = %percentage%%
- format-prefix = "🌞 "
- format-underline = #9f78e1
-#+END_SRC
-
-*** ACPI backlight
-:PROPERTIES:
-:CUSTOM_ID: Modules-Hardware-ACPI_backlight-9eaeaa79
-:END:
-This module indicates the backlight level of a screen thanks to the ACPI Linux module. There isn’t much to tell about the module itself other than it inherits the module described above, [[#Modules-Hardware-Xbacklight-2901c504][xbacklight]]. It also sets which driver should be used, in this case the ~intel_backlight~ driver.
-#+BEGIN_SRC conf-windows
- [module/backlight-acpi]
- inherit = module/xbacklight
- type = internal/backlight
- card = intel_backlight
-#+END_SRC
-
-*** CPU
-:PROPERTIES:
-:CUSTOM_ID: Modules-Hardware-CPU-365dcb98
-:END:
-This module indicates how much of the CPU is being used. As shown below, I made it so we can see the load on each core. The first thing to do is to declare the module as an internal module dedicated to the CPU.
-#+BEGIN_SRC conf-windows
- [module/cpu]
- type = internal/cpu
-#+END_SRC
-
-Now, we can set the refresh rate in seconds of the module. I like it at two seconds:
-#+BEGIN_SRC conf-windows
- interval = 2
-#+END_SRC
-
-Now, let’s declare what will be displayed. The format will be a computer emoji followed by ramp characters.
-#+BEGIN_SRC conf-windows
- format =
- format-prefix = "💻 "
- label = %percentage%%
- ramp-coreload-0 = ▁
- ramp-coreload-1 = ▂
- ramp-coreload-2 = ▃
- ramp-coreload-3 = ▄
- ramp-coreload-4 = ▅
- ramp-coreload-5 = ▆
- ramp-coreload-6 = ▇
- ramp-coreload-7 = █
-#+END_SRC
-
-Finally, this module will be underlined in red.
-#+BEGIN_SRC conf-windows
- format-underline = #f90000
-#+END_SRC
-
-*** Memory
-:PROPERTIES:
-:CUSTOM_ID: Modules-Hardware-Memory-2f2f9475
-:END:
-Similarly to the CPU module, it is possible for Polybar to display the RAM load of the computer. As above, let’s declare this module as an internal module to Polybar:
-#+BEGIN_SRC conf-windows
- [module/memory]
- type = internal/memory
-#+END_SRC
-
-As the CPU module still, the refresh rate will be of two seconds.
-#+BEGIN_SRC conf-windows
- interval = 2
-#+END_SRC
-
-Its format will be the percentage of used RAM, prefixed by a disk emoji.
-#+BEGIN_SRC conf-windows
- format =
- format-prefix = "💿 "
- label = %gb_used%
-#+END_SRC
-
-Lastly, it will be underlined in green.
-#+BEGIN_SRC conf-windows
- format-underline = #4bffdc
-#+END_SRC
-
-*** Wlan
-:PROPERTIES:
-:CUSTOM_ID: Modules-Hardware-Wlan-3457f36b
-:END:
-It is possible for Polybar to display the name of the current WiFi network the computer is connected to. For that, we first need to declare the Wlan module as an internal module of Polybar.
-#+BEGIN_SRC conf-windows
- [module/wlan]
- type = internal/network
-#+END_SRC
-
-Now, we should set the name of the interface. As this depends on the hardware I am using, I am going to rely on the machine’s hostname and on some Elisp code to get this setting right.
-#+NAME: name-wlan-interface
-#+BEGIN_SRC emacs-lisp :exports code :tangle no
- (cond ((string= system-name "Marpa") "wlp8s0")
- ((string= system-name "gampo") "wlp3s0"))
-#+END_SRC
-
-#+BEGIN_SRC conf-windows
- interface = <>
-#+END_SRC
-
-The name of the current WiFi network will be refreshed every three seconds.
-#+BEGIN_SRC conf-windows
- interval = 3.0
-#+END_SRC
-
-The format of the module when connected to a network will the the display of the antenna emoji, followed by the name of the network. When disconnected, the module will simply be empty.
-#+BEGIN_SRC conf-windows
- format-connected =
- format-connected-prefix = "📶 "
- label-connected = %essid%
-#+END_SRC
-
-*** Ethernet
-:PROPERTIES:
-:CUSTOM_ID: Modules-Hardware-Ethernet-dc749304
-:END:
-Just like any other module, the ethernet module has to be declared as an internal module.
-#+BEGIN_SRC conf-windows
- [module/eth]
- type = internal/network
-#+END_SRC
-
-And just like the Wlan module, it requires an interface which can vary depending on the machine I am using, hence this piece of Elisp:
-#+NAME: name-eth-interface
-#+BEGIN_SRC emacs-lisp :exports code :tangle no
- (cond ((string= system-name "Marpa") "enp9s0")
- ((string= system-name "gampo") "enp0s25"))
-#+END_SRC
-
-#+BEGIN_SRC conf-windows
- interface = <>
-#+END_SRC
-
-The format of this module will be the local address of the computer on the network, and it will be prefixed by a desktop computer emoji. Meanwhile, when disconnected, the module won’t be visible.
-#+BEGIN_SRC conf-windows
- format-connected = <>
- format-connected-prefix = "🖥 "
- label-connected = %local_ip%
- format-disconnected =
-#+END_SRC
-
-The module will be underlined in green.
-#+BEGIN_SRC conf-windows
- format-connected-underline = #55aa55
-#+END_SRC
-
-*** Volume
-:PROPERTIES:
-:CUSTOM_ID: Modules-Hardware-Volume-ebf9f7a4
-:END:
-The volume module in Polybar is linked to its internal bindings to ALSA. Let’s declare it accordingly.
-#+BEGIN_SRC conf-windows
- [module/volume]
- type = internal/alsa
-#+END_SRC
-
-Its format is quite simple: if the audio is not muted, it is then prefixed with a speaker emoji, followed by the volume percentage.
-#+BEGIN_SRC conf-windows
- format-volume =
- format-volume-prefix = "🔈 "
- label-volume = %percentage%%
-#+END_SRC
-
-If the audio is muted, then the only thing the user will see is the muted speaker emoji followed by the text “muted”.
-#+BEGIN_SRC conf-windows
- format-muted-prefix = "🔇 "
- label-muted = muted
-#+END_SRC
-
-In any case, it will be underlined in green.
-#+BEGIN_SRC conf-windows
- format-volume-underline = #55aa55
-#+END_SRC
-
-*** Temperature
-:PROPERTIES:
-:CUSTOM_ID: Modules-Hardware-Temperature-a9f08cde
-:END:
-The temperature module checks the temperature of the CPU, and warns the user above a certain threshold of heat, in my case if my CPU is above 60°C.
-#+BEGIN_SRC conf-windows
- [module/temperature]
- type = internal/temperature
- thermal-zone = 0
- warn-temperature = 60
-#+END_SRC
-
-The format of the module is the thermometer emoji followed by the temperature of the CPU. If the CPU becomes too hot, the text will change color for the secondary foreground color.
-#+BEGIN_SRC conf-windows
- format =
- format-underline = #f50a4d
- format-warn =
- format-warn-underline = ${self.format-underline}
- format-prefix = "🌡 "
- format-warn-prefix = "🌡 "
-
- label = %temperature-c%
- label-warn = %temperature-c%
- label-warn-foreground = ${colors.secondary}
-#+END_SRC
-
-** Software
-:PROPERTIES:
-:CUSTOM_ID: Modules-Software-f6529189
-:END:
-*** Window title
-:PROPERTIES:
-:CUSTOM_ID: Modules-Software-Window_title-3f931641
-:END:
-This module’s aim is to simply provide the name of the currently focused window given by Xorg. This module is an internal module to polybar, that is to say it is built-in, and is of the type ~xwindow~. So, let’s declare the module accordingly, including the piece of common code declared at the beginning of the chapter:
-#+BEGIN_SRC conf-windows
- [module/xwindow]
- type = internal/xwindow
- <>
-#+END_SRC
-
-Now we can take care of the label, which is the actual text that will be displayed. In our case, we want the label to be the title of the current X window, hence the value of ~label~, and we don’t want it to be too long, though I’m not sure I’ve often seen window titles longer than 70 characters.
-#+BEGIN_SRC conf-windows
- label = %title%
- label-maxlen = 70
-#+END_SRC
-
-*** i3
-:PROPERTIES:
-:CUSTOM_ID: Modules-Software-i3-db36ddfb
-:END:
-Now comes the module for i3 interaction. Thanks to this module, it is possible to show which workspaces are active and focused, and it is possible to change workspaces by clicking on the ones displayed in the bar. First, let’s declare it; it is an internal module by the way.
-#+BEGIN_SRC conf-windows
- [module/i3]
- type = internal/i3
-#+END_SRC
-
-Now, let’s display only the workspaces that are on the current output. This means if a workspace is either inactive or on another screen or output, it won’t be displayed.
-#+BEGIN_SRC conf-windows
- pin-workspaces = true
-#+END_SRC
-
-We also want our workspaces to be sorted by number rather than by output.
-#+BEGIN_SRC conf-windows
- index-sort = true
-#+END_SRC
-
-I don’t want to be able to scroll through the workspaces when my mouse is hovering the module: when it happens, most of the time it was done accidentally. So let’s deactivate that. However, I sometimes like to click on them to switch from one another, so we’ll keep that activated.
-#+BEGIN_SRC conf-windows
- enable-scroll = false
- wrapping-scroll = false
- reverse-scroll = false
- enable-click = true
-#+END_SRC
-
-This parameters splits the workspaces’ name on ~:~. Let’s deactivate that.
-#+BEGIN_SRC conf-windows
- strip-wsnumbers = false
-#+END_SRC
-
-An on the topic of workspaces’ name, ~fuzzy-match~ allows the user to use fuzzy search for workspaces’ name when we will be applying custom names below. Not really useful since I only use the default workspaces’ name, but it’s good to have it enabled by default.
-#+BEGIN_SRC conf-windows
- fuzzy-match = true
-#+END_SRC
-
-The label format is described first by its label, but also by one of its three possible modes: focused, visible or unfocused. These will be discussed later, but for now let’s simply set our format.
-#+begin_src conf-windows
- format =
-#+end_src
-
-We also wand to set the label mode to be whichever mode the workspace described by polybar is in. This label will also have a padding of 2 pixels, and the text will be written in white.
-#+begin_src conf-windows
- label-mode = %mode%
- label-mode-padding = 2
- label-mode-foreground = #000
-#+end_src
-
-**** Workspace icons
-:PROPERTIES:
-:CUSTOM_ID: Modules-Software-i3-Workspace_icons-89237191
-:END:
-Now, let’s name our workspaces. We can give them whatever name we want them to have, but I just like the aesthetics of Japanese characters, so let’s go with the kanji equivalent of the number of the workspaces.
-#+NAME: ws-names
-| workspace number | name |
-|------------------+------|
-| 1 | 一 |
-| 2 | 二 |
-| 3 | 三 |
-| 4 | 四 |
-| 5 | 五 |
-| 6 | 六 |
-| 7 | 七 |
-| 8 | 八 |
-| 9 | 九 |
-| 0 | 十 |
-
-Here are the corresponding configuration lines:
-#+BEGIN_SRC conf-windows
-<>
-#+END_SRC
-
-In case we create a workspace which isn’t named from ~0~ to ~9~, I want it to appear as is.
-#+begin_src conf-windows
- ws-icon-default = %index%
-#+end_src
-
-**** Focused workspaces
-:PROPERTIES:
-:CUSTOM_ID: Modules-Software-i3-Focused_workspaces-0ca3b93d
-:END:
-Now we can define the label itself. First, we will need to define the label when the workspace is focused. We’ll simply take the alternative background for the focused label, and the underline will be defined from Xrdb’s 8th color, with yellow as the fallback color. It will also have a two pixels padding. The text itself will be the dynamic icons declared above.
-#+begin_src conf-windows
- label-focused = %icon%
- label-focused-background = ${colors.background-alt}
- label-focused-underline = ${xrdb:color8:#ffff00}
- label-focused-padding = 2
-#+end_src
-
-**** Visible workspaces
-:PROPERTIES:
-:CUSTOM_ID: Modules-Software-i3-Visible_workspaces-4be78e50
-:END:
-The ~visible~ label is related to the ~focused~ labels since it is describing workspaces that can be seen, but are not currently focused, i.e. a workspace that appears on another screen than the one currently used so it is visible, but it isn’t focused. The difference with the ~unfocused~ workspaces is that the latter are neither focused nor visible. As you can see, we are simply using all of the declarations from above for the focused labels so we can ensure they appear the same way the focused labels do.
-#+begin_src conf-windows
- label-visible = ${self.label-focused}
- label-visible-background = ${self.label-focused-background}
- label-visible-underline = ${self.label-focused-underline}
- label-visible-padding = ${self.label-focused-padding}
-#+end_src
-
-**** Unfocused workspaces
-:PROPERTIES:
-:CUSTOM_ID: Modules-Software-i3-Unfocused_workspaces-13063042
-:END:
-When it comes to the unfocused label, there won’t be any custom background or underline, so we’ll just copy the two remaining lines from the focused labels for unfocused labels.
-#+begin_src conf-windows
- label-unfocused = %icon%
- label-unfocused-padding = 2
-#+end_src
-
-**** Urgent workspaces
-:PROPERTIES:
-:CUSTOM_ID: Modules-Software-i3-Urgent_workspaces-ed2bd93c
-:END:
-Lastly, we get our urgent workspaces: workspaces in which most of the time it’s just a popup that appeared or a software that finally launched itself while working on something else on another workspace. To make it a bit more unique, let’s declare its background as being the color 0 from xrdb, with some dark red as the fallback color. And as the other labels, the text will be the icon and it will have a two pixels padding.
-#+begin_src conf-windows
- label-urgent = %icon%
- label-urgent-background = ${xrdb:color0:#bd2c40}
- label-urgent-padding = 2
-#+end_src
-
-*** Mpd
-:PROPERTIES:
-:CUSTOM_ID: Modules-Software-Mpd-4b1ec78e
-:END:
-Mpd is a music server for GNU/Linux systems that interfaces will several front-ends, including ncmpcpp (the main one I use), ncmpcpp and mpc. It also interfaces with polybar thanks to some built in commands.
-
-First, let’s declare our module as an internal module.
-#+BEGIN_SRC conf-windows
- [module/mpd]
- type = internal/mpd
-#+END_SRC
-
-The next thing we want to do is set the label for the module: we will display both the title and the name of the artist of the song playing. The maximum length will be 70 characters.
-#+BEGIN_SRC conf-windows
- label-song = %title% - %artist%
- label-song-maxlen = 70
- label-song-ellipsis = true
-#+END_SRC
-
-While Mpd is online, the format of the module should be the control icons and then the song label.
-#+BEGIN_SRC conf-windows
- format-online =
- icon-prev = ⏭
- icon-stop = ⏹
- icon-play = ▶
- icon-pause = ⏸
- icon-next = ⏭
-#+END_SRC
-
-If Mpd is offline, then I would like to display a short messages that tells the user so.
-#+BEGIN_SRC conf-windows
- format-offline =
- label-offline = 🎵 mpd is offline
-#+END_SRC
-
-*** Date
-:PROPERTIES:
-:CUSTOM_ID: Modules-Software-Date-f7338626
-:END:
-This module is really simple: it gives the current date. It is an internal module, and as declared below, it updates every second:
-#+BEGIN_SRC conf-windows
- [module/date]
- type = internal/date
- interval = 1
-#+END_SRC
-
-The main date and time format is the standard one, following the ISO-8601 standard.
-#+BEGIN_SRC conf-windows
- date = %Y-%m-%d
- time = %H-%M-%S
-#+END_SRC
-
-It also has an alternative format which I occasionally use, which displays the date and time in the Japanese format.
-#+BEGIN_SRC conf-windows
- date-alt = %A %d, %B
- time-alt = %H:%M:%S
-#+END_SRC
-
-The format is quite simple: a clock emoji preceding the date and time.
-#+BEGIN_SRC conf-windows
- format-prefix = "🕑 "
- label = %date% %time%
-#+END_SRC
-
-This module is underlined in blue:
-#+BEGIN_SRC conf-windows
- format-underline = #0a6cf5
-#+END_SRC
-
-* Footnotes
-:PROPERTIES:
-:CUSTOM_ID: Footnotes-62d05520
-:END:
-
-[fn:1] [[https://github.com/polybar/polybar/wiki/Fonts][https://github.com/polybar/polybar/wiki/Fonts]]
-
-# LocalWords: Siji pixelsize Fira Mincho IPAMincho Unifont unifont fontformat
-# LocalWords: truetype antialias xwindow wlan eth acpi cpu
diff --git a/org/config/Deprecated/spacemacs.org b/org/config/Deprecated/spacemacs.org
deleted file mode 100644
index 3aff7fe..0000000
--- a/org/config/Deprecated/spacemacs.org
+++ /dev/null
@@ -1,5252 +0,0 @@
-#+title: Spacemacs Configuration
-#+setupfile: ../headers
-#+OPTIONS: unique-id:t
-#+HTML_HEAD_EXTRA:
-#+HTML_HEAD_EXTRA:
-#+HTML_HEAD_EXTRA:
-#+PROPERTY: header-args: :mkdirp yes :lexical t
-
-* Introduction
-:PROPERTIES:
-:CUSTOM_ID: Introduction-f1cbb8bb
-:END:
-#+begin_center
-*Before proceeding, be aware that I deprecated this i3 config on October 20th 2021, meaning I won’t update it anymore unless I use it again some day in the future. I will keep it on my website though.*
-#+end_center
-
-This file is the main source file for my Spacemacs configuration which
-contains most of the user code. It is exported thanks to Emacs’ code
-tangling from the original Org file which you can find on my dotfiles’
-repository[fn:1] if you are reading the web version of it. You can
-also find there my ~.spacemacs~[fn:2] and its code which isn’t part of
-the present file. As you can see in my ~.spacemacs~, at init-time, if
-Emacs detects the tangled configuration files are older than the Org
-file, then Emacs tangles them again, and then loads them.
-
-* Spacemacs layers and packages
-:PROPERTIES:
-:CUSTOM_ID: Spacemacs_layers_and_packages-6d318b87
-:header-args:emacs-lisp: :mkdirp yes :tangle ~/.emacs.spacemacs/private/spacemacs-layers.el :exports code :results silent :lexical t
-:END:
-#+BEGIN_SRC emacs-lisp :exports none
-;; -*- lexical-binding: t -*-
-#+END_SRC
-
-Here will be our layer configuration set. Everything here is set with a
-~setq-default~ in the ~dotspacemacs/layers~ function like so:
-#+BEGIN_SRC emacs-lisp :tangle no
-(defun dotspacemacs/layers ()
- (setq-default
- ;; configuration goes here
- ))
-#+END_SRC
-
-** General configuration
-:PROPERTIES:
-:CUSTOM_ID: Spacemacs_layers_and_packages-General_configuration-66b4311e
-:END:
-First, we need to tell Spacemacs which base distribution we are using. This is a
-layer contained in the directory ~+distribution~. For now, available
-distributions are ~spacemacs-base~ and ~spacemacs~ (the default one).
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-distribution 'spacemacs)
-#+END_SRC
-
-We can seet a lazy installation of layers —i.e. layers are installed only when a
-file with a supported type is opened. Possible values are:
-- ~all~ :: will lazy install any layer that support lazy installation even the
- layers listed in ~dotspacemacs-configuration-layers~
-- ~unused~ :: will lazy install only unused layers (i.e. layers not listed in
- the variable ~dotspacemacs-configuration-layers~)
-- ~nil~ :: disables the lazy installation feature and you have to explicitly
- list a layer in the variable ~dotspacemacs-configuration-layers~ to install
- it.
-The default value is ~unused~.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-enable-lazy-installation nil)
-#+END_SRC
-
-If the following variable is non-nil, Spacemacs will ask for confirmation before
-installing a layer lazily. The default value is ~t~.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-ask-for-lazy-installation t)
-#+END_SRC
-
-** Package management
-:PROPERTIES:
-:CUSTOM_ID: Spacemacs_layers_and_packages-Package_management-0add1a62
-:END:
-It is possible to indicate to Spacemacs a list of additional paths where to look
-for configuration layers. Paths must have a trailing slash, i.e.
-=~/.mycontribs/=. As you can see, I added only one:
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-configuration-layer-path
- '("~/fromGIT/emacs-packages"))
-#+END_SRC
-
-However, I do have additional packages I installed either from the Elpa or the
-Melpa. These are set in ~dotspacemacs-additional-packages~, a list of additional
-packages that will be installed without being wrapped in a layer. If I need some
-configuration for these packages, then I should consider creating a layer. I can
-also puth the configuration in ~dotspacemacs/user-config~. To use a local
-version of a package, use the ~:location~ property, for instance:
-#+BEGIN_SRC emacs-lisp :tangle no
-'(your-package :location "~/path/to/your-package/")
-#+END_SRC
-
-With the variable ~dotspacemacs-additional-packages~, it is possible to install
-extra packages which are not already included in any layers. Dependencies should
-be explicitly included as they won’t be resolved automatically. Here is a table
-of all the extra packages I use:
-#+NAME: extra-packages
-| name of the package | why is it installed |
-|----------------------------+--------------------------------------------------------|
-| caddyfile-mode | Major mode for editing Caddyfiles |
-| dired-git-info | Git information in Dired buffers |
-| diredfl | Extra font lock rules for a more colourful dired |
-| edit-indirect | edit region in separate buffer |
-| elcord | rich integration of Emacs in Discord |
-| eshell-syntax-highlighting | Syntax highlighting for Eshell |
-| info-colors | Extra colors for Emacs's Info-mode |
-| multiple-cursors | I don’t like the layer, I prefer this package alone |
-| ob-latex-as-png | Inline arbitrary LaTeX snippets as PNGs in Emacs |
-| org-sidebar | display on the side the outline of an Org buffer |
-| org-tree-slide | presentation tool for org-mode |
-| outorg | edit comments as Org-mode buffers |
-| ox-ssh | SSH config export for org-mode |
-| pinentry | enter a GPG password from Emacs |
-| nord-theme | An arctic, north-bluish clean and elegant Emacs theme. |
-| s | The long lost Emacs string manipulation library. |
-| sicp | Texinfo version of the [[https://mitpress.mit.edu/sites/default/files/sicp/index.html][SICP]] |
-| visual-fill-column | allow the use of ~fill-column~ in ~visual-line-mode~ |
-| wrap-region | easily wrap region with delimiters |
-| wttrin | weather in Emacs |
-| yasnippet-snippets | snippets for YaSnippet |
-
-#+name: make-extra-pkg
-#+begin_src emacs-lisp :var packages=extra-packages[,0] :tangle no :exports none
-(mapcar 'make-symbol packages)
-#+end_src
-
-#+begin_src emacs-lisp :noweb yes :exports none
-(setq-default dotspacemacs-additional-packages '<>)
-#+end_src
-
-It is possible to also list packages that cannot be updated:
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-frozen-packages '(helm-icons))
-#+END_SRC
-
-And to list packages which won’t be installed nor loaded:
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-excluded-packages '(company-tern))
-#+END_SRC
-
-Finally, it is possible to define the behaviour of Spacemacs when installing
-packages. Possible values are:
-- ~used-only~ :: installs only explicitly used packages and deletes any unused
- packages as well as their unused dependencies
-- ~used-but-keep-unused~ :: installs only the used packages but won’t delete
- unused ones
-- ~all~ :: installs *all* packages supported by Spacemacs and never uninstalls
- them.
-The default value is ~used-only~.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-install-packages 'used-only)
-#+END_SRC
-
-** Layers
-:PROPERTIES:
-:CUSTOM_ID: Spacemacs_layers_and_packages-Layers-36e1c90c
-:END:
-All layers are set one variable: ~dotspacemacs-configuration-layers~. This
-variable is a list of layers, some of them will have some custom variables.
-Typically, the variable will be set like so:
-#+BEGIN_SRC emacs-lisp :tangle no
-(setq-default dotspacemacs-configuration-layers
- '(emacs-lisp
- helm
- multiple-cursors
- org
- (shell :variables shell-default-height 30
- shell-default-position 'bottom)
- treemacs))
-#+END_SRC
-
-# Don’t delete this code block, it wraps the layers
-#+BEGIN_SRC emacs-lisp :exports none
-(setq-default dotspacemacs-configuration-layers '(
-#+END_SRC
-
-*** Checkers
-:PROPERTIES:
-:CUSTOM_ID: Spacemacs_layers_and_packages-Layers-Checkers-aefeae26
-:END:
-The two first checkers I use are for spell and syntax checking. ~spell-checking~
-is disabled by default, however it should auto-detect the dictionary to use.
-#+BEGIN_SRC emacs-lisp
-(spell-checking :variables
- spell-checking-enable-by-default nil
- spell-checking-enable-auto-dictionary t)
-syntax-checking
-#+END_SRC
-
-*** Completion
-:PROPERTIES:
-:CUSTOM_ID: Spacemacs_layers_and_packages-Layers-Completion-883e2b83
-:END:
-~auto-completion~ is a layer enabled in order to provide auto-completion to all
-supported language layers. It is set so that the =RET= key has no behavior with
-this layer, however the =TAB= key cycles between candidates displayed by the
-auto-completion toolbox. I also want the autocompletion to include snippets in
-the popup, and the content of the popup is sorted by usage. It is also disabled
-for two modes: magit and Org.
-#+BEGIN_SRC emacs-lisp
-(auto-completion :variables
- auto-completion-complete-with-key-sequence-delay 0.2
- auto-completion-enable-help-tooltip 'manual
- auto-completion-enable-sort-by-usage t
- :disabled-for
- org
- git)
-#+END_SRC
-
-~helm~ is also enabled, with its header disabled.
-#+BEGIN_SRC emacs-lisp
-(helm :variables helm-no-header t)
-#+END_SRC
-
-*** Email
-:PROPERTIES:
-:CUSTOM_ID: Spacemacs_layers_and_packages-Layers-Email-67c16308
-:END:
-I use as my daily Email client ~mu4e~, so let’s enable it and tell Emacs where
-mu4e is installed. I also tell mu4e to use maildirs extensions, use async
-operations, where to keep attachments, and enable the mu4e modeline.
-#+BEGIN_SRC emacs-lisp
-(mu4e :variables
- mu4e-installation-path "/usr/share/emacs/site-lisp"
- mu4e-use-maildirs-extension t
- mu4e-enable-mode-line t
- mu4e-attachment-dir "~/Documents/mu4e")
-#+END_SRC
-
-*** Emacs
-:PROPERTIES:
-:CUSTOM_ID: Spacemacs_layers_and_packages-Layers-Emacs-8e976e5c
-:END:
-The first layer enabled in this category is ~better-defaults~. I also made it so
-that when a command equivalent to ~C-a~ or ~C-e~ is pressed, the cursor will
-respectively first move to the beginning of code first before going past the
-indentation and to the end of the code before going to the end of the line
-before going over the end of the comments on the same line.
-#+BEGIN_SRC emacs-lisp
-(better-defaults :variables
- better-defaults-move-to-beginning-of-code-first t
- better-defaults-move-to-end-of-code-first t)
-#+END_SRC
-
-I also enabled ~ibuffer~ and made it so that buffers are sorted by projects.
-#+BEGIN_SRC emacs-lisp
-(ibuffer :variables
- ibuffer-group-buffers-by 'projects)
-#+END_SRC
-
-Most important of all, the ~org~ layer is also enabled. I enabled support for
-Epub exports, Github, Reveal.JS exports, and sticky headers. Project support is
-also enabled through files named ~TODOs.org~. I also set the org-download folder
-for images in =~/Pictures/org/=, and I set the =RET= key to follow org links if
-the cursor is on one.
-#+BEGIN_SRC emacs-lisp
-(org :variables
- org-enable-epub-support t
- org-enable-github-support t
- org-enable-hugo-support t
- org-enable-reveal-js-support t
- org-enable-sticky-header t
- org-enable-appear-support t
- spaceline-org-clock-p t
- org-projectile-file "TODOs.org"
- org-download-image-dir "~/Pictures/org/"
- org-return-follows-link t)
-#+END_SRC
-
-The ~semantic~ layer is also enabled.
-#+BEGIN_SRC emacs-lisp
-semantic
-#+END_SRC
-
-*** File trees
-:PROPERTIES:
-:CUSTOM_ID: Spacemacs_layers_and_packages-Layers-File_trees-5b6ed3e4
-:END:
-In this category, I only enabled one layer: ~treemacs~. In this layer, I set is
-so that treemacs syncs with my current buffer, and it automatically refreshes
-its buffer when there is a change in the part of the file system shown by
-treemacs.
-#+BEGIN_SRC emacs-lisp
-(treemacs :variables
- treemacs-use-follow-mode t
- treemacs-use-filewatch-mode t)
-#+END_SRC
-
-*** Fonts
-:PROPERTIES:
-:CUSTOM_ID: Spacemacs_layers_and_packages-Layers-Fonts-11de8977
-:END:
-In this category, again, one layer is enabled: ~unicode-fonts~. This layer
-addssupport for the ~unicode-fonts~ package.
-#+BEGIN_SRC emacs-lisp
-(unicode-fonts :variables
- unicode-fonts-enable-ligatures t
- unicode-fonts-ligature-modes '(prog-mode)
- unicode-fonts-ligature-set '("|||>" "<|||" "<==>" "" "---" "-<<"
- "<~~" "<~>" "<*>" "<||" "<|>" "<$>" "<==" "<=>" "<=<" "<->"
- "<--" "<-<" "<<=" "<<-" "<<<" "<+>" ">" "###" "#_(" "..<"
- "..." "+++" "/==" "///" "_|_" "www" "&&" "^=" "~~" "~@" "~="
- "~>" "~-" "**" "*>" "*/" "||" "|}" "|]" "|=" "|>" "|-" "{|"
- "[|" "]#" "::" ":=" ":>" ":<" "$>" "==" "=>" "!=" "!!" ">:"
- ">=" ">>" ">-" "-~" "-|" "->" "--" "-<" "<~" "<*" "<|" "<:"
- "<$" "<=" "<>" "<-" "<<" "<+" "" "#{" "#[" "#:" "#=" "#!"
- "##" "#(" "#?" "#_" "%%" ".=" ".-" ".." ".?" "+>" "++" "?:"
- "?=" "?." "??" ";;" "/*" "/=" "/>" "//" "__" "~~" "(*" "*)"
- "\\\\" "://"))
-#+END_SRC
-
-*** Fun
-:PROPERTIES:
-:CUSTOM_ID: Spacemacs_layers_and_packages-Layers-Fun-0728c04c
-:END:
-In this category, I only enabled two layers: ~selectric~ and ~xkcd~.
-#+BEGIN_SRC emacs-lisp
-selectric xkcd
-#+END_SRC
-
-*** Internationalization
-:PROPERTIES:
-:CUSTOM_ID: Spacemacs_layers_and_packages-Layers-Internationalization-69601ff8
-:END:
-In this category, I enabled the ~keyboard-layout~ layer to enable compatibility
-with the bépo layout. This layer, however, is disabled for magit, Dired and eww.
-#+BEGIN_SRC emacs-lisp
-(keyboard-layout :variables
- kl-layout 'bepo
- kl-disabled-configurations '(magit dired eww))
-#+END_SRC
-
-*** Programming languages
-:PROPERTIES:
-:CUSTOM_ID: Spacemacs_layers_and_packages-Layers-Programming_languages-4c318b81
-:END:
-**** Domain-specific (DSLs)
-:PROPERTIES:
-:CUSTOM_ID: Spacemacs_layers_and_packages-Layers-Programming_languages-Domain-specific_(DSLs)-2c919937
-:END:
-In this category, I enabled support for the ~major-modes~ layer for the Arch
-Linux PKGBUILDs support, ~emacs-lisp~ and ~scheme~ layers, support for the CSV
-format with the ~csv~ layer, the ~yaml~ language, shell scripting languages and
-support for the ~dot~ tool with the ~graphviz~ layer.
-#+BEGIN_SRC emacs-lisp
-major-modes emacs-lisp scheme graphviz yaml shell-scripts
-#+END_SRC
-
-I also added support for HTML and CSS with the ~html~ layer, with the web
-formatting tool set to ~web-beautify~, and the LSP layer compatibility enabled
-for CSS, less, SCSS and HTML.
-#+BEGIN_SRC emacs-lisp
-(html :variables
- web-fmt-tool 'web-beautify
- css-enable-lsp t
- less-enable-lsp t
- scss-enable-lsp t
- html-enable-lsp t)
-#+END_SRC
-
-The ~json~ layer is also enabled, with the format tool set to ~web-beautify~.
-#+BEGIN_SRC emacs-lisp
-(json :variables
- json-fmt-tool 'web-beautify)
-#+END_SRC
-
-The LaTeX layer has also been enabled, with its default compiler set to XeLaTeX.
-I also enabled the auto-fill feature, the folding capacity and the “magic”
-symbols.
-#+BEGIN_SRC emacs-lisp
-(latex :variables
- latex-build-command "xelatex"
- latex-enable-auto-fill t
- latex-enable-folding t
- latex-enable-magic t)
-#+END_SRC
-
-The Markdown layer has been enabled, with support for live preview with ~vmd~,
-and and automatic MMM-mode generation for C, C++, Python, Rust and Emacs Lisp.
-#+BEGIN_SRC emacs-lisp
-(markdown :variables
- markdown-live-preview-engine 'vmd
- markdown-mmm-auto-modes '("c"
- "c++"
- "python"
- "rust"
- ("elisp" "emacs-lisp")))
-#+END_SRC
-
-PlantUML is a very useful DSL for creating UML diagrams from some text
-description. As you can see below, this layer will be enabled, both as a
-standalone mode for opening ~.pum~ files, but also for org-mode code blocks.
-#+BEGIN_SRC emacs-lisp
-(plantuml :variables
- plantuml-jar-path "~/.local/bin/plantuml.jar"
- org-plantuml-jar-path "~/.local/bin/plantuml.jar")
-#+END_SRC
-
-#+BEGIN_SRC emacs-lisp
-(bibtex :variables
- org-ref-default-bibliography '("~/Documents/Papers/references.bib")
- org-ref-pdf-directory "~/Documents/Papers"
- org-ref-bibliography-notes "~/Documents/Papers/notes.org")
-#+END_SRC
-
-#+BEGIN_SRC emacs-lisp
-csv
-#+END_SRC
-
-**** Frameworks
-:PROPERTIES:
-:CUSTOM_ID: Spacemacs_layers_and_packages-Layers-Programming_languages-Frameworks-f7c21585
-:END:
-Only one framework support has been enabled so far, and is is for the Django
-framework.
-#+BEGIN_SRC emacs-lisp
-django
-#+END_SRC
-
-**** General-purpose
-:PROPERTIES:
-:CUSTOM_ID: Spacemacs_layers_and_packages-Layers-Programming_languages-General-purpose-1ed71a5b
-:END:
-Among the layers I activated, the only one without any specific configuration is
-the ~asm~ layer for the Assembly language.
-#+BEGIN_SRC emacs-lisp
-asm
-#+END_SRC
-
-Next, you can find the C/C++ layer for which I set the default language for ~.h~
-files to be C. I also enabled support for subprojects and organization of the
-include directives on a file save. I also set a couple of LSP-related variables,
-such as the LSP executable for C/C++ for its CCLS backend and some highlight
-variables.
-#+BEGIN_SRC emacs-lisp
-(c-c++ :variables
- c-c++-default-mode-for-headers 'c-mode
- c-c++-adopt-subprojects t
- c-c++-enable-c++11 t
- c-c++-backend 'lsp-clangd
- c-c++-lsp-enable-semantic-highlight t
- c-c++-lsp-semantic-highlight-method 'overlay
- c-c++-lsp-semantic-highlight-rainbow t
- c++-enable-organize-includes-on-save t)
-#+END_SRC
-
-Dart has also been enabled, with a custom path to the SDK of the Dart server,
-and to the LSP server of Dart.
-#+BEGIN_SRC emacs-lisp
-(dart :variables
- lsp-dart-project-sdk-dir "/opt/dart-sdk/"
- lsp-dart-sdk-dir "/opt/dart-sdk/")
-#+END_SRC
-
-When it comes to the Python layer, I set its backend and formatter to be bound
-to the LSP layer. Its fill columnn was also set to 80 characters, imports are
-sorted on save, and the tests can be run using either nose.el or pytest.
-#+BEGIN_SRC emacs-lisp
-(python :variables
- python-fill-column 80
- python-test-runner '(pytest nose))
-#+END_SRC
-
-With the Rust layer, the only custom configuration set is the backend being
-bound to the LSP layer.
-#+BEGIN_SRC emacs-lisp
-(rust :variables rust-backend 'lsp)
-#+END_SRC
-
-As regards the JavaScript layer, I set its backend to the LSP layer, and bound
-its format tool to ~web-beautify~ and its REPL is browser-based. I also want to
-include ~node_modules/.bin~ to be automatically added to the buffer local
-~exec_path~.
-#+BEGIN_SRC emacs-lisp
-(javascript :variables
- javascript-backend 'lsp
- javascript-fmt-tool 'web-beautify
- javascript-repl 'skewer
- node-add-modules-path t)
-#+END_SRC
-
-Alternatively, I also use Typescript which is a sort of better Javascript as it
-should have been, with the LSP backend.
-#+BEGIN_SRC emacs-lisp
-(typescript :variables
- typescript-backend 'lsp)
-#+END_SRC
-
-I am also currently using the Awesome window manager which requires the Lua
-programming language, so here it is.
-#+BEGIN_SRC emacs-lisp
-(lua :variables
- lua-backend 'lsp-emmy
- lua-lsp-emmy-jar-path "~/.config/awesome/EmmyLua-LS-all.jar"
- lua-lsp-emmy-java-path "java"
- lua-lsp-emmy-enable-file-watchers t)
-#+END_SRC
-
-#+BEGIN_SRC emacs-lisp
-(php :variables php-backend 'lsp)
-#+END_SRC
-
-*** Readers
-:PROPERTIES:
-:CUSTOM_ID: Spacemacs_layers_and_packages-Layers-Readers-65e8e4ae
-:END:
-**** Epub and Pdf readers
-:PROPERTIES:
-:CUSTOM_ID: Spacemacs_layers_and_packages-Layers-Readers-Epub_and_Pdf_readers-0ef6688f
-:END:
-In this category, only the ~epub~ and ~pdf~ layers are enabled without any
-special configuration, so I can read these files from Emacs directly.
-#+BEGIN_SRC emacs-lisp
-epub pdf
-#+END_SRC
-
-**** Elfeed
-:PROPERTIES:
-:CUSTOM_ID: Spacemacs_layers_and_packages-Layers-Readers-Elfeed-78877179
-:END:
-Elfeed is an Emacs feeed and RSS reader which can be managed through org files.
-Actually, through only one file in my case, located in my =~/org= directory.
-#+BEGIN_SRC emacs-lisp
-(elfeed :variables
- rmh-elfeed-org-files '("~/org/elfeed.org"))
-#+END_SRC
-
-*** Version control
-:PROPERTIES:
-:CUSTOM_ID: Spacemacs_layers_and_packages-Layers-Version_control-bc8e286a
-:END:
-Only the ~git~ layer is enabled in this category.
-#+BEGIN_SRC emacs-lisp
-git
-#+END_SRC
-
-*** Themes
-:PROPERTIES:
-:CUSTOM_ID: Spacemacs_layers_and_packages-Layers-Themes-d88d1225
-:END:
-Here, the ~colors~ layer is the only one enabled. It activates support for
-identifiers colorization, and strings representing colors.
-#+BEGIN_SRC emacs-lisp
-colors
-#+END_SRC
-
-*** Tools
-:PROPERTIES:
-:CUSTOM_ID: Spacemacs_layers_and_packages-Layers-Tools-e57e405e
-:END:
-In this category, the first layer to be enabled is the CMake layer for which I
-enabled support for the ~cmake-ide~ package.
-#+BEGIN_SRC emacs-lisp
-(cmake :variables
- cmake-enable-cmake-ide-support t)
-#+END_SRC
-
-Next, we have the Docker, Nginx, Pass (the standard Unix password manager),
-Prettier, Systemd, Meson, Imenu-list, Web-beautify, Dap, and Helpful.
-#+BEGIN_SRC emacs-lisp
-dap docker helpful imenu-list meson nginx pass prettier systemd web-beautify
-#+END_SRC
-
-Of course, let’s not forget about the awesome LSP layer:
-#+BEGIN_SRC emacs-lisp
-(lsp :variables lsp-lens-enable t
- lsp-use-lsp-ui t
- lsp-rust-server 'rust-analyzer)
-#+END_SRC
-
-We also have the RestClient layer enabled for which I enabled the Org
-compatibility support.
-#+BEGIN_SRC emacs-lisp
-(restclient :variables
- restclient-use-org t)
-#+END_SRC
-
-LanguageTool works with Flyspell and will check for grammatical issues in my
-english texts.
-#+BEGIN_SRC emacs-lisp
-(languagetool :variables
- langtool-default-language "en-US"
- languagetool-show-error-on-jump t
- langtool-java-classpath "/usr/share/languagetool:/usr/share/java/languagetool/*")
-#+END_SRC
-
-
-And finally, we also have the Shell layer for which I specified its default
-height when spawning at the bottom of the screen should be 40 lines high, and
-the default shell to invoke is Eshell.
-#+BEGIN_SRC emacs-lisp
-(shell :variables
- shell-default-height 40
- shell-default-position 'bottom
- shell-default-shell 'eshell)
-#+END_SRC
-
-*** Web Services
-:PROPERTIES:
-:CUSTOM_ID: Spacemacs_layers_and_packages-Layers-Web_Services-c2888251
-:END:
-In this category, I have only enabled a layer for Twitter support.
-#+BEGIN_SRC emacs-lisp
-twitter
-#+END_SRC
-
-*** Custom layers
-:PROPERTIES:
-:CUSTOM_ID: Spacemacs_layers_and_packages-Layers-Custom_layers-69473533
-:END:
-Lastly, one custom layers have been enabled: my custom layer for conlanging
-tools.
-#+BEGIN_SRC emacs-lisp
-conlanging
-#+END_SRC
-
-# Don’t delete this code block, it wraps the layers
-#+BEGIN_SRC emacs-lisp :exports none
-))
-#+END_SRC
-
-* Init
-:PROPERTIES:
-:header-args:emacs-lisp: :mkdirp yes :tangle ~/.emacs.spacemacs/private/spacemacs-init.el :exports code :results silent :lexical t
-:CUSTOM_ID: Init-99a4b561
-:END:
-#+BEGIN_SRC emacs-lisp :exports none
-;; -*- lexical-binding: t -*-
-#+END_SRC
-
-The ~dotspacemacs/init~ function is the one called at the very begining of the
-Spacemacs startup, before any kind of configuration, including the layer
-configuration. Only the values of the Spacemacs settings should be modified
-here. By default, every values are set in a ~setq-default~ sexp, and they
-represent all the supported Spacemacs settings. Hence, the function looks like
-this:
-#+BEGIN_SRC emacs-lisp :tangle no
-(defun dotspacemacs/init ()
- (setq-default
- ;; default Spacemacs configuration here
- ))
-#+END_SRC
-
-** Handling my Spacemacs litterate config
-:PROPERTIES:
-:header-args:emacs-lisp: :tangle no :exports code :results silent :lexical t
-:CUSTOM_ID: Init-Handling-my-Spacemacs-litterate-config-679170db
-:END:
-Just before we get onto the usual content of the ~dotspacemacs/init~ function
-you would find in a typical Spacemacs installation, I would like to talk a bit
-about how I manage writing a litterate config for Spacemacs and ensure Emacs
-starts with an up-to-date configuration from said litterate config. For that, I
-actually declared a couple of variables:
-#+BEGIN_SRC emacs-lisp
-(defvar phundrak--dotspacemacs-src-dir "~/.emacs.spacemacs/private/"
- "Directory for my exported Elisp configuration files")
-(defvar phundrak--dotspacemacs-src "~/org/config/emacs.org"
- "My litterate config file for Emacs")
-(defvar phundrak--dotspacemacs-si (concat phundrak--dotspacemacs-src-dir "spacemacs-init"))
-(defvar phundrak--dotspacemacs-sl (concat phundrak--dotspacemacs-src-dir "spacemacs-layers"))
-(defvar phundrak--dotspacemacs-uc (concat phundrak--dotspacemacs-src-dir "user-config"))
-(defvar phundrak--dotspacemacs-ui (concat phundrak--dotspacemacs-src-dir "user-init"))
-(defvar phundrak--dotspacemacs-files (list phundrak--dotspacemacs-si phundrak--dotspacemacs-sl
- phundrak--dotspacemacs-uc phundrak--dotspacemacs-ui))
-#+END_SRC
-I also declared the following function that tells me if my Elisp files are more
-recent than my ~emacs.org~ file. The ~compiled?~ argument lets me compare either
-the ~.el~ files if it is ~nil~, or the ~.elc~ files if it is ~t~.
-#+BEGIN_SRC emacs-lisp
-(defun phundrak-update-config-files-p (&optional compiled?)
- "Verify if any of my exported Elisp configuration files are
-newer than my litterate configuration.
-
-If `COMPILED?' is `t', check the `.elc' files instead of the
-`.el' files."
- (catch 'ret
- (dolist (file phundrak--dotspacemacs-files)
- (when (file-newer-than-file-p phundrak--dotspacemacs-src
- (format "%s.%s"
- file
- (if compiled? "elc" "el")))
- (throw 'ret t)))))
-#+END_SRC
-
-Now I know a couple of my files that get exported by this document. If I compare
-how recent these files are compared to my litterate config, I know if Emacs
-missed tangling its configuration before launching, so if any of my ~si~, ~sl~,
-~uc~, or ~ui~ files are older than my ~emacs.org~, then I’ll tangle the latter;
-and since my user config is growing longer and longer, I want Emacs to be able
-to parse it fast next time it boots, so let’s compile my exported ~.el~ files!
-#+BEGIN_SRC emacs-lisp
-(when (or (file-newer-than-file-p phundrak--dotspacemacs-src (concat phundrak--dotspacemacs-si ".el"))
- (file-newer-than-file-p phundrak--dotspacemacs-src (concat phundrak--dotspacemacs-sl ".el"))
- (file-newer-than-file-p phundrak--dotspacemacs-src (concat phundrak--dotspacemacs-ui ".el"))
- (file-newer-than-file-p phundrak--dotspacemacs-src (concat phundrak--dotspacemacs-uc ".el")))
- (message "Exporting new Emacs configuration from spacemacs.org through org-babel...")
- (with-temp-buffer
- (shell-command (format "emacs -Q --batch %s %s %s"
- "--eval \"(require 'ob-tangle)\""
- "--eval \"(setq org-confirm-babel-evaluate nil)\""
- (format "--eval '(org-babel-tangle-file \"%s\")'"
- phundrak--dotspacemacs-src))
- (current-buffer)))
- (message "Exporting new Emacs configuration from spacemacs.org through org-babel...done")
- (with-temp-buffer
- (byte-recompile-directory phundrak--dotspacemacs-src-dir
- 0 t)))
-#+END_SRC
-All that’s left to do in the Spacemacs functions is to call ~load~ on ~si~,
-~sl~, ~uc~, and ~ui~. Be aware this sub-chapter won’t be tangled, so it might
-not be up to date with the [[https://labs.phundrak.com/phundrak/dotfiles/src/branch/master/.spacemacs][actual dotspacemacs file]]. Please check it just in
-case something changed and I forgot to update this part of ~emacs.org~.
-
-** Emacs with pdumper
-:PROPERTIES:
-:CUSTOM_ID: Init-Emacs_with_pdumper-f24ab30b
-:END:
-It is possible to compile Emacs 27 from source with support for the portable
-dumper, as shown in Spacemacs’ ~EXPERIMENTAL.org~ file. I do not use this
-feature yet, as I am still on Emacs 26 provided from Arch Linux’s repositories,
-so I’ll disable the Spacemacs support for this feature. The default value of
-this variable is ~nil~.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-enable-emacs-pdumper t)
-#+END_SRC
-
-In case the support for pdumper was enabled, Spacemacs needs to know the name of
-the Emacs executable which supports such a feature. The executable must be in
-the user’s ~PATH~. By default, the value of the variable is ~"emacs"~.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-emacs-pdumper-executable-file "emacs")
-#+END_SRC
-
-And finally, we can name the Spacemacs dump file. This is the file that will be
-created by the portable dumper in the cache directory under the ~dumps~
-sub-directory. To load it when starting Emacs, the parameter ~--dump-file~
-should be added when invoking Emacs 27.1 executable from the command line, for
-instance:
-#+BEGIN_SRC sh :tangle no :exports code
-./emacs --dump-file=~/.emacs.spacemacs/.cache/dumps/spacemacs.pdmp
-#+END_SRC
-
-The default value of this variable is ~"spacemacs.pdmp"~.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-emacs-dumper-dump-file
- (format "spacemacs-%s.pdmp" emacs-version))
-#+END_SRC
-
-** Package managment and updates
-:PROPERTIES:
-:CUSTOM_ID: Init-Package_managment_and_updates-79363da3
-:END:
-Spacemacs’ core configuration can be updated via git commands using Github
-services. If Spacemacs is not set to the ~develop~ branch, it can check by
-itself if any update is available. However, I am using said branch, therefore I
-should set this variable to ~nil~. The default value is ~nil~.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-check-for-update nil)
-#+END_SRC
-
-When it comes to package management, Spacemacs is able to store them in
-different directories depending on the version of Emacs used or based on other
-variables. I personally prefer to use the value ~emacs-version~ since it makes
-it easier to upgrade or downgrade Emacs without any conflict with the already
-installed packages. The default value is ~emacs-version~.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-elpa-subdirectory 'emacs-version)
-#+END_SRC
-
-Spacemacs has a capacity of performing rollbacks after updates. We can set the
-maximum number of rollback slots to keep in the cache. The default value is ~5~.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-max-rollback-slots 5)
-#+END_SRC
-
-*** Elpa repository
-:PROPERTIES:
-:CUSTOM_ID: Init-Package_managment_and_updates-Elpa_repository-c07fb1c4
-:END:
-It is possible to ask Emacs to use an HTTPS connection when contacting the Elpa
-whenever possible. This value should be set to ~nil~ when the user has no way to
-contact the Elpa though HTTPS, otherwise it is strongly recommended to let it
-set to ~t~. This variable however has no effect if Emacs is launched with the
-parameter ~--insecure~ which forces the value of this variable to ~nil~. The
-default value is ~t~.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-elpa-https t)
-#+END_SRC
-
-We can set a maximum amount of seconds which will represent the maximum allowed
-time to contact the Elpa repository. By default, this setting is set on ~5~.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-elpa-timeout 5)
-#+END_SRC
-
-*** Spacelpa repository
-:PROPERTIES:
-:CUSTOM_ID: Init-Package_managment_and_updates-Spacelpa_repository-a431b288
-:END:
-The Spacelpa repository is a Spacemacs-specific package repository. It is
-possible to use it as the primary source to install a locked version of a
-package. If the below value is set to ~nil~, then Spacemacs will install the
-latest version of packages from MELPA. I personally don’t use it, so I let it
-set to ~nil~. The default value is ~nil~.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-use-spacelpa nil)
-#+END_SRC
-
-If the below value is not ~nil~, then the signature for the downloaded Spacelpa
-packages must be verified.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-verify-spacelpa-archives t)
-#+END_SRC
-
-** Editing style
-:PROPERTIES:
-:CUSTOM_ID: Init-Editing_style-56d58a4b
-:END:
-By default, Spacemacs encourages the use of evil-mode, which brings vim
-keybinding in Emacs. Still, it has three different styles available:
-- ~vim~, which goes full evil-mode usage and most adapted to Emacs newcomers,
- especially if they were used to vim before, with the use of a normal mode and
- an insert mode.
-- ~emacs~ which keeps an Emacs-like feel to the keybindings, without any
- difference between an insert or normal mode.
-- ~hybrid~ is a modification of the ~vim~ mode which brings the ~emacs~ style in
- insert mode, but otherwise behaves like the ~vim~ style in normal mode. This
- is the style I personally use.
-The value can also be a list with the ~:variables~ keyword (similar to layers).
-Check the editing styles section of the documentation for details on available
-variables. The default value is ~vim~.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-editing-style
- '(hybrid :variables
- hybrid-mode-enable-evilified-state t
- hybrid-mode-default-state 'normal))
-#+END_SRC
-
-If non-nil, the paste transient-state is enabled. While enabled, after you paste
-something, pressing ~C-j~ and ~C-k~ several times cycles through the elements in
-the ~kill-ring~. Default ~nil~.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-enable-paste-transient-state t)
-#+END_SRC
-
-** Spacemacs home configuration
-:PROPERTIES:
-:CUSTOM_ID: Init-Spacemacs_home_configuration-8375cdcc
-:END:
-The value below specifies the startup banner of Spacemacs. The default value is
-~official~, it displays the official Spacemacs logo. An integer value is the
-index of text banner, ~random~ chooses a random text banner in the
-~core/banners~ directory. A string value must be a path to an image format
-supported by your Emacs build. If the value is nil, then no banner is displayed.
-The default value is ~official~.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-startup-banner 'official)
-#+END_SRC
-
-On the Spacemacs homepage, a list of elements can also be shown, be it recent
-files, projects, agenda items,… Each of the elements making up the list value of
-the below variable are pairs in the form ~(list-type . list-size)~. If the value
-is ~nil~, then it is disabled. The possible values for ~list-type~ are:
-- ~recents~ :: displays recently opened files
-- ~bookmarks~ :: displays saved bookmarks
-- ~projects~ :: displays projectile projects recently opened
-- ~agenda~ :: displays upcoming events from Org-mode agendas
-- ~todos~ :: displays recent TODOs detected in projectile projects
-The order in which they are set in the below list affects their order on the
-Spacemacs startup page. List sikes may be ~nil~, in which case
-~spacemacs-buffer-startup-lists-length~ takes effect.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-startup-lists '((recents . 15)
- (projects . 15)))
-#+END_SRC
-
-The below variable allows the startup page to respond to resize events. Its
-default value is ~t~.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-startup-buffer-responsive t)
-#+END_SRC
-
-If non-nil show the version string in the Spacemacs buffer. It will appear as
-~(spacemacs version)@(emacs version)~. Default ~t~.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-startup-buffer-show-version t)
-#+END_SRC
-
-** Default major modes
-:PROPERTIES:
-:CUSTOM_ID: Init-Default_major_modes-37f4a891
-:END:
-The below variable sets a default major mode for a new empty buffer. Possible
-values are mode names such as ~text-mode~, or ~nil~ to use Fundamental mode. The
-default value is ~text-mode~, but I prefer to use ~org-mode~ by default.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-new-empty-buffer-major-mode 'org-mode)
-#+END_SRC
-
-Similarly, the below variable sets the default mode for the scratch buffer. Its
-default value is ~text-mode~, but I set it to use ~emacs-lisp-mode~ by default.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-scratch-mode 'emacs-lisp-mode)
-#+END_SRC
-
-By the way, it is possible to set a default message for the scratch buffer, such
-as “Welcome to Spacemacs!”. I prefer to keep it clean. The default value is
-~nil~.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-initial-scratch-message nil)
-#+END_SRC
-
-** Visual configuration
-:PROPERTIES:
-:CUSTOM_ID: Init-Visual_configuration-c4116cc1
-:END:
-*** Themes
-:PROPERTIES:
-:CUSTOM_ID: Init-Visual_configuration-Themes-315992bb
-:END:
-Spacemacs makes it quite easy to use themes and organize them. The below value
-is a list of themes, the first of the list is loaded when Spacemacs starts. The
-user can press ~SPC T n~ to cycle to the next theme in the list.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-themes '(nord doom-nord doom-vibrant spacemacs-dark
- doom-one doom-opera doom-dracula doom-molokai
- doom-peacock doom-sourcerer doom-spacegrey
- kaolin-dark kaolin-aurora kaolin-bubblegum
- kaolin-galaxy kaolin-mono-dark kaolin-temple
- kaolin-valley-dark))
-#+END_SRC
-
-Emacs also makes use of themes for the Spaceline at the bottom of buffers.
-Supported themes are:
-- ~spacemacs~
-- ~all-the-icons~
-- ~custom~
-- ~doom~ (the one I use)
-- ~vim-powerline~
-- ~vanilla~
-The first three are Spaceline themes. ~doom~ is the Doom-Emacs mode-line, and
-~vanilla~ is the default Emacs mode-line. ~custom~ is a user defined theme,
-refer to Spacemacs’ ~DOCUMENTATION.org~ file for more info on how to create your
-own Spaceline theme. Value can be a symbol or list with additional properties.
-The default value is ~'(spacemacs :separator wave :separator-scale 1.5))~.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-mode-line-theme '(doom
- :separator wave
- :separator-scale 1.0))
-#+END_SRC
-
-It is also possible to color the cursor depending on which mode Spacemacs is in,
-in order to mach the state color in GUI Emacs. The default value is ~t~.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-colorize-cursor-according-to-state t)
-#+END_SRC
-
-The below variable sets either the default font or a prioritized list of fonts
-to be used by Emacs. The ~:size~ can be specified as a non-negative integer
-(pixel size), or a floating-point (point size). Point size is recommended,
-because it’s device independent (add a ~.0~ to make an integer a floating
-point). The default size is ~10.0~.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-default-font '("Cascadia Code"
- :size 9.0))
-#+END_SRC
-
-I also added the following code in order to define a fallback font for emojis,
-defined only on their unicode range:
-#+BEGIN_SRC emacs-lisp
-(set-fontset-font "fontset-default" '(#x1f600 . #x1f64f) "NotoEmoji Nerd Font")
-#+END_SRC
-
-*** Other on-screen elements
-:PROPERTIES:
-:CUSTOM_ID: Init-Visual_configuration-Other_on-screen_elements-7d334e09
-:END:
-~which-key~ is a helper which displays available keyboard shortcuts. This
-variable sets in seconds the time Spacemacs should wait between a key press and
-the moment ~which-key~ should be shown.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-which-key-delay 1)
-#+END_SRC
-
-This variable sets ~which-key~'s frame position. Possible values are:
-- ~right~
-- ~bottom~
-- ~right-then-bottom~
-~right-then-bottom~ tries to display the frame to the right, but if there is
-insufficient space it displays it at the bottom. The default value is ~bottom~.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-which-key-position 'right-then-bottom)
-#+END_SRC
-
-This controls where ~switch-to-buffer~ displays the buffer. If the value is
-~nil~, ~switch-to-buffer~ displays the buffer in the current window even if
-another same-purpose window is available. If non-nil, ~switch-to-buffer~
-displays the buffer in a same-purpose window even if the buffer can be displayed
-in the current window. The default value is ~nil~.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-switch-to-buffer-prefers-purpose nil)
-#+END_SRC
-
-If this variable is non-nil, a progress bar is displayed when Spacemacs is
-loading. This may increase the boot time on some systems and emacs builds, set
-it to ~nil~ to boost the loading time. The default value is ~t~.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-loading-progress-bar t)
-#+END_SRC
-
-If the value is non-nil, Emacs will show the title of the transient states. The
-default value is ~t~.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-show-transient-state-title t)
-#+END_SRC
-
-If non-nil, this will show the color guide hint for transient state keys. The
-default value is ~t~.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-show-transient-state-color-guide t)
-#+END_SRC
-
-If non-nil, unicode symbols are displayed in the mode line. If you use Emacs as
-a daemon and want unicode characters only in GUI set the value to quoted
-~display-graphic-p~. The default value is ~t~.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-mode-line-unicode-symbols t)
-#+END_SRC
-
-If non-nil, smooth scrolling (native-scrolling) is enabled. Smooth scrolling
-overrides the default behavior of Emacs which recenters point when it reaches
-the top or bottom of the screen. The default value is ~t~.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-smooth-scrolling t)
-#+END_SRC
-
-The following value controls the line number activation. If set to ~t~,
-~relative~ or ~visual~ then line numbers are enabled in all ~prog-mode~ and
-~text-mode~ derivatives. If set to ~relative~, line numbers are relative. If set
-to ~visual~, line numbers are also relative, but only visual lines are counted.
-For example, folded lines will not be counted and wrapped lines are counted as
-multiple lines. This variable can also be set to a property list for finer
-control:
-#+BEGIN_SRC emacs-lisp :tangle no
-'(:relative nil
- :visual nil
- :disabled-for-modes dired-mode
- doc-view-mode
- markdown-mode
- org-mode
- pdf-view-mode
- text-mode
- :size-limit-kb 1000)
-#+END_SRC
-
-When used in a plist, ~visual~ takes precendence over ~relative~.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-line-numbers '(:relative nil
- :visual nil
- :disabled-for-modes org-mode pdf-view-mode
- dired-mode doc-view-mode
- text-mode))
-#+END_SRC
-
-Select a scope to highlight delimiter. Possible values are:
-- ~any~
-- ~current~
-- ~all~
-- ~nil~
-The default value is ~all~ (highlights any scope and emphasis the current one).
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-highlight-delimiters 'all)
-#+END_SRC
-
-After a certain amount of time in seconds, Spacemacs can zone-out. The default
-value is ~nil~. I set it so Spacemacs zones out after 15 minutes.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-zone-out-when-idle 900)
-#+END_SRC
-
-Run ~spacemacs/prettify-org-buffer~ when visiting the ~README.org~ files of
-Spacemacs. The default value is ~nil~.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-pretty-docs nil)
-#+END_SRC
-
-If ~nil~, the home buffer shows the full path of agenda items and todos. If non
-~nil~, only the file name is shown.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-home-shorten-agenda-source t)
-#+END_SRC
-
-*** Appearance of Emacs frames
-:PROPERTIES:
-:CUSTOM_ID: Init-Visual_configuration-Appearance_of_Emacs_frames-59700bb7
-:END:
-Starting from Emacs 24.4, it is possible to make the Emacs frame fullscreen when
-Emacs starts up if the variable is set to a non-nil value. The default value is
-~nil~.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-fullscreen-at-startup nil)
-#+END_SRC
-
-This variable is to be used if the user does not want to use native fullscreen
-with ~spacemacs/toggle-fullscreen~. This disables for instance the fullscreen
-animation under OSX. The default value is ~nil~.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-fullscreen-use-non-native nil)
-#+END_SRC
-
-If you do not start Emacs in fullscreen at startup, you might want it to be
-maximized by default. If the value for the variable below is set to be non-nil,
-the frame will be maximized. This can only work if
-~dotspacemacs-fullscreen-at-startup~ is set to ~nil~, and it is only available
-from Emacs 24.4 onwards. The default value is ~nil~.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-maximized-at-startup nil)
-#+END_SRC
-
-If non-nil, the frame is undecorated when Emacs starts up. Combine this with the
-variable ~dotspacemacs-maximized-at-startup~ in OSX to obtain borderless
-fullscreen. The default value is ~nil~.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-undecorated-at-startup nil)
-#+END_SRC
-
-You can also set a transparency level for Emacs when you toggle the transparency
-of the frame with ~toggle-transparency~. The value of the transparency, going
-from 0 to 100 in increasing opacity, describes the transparency level of a frame
-when it’s active or selected. The default value is ~90~.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-active-transparency 85)
-#+END_SRC
-
-Similarly, you can set a value from 0 to 100 in increasing opacity which
-describes the transparency level of a frame when it’s inactive or deselected.
-The default value is ~90~.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-inactive-transparency 80)
-#+END_SRC
-
-The variable below sets the format of frame title. You can use:
-- ~%a~ :: the ~abbreviated-file-name~ or ~buffer-name~
-- ~%t~ :: ~projectile-project-name~
-- ~%I~ :: ~invocation-name~
-- ~%S~ :: ~system-name~
-- ~%U~ :: contents of ~$USER~
-- ~%b~ :: buffer name
-- ~%f~ :: visited file name
-- ~%F~ :: frame name
-- ~%s~ :: process status
-- ~%p~ :: percent of buffer above top of window, or Top, Bot, or All
-- ~%P~ :: percent of buffer above bottom of window, perhaps plus Top, or Bot, or
- All
-- ~%m~ :: mode name
-- ~%n~ :: Narrow if appropriate
-- ~%z~ :: mnemonics of buffer, terminal, and keyboard coding systems
-- ~%Z~ :: like ~%z~, but including the end-of-line format
-The default value is ~"%I@%S"~.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-frame-title-format "Emacs: %b (%t) %U@%S")
-#+END_SRC
-
-Format specification for setting the icon title format. The default value is
-~nil~, same as ~frame-title-format~.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-icon-title-format nil)
-#+END_SRC
-
-** Spacemacs leader keys and shortcuts
-:PROPERTIES:
-:CUSTOM_ID: Init-Spacemacs_leader_keys_and_shortcuts-ebf21abe
-:END:
-The below setting sets the Spacemacs leader key. By default, this is the ~SPC~
-key.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-leader-key "SPC")
-#+END_SRC
-
-Once the leader key has been pressed, it is possible to set another key in order
-to call Emacs’ command ~M-x~. By default, it is again the ~SPC~ key.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-emacs-command-key "SPC")
-#+END_SRC
-
-It is also possible to invoke Vim Ex commands with the press of a key, and by
-default it is the ~:~ key.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-ex-command-key ":")
-#+END_SRC
-
-The below variable sets the leader key accessible in ~emacs-state~ and
-~insert-state~:
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-emacs-leader-key "M-m")
-#+END_SRC
-
-The major mode leader key is a shortcut key which is the equivalent of pressing
-~ m~. Set it to ~nil~ to disable it. Its default value is ~,~.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-major-mode-leader-key ",")
-#+END_SRC
-
-In ~emacs-state~ and ~insert-state~, the same major mode leader key can be
-accessible from another shortcut, which by default is ~C-M-m~ in terminal mode,
-or ~M-return~ in GUI mode.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-major-mode-emacs-leader-key
- (if window-system "" "C-M-m"))
-#+END_SRC
-
-These variables control whether separate commands are bound in the GUI to the
-key pairs ~C-i~ and ~TAB~, and ~C-m~ and ~RET~. Setting it to a non-nil value
-allows for separate commands under ~C-i~ and ~TAB~, and ~C-m~ and ~RET~. In the
-terminal, these pairs are generally indistinguishable, so this only works in the
-GUI. The default value is ~nil~.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-distinguish-gui-tab nil)
-#+END_SRC
-
-** Layouts
-:PROPERTIES:
-:CUSTOM_ID: Init-Layouts-61c0374d
-:END:
-The variable belows sets the name of the default layout. Its default value is
-~"Default"~.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-default-layout-name "Default")
-#+END_SRC
-
-If non-nil, the default layout name is displayed in the mode-line. The default
-value is ~nil~.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-display-default-layout nil)
-#+END_SRC
-
-If non-nil, then the last auto saved layouts are resumed automatically upon
-start. The default value is ~nil~.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-auto-resume-layouts nil)
-#+END_SRC
-
-If non-nil, the layout name will be auto-generated when creating new layouts. It
-only has an effect when using the “jump to layout by number” command. The
-default value is ~nil~.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-auto-generate-layout-names nil)
-#+END_SRC
-
-** Files-related settings
-:PROPERTIES:
-:CUSTOM_ID: Init-Files-related_settings-67fba383
-:END:
-The below value sets the size in MB above which Spacemacs will prompt to open
-the file literally in order to avoid preformance issues. Opening a file
-literally means that no major or minor mode is active. The default value is ~1~.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-large-file-size 5)
-#+END_SRC
-
-This variable sets the location where to auto-save files. Possible values are:
-- ~original~ :: auto-saves files in-place
-- ~cache~ :: auto-saves files in another file stored in the cache directory
-- ~nil~ :: disables auto-saving.
-The default value is ~cache~.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-auto-save-file-location 'original)
-#+END_SRC
-
-** Emacs server
-:PROPERTIES:
-:CUSTOM_ID: Init-Emacs_server-d3947c28
-:END:
-Emacs can be launched as a server if the following value is set to non-nil and
-if one isn’t already running. The default value is ~nil~.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-enable-server nil)
-#+END_SRC
-
-You can also set a custom emacs server socket location. If the value is ~nil~,
-Emacs will use whatever the Emacs default is, otherwise a directory path like
-="$HOME/.config/emacs/server"=. It has no effect if ~dotspacemacs-enable-server~
-is ~nil~.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-server-socket-dir nil)
-#+END_SRC
-
-It is also possible to tell Emacs that the quit function should keep the server
-open when quitting. The default value is ~nil~.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-persistent-server t)
-#+END_SRC
-
-** Miscellaneous
-:PROPERTIES:
-:CUSTOM_ID: Init-Miscellaneous-6b4f0b76
-:END:
-This value changes the folding method of code blocks. The possible values are
-either ~evil~, the default value, or ~origami~.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-folding-method 'evil)
-#+END_SRC
-
-If non-nil, ~smartparens-strict-mode~ will be enabled in programming modes. The
-default value is ~nil~.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-smartparens-strict-mode nil)
-#+END_SRC
-
-If non-nil, pressing the closing parenthesis ~)~ key in insert mode passes over
-any automatically added closing parenthesis, bracket, quote, etc… This can
-temporarily disabled by pressing ~C-q~ before ~)~. The default value is ~nil~.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-smart-closing-parenthesis nil)
-#+END_SRC
-
-List of search tool executable names. Spacemacs uses the first installed tool of
-the list. Supported tools are:
-- ~rg~
-- ~ag~
-- ~pt~
-- ~ack~
-- ~grep~
-The default value is ~'("rg" "ag" "pt" "ack" "grep")~.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-search-tools '("rg" "grep"))
-#+END_SRC
-
-Delete whitespace while saving buffer. Possible values are:
-- ~all~ :: aggresively delete empty lines and long sequences of whitespace
-- ~trailing~ :: only detele the whitespace at end of lines
-- ~changed~ :: to delete only whitespace for changed lines
-- ~nil~ :: disable cleanup
-The default value is ~nil~.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-whitespace-cleanup nil)
-#+END_SRC
-
-Set ~gc-cons-threshold~ and ~gc-cons-percentage~ when startup finishes. This is
-an advanced option and should not be changed unless you suspect performance
-issues due to garbage collection operations. The default is ~'(100000000 0.1)~
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-gc-cons '(100000000 0.1))
-#+END_SRC
-
-If non nil activate ~clean-aindent-mode~ which tries to correct virtual
-indentation of simple modes. This can interfer with mode specific indent
-handling like has been reported for ~go-mode~. If it does deactivate it here.
-Default ~t~.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-use-clean-aindent-mode t)
-#+END_SRC
-
-If non ~nil~, shift your number row to match the entered keyboard layout (only
-in insert state). Currently supported keyboard layouts are ~querty-us~,
-~quertz-de~ and ~querty-ca-fr~. New layouts can be added in ~spacemacs-editing~
-layer. Default ~nil~.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-swap-number-row nil)
-#+END_SRC
-
-Set ~read-process-output-max~ when startup finishes. This defines how much data
-is read from a foreign process. Setting this >= 1 MB should increase performance
-for lsp servers in emacs 27.
-#+BEGIN_SRC emacs-lisp
-(setq-default dotspacemacs-read-process-output-max (* 1024 1024 8))
-#+END_SRC
-
-* User Initialization
-:PROPERTIES:
-:CUSTOM_ID: User_Initialization-e0d21089
-:END:
-** User Init
-:PROPERTIES:
-:header-args:emacs-lisp: :mkdirp yes :tangle ~/.emacs.spacemacs/private/user-init.el :exports code :results silent :lexical t
-:CUSTOM_ID: User-Initialization-User-Init-a86829cf
-:END:
-#+BEGIN_SRC emacs-lisp :exports none
-;; -*- lexical-binding: t -*-
-#+END_SRC
-
-While Emacs and especially Spacemacs loads, I want it to initialize some
-elements and load some packages. First of all, I want it to load my private
-Emacs config file:
-#+BEGIN_SRC emacs-lisp
-(load "~/.emacs.spacemacs/private/private_emacs")
-#+END_SRC
-
-I would also like to enable the setup of flycheck for Rust when Flycheck is
-loaded:
-#+BEGIN_SRC emacs-lisp
-(add-hook 'flycheck-mode-hook #'flycheck-rust-setup)
-#+END_SRC
-
-By default, Flyspell should be disabled and only enabled manually.
-#+BEGIN_SRC emacs-lisp
-(flyspell-mode 0)
-#+END_SRC
-
-Finally, here is a quick workaround for Tramp, sometimes it cannot connect to my
-hosts if I don’t have this code snippet.
-#+BEGIN_SRC emacs-lisp
-(setq tramp-ssh-controlmaster-options
- "-o ControlMaster=auto -o ControlPath='tramp.%%C' -o ControlPersist=no")
-#+END_SRC
-
-#+BEGIN_SRC emacs-lisp
-(require 'org)
-#+END_SRC
-
-** User Load
-:PROPERTIES:
-:header-args:emacs-lisp: :mkdirp yes :tangle ~/.emacs.spacemacs/private/user-load.el :exports code :results silent :lexical t
-:CUSTOM_ID: User-Initialization-User-Load-488cf687
-:END:
-Then, I want a couple of requires:
-#+BEGIN_SRC emacs-lisp
-(require 'org-id)
-(require 'org-protocol)
-(require 'package)
-(require 'ox-latex)
-(require 'ox-publish)
-(require 'tramp)
-#+END_SRC
-
-* User Configuration
-:PROPERTIES:
-:header-args:emacs-lisp: :mkdirp yes :tangle ~/.emacs.spacemacs/private/user-config.el :exports code :results silent :lexical t
-:CUSTOM_ID: User_Configuration-4a937fe5
-:END:
-#+BEGIN_SRC emacs-lisp :exports none
-;; -*- lexical-binding: t -*-
-#+END_SRC
-** Custom functions, macros, and variables
-:PROPERTIES:
-:CUSTOM_ID: User_Configuration-Custom_functions-ceb4bc42
-:END:
-In this section, I will put my various custom functions that do not fit in other
-sections and which are more oriented towards general usage throughout Emacs and
-in Elisp code.
-
-Almost all of my code snippets will be prefixed by either my name or the name of
-the package or layer they are part of, unless they are an explicit overwrite of
-a function that already exists.
-*** Elisp Utilities and Predicates
-:PROPERTIES:
-:CUSTOM_ID: User-Configuration-Custom-functions-macros-and-variables-Predicates-5598df46
-:END:
-**** ~phundrak-filter~
-:PROPERTIES:
-:CUSTOM_ID: User-Configuration-Custom-functions-macros-and-variables-Elisp-Utilities-and-Predicates-phundrak-filter-2d3c5a5b
-:END:
-#+name: elisp-phundrak-filter
-#+BEGIN_SRC emacs-lisp
-(defun phundrak-filter (fn list)
- "Filter `LIST' according to the predicate `FN'.
-
-All elements from `LIST' that do not satisfy the predicate `FN'
-will be left out of the result, while all elements that do
-satisfy it will be included in the resulting list. This function
-also preserves the relative position between elements that
-satisfy the predicate."
- (declare (pure t) (side-effect-free t))
- (when list
- (let ((rest (phundrak-filter fn
- (cdr list))))
- (if (funcall fn
- (car list))
- (cons (car list) rest)
- rest))))
-#+END_SRC
-
-**** ~phundrak-all?~
-:PROPERTIES:
-:CUSTOM_ID: User-Configuration-Custom-functions-macros-and-variables-phundrak-all-0655600c
-:END:
-This function is inspired by dash’s ~-all?~ function: it will test all the
-elements of the list ~seq~ against the predicate ~fn~ which should return either
-~t~ or ~nil~. If all of them return something else than ~nil~, then it is a
-success, otherwise it is a failure. Note that empty lists will always return
-~t~.
-#+BEGIN_SRC emacs-lisp
-(defun phundrak-all? (fn seq)
- "Check if all members of `SEQ' satisfy predicate `FN'. Note that
-it will return t if `SEQ' is nil."
- (declare (pure t) (side-effect-free t))
- (if seq
- (and (funcall fn (car seq))
- (phundrak-all? fn (cdr seq)))
- t))
-#+END_SRC
-
-**** ~phundrak-none?~
-:PROPERTIES:
-:CUSTOM_ID: User-Configuration-Custom-functions-macros-and-variables-phundrak-none-463dee26
-:END:
-In the same vein as ~phundrak-all?~, ~phundrak-none?~ checks if all elements of
-~seq~ do not satify the predicate ~fn~. Again, if the list is empty, it will
-return ~t~.
-#+name: elisp-phundrak-none
-#+BEGIN_SRC emacs-lisp
-(defun phundrak-none? (fn seq)
- "Check if all members of `SEQ' do not satisfy predicate `FN'.
-Note that it will return t if `SEQ' is nil."
- (declare (pure t) (side-effect-free t))
- (if seq
- (and (not (funcall fn (car seq)))
- (phundrak-none? fn (cdr seq)))
- t))
-#+END_SRC
-
-**** ~phundrak-zip~
-:PROPERTIES:
-:CUSTOM_ID: User-Configuration-Custom-functions-macros-and-variables-Elisp-Utilities-and-Predicates-phundrak-zip-8a49b20f
-:END:
-#+name: elisp-phundrak-zip
-#+BEGIN_SRC emacs-lisp
-(defun phundrak-zip (&rest lists)
- "Zip `LISTS' together.
-Be aware only the amount of elements of the smallest list will be zipped."
- (declare (pure t) (side-effect-free t))
- (when lists
- (let ((lists (if (= 1 (length lists)) ; only one element => a list of lists was passed
- (car lists)
- lists)))
- (when (phundrak-none? 'null lists)
- (cons (mapcar 'car lists)
- (phundrak-zip (mapcar 'cdr lists)))))))
-#+END_SRC
-
-*** Eshell Prompt-Related Functions
-:PROPERTIES:
-:CUSTOM_ID: User-Configuration-Custom-functions-macros-and-variables-Eshell-prompt-related-functions-79d07f21
-:END:
-**** ~phundrak-eshell-git-status~
-:PROPERTIES:
-:CUSTOM_ID: User-Configuration-Custom-functions-macros-and-variables-phundrak-eshell-git-status-28f16e94
-:END:
-This function is used in my Eshell prompt which you can consult [[#User_Configuration-Eshell-Eshell_theme-a06715a9][here]]. This
-function basically executes two git calls to get some information about a git
-repo, which path we provide as an argument. Based on the result of these git
-calls, the function will know what it needs to know about the repo to build a
-git prompt that will be inserted in my Eshell prompt. And just for shit and
-giggles, I’ve made it so it is a powerline prompt.
-#+BEGIN_SRC emacs-lisp
-(defun phundrak-eshell-git-status ($path &optional $background-color)
- "Returns a string indicating the status of the repository located
-in `$PATH' if it exists. It should also append the name of the
-current branch if it is not `master' or `main'.
-`$BACKGROUND-COLOR' allows to choose the color that will be
-visible behind the powerline characters. The theme is inspired by
-the bobthefish theme for the fish shell which you can find here:
-https://github.com/oh-my-fish/theme-bobthefish
-
-Color code:
-- green:
-- orange: tracked stuff is staged but not commited
-- red: tracked stuff is modified and not commited
-
-Symbols:
-- `*': dirty working dir, RED
-- `~': staged changes, ORANGE
-- `…': untracked files, GREEN
-- `$': stashed changes
-- `-': unpulled commits
-- `-': unpushed commits
-- `±': unpulled and unpushed commits"
- (let* ((git-status-command (concat "cd " $path "; git status"))
- (git-stash-status-command (concat "cd " $path "; git stash list"))
- (status (eshell-command-result git-status-command))
- (stashstat (eshell-command-result git-stash-status-command))
- (detached (s-contains? "HEAD detached" status))
- (dirty (s-contains? "Changes not staged for commit" status))
- (staged (s-contains? "Changes to be committed" status))
- (untracked (s-contains? "Untracked files" status))
- (pullable (s-contains? "git pull" status))
- (pushable (s-contains? "git push" status))
- (branch (replace-regexp-in-string "On Branch \\(.*\\)\n\\(.\\|\n\\)*" "\\1" status))
- (branch (unless (or (string= "master" branch)
- (string= "main" branch)
- detached)
- branch)))
- (let ((prompt (concat " "
- (if detached ">" "")
- (when branch (concat " " branch " "))
- (when dirty "*")
- (when staged "~")
- (when untracked "…")
- (cond ((and pullable pushable) "±")
- (pullable "-")
- (pushable "+"))
- (when stashstat "$")
- " "))
- (accent (cond
- (dirty phundrak-nord11)
- (staged phundrak-nord13)
- (t phundrak-nord14)))
- (background (if $background-color
- $background-color
- phundrak-nord0)))
- (concat (with-face ""
- :background accent
- :foreground background)
- (with-face prompt
- :background accent
- :foreground (if dirty phundrak-nord6 background))
- (with-face ""
- :background background
- :foreground accent)))))
-#+END_SRC
-
-**** ~phundrak-git-repo-root~
-:PROPERTIES:
-:CUSTOM_ID: User-Configuration-Custom-functions-macros-and-variables-phundrak-git-repo-root-f7cf3bb9
-:END:
-This function detects if the path passed as an argument points to a git
-directory or to one of its subdirectories. If it is, it will return the path to
-the root of the git repository, else it will return ~nil~.
-#+BEGIN_SRC emacs-lisp
-(defun phundrak-git-repo-root ($path)
- "Return `$PATH' if it points to a git repository or one of its
-subdirectories."
- (when $path
- (if (f-dir? (concat $path "/.git"))
- $path
- (phundrak-git-repo-root (f-parent $path)))))
-#+END_SRC
-
-**** ~phundrak-prompt-toggle-abbreviation~
-:PROPERTIES:
-:CUSTOM_ID: User-Configuration-Custom-functions-macros-and-variables-phundrak-prompt-toggle-abbreviation-753ca549
-:END:
-#+BEGIN_SRC emacs-lisp
-(defvar phundrak-prompt--abbreviate t
- "Whether or not to abbreviate the displayed path in the Eshell
-prompt.")
-
-(defun phundrak-prompt-toggle-abbreviation ()
- "Toggles whether the Eshell prompt should shorten the name of
-the parent directories or not. See `phundrak-eshell-prompt'."
- (interactive)
- (setq phundrak-prompt--abbreviate (not phundrak-prompt--abbreviate)))
-#+END_SRC
-
-**** ~phundrak-abbr-path~
-:PROPERTIES:
-:CUSTOM_ID: User-Configuration-Custom-functions-macros-and-variables-phundrak-abbr-path-559b46e3
-:END:
-The following is a nice little function I use in my Eshell prompt. It shortens
-the name of all the parent directories of the current one in its path, but
-leaves the current one written in full. It also abbreviates the equivalent of
-the ~$HOME~ (~/home//~) directory to a simple =~=.
-#+BEGIN_SRC emacs-lisp
-(defun phundrak-abbr-path ($path &optional $abbreviate)
- "Abbreviate `$PATH'. If `$ABBREVIATE' is t, then all parent
-directories of the current directory will be abbreviated to one
-letter only. If a parent directory is a hidden directory (i.e.
-preceeded by a dot), the directory will be abbreviated to the dot
-plus the first letter of the name of the directory (e.g.
-\".config\" -> \".c\").
-
-For public use of the function, `$PATH' should be a string
-representing a UNIX path. For internal use, `$PATH' can also be a
-list. If `$PATH' is neither of those, an error will be thrown by
-the function."
- (cond
- ((stringp $path) (f-short
- (if $abbreviate
- (phundrak-abbr-path (f-split (phundrak-abbr-path $path)))
- $path)))
- ((null $path) "")
- ((listp $path)
- (f-join (cond ((= 1 (length $path)) (car $path))
- (t (let* ((dir (car $path))
- (first-char (s-left 1 dir)))
- (if (string= "." first-char)
- (s-left 2 dir)
- first-char))))
- (phundrak-abbr-path (cdr $path))))
- (t (error "Invalid argument %s, neither stringp nor listp" $path))))
-#+END_SRC
-
-*** Files-Related Functions
-:PROPERTIES:
-:CUSTOM_ID: User-Configuration-Custom-functions-macros-and-variables-Files-related-functions-0b66f353
-:END:
-**** ~phundrak-file-to-string~
-:PROPERTIES:
-:CUSTOM_ID: User-Configuration-Custom-functions-macros-and-variables-phundrak-file-to-string-efab0fba
-:END:
-#+BEGIN_SRC emacs-lisp
-(defun phundrak-file-to-string (FILE)
- "Returns the content of `FILE' as a string."
- (with-temp-buffer
- (insert-file-contents FILE)
- (buffer-string)))
-#+END_SRC
-
-**** ~phundrak-find-org-files~
-:PROPERTIES:
-:CUSTOM_ID: Custom-functions-phundrak-find-org-files-a8fd200f
-:END:
-There are lots of files which I want to be able to quickly open. I used to have
-one shortcut for each one of these files, but as their number grew, I decided to
-switch to helm for my file selector which will be called by only one common
-shortcut. Most of my files will be located in =~/org=, but I have some
-conlanging files which are located in =~/Documents/conlanging=, and all my
-university notes are in =~/Documents/university=. Let’s declare these
-directories in a variable:
-#+BEGIN_SRC emacs-lisp
-(defvar phundrak-org-directories '("~/org"
- "~/Documents/university/S8"
- "~/Documents/conlanging")
- "Directories in which to look for org files with the function
-`phundrak-find-org-files'.")
-#+END_SRC
-
-With this established, let’s write some emacs-lisp that will allow me to get a
-list of all these files and select them through helm. Be aware that I will be
-using some functions from third party packages, such as [[https://github.com/magnars/s.el][s.el]] and [[https://github.com/magnars/dash.el][dash]], as well
-as [[https://github.com/sharkdp/fd][fd]].
-#+BEGIN_SRC emacs-lisp
-(defun phundrak-find-org-files ()
- "Find all org files in the directories listed in
-`phundrak-org-directories', then list them in an ido buffer where
-the user can match one and open it."
- (interactive)
- (find-file
- (ivy-completing-read
- "Org File: "
- (s-split "\n"
- (mapconcat (lambda (path)
- (shell-command-to-string
- (format "fd . %s -e org -c never" path)))
- phundrak-org-directories
- "\n")))))
-#+END_SRC
-
-**** ~phundrak-open-marked-files~
-:PROPERTIES:
-:CUSTOM_ID: User-Configuration-Custom-functions-macros-and-variables-phundrak-open-marked-files-b87d37f7
-:END:
-This function is particularly useful in Dired buffers when someone wants to open
-multiple files. This function will basically look for all marked files in the
-current dired buffer and open each one of them in their individual buffer.
-#+BEGIN_SRC emacs-lisp
-(defun phundrak-open-marked-files ()
- "This function allows the user to open all marked files in a
-Dired buffer at once."
- (interactive)
- (let ((file-list (if (string= major-mode "dired-mode")
- (dired-get-marked-files)
- (list (buffer-file-name)))))
- (mapc (lambda (file)
- (find-file file))
- file-list)))
-#+END_SRC
-
-**** ~xah/open-in-external-app~
-:PROPERTIES:
-:CUSTOM_ID: User-Configuration-Custom-functions-macros-and-variables-xah-open-in-external-app-2655f31c
-:END:
-Here is another of Xah’s functions, this time to open a file externally to
-Emacs. For instance, I sometimes want to open a PDF in Zathura rather than in
-Emacs, or an HTML file in Firefox. With this function, it is now possible!
-#+BEGIN_SRC emacs-lisp
-(defun xah/open-in-external-app (&optional files)
- "Open the current file or dired marked files in external app.
-The app is chosen from your OS’ preference.
-
-When called in emacs lisp, if `FILES' is given, open that.
-
-URL `http://ergoemacs.org/emacs/emacs_dired_open_file_in_ext_apps.html'
-Version 2019-01-18"
- (interactive)
- (let* (($file-list (if files
- (progn (list files))
- (if (string-equal major-mode "dired-mode")
- (dired-get-marked-files)
- (list (buffer-file-name)))))
- ($do-it-p (if (<= (length $file-list) 5)
- t
- (y-or-n-p "Open more than 5 files? "))))
- (when $do-it-p
- (mapc (lambda ($fpath)
- (let ((process-connection-type nil))
- (start-process "" nil "xdg-open" $fpath)))
- $file-list))))
-#+END_SRC
-
-*** Theming
-:PROPERTIES:
-:CUSTOM_ID: User-Configuration-Custom-functions-macros-and-variables-Theming-7ad4dc46
-:END:
-**** Nord theming variables
-:PROPERTIES:
-:CUSTOM_ID: User_Configuration-Custom_functions_and_variables-Some_theming_variables-9b853a99
-:END:
-Yes, I do use a preconfigured theme, as mentioned above, but for some elements
-such as Eshell, I need to define some variables for color, and I’ll do it here.
-#+BEGIN_SRC emacs-lisp
-(defvar phundrak-nord0 "#2e3440")
-(defvar phundrak-nord1 "#3b4252")
-(defvar phundrak-nord2 "#434c5e")
-(defvar phundrak-nord3 "#4c566a")
-(defvar phundrak-nord4 "#d8dee9")
-(defvar phundrak-nord5 "#e5e9f0")
-(defvar phundrak-nord6 "#eceff4")
-(defvar phundrak-nord7 "#8fbcbb")
-(defvar phundrak-nord8 "#88c0d0")
-(defvar phundrak-nord9 "#81a1c1")
-(defvar phundrak-nord10 "#5e81ac")
-(defvar phundrak-nord11 "#bf616a")
-(defvar phundrak-nord12 "#d08770")
-(defvar phundrak-nord13 "#ebcb8b")
-(defvar phundrak-nord14 "#a3be8c")
-(defvar phundrak-nord15 "#b48ead")
-#+END_SRC
-
-**** ~with-face~
-:PROPERTIES:
-:CUSTOM_ID: User-Configuration-Custom-functions-macros-and-variables-with-face-7974e15f
-:END:
-~with-face~ is a simple yet very useful macro that allows me to easily create
-strings with faces defined as properties to the string passed as the first
-argument. Here is how it is implemented:
-#+BEGIN_SRC emacs-lisp
-(defmacro with-face ($str &rest $properties)
- "Helper macro for creating strings `$STR' with `$PROPERTIES'"
- `(propertize ,$str 'face (list ,@$properties)))
-#+END_SRC
-
-*** ~phundrak-blog-publish~
-:PROPERTIES:
-:CUSTOM_ID: User-Configuration-Custom-functions-macros-and-variables-phundrak-blog-publish-99c96b2d
-:END:
-This function is quite a simple function made to automatically publish [[https://blog.phundrak.com][my blog]]
-based on Hugo. After exporting my blog using ~ox-hugo~, I simply have to call
-this function which will look for all files located in =~/org/blog/public= and
-copy them to my remote server once ~hugo~ has been executed in =~/org/blog=.
-#+BEGIN_SRC emacs-lisp
-(defun phundrak-blog-publish ()
- "Publish my blog through Hugo and rsync to my remote server."
- (interactive)
- (let* ((blog-path "~/org/blog")
- (public-path (concat blog-path "/public"))
- (target-path "/rsync:Tilo:/home/phundrak/www/phundrak.com/blog"))
- (shell-command (format "cd %s && hugo" blog-path))
- (let ((files (mapcar (lambda (file)
- (f-relative file public-path))
- (f-files (format "%s/public" blog-path) nil t))))
- (dolist (file files)
- (copy-file (concat public-path "/" file)
- (concat target-path "/" file)
- t nil t)))))
-#+END_SRC
-
-*** ~phundrak-yas-rust-new-assignments~
-:PROPERTIES:
-:CUSTOM_ID: Custom-functions-yas-rust-new-assignments-4ad16bde
-:END:
-The following function is a function that will allow me to easily create ~new~
-functions for Rust structs. Inspired from [[https://github.com/jorgenschaefer/elpy][elpy]]’s ~elpy-snippet-init-assignments~
-function, it will automatically write assignments to my new struct as I write
-new parameters in the ~new~ function. It also comes with a helper function that
-parses the arguments given to the ~new~ function.
-#+BEGIN_SRC emacs-lisp
-(defun phundrak--yas-snippet-split-rust-args ($arg-string)
- "Split a Rust argument string `$ARG-STRING' into ((name,
-default)...) tuples"
- (mapcar (lambda ($elem)
- (split-string $elem "[[:blank:]]*:[[:blank:]]*" t))
- (split-string $arg-string "[[:blank:]]*,[[:blank:]]*" t)))
-
-(defun phundrak-yas-rust-new-assignments ($arg-string)
- "Return a typical new assignment for arguments.
-Inspired from elpy’s functions https://github.com/jorgenschaefer/elpy"
- (let ((indentation (make-string (save-excursion
- (goto-char start-point)
- (current-indentation))
- ?\s)))
- (mapconcat (lambda ($elem)
- (if (string-match "^\\*" (car $elem))
- ""
- (format "%s,\n%s" (car $elem) indentation)))
- (phundrak--yas-snippet-split-rust-args $arg-string)
- "")))
-#+END_SRC
-
-*** ~screenshot-svg~
-:PROPERTIES:
-:CUSTOM_ID: User-Configuration-Custom-functions-macros-and-variables-screenshot-svg-9e2e21d2
-:END:
-This function allows for taking SVG screenshots of Emacs from itself using
-Cairo. The function definition was taken [[https://github.com/caiohcs/my-emacs#screenshots][from here]].
-#+BEGIN_SRC emacs-lisp
-(defun screenshot-svg ()
- "Save a screenshot of the current frame as an SVG image.
-Saves to a temp file and puts the filename in the kill ring."
- (interactive)
- (let* ((filename (make-temp-file "Emacs" nil ".svg"))
- (data (x-export-frames nil 'svg)))
- (with-temp-file filename
- (insert data))
- (kill-new filename)
- (message filename)))
-#+END_SRC
-
-*** ~xah/dired-sort~
-:PROPERTIES:
-:CUSTOM_ID: User-Configuration-Custom-functions-macros-and-variables-xah-dired-sort-28bde838
-:END:
-This function comes directly from Xah Lee’s website and allows the user to sort
-files in a dired buffer depending on four factors:
- - File name
- - File size
- - Last modification date
- - File extension
-#+BEGIN_SRC emacs-lisp
-(defun xah/dired-sort ()
- "Sort dired dir listing in different ways. Prompt for a choice.
-URL `http://ergoemacs.org/emacs/dired_sort.html'
-Version 2018-12-23, modified by Phundrak on 2019-08-06"
- (interactive)
- (let ($sort-by $arg)
- (setq $sort-by (ido-completing-read "Sort by:" '( "name" "size" "date" "extension" )))
- (cond
- ((equal $sort-by "name") (setq $arg "-ahl --group-directories-first"))
- ((equal $sort-by "date") (setq $arg "-ahl -t --group-directories-first"))
- ((equal $sort-by "size") (setq $arg "-ahl -S --group-directories-first"))
- ((equal $sort-by "extension") (setq $arg "-ahlD -X --group-directories-first"))
- (t (error "logic error 09535" )))
- (dired-sort-other $arg )))
-#+END_SRC
-
-** Editing and modes
-:PROPERTIES:
-:CUSTOM_ID: User_Configuration-Editing_and_modes-7dbaf258
-:END:
-There is first a setting I would like to enable to make the navigation through
-text a bit easier which is to enable the subword mode. This allows me to iterate
-through words that are in CamelCase more easily, I don’t have to go either to
-the beginning or the end of the word and then move my cursor a bunch of times to
-get to the subword I want to modify.
-#+BEGIN_SRC emacs-lisp
-(global-subword-mode 1)
-#+END_SRC
-
-*** Default modes
-:PROPERTIES:
-:CUSTOM_ID: User_Configuration-Editing_and_modes-Default_modes-50d4e086
-:END:
-Some buffers sometimes won’t have a default mode at all, such as the ~*scratch*~
-buffer. In any vanilla configuration, they will then default to ~text-mode~. I
-personally prefer ~org-mode~ to be my default mode, so let’s set it so!
-#+BEGIN_SRC emacs-lisp
-(setq edit-server-default-major-mode 'org-mode)
-#+END_SRC
-
-*** Evil
-:PROPERTIES:
-:CUSTOM_ID: User_Configuration-Editing_and_modes-Evil-3cedaaee
-:END:
-Evil is not really smart by default when I ask it to undo stuff. As an example,
-let’s say I enter insert-mode and write a whole paragraph, and then I exit
-insert-mode back to normal-mode, and I notice a small mistake I made when typing
-my stuff down, like accidentally using a snippet from yasnippet, and I want to
-undo that. My initial reaction would be to press ~u~ to undo, and so would be
-yours too right? That’s the wrong answer with evil, since it considers your
-actions between entering and leaving insert-mode as only one action, and it
-would thus erase your /WHOLE PARAGRAPH/. Fortunately, there is a way to make the
-undo action more granular, but it comes at the cost of increasing the amount of
-undo actions you can do (which shouldn’t really matter if you don’t have a
-potato PC).
-#+BEGIN_SRC emacs-lisp
-(setq undo-limit 500000
- evil-want-fine-undo t)
-#+END_SRC
-
-*** File extensions
-:PROPERTIES:
-:CUSTOM_ID: User_Configuration-File_extensions-f76fe752
-:END:
-Sometimes, Emacs doesn’t recognize or misrecognizes some extensions, resulting
-in a wrong mode set for said file. Let’s fix that by associating the extension
-with the desired mode:
-#+BEGIN_SRC emacs-lisp
-(dolist (e '(("xml" . web-mode)
- ("xinp" . web-mode)
- ("aiml" . web-mode)
- ("C" . c++-mode)
- ("dconf" . conf-mode)
- ("yy" . bison-mode)
- ("ll" . flex-mode)
- ("s" . asm-mode)
- ("pl" . prolog-mode)
- ("l" . scheme-mode)
- ("vs" . glsl-mode)
- ("fs" . glsl-mode)))
- (push (cons (concat "\\."
- (car e)
- "\\'") (cdr e))
- auto-mode-alist))
-#+END_SRC
-
-We also have a couple of extensions which should all be in ~conf-unix-mode~,
-let’s indicate that to Emacs:
-#+BEGIN_SRC emacs-lisp
-(dolist (e '("service" "timer" "target" "mount" "automount"
- "slice" "socket" "path" "netdev" "network"
- "link"))
- (push (cons (concat "\\." e "\\'") 'conf-unix-mode)
- auto-mode-alist))
-#+END_SRC
-
-*** Hooks
-:PROPERTIES:
-:CUSTOM_ID: User_Configuration-Miscellaneous-Hooks-86da2da0
-:END:
-I also have some hooks I use for enabling some major and minor modes. The first
-one here allows the execution of the deletion of trailing space each time I save
-a file.
-#+BEGIN_SRC emacs-lisp
-(add-hook 'before-save-hook 'delete-trailing-whitespace)
-#+END_SRC
-
-I also want to always be in ~visual-line-mode~ so Emacs soft-wraps lines that
-are too long for the buffer they are displayed in. This will also be enabled for
-Elfeed.
-#+BEGIN_SRC emacs-lisp
-(add-hook 'prog-mode-hook 'visual-line-mode)
-(add-hook 'elfeed-read-mode-hook 'visual-line-mode)
-#+END_SRC
-
-I also want for some non-programming modes to enable a hard-limit in terms of
-how many characters can fit on one line. The modes that benefit are
-~message-mode~, ~org-mode~, ~text-mode~ and ~markdown-mode~.
-#+BEGIN_SRC emacs-lisp
-(mapc (lambda (x)
- (add-hook x 'visual-line-mode))
- '(message-mode-hook
- text-mode-hook
- markdown-mode-hook))
-#+END_SRC
-
-*** Twittering mode
-:PROPERTIES:
-:CUSTOM_ID: User_Configuration-Miscellaneous-Twittering_mode-b97d9327
-:END:
-For ~twittering-mode~, a Twitter major mode for Emacs, I want to encrypt my data
-using a master password, which I do thanks to this option:
-#+BEGIN_SRC emacs-lisp
-(setq twittering-use-master-password t)
-#+END_SRC
-
-*** Wrapping regions
-:PROPERTIES:
-:CUSTOM_ID: User_Configuration-Editing_and_modes-Wrapping_regions-2250281e
-:END:
-I really like the ~M-(~ keybinding for wrapping a selected region between
-parenthesis. However, parenthesis are not everything (even in Lisp dialects),
-and other wrappers could be nice. And they are! Here is how they are declared:
-#+BEGIN_SRC emacs-lisp
-(global-set-key (kbd "M-[") 'insert-pair)
-(global-set-key (kbd "M-{") 'insert-pair)
-(global-set-key (kbd "M-<") 'insert-pair)
-(global-set-key (kbd "M-'") 'insert-pair)
-(global-set-key (kbd "M-`") 'insert-pair)
-(global-set-key (kbd "M-\"") 'insert-pair)
-#+END_SRC
-
-For the record, this is from [[http://www.howardism.org/][Howard Abram]]’s [[https://github.com/howardabrams/dot-files][dotfiles]].
-
-** Emacs builtins
-:PROPERTIES:
-:CUSTOM_ID: User_Configuration-Emacs_builtins-7822b8dd
-:END:
-*** Dired
-:PROPERTIES:
-:CUSTOM_ID: User_Configuration-Dired-ef8a7cac
-:END:
-When it comes to dired, I chose do modify some elements on how things are sorted
-and shown, but there isn’t much configuration. First, I want to always copy
-folders in a recursive way, no questions asked.
-#+BEGIN_SRC emacs-lisp
-(setq dired-recursive-copies 'always)
-#+END_SRC
-
-Also, when I have two Dired buffers opened side by side, I generally want them
-to interact with each other, for example if I want to move around or copy stuff.
-So, let’s tell Emacs that:
-#+BEGIN_SRC emacs-lisp
-(setq dired-dwim-target t)
-#+END_SRC
-
-Finally, let’s tell Dired how to sort the elements to be displayed: directories
-first, non-hidden first.
-#+BEGIN_SRC emacs-lisp
-(setq dired-listing-switches "-ahl --group-directories-first")
-#+END_SRC
-
-By the way, let’s enable ~org-download~ when we are in a Dired buffer:
-#+BEGIN_SRC emacs-lisp
-(add-hook 'dired-mode-hook 'org-download-enable)
-#+END_SRC
-
-Finally, let’s enable globally ~diredfl~ so we can get a colourful Dired buffer
-each time we open one:
-#+BEGIN_SRC emacs-lisp
-(diredfl-global-mode 1)
-#+END_SRC
-
-*** Emacs Lisp
-:PROPERTIES:
-:CUSTOM_ID: User-Configuration-Emacs-builtins-Emacs-Lisp-219d4260
-:END:
-For some reason, =flycheck-mode= is not enabled by default when in an elisp
-buffer. Let’s add that:
-#+BEGIN_SRC emacs-lisp
-(add-hook 'emacs-lisp-mode-hook 'flycheck-mode)
-#+END_SRC
-
-*** Eshell
-:PROPERTIES:
-:CUSTOM_ID: User_Configuration-Eshell-3012e67e
-:END:
-Eshell is a built-in shell available from Emacs which I use almost as often as
-Fish. Some adjustments are necessary for making this shell usable for me.
-
-But first, here is a screenshot of what to expect visually from my configuration
-of Eshell when it is launched:
-
-#+include: ../img/eshell.svg export html
-
-**** Aliases
-:PROPERTIES:
-:CUSTOM_ID: User_Configuration-Eshell-Aliases-ef06615f
-:END:
-This function is a function that will come in very handy for Eshell functions
-that call shell processes. It concatenates the initial string ~command~ with all
-the arguments ~args~, each separated with a space.
-#+BEGIN_SRC emacs-lisp
-(defun phundrak/concatenate-shell-command ($command &rest $args)
- (string-join (cons $command $args) " "))
-#+END_SRC
-
-Just like most shells, it is possible to declare in Eshell aliases. First, I
-would like to be able to use ~open~ to open files in Emacs:
-#+BEGIN_SRC emacs-lisp
-(defalias 'open 'find-file)
-#+END_SRC
-
-I also have ~openo~ which allows me to perform the same action, but in another
-window:
-#+BEGIN_SRC emacs-lisp
-(defalias 'openo 'find-file-other-window)
-#+END_SRC
-
-The function ~yes-or-no-p~ is also aliased to ~y-or-n-p~ so I only have to
-answer by ~y~ or ~n~ instead of typing ~yes~ or ~no~.
-#+BEGIN_SRC emacs-lisp
-(defalias 'yes-or-no-p 'y-or-n-p)
-#+END_SRC
-
-For some ease of use, I’ll also declare ~list-buffers~ as an alias of ~ibuffer~.
-#+BEGIN_SRC emacs-lisp
-(defalias 'list-buffers 'ibuffer)
-#+END_SRC
-
-~mkcd~ is a function that allows me to create a directory and ~cd~ into it at
-the same time.
-#+begin_src emacs-lisp
-(defun eshell/mkcd ($directory)
- (eshell/mkdir "-p" $directory)
- (cd $directory))
-#+end_src
-
-**** Custom functions
-:PROPERTIES:
-:CUSTOM_ID: User_Configuration-Eshell-Custom_functions-79d98245
-:END:
-When I’m in Eshell, sometimes I wish to open multiple files at once in Emacs.
-For this, when I have several arguments for ~find-file~, I want to be able to
-open them all at once. Let’s modify ~find-file~ like so:
-#+BEGIN_SRC emacs-lisp
-(defadvice find-file (around find-files activate)
- "Also find all files within a list of files. This even works recursively."
- (if (listp filename)
- (cl-loop for f in filename do (find-file f wildcards))
- ad-do-it))
-#+END_SRC
-
-I also want to be able to have multiple instances of Eshell opened at once. For
-that, I declared the function ~eshell-new~ that does exactly that.
-#+BEGIN_SRC emacs-lisp
-(defun eshell-new()
- "Open a new instance of eshell."
- (interactive)
- (eshell 'N))
-#+END_SRC
-
-***** Redirect text editors to Emacs
-:PROPERTIES:
-:CUSTOM_ID: User_Configuration-Eshell-Custom_functions-Redirect_text_editors_to_Emacs-dff362c6
-:END:
-I still have some stupid muscle memory telling me to open ~emacs~ in the
-terminal, which is stupid with Eshell since I’m already inside Emacs. So, let’s
-open each file passed to the ~emacs~ command and bury the eshell buffer (we’ll
-get back to it later).
-#+BEGIN_SRC emacs-lisp
-(defun eshell/emacs (&rest $files)
- "Open a file in a new buffer. Old habits die hard"
- (if $files
- (mapc #'find-file
- (mapcar #'expand-file-name
- (eshell-flatten-list (reverse $files))))
- (bury-buffer)))
-#+END_SRC
-
-**** Environment variables
-:PROPERTIES:
-:CUSTOM_ID: User_Configuration-Eshell-Environment_variables-8dac73e0
-:END:
-Some environment variables need to be correctly set so Eshell can correctly
-work. The first environment variable to be set is the ~PATH~, as I have a couple
-of directories where executables are located. Let’s add them to our path.
-#+BEGIN_SRC emacs-lisp
-(setenv "PATH"
- (concat
- (getenv "HOME") "/.pub-cache/bin"
- ":" (getenv "HOME") "/.local/bin"
- ":" (getenv "HOME") "/go/bin"
- ":" (getenv "HOME") "/.cargo/bin"
- ":" (getenv "HOME") "/.gem/ruby/2.6.0/bin"
- ":" (getenv "PATH")))
-#+END_SRC
-
-I would also like to set two environment variables related to Dart development:
-the ~DART_SDK~ and ~ANDROID_HOME~ variables.
-#+BEGIN_SRC emacs-lisp
-(setenv "DART_SDK" "/opt/dart-sdk/bin")
-(setenv "ANDROID_HOME" (concat (getenv "HOME") "/Android/Sdk/"))
-#+END_SRC
-
-Finally, I’d like to add a custom directory to the ~PKG_CONFIG_PATH~:
-#+BEGIN_SRC emacs-lisp
-(setenv "PKG_CONFIG_PATH" (concat
- "/usr/local/lib/pkgconfig/" ":"
- (getenv "PKG_CONFIG_PATH")))
-#+END_SRC
-
-The ~EDITOR~ variable also needs to be set for git commands, especially the
-~yadm~ commands.
-#+BEGIN_SRC emacs-lisp
-(setenv "EDITOR" "emacsclient -c")
-#+END_SRC
-
-#+BEGIN_SRC emacs-lisp
-(setenv "SHELL" "/bin/sh")
-#+END_SRC
-
-**** Eshell banner
-:PROPERTIES:
-:CUSTOM_ID: User-Configuration-Emacs-builtins-Eshell-Eshell-banner-12d63d67
-:END:
-The code creating the Eshell banner is a bit lengthy and requires some
-additional explanations that would make the following chapter [[#User_Configuration-Eshell-Eshell_theme-a06715a9][Eshell theme]] too
-long. So, here it is!
-
-The banner for Eshell will collect some system information and display them
-gracefully. These pieces of information are:
-- The GNU/Linux distribution running (I do not use any other OS on my computer)
-- The kernel name and its version
-- The machine’s hostname
-- Its uptime
-- Its RAM and Swap usage
-- How full are its mountpoints
-Some of these information can be grabbed directly from Emacs built-in functions,
-but some others need to be retrieved manually. Let’s first get into it with the
-mounted partitions for which we’ll define a structure:
-#+BEGIN_SRC emacs-lisp
-(cl-defstruct phundrak/mounted-partitions
- "Object representing a mounted partition found in the system"
- path size used percent)
-#+END_SRC
-
-We’ll also define a variable setting the maximum length of a partition path
-before it gets abbreviated:
-#+BEGIN_SRC emacs-lisp
-(defvar phundrak//eshell-banner--max-length-part 13
- "Maximum length of a partition path")
-#+END_SRC
-
-Now, we can get our partitions. For this, we’ll make a call to the shell command
-~df -lH~ and we’ll keep only the partitions mounted on a device stored in
-~/dev~, for instance on ~/dev/sda~. And as mentioned above, if the mount path of
-the partition exceeds the length specified by
-~phundrak//eshell-banner--max-length-part~, it will get abbreviated by
-[[#User-Configuration-Custom-functions-macros-and-variables-phundrak-abbr-path-559b46e3][~phundrak-abbr-path~]].
-#+BEGIN_SRC emacs-lisp
-(defun phundrak/get-mounted-partitions ()
- (let ((partitions (s-split "\n"
- (shell-command-to-string "df -lH")
- t)))
- (-keep (lambda (partition)
- (let* ((partition (s-split " " partition t))
- (filesystem (nth 0 partition))
- (size (nth 1 partition))
- (used (nth 2 partition))
- (percent (nth 4 partition))
- (mount (nth 5 partition)))
- (when (s-prefix? "/dev" filesystem)
- (make-phundrak/mounted-partitions
- :path (if (> phundrak//eshell-banner--max-length-part (length mount))
- mount
- (phundrak-abbr-path mount t))
- :size size
- :used used
- :percent (string-to-number (s-chop-suffix "%" percent))))))
- partitions)))
-#+END_SRC
-
-We’ll need some padding for the name of the information displayed on the left
-hand side of the banner. The maximum length without any partitions is eight
-characters due to the text ~Hostname~, so if any partition path is longer than
-this, the left padding will increase.
-#+BEGIN_SRC emacs-lisp
-(defun phundrak//eshell-banner--get-left-pad (initial-pad partitions)
- (if partitions
- (let ((part-length (length (phundrak/mounted-partitions-path (car partitions)))))
- (phundrak//eshell-banner--get-left-pad (if (> part-length initial-pad)
- part-length
- initial-pad)
- (cdr partitions)))
- initial-pad))
-#+END_SRC
-
-Now, Let’s set three variables that will be used in the function following this
-declaration. They will be used to determine in which color a percentage should
-be displayed. I’ll consider any percentage below 60% to be acceptable and
-therefore displayed in green. However, starting from this threshold, I want the
-user to be noticed of the usage of whatever percentage shown that it has gone up
-and it should be watched and displayed in yellow. Above 75%, the user should
-consider this a warning, and the percentage will be displayed in orange. Above
-90%, it is considered critical and the percentage will be displayed in red.
-#+BEGIN_SRC emacs-lisp
-(defvar phundrak//eshell-banner--critical-percentage 90)
-(defvar phundrak//eshell-banner--warning-percentage 75)
-(defvar phundrak//eshell-banner--notice-percentage 60)
-
-(defun phundrak//eshell-banner--color-percentage (percentage)
- (cond
- ((> percentage phundrak//eshell-banner--critical-percentage)
- (with-face (format "%2d" percentage) :foreground phundrak-nord11))
- ((> percentage phundrak//eshell-banner--warning-percentage)
- (with-face (format "%2d" percentage) :foreground phundrak-nord12))
- ((> percentage phundrak//eshell-banner--notice-percentage)
- (with-face (format "%2d" percentage) :foreground phundrak-nord13))
- (t
- (with-face (format "%2d" percentage) :foreground phundrak-nord14))))
-#+END_SRC
-
-This function will be used when displaying progress bars. These will be used for
-displaying the Ram, Swap and partitions usage of the system, displaying the used
-part in red and the free part in green. For this, we just need to know the size
-of the progress bar we wish to use as well as how full it should be. Note that
-the percentage should be between 0 and 100.
-#+BEGIN_SRC emacs-lisp
-(defun phundrak//eshell-banner--progress-bar (length percentage)
- (let* ((length-green (if (= 0 percentage)
- 0
- (/ (* length percentage) 100)))
- (length-red (- length length-green)))
- (concat (with-face "[" :weight 'bold)
- (with-face (s-repeat length-green "=")
- :weight 'bold :foreground phundrak-nord14)
- (with-face (s-repeat length-red "=")
- :weight 'bold :foreground phundrak-nord11)
- (with-face "]" :weight 'bold))))
-#+END_SRC
-
-This function will be used in two distinct functions: ~phundrak-eshell-banner~
-which we will see later, and ~phundrak//eshell-banner--display-memory~ which we
-will see now. This function displays information for the two types of memory we
-have, RAM and Swap memory. Here is the definition of this function:
-#+BEGIN_SRC emacs-lisp
-(defun phundrak//eshell-banner--display-memory (type used total text-padding ramp-length)
- (let ((percentage (if (= used 0)
- 0
- (/ (* 100 used) total))))
- (concat (s-pad-right text-padding "." type)
- ": "
- (phundrak//eshell-banner--progress-bar ramp-length
- percentage)
- (format " %6s / %-5s ("
- (file-size-human-readable used)
- (file-size-human-readable total))
- (phundrak//eshell-banner--color-percentage
- percentage)
- "%)\n")))
-#+END_SRC
-
-We now need a function for displaying partitions. As you can see, it will be
-quite similar to the above one:
-#+BEGIN_SRC emacs-lisp
-(defun phundrak//eshell-banner--display-partition (part left-pad ramp-length)
- (concat (s-pad-right left-pad "."
- (with-face (phundrak/mounted-partitions-path part)
- :weight 'bold))
- ": "
- (phundrak//eshell-banner--progress-bar ramp-length
- (phundrak/mounted-partitions-percent part))
- (format " %6s / %-5s (%s%%)"
- (phundrak/mounted-partitions-used part)
- (phundrak/mounted-partitions-size part)
- (phundrak//eshell-banner--color-percentage (phundrak/mounted-partitions-percent part)))))
-#+END_SRC
-
-And we can now build our banner! Here is our function that does exactly that:
-#+BEGIN_SRC emacs-lisp
-(defun phundrak-eshell-banner ()
- (let* ((partitions (phundrak/get-mounted-partitions))
- (os (replace-regexp-in-string
- ".*\"\\(.+\\)\""
- "\\1"
- (car (-filter (lambda (line)
- (s-contains? "PRETTY_NAME" line))
- (s-lines (phundrak-file-to-string "/etc/os-release"))))))
- (memory (-map (lambda (line)
- (s-split " " line t))
- (s-split "\n"
- (shell-command-to-string "free -b | tail -2")
- t)))
- (ram (nth 0 memory))
- (swap (nth 1 memory))
- (ramp-length 41)
- (left-pad (phundrak//eshell-banner--get-left-pad phundrak//eshell-banner--max-length-part partitions))
- (right-pad 8)
- (left-column-width 27))
- (concat (format "%s\n" (s-repeat 79 "="))
- ;; OS and Kernel
- (format "%s: %s%s: %s\n"
- (s-pad-right left-pad "." "OS")
- (s-pad-right left-column-width
- " "
- (with-face (s-trim os)
- :weight 'bold))
- (s-pad-right right-pad "." "Kernel")
- (with-face (concat "Linux " operating-system-release)
- :weight 'bold))
- ;; Hostname and Uptime
- (format "%s: %s%s: %s\n"
- (s-pad-right left-pad "." "Hostname")
- (s-pad-right left-column-width
- " "
- (with-face (system-name) :weight 'bold))
- (s-pad-right right-pad "." "Uptime")
- (with-face (s-chop-prefix "up "
- (s-trim (shell-command-to-string "uptime -p")))
- :weight 'bold))
- ;; RAM ramp
- (phundrak//eshell-banner--display-memory "Ram"
- (string-to-number (nth 2 ram))
- (string-to-number (nth 1 ram))
- left-pad
- ramp-length)
- ;; SWAP ramp
- (phundrak//eshell-banner--display-memory "Swap"
- (string-to-number (nth 2 swap))
- (string-to-number (nth 1 swap))
- left-pad
- ramp-length)
- ;; Partitions
- (mapconcat (lambda (part)
- (phundrak//eshell-banner--display-partition part left-pad ramp-length))
- partitions
- "\n")
- (format "\n%s\n" (s-repeat 79 "=")))))
-#+END_SRC
-
-We now only have to set the result of this function as our Eshell banner. Since
-a simple ~setq~ would only run ~phundrak-eshell-banner~ once when Emacs starts,
-we’ll actually make Emacs set the value of ~eshell-banner-message~ each time it
-is required by Eshell with a hook:
-#+BEGIN_SRC emacs-lisp
-(add-hook 'eshell-banner-load-hook
- (lambda ()
- (setq eshell-banner-message (phundrak-eshell-banner))))
-#+END_SRC
-
-**** Eshell theme and prompt
-:PROPERTIES:
-:CUSTOM_ID: User_Configuration-Eshell-Eshell_theme-a06715a9
-:END:
-As with most shells, again, it is possible to customize the appearance of the
-Eshell prompt. As you can see, my prompt has some Nord colors, a shortened path,
-a git prompt, and an indicator of whether the previous command succeeded or
-failed. Note however that the abbreviation of the current path depends on the
-value of ~phundrak-prompt--abbreviate~, if it is ~t~ it is abbreviated;
-otherwise, it is kept in full. It can be toggled with a keyboard shortcut, see
-[[#User_Configuration-Shortcuts-Toggle-d53c27ef][Keybindings: Toggle]].
-#+BEGIN_SRC emacs-lisp
-(defun phundrak-eshell-prompt ()
- "Definition of my prompt for Eshell
-It displays a powerline prompt, with first an abbreviated path to
-the current directory. If `phundrak-prompt--abbreviate' is `t',
-then all preceding directories will be abbreviated to one
-character, except hidden directory which first character will be
-preceded by a dot. Otherwise, the full name of the directories is
-displayed.
-
-Then, if the current directory is a git repository or one of its
-subdirectories, it will display the current state of the
-repository. See `phundrak-eshell-git-status'
-
-Finally, a lambda character is displayed, either in blue or in
-red depending on if the last eshell command was a success or a
-failure respectively."
- (let* ((header-bg phundrak-nord0)
- ($path (phundrak-abbr-path (eshell/pwd)))
- ($git-path (phundrak-git-repo-root $path))
- ($abbr-path (phundrak-abbr-path $path phundrak-prompt--abbreviate))
- ($background phundrak-nord1)
- ($foreground phundrak-nord14)
- ($success phundrak-nord10)
- ($error phundrak-nord11))
- (concat (with-face (concat " "
- (phundrak-abbr-path (if $git-path
- $git-path
- $path)
- phundrak-prompt--abbreviate)
- " ")
- :foreground $foreground
- :background $background)
- (when $git-path
- (concat (phundrak-eshell-git-status $path $background)
- (with-face (format "%s "
- (let (($in-git-path (phundrak-abbr-path (f-relative $path $git-path)
- phundrak-prompt--abbreviate)))
- (if (string= "." $in-git-path)
- ""
- (concat " " $in-git-path))))
- :foreground $foreground
- :background $background)))
- (with-face "λ "
- :foreground (if (zerop eshell-last-command-status)
- $success
- $error)
- :background $background)
- (with-face "" :foreground $background)
- " ")))
-#+END_SRC
-
-Now, let’s declare our prompt regexp and our prompt functions:
-#+BEGIN_SRC emacs-lisp
-(setq eshell-prompt-regexp "^[^\n]*λ "
- eshell-prompt-function 'phundrak-eshell-prompt)
-#+END_SRC
-
-I also don't want the banner to be displayed, I know I entered the Elisp shell,
-no need to remind me. Maybe I’ll do something with it one day.
-#+BEGIN_SRC emacs-lisp
-(setq eshell-banner-message "")
-#+END_SRC
-
-Finally, let’s enable some fish-like syntax highlighting:
-#+BEGIN_SRC emacs-lisp
-(eshell-syntax-highlighting-global-mode +1)
-#+END_SRC
-
-***** TODO Fix right column padding :noexport:
-:PROPERTIES:
-:CUSTOM_ID: User-Configuration-Emacs-builtins-Eshell-Eshell-theme-and-prompt-Fix-right-column-padding-960cf0cb
-:END:
-The uptime can get longer than allocated in the banner and be longer than the
-theoretical longest line the banner can be. Execute the ~uptime~ command, find
-out the length of the result and compute the padding based on the maximum length
-between the kernel’s name and the uptime’s length.
-
-***** TODO Add battery level to banner :noexport:
-:PROPERTIES:
-:CUSTOM_ID: User-Configuration-Emacs-builtins-Eshell-Eshell-theme-and-prompt-Add-battery-level-to-banner-7ef9bd5a
-:END:
-Add battery level to banner if computer is a laptop, and display if it is
-charging or discharging. See [[https://tecosaur.github.io/emacs-config/config.html#simple-settings][Tecosaur’s config]] for a way to detect if a battery
-is present or not (basically use the function ~battery~).
-
-**** Visual commands
-:PROPERTIES:
-:CUSTOM_ID: User_Configuration-Eshell-Visual_commands-2b15e0dc
-:END:
-With Eshell, some commands don’t work very well, especially commands that create
-a TUI. So, let’s declare them as visual commands or subcommands:
-#+BEGIN_SRC emacs-lisp
-(setq eshell-visual-commands
- '("fish" "zsh" "bash" "tmux" "htop" "top" "vim" "bat" "nano")
- eshell-visual-subcommands
- '("git" "log" "l" "diff" "show"))
-#+END_SRC
-
-*** Org-mode
-:PROPERTIES:
-:CUSTOM_ID: User_Configuration-Org-mode-04ab8ad3
-:header-args:emacs-lisp: :tangle no :exports code :results silent
-:END:
-Org-mode is probably one of the best if not the best Emacs feature I have ever
-discovered. It is awesome for writing documents, regardless of the format you
-need it to be exported to, for agenda management, and for literary programming,
-such as with this document.
-#+BEGIN_SRC emacs-lisp
-(with-eval-after-load 'org
- ;; configuration goes here
- )
-#+END_SRC
-
-#+BEGIN_SRC emacs-lisp :tangle ~/.emacs.spacemacs/private/user-config.el :exports none :noweb yes
-(with-eval-after-load 'org
- ;; agenda
- <>
- <>
- ;; Babel
- <>
- <>
- <>
- <>
- ;; Beautiful org
- <>
- <>
- <>
- <>
- <>
- <>
- <>
- <>
- <>
- ;; Capture
- <>
- <>
- ;; Custom functions
- ;;;; Better IDs
- <>
- <>
- <>
- <>
- ;; File export
- <>
- ;;;; Latex
- <>
- <>
- <>
- <>
- <>
- ;;;; HTML
- <>
- <>
- ;; Latex Formats
- <>
- ;; Projects
- <>
- ;; Variables
- ;;;; Behavior
- <>
- <>
- <>
- <>
- <>
- <>
- <>
- ;;;; User information
- <>
- )
-#+END_SRC
-
-**** Agenda
-:PROPERTIES:
-:CUSTOM_ID: User_Configuration-Org-mode-Org_agenda-53f9d319
-:END:
-One awesome feature of Org mode is the agenda. By default, my agendas are stored
-in =~/org/agenda=.
-#+NAME: org-agenda-files
-#+BEGIN_SRC emacs-lisp
-(setq org-agenda-files (list "~/org/agenda" "~/org/notes.org"))
-#+END_SRC
-
-I also have a custom command in Org agenda to mark some tasks as daily tasks
-with the =:DAILY:= tag,:
-#+NAME: org-agenda-custom-commands
-#+BEGIN_SRC emacs-lisp
-(setq org-agenda-custom-commands
- '(("h" "Daily habits"
- ((agenda ""))
- ((org-agenda-show-log t)
- (org-agenda-ndays 7)
- (org-agenda-log-mode-items '(state))
- (org-agenda-skip-function
- '(org-agenda-skip-entry-if 'notregexp
- ":DAILY:"))))
- ("Y" "Yearly events"
- ((agenda ""))
- ((org-agenda-show-log t)
- (org-agenda-ndays 365)
- (org-agenda-log-mode-items '(state))
- (org-agenda-skip-entry-if 'notregexp
- ":YEARLY:")))))
-#+END_SRC
-
-**** Babel
-:PROPERTIES:
-:CUSTOM_ID: User_Configuration-Org-mode-Org_babel_languages-c062fc16
-:END:
-One of the amazing features of org-mode is its literary programming capacities
-by running code blocks from within Org-mode itself. But for that, only a couple
-of languages are supported directly by Org-mode itself, and they need to be
-activated. Here are the languages I activated in my Org-mode configuration:
-#+NAME: org-babel-languages-table
-| C |
-| dot |
-| emacs-lisp |
-| gnuplot |
-| latex |
-| latex-as-png |
-| makefile |
-| plantuml |
-| python |
-| restclient |
-| sass |
-| scheme |
-| shell |
-
-#+NAME: org-babel-languages-gen
-#+header: :cache yes :results replace
-#+header: :var languages=org-babel-languages-table[,0]
-#+BEGIN_SRC emacs-lisp :exports none
-(format "'(%s)"
- (mapconcat (lambda ($language)
- (format "(%s . t)" $language))
- languages
- "\n "))
-#+END_SRC
-
-#+RESULTS[71d98616bf4f1351ca93aea4972be0ba58057230]: org-babel-languages-gen
-#+begin_example
-'((C . t)
- (dot . t)
- (emacs-lisp . t)
- (gnuplot . t)
- (latex . t)
- (latex-as-png . t)
- (makefile . t)
- (plantuml . t)
- (python . t)
- (restclient . t)
- (sass . t)
- (scheme . t)
- (shell . t))
-#+end_example
-
-The corresponding code is as follows:
-#+NAME: org-babel-load-languages
-#+BEGIN_SRC emacs-lisp :noweb yes
-(org-babel-do-load-languages
- 'org-babel-load-languages
- <>)
-#+END_SRC
-
-Scheme requires a default implementation for geiser:
-#+NAME: org-babel-set-geiser
-#+BEGIN_SRC emacs-lisp
-(setq geiser-default-implementation 'racket)
-#+END_SRC
-
-By the way, I wish to see source code behave the same way in the source blocks
-as in their own major mode. Let’s tell Emacs so:
-#+NAME: org-src-tab-acts-natively
-#+BEGIN_SRC emacs-lisp
-(setq org-src-tab-acts-natively t)
-#+END_SRC
-
-Lastly, I know this can be a terrible idea, but I want Emacs to just evaluate
-Org code blocks without asking me. Of course, this could represent some big
-security issue if not careful enough, but I generaly just open my own org files.
-#+NAME: org-confirm-babel
-#+BEGIN_SRC emacs-lisp
-(setq org-confirm-babel-evaluate nil)
-#+END_SRC
-
-**** Beautify Org-mode
-:PROPERTIES:
-:CUSTOM_ID: Beautify-Org-mode-0506af2f
-:END:
-As I will always say, orgmode is an amazing piece of software that deserves
-particular care and love. That is why I want to give it a unique look and feel
-compared to the rest of my Emacs configuration, in order to make it feel much
-more comfortable. You will find below how my org buffers look like when I open
-one of them.
-
-#+begin_export html
-
-#+end_export
-
-In order to make org-mode even sexier, let’s enable ~variable-pitch-mode~ for
-org-mode so we can get some proportional font. I’ll also remove ~auto-fill-mode~
-which seems to stick to Orgmode like hell and I don’t know why.
-#+NAME: beautiful-org-hooks
-#+BEGIN_SRC emacs-lisp
-(add-hook 'org-mode-hook 'visual-line-mode)
-(remove-hook 'org-mode-hook 'auto-fill-mode)
-(add-hook 'org-mode-hook 'variable-pitch-mode)
-(auto-fill-mode -1)
-#+END_SRC
-
-You can then see the modified faces for org-mode [[#User-Configuration-Visual-configuration-Better-faces-Org-mode-07754177][here]].
-
-By default, I would like my org-mode buffers to be indented and tables to be
-aligned.
-#+NAME: beautiful-org-options
-#+BEGIN_SRC emacs-lisp
-(setq org-startup-indented t
- org-startup-align-all-tables t)
-#+END_SRC
-
-***** Fontifying parts of org-mode
-:PROPERTIES:
-:CUSTOM_ID: User-Configuration-Emacs-builtins-Org-mode-Beautify-Org-mode-Fontifying-parts-of-org-mode-f690ee40
-:END:
-Some blocks of org-mode should have their own face, such as the whole heading
-line, the done headline, the quote and the verse blocks,… actually, let’s enable
-that for all of them.
-#+name: beautiful-org-fontify-blocks
-#+BEGIN_SRC emacs-lisp
-(setq org-pretty-entities t
- org-fontify-whole-heading-line t
- org-fontify-done-headline t
- org-fontify-quote-and-verse-blocks t)
-#+END_SRC
-
-***** Fontifying inline src blocks
-:PROPERTIES:
-:CUSTOM_ID: User-Configuration-Emacs-builtins-Org-mode-Beautify-Org-mode-Fontifying-inline-src-blocks-bf879724
-:END:
-When it comes to source blocks in org-mode, Emacs handle them really well with
-some beautiful syntax highlight thanks to the the languages’ major mode and
-their font-locks. But inline src blocks are the forgotten child and get next to
-no love, which is really sad ; I want it to feel loved, to stand out from the
-crowd and to give me what its brother gives me already!
-
-Enters [[https://tecosaur.github.io/emacs-config/config.html#fontifying-inline-src][Tecosaur’s config]]! With ~org-src-font-lock-fontify-block~, anything’s
-possible! And ~{{{results(...)}}}~ can also have the ~org-block~ face applied to
-match and make org-mode even more beautiful! Let’s do it:
-#+name: beautiful-org-fontify-inline
-#+BEGIN_SRC emacs-lisp
-(defvar org-prettify-inline-results t
- "Whether to use (ab)use prettify-symbols-mode on
-{{{results(...)}}}.")
-
-(defun org-fontify-inline-src-blocks (limit)
- "Try to apply `org-fontify-inline-src-blocks-1'."
- (condition-case nil
- (org-fontify-inline-src-blocks-1 limit)
- (error (message "Org mode fontification error in %S at %d"
- (current-buffer)
- (line-number-at-pos)))))
-
-(defun org-fontify-inline-src-blocks-1 (limit)
- "Fontify inline src_LANG blocks, from `point' up to `LIMIT'."
- (let ((case-fold-search t))
- (when
- ; stolen from `org-element-inline-src-block-parser'
- (re-search-forward "\\_> info caddr (alist-get :file))))
- (unless file-name
- (setq file-name (make-temp-file "babel-lsp-")))
- (setq buffer-file-name file-name)
- (lsp-deferred)))
- (put ',intern-pre 'function-documentation
- (format "Enable lsp-mode in the buffer of org source block (%s)."
- (upcase ,lang)))
- (if (fboundp ',edit-pre)
- (advice-add ',edit-pre :after ',intern-pre)
- (progn
- (defun ,edit-pre (info)
- (,intern-pre info))
- (put ',edit-pre 'function-documentation
- (format "Prepare local buffer environment for org source block (%s)."
- (upcase ,lang))))))))
-(defvar org-babel-lsp-lang-list
- '(<>))
-(dolist (lang org-babel-lsp-lang-list)
- (eval `(lsp-org-babel-enable ,lang)))
-#+END_SRC
-
-Here is one behavior that I really want to see modified: the ability to use
-~M-RET~ without slicing the text the marker is on.
-#+NAME: org-M-RET-may-split-line
-#+BEGIN_SRC emacs-lisp
-(setq org-M-RET-may-split-line nil)
-#+END_SRC
-
-Since Org 9.3, Org no longer attempts to restore the window configuration in the
-frame to which the user returns after editing a source block with
-~org-edit-src-code~. This means with the original value of
-~org-src-window-setup~ (~reorganize-frame~), the current frame will be split in
-two between the original org window and the source window, and once we quit the
-source window only the org window will remain. This is not a desired behavior
-for me, so I chose to set this variable to ~split-window-right~ in order to keep
-my windows organization and have a similar behavior to the old one.
-#+NAME: org-src-window-setup
-#+BEGIN_SRC emacs-lisp
-(setq org-src-window-setup 'split-window-below)
-#+END_SRC
-
-However, it is not rare that I want to change that for an horizontal split,
-which can be achieved with the value ~split-window-below~. Thus, I have made
-this function that allows me to switch between the (default) vertical split and
-the horizontal split.
-#+NAME: org-src-window-toggle
-#+BEGIN_SRC emacs-lisp
-(defun phundrak/toggle-org-src-window-split ()
- "This function allows the user to toggle the behavior of
-`org-edit-src-code'. If the variable `org-src-window-setup' has
-the value `split-window-right', then it will be changed to
-`split-window-below'. Otherwise, it will be set back to
-`split-window-right'"
- (interactive)
- (if (equal org-src-window-setup 'split-window-right)
- (setq org-src-window-setup 'split-window-below)
- (setq org-src-window-setup 'split-window-right))
- (message "Org-src buffers will now split %s"
- (if (equal org-src-window-setup 'split-window-right)
- "vertically"
- "horizontally")))
-#+END_SRC
-
-When creating a link to an Org flie, I want to create an ID only if the link is
-created interactively, and only if there is no custom ID already created.
-#+NAME: org-id-link-to-org
-#+BEGIN_SRC emacs-lisp
-(setq org-id-link-to-org-use-id 'create-if-interactive-and-no-custom-id)
-#+END_SRC
-
-The tag ~:noexport:~ is fine and all, but it doesn’t allow for hidden org
-structures, that is headers that are visible in the org buffer but once the file
-is exported to another format the header disappears but its content stays.
-~ox-extra~ has such a feature through ~ignore-headlines~.
-#+BEGIN_SRC emacs-lisp
-(require 'ox-extra)
-(ox-extras-activate '(ignore-headlines))
-#+END_SRC
-This gives us access to the ~:ignore:~ tag which allows the behavior above
-mentioned.
-
-**** Capture
-:PROPERTIES:
-:CUSTOM_ID: User_Configuration-Org-mode-Org_capture-f58979cf
-:header-args:org: :mkdirp yes :padline no
-:END:
-Org-capture is an amazing feature of Org-mode which allows me to quickly save
-links, resources, reminders, and notes in neatly organized org files. Here they
-are described:
-#+NAME: org-capture-target-files
-#+BEGIN_SRC emacs-lisp
-(defvar org-conlanging-file "~/org/conlanging.org")
-(defvar org-default-notes-file "~/org/notes.org")
-(defvar org-journal-file "~/org/journal.org")
-(defvar org-linguistics-notes-file "~/org/linguistics-notes.org")
-(defvar org-novel-notes-file "~/org/novel-notes.org")
-(defvar org-private-agenda-file "~/org/agenda/private.org")
-(defvar org-school-agenda-file "~/org/agenda/school.org")
-(defvar org-wordbuilding-file "~/org/worldbuilding.org")
-#+END_SRC
-
-With Spacemacs, an Org capture can be invoked with the shortcut ~SPC a o c~. It
-will then ask which template I wish to use. In the table below are described the
-shortcuts that are available after ~SPC a o c~ is invoked. The /name/ will be
-the one displayed in Org capture’s interface, the /title/ is the headline where
-to save the capture (if it does not differ from the capture’s name, the cell
-will be blank). The /insertion mode/ tells Emacs how to add the capture to the
-/file/, using which /template/. A line with no insertion mode, file, or template
-is just a category. All of the following insert entries to their org files, that
-is a new org node with a headline and some content.
-#+NAME: org-capture-shortcuts-table
-| Shortcut | Name | Title | Insertion mode | file | template |
-|----------+---------------+-----------+----------------+-------------------------+--------------------------|
-| e | Email | | | | |
-| ew | Write Email | Emails | file+headline | org-default-notes-file | emails.orgcaptmpl |
-| j | Journal | | file+datetree | org-journal-file | journal.orgcaptmpl |
-| l | Link | | | | |
-| ll | General | | file+headline | org-default-notes-file | link.orgcaptmpl |
-| ly | YouTube | | file+headline | org-default-notes-file | youtube.orgcaptmpl |
-| L | Protocol Link | Link | file+headline | org-default-notes-file | protocol-link.orgcaptmpl |
-| n | Notes | | | | |
-| nc | Conlanging | Note | file+headline | org-conlanging-file | notes.orgcaptmpl |
-| nn | General | | file+headline | org-default-notes-file | notes.orgcaptmpl |
-| nN | Novel | Note | file+headline | org-novel-notes-file | notes.orgcaptmpl |
-| nq | Quote | | file+headline | org-default-notes-file | notes-quote.orgcaptmpl |
-| nw | Worldbuilding | Note | file+headline | org-wordbuilding-file | notes.orgcaptmpl |
-| N | Novel | | | | |
-| Ni | Ideas | | file+headline | org-novel-notes-file | notes.orgcaptmpl |
-| p | Protocol | Link | file+headline | org-default-notes-file | protocol.orgcaptmpl |
-| r | Resources | | | | |
-| rc | Conlanging | Resources | file+headline | org-conlanging-file | resource.orgcaptmpl |
-| re | Emacs | | file+headline | org-default-notes-file | resource.orgcaptmpl |
-| ri | Informatique | | file+headline | org-default-notes-file | resource.orgcaptmpl |
-| rl | Linguistics | | file+headline | org-default-notes-file | resource.orgcaptmpl |
-| rL | Linux | | file+headline | org-default-notes-file | resource.orgcaptmpl |
-| rw | Worldbuilding | Resources | file+headline | org-wordbuilding-file | resource.orgcaptmpl |
-| t | Tasks | | | | |
-| tb | Birthday | | file+headline | org-private-agenda-file | birthday.orgcaptmpl |
-| te | Event | | file+headline | org-private-agenda-file | event.orgcaptmpl |
-| th | Health | | file+headline | org-private-agenda-file | health.orgcaptmpl |
-| ti | Informatique | | file+headline | org-private-agenda-file | informatique.orgcaptmpl |
-
-#+NAME: org-capture-shortcut-gen
-#+header: :exports none :cache yes :results replace
-#+BEGIN_SRC emacs-lisp :var table=org-capture-shortcuts-table
-(format "'(%s)"
- (mapconcat (lambda (entry)
- (let* ((shortcut (nth 0 entry))
- (name (nth 1 entry))
- (title (nth 2 entry))
- (insertmode (nth 3 entry))
- (fileinsert (nth 4 entry))
- (sourceorg (nth 5 entry)))
- (if (string= "" insertmode)
- (format "(\"%s\" \"%s\")" shortcut name)
- (concat (format "(\"%s\" \"%s\" entry\n" shortcut name)
- (format " (%s %s%s)\n" insertmode fileinsert
- (if (string= "file+datetree" insertmode) ""
- (format " \"%s\"" (if (string= "" title) name title))))
- (format " (file \"~/org/capture/%s\"))" sourceorg)))) )
- table "\n "))
-#+END_SRC
-
-#+RESULTS[ec10a65e789d0f3d318de419a7c08e1f41dcb65a]: org-capture-shortcut-gen
-#+begin_example
-'(("e" "Email")
- ("ew" "Write Email" entry
- (file+headline org-default-notes-file "Emails")
- (file "~/org/capture/emails.orgcaptmpl"))
- ("j" "Journal" entry
- (file+datetree org-journal-file)
- (file "~/org/capture/journal.orgcaptmpl"))
- ("l" "Link")
- ("ll" "General" entry
- (file+headline org-default-notes-file "General")
- (file "~/org/capture/link.orgcaptmpl"))
- ("ly" "YouTube" entry
- (file+headline org-default-notes-file "YouTube")
- (file "~/org/capture/youtube.orgcaptmpl"))
- ("L" "Protocol Link" entry
- (file+headline org-default-notes-file "Link")
- (file "~/org/capture/protocol-link.orgcaptmpl"))
- ("n" "Notes")
- ("nc" "Conlanging" entry
- (file+headline org-conlanging-file "Note")
- (file "~/org/capture/notes.orgcaptmpl"))
- ("nn" "General" entry
- (file+headline org-default-notes-file "General")
- (file "~/org/capture/notes.orgcaptmpl"))
- ("nN" "Novel" entry
- (file+headline org-novel-notes-file "Note")
- (file "~/org/capture/notes.orgcaptmpl"))
- ("nq" "Quote" entry
- (file+headline org-default-notes-file "Quote")
- (file "~/org/capture/notes-quote.orgcaptmpl"))
- ("nw" "Worldbuilding" entry
- (file+headline org-wordbuilding-file "Note")
- (file "~/org/capture/notes.orgcaptmpl"))
- ("N" "Novel")
- ("Ni" "Ideas" entry
- (file+headline org-novel-notes-file "Ideas")
- (file "~/org/capture/notes.orgcaptmpl"))
- ("p" "Protocol" entry
- (file+headline org-default-notes-file "Link")
- (file "~/org/capture/protocol.orgcaptmpl"))
- ("r" "Resources")
- ("rc" "Conlanging" entry
- (file+headline org-conlanging-file "Resources")
- (file "~/org/capture/resource.orgcaptmpl"))
- ("re" "Emacs" entry
- (file+headline org-default-notes-file "Emacs")
- (file "~/org/capture/resource.orgcaptmpl"))
- ("ri" "Informatique" entry
- (file+headline org-default-notes-file "Informatique")
- (file "~/org/capture/resource.orgcaptmpl"))
- ("rl" "Linguistics" entry
- (file+headline org-default-notes-file "Linguistics")
- (file "~/org/capture/resource.orgcaptmpl"))
- ("rL" "Linux" entry
- (file+headline org-default-notes-file "Linux")
- (file "~/org/capture/resource.orgcaptmpl"))
- ("rw" "Worldbuilding" entry
- (file+headline org-wordbuilding-file "Resources")
- (file "~/org/capture/resource.orgcaptmpl"))
- ("t" "Tasks")
- ("tb" "Birthday" entry
- (file+headline org-private-agenda-file "Birthday")
- (file "~/org/capture/birthday.orgcaptmpl"))
- ("te" "Event" entry
- (file+headline org-private-agenda-file "Event")
- (file "~/org/capture/event.orgcaptmpl"))
- ("th" "Health" entry
- (file+headline org-private-agenda-file "Health")
- (file "~/org/capture/health.orgcaptmpl"))
- ("ti" "Informatique" entry
- (file+headline org-private-agenda-file "Informatique")
- (file "~/org/capture/informatique.orgcaptmpl")))
-#+end_example
-
-Below you can find the equivalent code as described above.
-#+NAME: org-capture-templates
-#+BEGIN_SRC emacs-lisp :noweb yes
-(setq
- org-capture-templates
- <>)
-#+END_SRC
-
-You may notice a capture entry for my journal, and this is due to the fact I do
-not use ~org-journal~ anymore: it was too overpowered for me, and I prefer to
-keep it simple with a single file. And as you can see, and unlike a lot of other
-Emacs configurations, the content of the template is not set in the variable,
-but in external files which can be modified freely as actual Org buffers instead
-of trying to get a proper one with loads of ~\n~ characters and such. All these
-templates are declared below.
-
-My org capture templates are not tangled into my Emacs configuration
-files, but into separate ~.orgcaptmpl~ files stored into =~/org/capture/=.
-You can find these in my repository [[https://labs.phundrak.com/phundrak/dotfiles/src/branch/master/org/capture][here]] or [[https://github.com/Phundrak/dotfiles/tree/master/org/capture][here]].
-
-**** Custom org-mode functions
-:PROPERTIES:
-:CUSTOM_ID: User_Configuration-Org-mode-Custom_org-mode_functions-f1726995
-:END:
-We begin with a couple of custom functions that I use in my org-mode files.
-
-***** Custom and unique headings ID
-:PROPERTIES:
-:CUSTOM_ID: User_Configuration-Org-mode-Custom_org-mode_functions-Custom_and_unique_headings_ID-44d2beaf
-:END:
-The first ones are dedicated to provide org-mode headings a fixed and unique ID
-that won’t change over time. This code was taken from
-[[https://writequit.org/articles/emacs-org-mode-generate-ids.html][https://writequit.org/articles/emacs-org-mode-generate-ids.html]]. The first
-function’s job is to create these unique IDs
-#+NAME: org-better-id-new
-#+BEGIN_SRC emacs-lisp
-(defun eos/org-id-new (&optional prefix)
- "Create a new globally unique ID.
-
-An ID consists of two parts separated by a colon:
-- a prefix
-- a unique part that will be created according to
- `org-id-method'.
-
-PREFIX can specify the prefix, the default is given by the
-variable `org-id-prefix'. However, if PREFIX is the symbol
-`none', don't use any prefix even if `org-id-prefix' specifies
-one.
-
-So a typical ID could look like \"Org-4nd91V40HI\"."
- (let* ((prefix (if (eq prefix 'none)
- ""
- (concat (or prefix org-id-prefix)
- "-"))) unique)
- (when (equal prefix "-")
- (setq prefix ""))
- (cond
- ((memq org-id-method
- '(uuidgen uuid))
- (setq unique (org-trim (shell-command-to-string org-id-uuid-program)))
- (unless (org-uuidgen-p unique)
- (setq unique (org-id-uuid))))
- ((eq org-id-method 'org)
- (let* ((etime (org-reverse-string (org-id-time-to-b36)))
- (postfix (when org-id-include-domain
- (progn
- (require 'message)
- (concat "@"
- (message-make-fqdn))))))
- (setq unique (concat etime postfix))))
- (t (error "Invalid `org-id-method'")))
- (concat prefix (car (split-string unique "-")))))
-#+END_SRC
-
-Now, let’s see the function that will be used to get the custom id of a heading
-at point. If the function does not detect any custom ID, then one should be
-created and inserted.
-#+NAME: org-better-id-get
-#+BEGIN_SRC emacs-lisp
-(defun eos/org-custom-id-get (&optional pom create prefix)
- "Get the CUSTOM_ID property of the entry at point-or-marker POM.
-If POM is nil, refer to the entry at point. If the entry does not
-have an CUSTOM_ID, the function returns nil. However, when CREATE
-is non nil, create a CUSTOM_ID if none is present already. PREFIX
-will be passed through to `eos/org-id-new'. In any case, the
-CUSTOM_ID of the entry is returned."
- (interactive)
- (org-with-point-at pom
- (let* ((orgpath (mapconcat #'identity (org-get-outline-path) "-"))
- (heading (replace-regexp-in-string
- "[_-]+$" ""
- (replace-regexp-in-string
- "[-_]+" "-"
- (replace-regexp-in-string
- "[^a-zA-Z0-9-_]" "-"
- (if (string= orgpath "")
- (org-get-heading t t t t)
- (concat orgpath "_" (org-get-heading t t t t)))))))
- (id (org-entry-get nil "CUSTOM_ID")))
- (cond
- ((and id
- (stringp id)
- (string-match "\\S-" id)) id)
- (create (setq id (eos/org-id-new (concat prefix heading)))
- (org-entry-put pom "CUSTOM_ID" id)
- (org-id-add-location id
- (buffer-file-name (buffer-base-buffer)))
- id)))))
-#+END_SRC
-
-Finally, this is the function that gets called on file saves. If the function
-detects ~auto-id:t~ among the org options in the ~#+OPTIONS:~ header, then the
-above function is called.
-#+NAME: org-better-id-add-ids
-#+BEGIN_SRC emacs-lisp
-(defun eos/org-add-ids-to-headlines-in-file ()
- "Add CUSTOM_ID properties to all headlines in the current file
-which do not already have one.
-
-Only adds ids if the `auto-id' option is set to `t' in the file
-somewhere. ie, #+OPTIONS: auto-id:t"
- (interactive)
- (save-excursion
- (widen)
- (goto-char (point-min))
- (when (re-search-forward "^#\\+OPTIONS:.*auto-id:t" (point-max) t)
- (org-map-entries (lambda () (eos/org-custom-id-get (point) 'create))))))
-#+END_SRC
-
-Let’s add a hook to the above function so it is called automatically on save,
-and only in read-write functions.
-#+NAME: org-better-id-hooks
-#+BEGIN_SRC emacs-lisp
-(add-hook 'org-mode-hook
- (lambda ()
- (add-hook 'before-save-hook
- (lambda ()
- (when (and (eq major-mode 'org-mode)
- (eq buffer-read-only nil))
- (eos/org-add-ids-to-headlines-in-file))))))
-#+END_SRC
-
-**** File export
-:PROPERTIES:
-:CUSTOM_ID: User_Configuration-Org-mode-Org_files_exports-1e194169
-:END:
-I want to disable by default behavior of ~^~ and ~_~ for only one character,
-making it compulsory to use instead ~^{}~ and ~_{}~ respectively. This is due to
-my frequent usage of the underscore in my org files as a regular character and
-not a markup one, especially when describing phonetics evolution. So, let’s
-disable it:
-#+NAME: org-use-sub-superscripts
-#+BEGIN_SRC emacs-lisp
-(setq org-use-sub-superscripts (quote {}))
-#+END_SRC
-
-***** LaTeX
-:PROPERTIES:
-:CUSTOM_ID: User-Configuration-Emacs-builtins-Org-mode-File-export-LaTeX-92bbd6f3
-:END:
-When it comes to exports, I want the LaTeX and PDF exports to be done with
-XeLaTeX only. This implies the modification of the following variable:
-#+NAME: org-latex-compiler
-#+BEGIN_SRC emacs-lisp
-(setq org-latex-compiler "xelatex")
-#+END_SRC
-
-I also want to get by default ~minted~ for LaTeX listings so I can have syntax
-highlights:
-#+NAME: org-latex-listings
-#+BEGIN_SRC emacs-lisp
-(setq org-latex-listings 'minted)
-#+END_SRC
-
-The default packages break my LaTeX exports: for some reasons, images are not
-loaded and exported in PDFs, so I needed to redifine the default packages
-excluding the one that broke my exports. I also added two default packages,
-~minted~ and ~xeCJK~ for syntax highlighting and Japanese (and additionally
-Chinese and Korean) support.
-#+NAME: org-latex-default-packages
-#+BEGIN_SRC emacs-lisp
-(setq org-latex-default-packages-alist '(("" "graphicx" t)
- ("T1" "fontspec" t ("pdflatex"))
- ("" "longtable" nil)
- ("" "wrapfig" nil)
- ("" "rotating" nil)
- ("normalem" "ulem" t)
- ("" "amsmath" t)
- ("" "textcomp" t)
- ("" "amssymb" t)
- ("" "capt-of" nil)
- ("" "minted" nil)
- ("" "hyperref" nil)))
-#+END_SRC
-
-By the way, reference links in LaTeX should be written in this format:
-#+NAME: org-export-latex-hyperref-format
-#+BEGIN_SRC emacs-lisp
-(setq org-export-latex-hyperref-format "\\ref{%s}")
-#+END_SRC
-
-When it comes to the export itself, the latex file needs to be processed several
-times through XeLaTeX in order to get some references right. Don’t forget to
-also run bibtex!
-#+NAME: org-latex-pdf-process
-#+BEGIN_SRC emacs-lisp
-(setq org-latex-pdf-process
- '("xelatex -8bit -shell-escape -interaction nonstopmode -output-directory %o %f"
- "bibtex %b"
- "xelatex -8bit -shell-escape -interaction nonstopmode -output-directory %o %f"
- "xelatex -8bit -shell-escape -interaction nonstopmode -output-directory %o %f"))
-#+END_SRC
-
-***** HTML
-:PROPERTIES:
-:CUSTOM_ID: User-Configuration-Emacs-builtins-Org-mode-File-export-HTML-192cba41
-:END:
-For Reveal.JS exports, I need to set where to find the framework by default:
-#+NAME: org-re-reveal-root
-#+BEGIN_SRC emacs-lisp
-(setq org-re-reveal-root "https://cdn.jsdelivr.net/npm/reveal.js")
-#+END_SRC
-
-On HTML exports, Org-mode tries to include a validation link for the exported
-HTML. Let’s disable that since I never use it.
-#+NAME: org-html-validation
-#+BEGIN_SRC emacs-lisp
-(setq org-html-validation-link nil)
-#+END_SRC
-
-However, something I very often use are metadata information in my HTML files. I
-just want to automate that. Fortunately, [[https://tecosaur.github.io/emacs-config/config.html#extra-header-content,code--3][Tecosaur comes to the rescue]]! First,
-here is our function that will generate all the meta tags in our HTML:
-#+BEGIN_SRC emacs-lisp
-(defun org-html-meta-tags-fancy (info)
- "Use the INFO plist to construct the meta tags, as described in
-`org-html-meta-tags'."
- (message "%s" info)
- (let ((title (org-html-plain-text
- (org-element-interpret-data (plist-get info :title)) info))
- (author (and (plist-get info :with-author)
- (let ((auth (plist-get info :author)))
- ;; Return raw Org syntax.
- (and auth (org-html-plain-text
- (org-element-interpret-data auth) info))))))
- (list
- (when (org-string-nw-p author)
- (list "name" "author" author))
- (when (org-string-nw-p (plist-get info :description))
- (list "name" "description"
- (plist-get info :description)))
- '("name" "generator" "org mode (Emacs)")
- '("name" "theme-color" "#3b4252")
- '("property" "og:type" "article")
- (list "property" "og:title" title)
- (let ((subtitle (org-export-data (plist-get info :subtitle) info)))
- (when (org-string-nw-p subtitle)
- (list "property" "og:description" subtitle)))
- (let ((meta-image (org-export-data (plist-get info :metaimage) info)))
- (when (org-string-nw-p meta-image)
- (list "property" "og:image" meta-image)))
- (let ((meta-image-type (org-export-data (plist-get info :metaimagetype) info)))
- (when (org-string-nw-p meta-image-type)
- (list "property" "og:image:type" meta-image-type)))
- (let ((meta-image-width (org-export-data (plist-get info :metaimagewidth) info)))
- (when (org-string-nw-p meta-image-width)
- (list "property" "og:image:width" meta-image-width)))
- (let ((meta-image-height (org-export-data (plist-get info :metaimageheight) info)))
- (when (org-string-nw-p meta-image-height)
- (list "property" "og:image:height" meta-image-height)))
- (let ((meta-image-alt (org-export-data (plist-get info :metaimagealt) info)))
- (when (org-string-nw-p meta-image-alt)
- (list "property" "og:image:alt" meta-image-alt)))
- (when (org-string-nw-p author)
- (list "property" "og:article:author:first_name" (car (s-split-up-to " " author 2))))
- (when (and (org-string-nw-p author) (s-contains-p " " author))
- (list "property" "og:article:author:last_name" (cadr (s-split-up-to " " author 2))))
- (list "property" "og:article:published_time" (format-time-string "%FT%T%z")))))
-#+END_SRC
-
-This will use some special keywords in our org buffer and insert their content in
-
-Now let’s bind it to when we export our org buffer to HTML:
-#+BEGIN_SRC emacs-lisp
-(unless (functionp #'org-html-meta-tags-default)
- (defalias 'org-html-meta-tags-default #'ignore))
-(setq org-html-meta-tags #'org-html-meta-tags-fancy)
-#+END_SRC
-
-**** LaTeX formats
-:PROPERTIES:
-:CUSTOM_ID: User_Configuration-Org-mode-Custom_LaTeX_formats-8e8dca1c
-:END:
-I currently have two custom formats for my Org-mode exports: one for general use
-(initialy for my conlanging files, hence its ~conlang~ name), and one for beamer
-exports.
-
-Below is the declaration of the ~conlang~ LaTeX class:
-#+NAME: org-latex-class-conlang
-#+BEGIN_SRC emacs-lisp
-'("conlang"
- "\\documentclass{book}"
- ("\\chapter{%s}" . "\\chapter*{%s}")
- ("\\section{%s}" . "\\section*{%s}")
- ("\\subsection{%s}" . "\\subsection*{%s}")
- ("\\subsubsection{%s}" . "\\subsubsection*{%s}"))
-#+END_SRC
-
-And here is the declaration of the ~beamer~ class:
-#+NAME: org-latex-class-beamer
-#+BEGIN_SRC emacs-lisp
-`("beamer"
- ,(concat "\\documentclass[presentation]{beamer}\n"
- "[DEFAULT-PACKAGES]"
- "[PACKAGES]"
- "[EXTRA]\n")
- ("\\section{%s}" . "\\section*{%s}")
- ("\\subsection{%s}" . "\\subsection*{%s}")
- ("\\subsubsection{%s}" . "\\subsubsection*{%s}"))
-#+END_SRC
-
-Both these classes have to be added to ~org-latex-classes~ like so:
-#+NAME: org-latex-classes
-#+BEGIN_SRC emacs-lisp :noweb yes
-(eval-after-load "ox-latex"
- '(progn
- (add-to-list 'org-latex-classes
- <>
- )
- (add-to-list 'org-latex-classes
- <>
- )))
-#+END_SRC
-
-**** Projects
-:PROPERTIES:
-:CUSTOM_ID: User_Configuration-Org-mode-Org_projects-5be088cd
-:END:
-Another great features of Org-mode is the Org projects that allow the user to
-easily publish a bunch of org files to a remote location. Here is the current
-declaration of my projects, which will be detailed later:
-#+NAME: org-publish-projects
-#+BEGIN_SRC emacs-lisp :noweb yes
-<>
-<>
-(setq org-publish-project-alist
- `(
- <>
- <>
- <>
- <>
- <>
- <>
- <>))
-#+END_SRC
-
-***** Configuration website
-:PROPERTIES:
-:CUSTOM_ID: User_Configuration-Org-mode-Org_projects-Configuration_website-79bd0468
-:END:
-This is my configuration for exporting my dotfiles to my website in a web format
-only. No PDFs or anything, just HTML. Please note that I do not use that often
-anymore, I much prefer the automatic script that I have which deploys through my
-Drone instance my website on git pushes.
-
-And before we get into the actual configuration, I would like to introduce a
-couple of variables. This is a bit more verbose than if I declared everything
-manually, but now I can change all three values at the same time without a
-hasle.
-#+NAME: org-proj-config-setup
-#+BEGIN_SRC emacs-lisp
-(defvar phundrak//projects-config-target
- "/rsync:Tilo:~/www/phundrak.com/config"
- "Points to where exported files for config.phundrak.com should be put")
-(defvar phundrak//projects-config-source
- "~/org/config/"
- "Points to where the sources for config.phundrak.com are")
-(defvar phundrak//projects-config-language
- "en"
- "Language of config.phundrak.com")
-(defvar phundrak//projects-config-recursive
- t
- "Defines whether subdirectories should be parsed for config.phundrak.com")
-#+END_SRC
-
-Now, here is my configuration. In this snippet, my org files located in my
-source directory get exported in the HTML format and published to my target
-directory on my remote server through RSYNC via TRAMP. A sitemap is
-automatically generated, which comes in handy with the online sitemap that is
-available through the navigation bar.
-#+NAME: org-proj-config-html
-#+BEGIN_SRC emacs-lisp
-("config-website-org"
- :base-directory ,phundrak//projects-config-source
- :base-extension "org"
- :publishing-directory ,phundrak//projects-config-target
- :recursive ,phundrak//projects-config-recursive
- :language ,phundrak//projects-config-language
- :publishing-function org-html-publish-to-html
- :headline-levels 5
- :auto-sitemap t
- :auto-preamble t)
-#+END_SRC
-
-We also have the component for all the static files needed to run the website
-(mostly images tbh).
-#+NAME: org-proj-config-static
-#+BEGIN_SRC emacs-lisp
-("config-website-static"
- :base-directory ,phundrak//projects-config-source
- :base-extension "png\\|jpg\\|gif\\|webp\\|svg\\|jpeg\\|ttf\\|woff\\|txt\\|epub\\|md"
- :publishing-directory ,phundrak//projects-config-target
- :recursive ,phundrak//projects-config-recursive
- :language ,phundrak//projects-config-language
- :publishing-function org-publish-attachment)
-#+END_SRC
-
-The project is then defined like so:
-#+NAME: org-proj-config
-#+BEGIN_SRC emacs-lisp
-("config-website"
- :components ("config-website-org"
- "config-website-static"))
-#+END_SRC
-
-***** Linguistics website
-:PROPERTIES:
-:CUSTOM_ID: User_Configuration-Org-mode-Org_projects-Linguistics_website-34b8d4e7
-:END:
-My linguistics website is made out of three projects. As for the previous
-project, let’s declare the common values for these.
-#+NAME: org-proj-lang-setup
-#+BEGIN_SRC emacs-lisp
-(defvar phundrak//projects-conlanging-target
- "/rsync:Tilo:~/www/phundrak.com/langue/"
- "Points to where exported files for langue.phundrak.com should be put")
-(defvar phundrak//projects-conlanging-source
- "~/Documents/conlanging/content/"
- "Points to where the sources for langue.phundrak.com are")
-(defvar phundrak//projects-conlanging-language
- "fr"
- "Language of langue.phundrak.com")
-(defvar phundrak//projects-conlanging-recursive
- t
- "Defines whether subdirectories should be parsed for langue.phundrak.com")
-#+END_SRC
-
-The first component is the one generating the HTML files from the org files.
-#+NAME: org-proj-lang-html
-#+BEGIN_SRC emacs-lisp
-("langue-phundrak-com-org"
- :base-directory ,phundrak//projects-conlanging-source
- :base-extension "org"
- :exclude "\\./\\(CONTRIB\\|README\\|head\\|temp\\|svg-ink\\).*"
- :publishing-directory ,phundrak//projects-conlanging-target
- :recursive ,phundrak//projects-conlanging-recursive
- :language ,phundrak//projects-conlanging-language
- :publishing-function org-html-publish-to-html
- :headline-levels 5
- :auto-sitemap t
- :auto-preamble t)
-#+END_SRC
-
-We also have the component for the LaTeX and PDF part of the website:
-#+NAME: org-proj-lang-pdf
-#+BEGIN_SRC emacs-lisp
-("langue-phundrak-com-pdf"
- :base-directory ,phundrak//projects-conlanging-source
- :base-extension "org"
- :exclude "\\./\\(CONTRIB\\|README\\|index\\|head\\|temp\\|svg-ink\\).*"
- :publishing-directory ,phundrak//projects-conlanging-target
- :recursive ,phundrak//projects-conlanging-recursive
- :language ,phundrak//projects-conlanging-language
- :publishing-function org-latex-publish-to-pdf
- :headline-levels 5
- :auto-preamble t)
-#+END_SRC
-
-And lastly, we have the component for all the static files needed to run the
-website:
-#+NAME: org-proj-lang-static
-#+BEGIN_SRC emacs-lisp
-("langue-phundrak-com-static"
- :base-directory ,phundrak//projects-conlanging-source
- :base-extension "png\\|jpg\\|gif\\|webp\\|svg\\|jpeg\\|ttf\\|woff\\|txt\\|epub"
- :publishing-directory ,phundrak//projects-conlanging-target
- :recursive ,phundrak//projects-conlanging-recursive
- :language ,phundrak//projects-conlanging-language
- :publishing-function org-publish-attachment)
-#+END_SRC
-
-The project is then defined like so:
-#+NAME: org-proj-lang
-#+BEGIN_SRC emacs-lisp
-("langue-phundrak-com"
- :components ("langue-phundrak-com-org"
- "langue-phundrak-com-static"
- "langue-phundrak-com-pdf"))
-#+END_SRC
-
-**** User information
-:PROPERTIES:
-:CUSTOM_ID: User_Configuration-Org-mode-Org_variables-User_information-6c7d5e3f
-:END:
-Some variables about myself need to be set so Org-mode knows what information to
-include in exported files.
-#+NAME: org-user-information
-#+BEGIN_SRC emacs-lisp
-(setq user-full-name "Lucien Cartier-Tilet"
- user-real-login-name "Lucien Cartier-Tilet"
- user-login-name "phundrak"
- user-mail-address "lucien@phundrak.com")
-#+END_SRC
-
-*** Recentf
-:PROPERTIES:
-:CUSTOM_ID: User-Configuration-Emacs-builtins-Recentf-b00d8ddd
-:END:
-~recentf-mode~ allows Emacs to list all recent files it read. It is also used by
-Spacemacs to display a list of recent files so they can be quickly opened by the
-user. Unfortunately, a lot of these files are just noise I don’t care about, but
-fortunately we can ignore files with the variable ~recentf-exclude~. So, I will
-ignore these paths:
-#+name: recentf-ignored-paths
-| =~/.authinfo.gpg= |
-| =~/.mail/= |
-| =~/.emacs.d/= |
-| =~/.emacs.spacemacs/= |
-| =~/.elfeed/index= |
-| =~/Documents/mu4e= |
-| =/tmp/= |
-
-#+name: recentf-ignored-paths-gen
-#+header: :var paths=recentf-ignored-paths
-#+BEGIN_SRC emacs-lisp :tangle no :exports none
-(mapconcat (lambda (path)
- (format "(add-to-list 'recentf-exclude\n (expand-file-name \"%s\"))"
- (replace-regexp-in-string "=" "" (car path))))
- paths
- "\n")
-#+END_SRC
-
-#+BEGIN_SRC emacs-lisp :noweb yes
-(with-eval-after-load 'recentf
- <>)
-#+END_SRC
-
-** Keybindings
-:PROPERTIES:
-:CUSTOM_ID: User_Configuration-Shortcuts-aef3f7a7
-:END:
-As you will see, I defined a LOT of custom keybindings. All of them are
-Spacemacs keybindings, defined in a way they can be used seamlessly with Evil.
-They almost all begin with ~o~, which is a prefix reserved for user-defined
-keybindings so they won’t conflict with any package. Let’s declare it like so.
-#+BEGIN_SRC emacs-lisp
-(spacemacs/declare-prefix "o" "custom")
-#+END_SRC
-
-Now, all keybindings that will be defined can be invoked in Normal-mode with the
-~SPC~ key followed by the sequence assigned to each keybinding.
-
-Before some more specialized categories, I have two commands which don’t fit
-into any other category that I sometime use. The first one is a fix for the Bépo
-keybindings which left out a keybind: ~winum-select-window-by-number~ is still
-bound to ~SPC ²~, which is not a key that is available on the bépo layout
-(instead, we use the dead key ~^~ followed by ~2~, or any digits). So instead,
-let’s use the key that is physically in the same place: ~$~.
-#+BEGIN_SRC emacs-lisp
-(spacemacs/declare-prefix "$" "select window by number")
-(spacemacs/set-leader-keys "$" 'winum-select-window-by-number)
-#+END_SRC
-
-The following, I use it rarely, it can launch an external command from Emacs to
-launch, for instance, my web browser or any other software not related to Emacs.
-It offers a similar interface to [[https://wiki.archlinux.org/index.php/Dmenu][dmenu]] through helm.
-#+BEGIN_SRC emacs-lisp
-(spacemacs/declare-prefix "or" "external command")
-(spacemacs/set-leader-keys "or" 'helm-run-external-command)
-#+END_SRC
-
-However this one I use often, generally in org or text buffers.
-#+BEGIN_SRC emacs-lisp
-(spacemacs/set-leader-keys "os" 'sort-lines)
-#+END_SRC
-
-*** Applications
-:PROPERTIES:
-:CUSTOM_ID: User_Configuration-Shortcuts-Applications-af8730b1
-:END:
-As this is a new category, let’s declare its prefix:
-#+BEGIN_SRC emacs-lisp
-(spacemacs/declare-prefix "oa" "applications")
-#+END_SRC
-
-Now, let’s also declare the keybindings in this category. ~oac~ will invoke
-Emacs’ calculator, while ~oac~ invokes the calendar, ~oae~ invokes the Eww web
-browser, and ~oaw~ invokes the weather forecast. Lastly, the apostrophe in ~o'~
-will invoke Eshell directly, without any popup window as with ~SPC '~ while
-~oan~ will open a new eshell buffer if another one already exists. ~ov~ will
-also open a vterm terminal.
-#+BEGIN_SRC emacs-lisp
-(spacemacs/set-leader-keys
- "o'" 'eshell-new
- "ov" 'vterm
- "oac" 'calc
- "oaC" 'calendar
- "oae" 'eww
- "oaw" 'wttrin)
-#+END_SRC
-
-**** Image mode
-:PROPERTIES:
-:CUSTOM_ID: User-Configuration-Keybindings-Applications-Image-mode-e5df694e
-:END:
-Viewing images in Emacs is nice, but I want to be able to do more than just view
-them, such as opening them in GIMP. I’ll also declare a couple of keybindings
-that make sense to me.
-#+BEGIN_SRC emacs-lisp
-(spacemacs/declare-prefix-for-mode 'image-mode "G" "Open in GIMP")
-(spacemacs/declare-prefix-for-mode 'image-mode "o" "Open in external viewer")
-(spacemacs/declare-prefix-for-mode 'image-mode "r" "Rotate clockwise")
-(spacemacs/set-leader-keys-for-major-mode 'image-mode
- "G" (lambda () (interactive) (start-process "" nil "gimp" (buffer-name)))
- "o" (lambda () (interactive) (start-process "" nil "xdg-open" (buffer-name)))
- "r" 'image-rotate)
-#+END_SRC
-
-**** Org tree slide
-:PROPERTIES:
-:CUSTOM_ID: User_Configuration-Keybindings-Applications-Org_tree_slide-29545c5e
-:END:
-Finally, here we have the keybindings for ~org-tree-slide~, a presentation mode
-with orgmode. Since I want the keys to be directly accessible without any prefix
-from Spacemacs, I’ll have to declare them the vanilla way. First we have
-keybindings that will launch the presentation:
-#+BEGIN_SRC emacs-lisp
-(define-key org-mode-map (kbd "") 'org-tree-slide-mode)
-(define-key org-mode-map (kbd "s-") 'org-tree-slide-skip-done-toggle)
-#+END_SRC
-
-Next, we have some additional keybindings that will only be active when in
-~org-tree-slide-mode~. The first one will allow us to exit this mode, while the
-second one will toggle the display of headers marked as ~DONE~. Next, we have
-~F9~ and ~F10~ which are bound to movement in the slide, while ~F11~ changes the
-way the content is displayed. We also set ~org-tree-slide-skip-outline-level~ to
-set the maximum depth we will display as an individual heading during the
-presentation.
-#+BEGIN_SRC emacs-lisp
-(when (require 'org-tree-slide nil t)
- (global-set-key (kbd "") 'org-tree-slide-mode)
- (global-set-key (kbd "S-") 'org-tree-slide-skip-done-toggle)
- (define-key org-tree-slide-mode-map (kbd "")
- 'org-tree-slide-move-previous-tree)
- (define-key org-tree-slide-mode-map (kbd "")
- 'org-tree-slide-move-next-tree)
- (define-key org-tree-slide-mode-map (kbd "")
- 'org-tree-slide-content)
- (setq org-tree-slide-skip-outline-level 4)
- (org-tree-slide-narrowing-control-profile)
- (setq org-tree-slide-skip-done nil))
-#+END_SRC
-
-*** Comments
-:PROPERTIES:
-:CUSTOM_ID: User_Configuration-Shortcuts-Comments-508db33d
-:END:
-Some keybindings are also related to comment editing, in particular using
-outorg. Let’s first declare the dedicated prefix:
-#+BEGIN_SRC emacs-lisp
-(spacemacs/declare-prefix "oc" "comments")
-#+END_SRC
-
-Now, let’s declare the following keybindings:
-#+BEGIN_SRC emacs-lisp
-(spacemacs/set-leader-keys
- "occ" 'outorg-copy-edits-and-exit
- "oce" 'outorg-edit-as-org
- "oco" 'outline-minor-mode)
-#+END_SRC
-
-~oco~ enables the outline minor mode, which then allows for the edition of
-comments in org buffers with ~oce~ and saving them to the original source file
-with ~occ~.
-
-*** Dired
-:PROPERTIES:
-:CUSTOM_ID: User-Configuration-Keybindings-Dired-2a45af8d
-:END:
-A couple of keybindings will be added to Dired. The first one is the opening
-parenthesis which will enable or disable ~dired-hide-details-mode~. On the other
-hand, a closing parenthesis will show git information in the current Dired
-buffer.
-#+BEGIN_SRC emacs-lisp
-(define-key dired-mode-map (kbd "(") 'dired-hide-details-mode)
-(define-key dired-mode-map (kbd ")") 'dired-git-info-mode)
-#+END_SRC
-
-Something I use from time to time is ~S-F1~ for opening dired in my ~$HOME~
-directory. For that, I simply did the following:
-#+BEGIN_SRC emacs-lisp
-(global-set-key (kbd "") (lambda () (interactive) (dired "~/")))
-#+END_SRC
-
-A couple of other useful utilities, sach as opening all marked files, sorting
-files, opening them externally and renaming them, are also bound to a simple key
-press:
-#+BEGIN_SRC emacs-lisp
-(define-key dired-mode-map (kbd "f") 'phundrak-open-marked-files)
-(define-key dired-mode-map (kbd "F") 'xah/open-in-external-app)
-(define-key dired-mode-map (kbd "s") 'xah/dired-sort)
-#+END_SRC
-
-*** Files
-:PROPERTIES:
-:CUSTOM_ID: User_Configuration-Shortcuts-Files-206c2126
-:END:
-#+BEGIN_SRC emacs-lisp
-(spacemacs/declare-prefix "of" "open org file")
-(spacemacs/set-leader-keys "of" 'phundrak-find-org-files)
-#+END_SRC
-
-I also have a shortcut for ~helm-locate~ in case I need to find a file that is
-not in these directories. One advantage of this over ~helm-find~ is that it
-doesn’t matter from where I call it, it will find any file on my system that
-matches the query, whereas ~helm-find~ will only search in the current directory
-and its subdirectories. This time, the declaration is much simpler:
-#+BEGIN_SRC emacs-lisp
-(spacemacs/declare-prefix "oF" "locate file")
-(spacemacs/set-leader-keys "oF" 'helm-locate)
-#+END_SRC
-
-And that’s it! This should list all my org files under these directories and
-give me fuzzy finding for these files. I just need to partially type the name of
-the file I want to open and it should open without any issue.
-
-*** Games
-:PROPERTIES:
-:CUSTOM_ID: User-Configuration-Keybindings-Games-c9e6ac80
-:END:
-Just to make it easier to launch it, I’ll declare a shortcut for launching
-tetris (which is built into Emacs).
-#+BEGIN_SRC emacs-lisp
-(spacemacs/declare-prefix "oat" "tetris")
-(spacemacs/set-leader-keys "oat" 'tetris)
-#+END_SRC
-
-Apparently, no evil keybindings are set for Tetris. Let’s declare them (adapted
-to the bépo layout):
-#+BEGIN_SRC emacs-lisp
-(require 'tetris)
-(define-key tetris-mode-map (kbd "c") 'tetris-move-left)
-(define-key tetris-mode-map (kbd "t") 'tetris-move-down)
-(define-key tetris-mode-map (kbd "s") 'tetris-rotate-prev)
-(define-key tetris-mode-map (kbd "r") 'tetris-move-right)
-#+END_SRC
-
-*** Multiple cursors
-:PROPERTIES:
-:CUSTOM_ID: User_Configuration-Shortcuts-Multiple_cursors-83db7c9c
-:END:
-I don’t really like Spacemacs’ layer for MultipleCursors, so I prefer to simply
-install the package and create shortcuts for it myself. Let’s first declare
-category:
-#+BEGIN_SRC emacs-lisp
-(spacemacs/declare-prefix "om" "multiple-cursors")
-#+END_SRC
-
-Now, let’s declare the shortcuts related to multiple-cursors:
-#+BEGIN_SRC emacs-lisp
-(spacemacs/set-leader-keys
- "ome" 'mc/edit-lines
- "omn" 'mc/mark-next-like-this
- "omp" 'mc/mark-previous-like-this
- "oma" 'mc/mark-all-like-this)
-#+END_SRC
-
-*** Org-mode
-:PROPERTIES:
-:CUSTOM_ID: User_Configuration-Shortcuts-Org-mode-a8938199
-:END:
-Now, onto some shortcuts related to org-mode. Let’s first declare the category:
-#+BEGIN_SRC emacs-lisp
-(spacemacs/declare-prefix-for-mode 'org-mode "mo" "custom" "User-defined keybindings")
-(spacemacs/declare-prefix-for-mode 'org-mode "mot" "toggle" "Toggle org elements")
-(spacemacs/declare-prefix-for-mode 'org-mode "moT" "tables")
-#+END_SRC
-
-#+BEGIN_SRC emacs-lisp
-(spacemacs/set-leader-keys-for-major-mode 'org-mode "ob" 'phundrak-blog-publish)
-(spacemacs/declare-prefix-for-mode 'org-mode "ob" "publish blog")
-#+END_SRC
-
-Now, I have a couple of shortcuts I use regularly:
-#+BEGIN_SRC emacs-lisp
-(spacemacs/set-leader-keys-for-major-mode 'org-mode
- "os" 'org-insert-structure-template
- "ots" 'phundrak/toggle-org-src-window-split
- "ott" 'org-sidebar-tree)
-(spacemacs/declare-prefix-for-mode 'org-mode "moS" "insert template")
-(spacemacs/declare-prefix-for-mode 'org-mode "mots" "toggle src split")
-#+END_SRC
-
-~os~ allows me to insert an org structure template defined in
-~org-structure-template-alist~ (see [[#User_Configuration-Org-mode-Org_variables-Org_behavior-0319db38][Org behavior]]), while ~ott~ displays the
-outline of the current org file.
-
-~oT~ is the prefix for tree-related operations:
-#+BEGIN_SRC emacs-lisp
-(spacemacs/declare-prefix-for-mode 'org-mode "moT" "tables")
-#+END_SRC
-
-These shortcuts allow to manipulate the width of the column the cursor is
-currently in, by either shrinking it, expanding it, or toggling its state
-between shrunk or expanded. A prefix for all of these commands has been also
-added in order to make the purpose of the shortcuts clearer.
-#+BEGIN_SRC emacs-lisp
-(spacemacs/set-leader-keys-for-major-mode 'org-mode
- "oTt" 'org-table-toggle-column-width
- "oTe" 'org-table-expand
- "oTs" 'org-table-shrink)
-(spacemacs/declare-prefix-for-mode 'org-mode "moTt" "toggle width")
-(spacemacs/declare-prefix-for-mode 'org-mode "moTe" "expand")
-(spacemacs/declare-prefix-for-mode 'org-mode "moTs" "shrink")
-#+END_SRC
-
-Finaly, I set the following shortcut in order to easily remove ~RESULTS~ blocks
-from org source code blocks:
-#+BEGIN_SRC emacs-lisp
-(spacemacs/set-leader-keys-for-major-mode 'org-mode
- "or" 'org-babel-remove-result-one-or-many)
-(spacemacs/declare-prefix-for-mode 'org-mode "mor" "remove org result")
-#+END_SRC
-
-*** Toggle
-:PROPERTIES:
-:CUSTOM_ID: User_Configuration-Shortcuts-Toggle-d53c27ef
-:END:
-This category allows to toggle some modes and options.
-#+BEGIN_SRC emacs-lisp
-(spacemacs/declare-prefix "ot" "toggle")
-#+END_SRC
-
-As you can see, I have here four shortcuts for toggling various elements in
-Emacs:
-- ~otb~ :: toggles ~fancy-battery-mode~. This comes in very handy when I am on a
- laptop that is not pluged in or which is charging.
-- ~otd~ :: toggles ~elcord-mode~. This mode is used to create an Emacs rich
- integration in Discord.
-- ~otf~ :: toggles the activation of FlyCheck, Emacs’ spell checker. It is by
- default disabled, and I can turn it on with this shortcut only when needed.
-- ~ots~ :: toggles ~prettify-symbols-mode~. This allows Emacs to replace some
- symbols by some others, like for example by replacing ~lambda~ in Emacs Lisp
- buffers with an actual λ.
-- ~otS~ :: toggles whether or not Eshell should shorten the current path in its
- prompt
-#+BEGIN_SRC emacs-lisp
-(spacemacs/set-leader-keys
- "otb" 'fancy-battery-mode
- "otd" 'elcord-mode
- "otf" 'flycheck-mode
- "ots" 'prettify-symbols-mode
- "otS" 'phundrak-prompt-toggle-abbreviation)
-#+END_SRC
-
-We also have some input methods-related shortcuts in a sub-category: ~oti~. The
-first shortcuts below are used to either toggle between no input method or the
-last one used (~otit~), or choose an input method among the various available
-ones from Emacs (~otis~).
-#+BEGIN_SRC emacs-lisp
-(spacemacs/declare-prefix "oti" "input methods")
-(spacemacs/set-leader-keys
- "otit" 'toggle-input-method
- "otis" 'set-input-method)
-#+END_SRC
-
-The shortcuts below though allow me to directly switch to one of these three
-known input methods I sometimes or often use, namely Japanese, Tibetan and IPA
-(by typing in X-SAMPA).
-#+BEGIN_SRC emacs-lisp
-(spacemacs/declare-prefix "otij" "Japanese")
-(spacemacs/declare-prefix "otix" "IPA (X-SAMPA)")
-(spacemacs/declare-prefix "otiT" "Tibetan")
-(spacemacs/set-leader-keys
- "otij" (lambda () (interactive) (set-input-method 'japanese))
- "otix" (lambda () (interactive) (set-input-method 'ipa-x-sampa))
- "otiT" (lambda () (interactive) (set-input-method 'tibetan-wylie)))
-#+END_SRC
-
-** Mu4e
-:PROPERTIES:
-:CUSTOM_ID: User_Configuration-Mu4e-f3df8e9e
-:END:
-Mu4e is a frontend for mu, an email analyzer which sits on top of a Maildir
-which gets updated with the ~mbsync~ command from ~isync~. It has a lot of neat
-features, but I guess my favorite ones are:
-1. the search query feature
-2. rendering an HTML email in the browser
-
-*** Setup
-:PROPERTIES:
-:CUSTOM_ID: User-Configuration-Mu4e-Setup-1d23809e
-:END:
-Due to mu sitting on top of a maildir, I need to tell mu4e where said maildir
-is, and point it the trash, archive, and sent folders as well as the refresh
-command and how frequently I want my emails to be refreshed.
-#+BEGIN_SRC emacs-lisp
-(setq mu4e-maildir "~/.mail"
- mu4e-trash-folder "/Trash"
- mu4e-refile-folder "/Archive"
- mu4e-sent-folder "/Sent"
- mu4e-drafts-folder "/Drafts"
- mu4e-get-mail-command "mbsync -a"
- mu4e-update-interval 60)
-#+END_SRC
-
-This source block is an example of the search queries in mu4e, and part of the
-reason why I very much like mu4e: these bookmarks are actually defined by search
-queries, but act as if they were just yet another type of custom inbox you get
-with modern Email client (and often you don’t even get them). All these
-bookmarks can be accessed through a shortcut on the main mu4e buffer, prefixed
-by ~b~. So, for instance, my unread messages are accessed through ~bU~.
-#+BEGIN_SRC emacs-lisp
-(setq mu4e-bookmarks
- `((,(s-join " "
- '("NOT flag:trashed"
- "AND (maildir:/Inbox OR maildir:/Junk)"
- "AND NOT to:CONLANG@LISTSERV.BROWN.EDU"
- "AND NOT to:AUXLANG@LISTSERV.BROWN.EDU"
- "AND NOT to:ateliers-emacs@framalistes.org"
- "AND NOT to:ateliers-paris@emacs-doctor.com"
- "AND NOT list:ateliers-emacs.framalistes.org"
- "AND NOT list:ateliers-paris.emacs-doctor.com"))
- "Inbox" ?i) ;; Inbox without the linguistics mailing lists
- (,(s-join " "
- '("NOT flag:trashed"
- "AND (maildir:/Inbox OR maildir:/Junk)"
- "AND (f:/.*up8\.edu|.*univ-paris8.*/"
- "OR c:/.*up8\.edu|.*univ-paris8.*/"
- "OR t:/.*up8\.edu|.*univ-paris8.*/)"))
- "University" ?u) ;; University-related emails
- (,(s-join " "
- '("to:CONLANG@LISTSERV.BROWN.EDU"
- "OR to:AUXLANG@LISTSERV.BROWN.EDU"))
- "Linguistics" ?l) ;; linguistics mailing lists
- (,(s-join " "
- '("list:ateliers-emacs.framalistes.org"
- "OR to:ateliers-paris@emacs-doctor.com"
- "OR list:ateliers-paris.emacs-doctor.com"))
- "Emacs" ?e) ;; Emacs mailing list
- ("maildir:/Sent" "Sent messages" ?s)
- ("flag:unread AND NOT flag:trashed" "Unread messages" ?U)
- ("date:today..now AND NOT flag:trashed" "Today's messages" ?t)
- ("date:7d..now AND NOT flag:trashed" "Last 7 days" ?w)
- ("date:1m..now AND NOT flag:trashed" "Last month" ?m)
- ("date:1y..now AND NOT flag:trashed" "Last year" ?y)
- ("flag:trashed AND NOT flag:trashed" "Trash" ?T)
- ("mime:image/* AND NOT flag:trashed" "Messages with images" ?p)))
-#+END_SRC
-
-On new email arrival, Emacs can send the system a notification which will be
-handled as any other notification received by the system and will display the
-number of unread emails to the user; in my case, notifications are handled by
-AwesomeWM.
-#+BEGIN_SRC emacs-lisp
-(setq mu4e-enable-notifications t
- mu4e-alert-email-notification-types '(count))
-(with-eval-after-load 'mu4e-alert
- (mu4e-alert-set-default-style 'notifications))
-(add-hook 'mu4e-view-mode-hook 'visual-line-mode)
-#+END_SRC
-
-This is the setup I have for my SMTP mail server: I point Emacs’ SMTP services
-to my private mail server on its SMTP port, which should be used with a STARTTLS
-stream. And I tell Emacs this is the default way to send an email.
-#+BEGIN_SRC emacs-lisp
-(setq smtpmail-smtp-server "mail.phundrak.com"
- smtpmail-smtp-service 587
- smtpmail-stream-type 'starttls
- message-send-mail-function 'smtpmail-send-it)
-#+END_SRC
-
-I wish my emails to be signed by default using PGP/MIME. ~mu4e~ uses ~message~
-for composing new emails, so I simply need to add the function that will add the
-signature to emails to the hook called when creating a new email.
-#+BEGIN_SRC emacs-lisp
-(add-hook 'mu4e-compose-mode-hook 'mml-secure-message-sign-pgpmime)
-#+END_SRC
-
-mu4e used to be able to export emails to PDFs, but unfortunately this
-possibility was discontinued. But we can (sort of) bring it back!
-#+BEGIN_SRC emacs-lisp
-(defun mu4e-action-open-as-pdf (msg)
- "Export and open as PDF a mu4e `MSG'"
- (let* ((date (mu4e-message-field msg :date))
- (infile (mu4e~write-body-to-html msg))
- (outfile (format-time-string "/tmp/%Y-%m-%d%H%M%S.pdf" date)))
- (with-temp-buffer
- (shell-command
- (format "wkhtmltopdf %s %s" infile outfile) t))
- (find-file outfile)))
-
-(add-to-list 'mu4e-view-actions '("PDF view" . mu4e-action-open-as-pdf) t)
-#+END_SRC
-
-Lastly, some emails are better displayed in a browser than in Emacs. My Emacs
-build has the webkit browser enabled, so I’ll add an option to open with it
-emails.
-#+BEGIN_SRC emacs-lisp
-(defun phundrak/mu4e-view-in-browser (msg)
- (xwidget-webkit-browse-url (concat "file://"
- (mu4e~write-body-to-html msg))))
-
-(add-to-list 'mu4e-view-actions
- '("Xwidget Webkit Browser" . phundrak/mu4e-view-in-browser)
- t)
-#+END_SRC
-
-*** Visual Configuration
-:PROPERTIES:
-:CUSTOM_ID: User-Configuration-Mu4e-Visual-Configuration-34f56f7e
-:END:
-The following also allows me to automatically include my signature in my Emails,
-to view images in my Emacs buffers and to show me the address of my contacts and
-not just their names.
-#+BEGIN_SRC emacs-lisp
-(setq mu4e-compose-signature-auto-include t
- mu4e-view-show-images t
- mu4e-view-prefer-html t
- mu4e-view-show-addresses t)
-#+END_SRC
-
-Now this hook is added so I can get a maximal width for the text of my emails, I
-really don’t like it when lines are kilometers long. I would like instead to
-hook ~visual-line-mode~ and ~auto-fill-mode~, but for some reasons Emacs throws
-an error when I add them, So I go with ~visual-fill-column-mode~ instead.
-#+BEGIN_SRC emacs-lisp
-(add-hook 'mu4e-view-mode-hook 'visual-fill-column-mode)
-#+END_SRC
-
-Icons are nice and all, but my current font does not display some of the default
-icons set by mu4e. Due to this, I will define back these icons to the original
-characters defined by mu4e:
-#+BEGIN_SRC emacs-lisp
-(setq mu4e-headers-draft-mark '("D" . "D")
- mu4e-headers-flagged-mark '("F" . "F")
- mu4e-headers-new-mark '("N" . "N")
- mu4e-headers-passed-mark '("P" . "P")
- mu4e-headers-replied-mark '("R" . "R")
- mu4e-headers-seen-mark '("S" . "S")
- mu4e-headers-trashed-mark '("T" . "T")
- mu4e-headers-attach-mark '("a" . "a")
- mu4e-headers-encrypted-mark '("x" . "x")
- mu4e-headers-signed-mark '("s" . "s")
- mu4e-headers-unread-mark '("u" . "u"))
-#+END_SRC
-
-I don’t like the American time format. I really don’t. I prefer much more
-something more standard, like ISO8601 standard. Not exactly ISO8601, but close
-to it. Also, fuck the paywalls imposed by ISO.
-#+BEGIN_SRC emacs-lisp
-(setq mu4e-view-date-format "%Y-%m-%d %R"
- mu4e-headers-date-format "%Y-%m-%d")
-#+END_SRC
-
-*** Misc
-:PROPERTIES:
-:CUSTOM_ID: User-Configuration-Mu4e-Misc-9c7a4f5b
-:END:
-I am unsure yet if this has any effect on mu4e, but this variable should
-discourage mu4e from reading rich text emails and instead open them as plain
-text. However, I do not wish to discourage opening HTML emails since I can open
-them in the browser.
-#+BEGIN_SRC emacs-lisp
-(setq mm-discouraged-alternatives '("text/richtext"))
-#+END_SRC
-
-** Miscellaneous
-:PROPERTIES:
-:CUSTOM_ID: User_Configuration-Miscellaneous-d230bc2f
-:END:
-I have a lot of variables that need to be set but don’t fall in any other
-category, so I’ll collect them here.
-
-I have this regexp for detecting paragraphs.
-#+BEGIN_SRC emacs-lisp
-(setq paragraph-start "\f\\|[ \t]*$\\|[ \t]*[-+*] ")
-#+END_SRC
-
-And this variable for Elcord so the main icon displayed in Discord is the icon
-representing the current major-mode. I also don’t want to display the small
-icon, so let’s get rid of that.
-#+BEGIN_SRC emacs-lisp
-(setq elcord-use-major-mode-as-main-icon t
- elcord-show-small-icon nil)
-#+END_SRC
-
-*** Pinentry
-:PROPERTIES:
-:CUSTOM_ID: User_Configuration-Miscellaneous-Pinentry-95004d5a
-:END:
-Pinentry should use the ~loopback~ mode when communicating with GnuPG. Let’s set
-it so:
-#+BEGIN_SRC emacs-lisp
-(setq epg-pinentry-mode 'loopback)
-#+END_SRC
-
-*** Wttr.in
-:PROPERTIES:
-:CUSTOM_ID: User_Configuration-Miscellaneous-Wttr.in_cities-dd24f8c5
-:END:
-Thanks to the wttrin package, I can get the weather forecast in Emacs for a
-couple of cities. I just need to specify them to Emacs like so:
-#+BEGIN_SRC emacs-lisp
-(setq wttrin-default-cities '("Aubervilliers" "Paris" "Lyon" "Nonières"
- "Saint Agrève"))
-#+END_SRC
-
-However, the package is currently broken (it was last updated in 2017): wttr.in
-now returns by default an HTML page instead of an ASCII result. In order to fix
-it, a ~?A~ must be added at the end of the request in order to get a nice
-output. Also, let’s use the HTTPS protocol while we’re at it.
-#+BEGIN_SRC emacs-lisp
-(defun wttrin-fetch-raw-string (query)
- "Get the weather information based on your QUERY."
- (let ((url-user-agent "curl"))
- (add-to-list 'url-request-extra-headers wttrin-default-accept-language)
- (with-current-buffer
- (url-retrieve-synchronously
- (format "http%s://wttr.in/%s?A"
- (if (gnutls-available-p) "s" "")
- query)
- (lambda (status)
- (switch-to-buffer (current-buffer))))
- (decode-coding-string (buffer-string)
- 'utf-8))))
-#+END_SRC
-
-** Nov-mode
-:PROPERTIES:
-:CUSTOM_ID: User_Configuration-Nov-mode-6f10765d
-:END:
-~nov-mode~ is the mode used in the Epub reader. Here I will write a little
-function that I will call through a hook each time I’m opening a new EPUB file.
-#+BEGIN_SRC emacs-lisp
-(defun my-nov-font-setup ()
- (face-remap-add-relative 'variable-pitch :family "Charis SIL"
- :size 16
- :height 1.0))
-#+END_SRC
-
-Let’s bind this function to the ~nov-mode~ hook. By the way, we’ll also enable
-the ~visual-line-mode~ here, just in case.
-#+BEGIN_SRC emacs-lisp
-(mapc (lambda (mode)
- (add-hook 'nov-mode-hook mode))
- '('my-nov-font-setup 'visual-line-mode))
-#+END_SRC
-
-Let’s also set the maximum length of the lines in ~nov-mode~:
-#+BEGIN_SRC emacs-lisp
-(setq nov-text-width 80)
-#+END_SRC
-
-** Programming
-:PROPERTIES:
-:CUSTOM_ID: User_Configuration-Programming-b4b565ae
-:END:
-*** LSP
-:PROPERTIES:
-:CUSTOM_ID: User_Configuration-LSP-4f8aa691
-:END:
-When it comes to the LSP layer, there are some options which are not enabled by
-default that I want to use, especially some modes I want to take advantage of.
-This is why I enable first the ~lsp-treemacs-sync-mode~ so treemacs is LSP
-aware:
-#+BEGIN_SRC emacs-lisp
-(lsp-treemacs-sync-mode 1)
-#+END_SRC
-
-I also enable some layers related to ~dap~, the Debug Adapter Protocol, which
-works really nicely with LSP. Let’s enable Dap’s modes:
-#+BEGIN_SRC emacs-lisp
-(dap-mode 1)
-(dap-ui-mode 1)
-(dap-tooltip-mode 1)
-#+END_SRC
-
-Finally, I also want the documentation tooltip to show up when the cursor is
-above a documented piece of code or symbol. Let’s enable that too:
-#+BEGIN_SRC emacs-lisp
-(tooltip-mode 1)
-#+END_SRC
-
-*** ASM configuration
-:PROPERTIES:
-:CUSTOM_ID: User_Configuration-ASM_configuration-f6dc7674
-:END:
-The first thing I will set with my ASM configuration is where the reference PDF
-is located.
-#+BEGIN_SRC emacs-lisp
-(setq x86-lookup-pdf "~/Documents/code/asm/Intelx86/325383-sdm-vol-2abcd.pdf")
-#+END_SRC
-
-I will also modify what the comment character is, from a ~;~ to a ~#~:
-#+BEGIN_SRC emacs-lisp
-(setq asm-comment-char ?\#)
-#+END_SRC
-
-*** C/C++
-:PROPERTIES:
-:CUSTOM_ID: User_Configuration-C-C++-76c3f997
-:END:
-As the C/C++ syntax is checked by flycheck, let’s make sure we are using the
-latest standard available, that is C++17 and C17, from Clang.
-#+BEGIN_SRC emacs-lisp
-(add-hook 'c-mode-hook
- (lambda ()
- (setq flycheck-clang-language-standard "c17")))
-(add-hook 'c++-mode-hook
- (lambda ()
- (setq flycheck-clang-language-standard "c++17")))
-#+END_SRC
-
-*** Dart configuration
-:PROPERTIES:
-:CUSTOM_ID: User_Configuration-Dart_configuration-ecf24ebf
-:END:
-For Dart, I mainly declared some custom shortcuts bound to ~dart-mode~ related
-to flutter, so nothing too exciting here. Some prefix are declared in order to
-avoid the shortcuts in helm to show up as just ~custom~.
-#+begin_src emacs-lisp
-(spacemacs/declare-prefix-for-mode 'dart-mode "mo" "user-defined")
-(spacemacs/declare-prefix-for-mode 'dart-mode "mof" "flutter")
-(spacemacs/declare-prefix-for-mode 'dart-mode "mofr" "flutter-run")
-#+end_src
-
-Now, for the shortcuts themselves:
-#+BEGIN_SRC emacs-lisp
-(spacemacs/set-leader-keys-for-major-mode 'dart-mode
- "ofH" 'flutter-hot-restart
- "ofh" 'flutter-hot-reload
- "ofq" 'flutter-quit
- "ofr" (lambda () (interactive) (flutter-run "-v"))
- "ofs" 'flutter-screenshot)
-#+END_SRC
-
-*** Emacs Lisp
-:PROPERTIES:
-:CUSTOM_ID: User_Configuration-Emacs_Lisp-59230f3c
-:END:
-Here will be stored my configuration directly related to Emacs Lisp, including
-some functions or default modes.
-
-**** Enable ~eldoc-mode~ by default
-:PROPERTIES:
-:CUSTOM_ID: User_Configuration-Emacs_Lisp-Enable_~eldoc-mode~_by_default-f131abde
-:END:
-By default, if some Elisp code is opened, I want to enable ~eldoc-mode~ so I can
-easily get some documentation on the symbols in the source code. This is done
-via the use of hooks.
-#+BEGIN_SRC emacs-lisp
-(add-hook 'prog-mode-hook 'eldoc-mode)
-#+END_SRC
-
-**** ~phundrak/write-to-buffer~
-:PROPERTIES:
-:CUSTOM_ID: User_Configuration-Emacs_Lisp-~phundrak-write-to-buffer~-2f192dd3
-:END:
-I was very surprised when I discovered no such function exists in Elisp. This
-function basically writes a string into a buffer, and optionally switches the
-user to the buffer. Here is the code for that function:
-#+BEGIN_SRC elisp :results silent
-(defun write-to-buffer ($input-string $outputbuf &optional $switchbuf)
- "Writes `$input-string' to the specified `output-buffer'. If
-`switch-buffer' is non-nil, the active buffer will switch to the
-output buffer; otherwise, it will take the user back to their
-initial buffer. Works with `$input-string' as a string or a list
-of strings."
- (let ((oldbuf (current-buffer)))
- (switch-to-buffer $outputbuf)
- (cond ((char-or-string-p $input-string) (insert $input-string))
- ((listp $input-string) (dolist (elem $input-string)
- (insert (format "%s\n" elem)))))
- (unless $switchbuf
- (switch-to-buffer oldbuf))))
-#+END_SRC
-
-*** Python
-:PROPERTIES:
-:CUSTOM_ID: User_Configuration-Python-9cdd1b06
-:END:
-Emacs throws me an error about the python interpreter, let’s silence it:
-#+BEGIN_SRC emacs-lisp
-(setq python-shell-completion-native-disabled-interpreters '("python"))
-#+END_SRC
-
-*** Rust
-:PROPERTIES:
-:CUSTOM_ID: User_Configuration-Rust-ba633575
-:END:
-I need to point to racer where the source code of Rust is located so I can get
-some documentation. This is installed with the ~rust-src~ component you can get
-through ~rustup~. To install it, simply run
-#+BEGIN_SRC sh :tangle no :exports code
-rustup component add rust-src
-#+END_SRC
-
-Now, the source code for Rust should be included in your installation. I
-personally prefer to develop with Rust stable, so let’s indicate to Emacs to
-search for documentation in the stable sources:
-#+BEGIN_SRC emacs-lisp
-(setq racer-rust-src-path
- "~/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src")
-#+END_SRC
-
-Rust’s default ~cargo check~ command is already very good, however I also enjoy
-getting some more hints while developping, and ~clippy~ does a very good job at
-it. To get clippy, I need to run the following to install it:
-#+BEGIN_SRC sh :tangle no :exports code
-rustup compontent add clippy
-#+END_SRC
-
-And this will get it installed with all of my Rust toolchain, and it will be
-updated with it. Now, let’s indicate LSP that I want to use that instead of
-~check~:
-#+BEGIN_SRC emacs-lisp
-(setq lsp-rust-analyzer-cargo-watch-command "clippy")
-#+END_SRC
-
-Finally, I wish to enable ~electric-pair-mode~ and ~indent-guide-mode~ for Rust
-files, so let’s enable that through the use of a hook:
-#+BEGIN_SRC emacs-lisp :tangle no
-(add-hook 'rust-mode-hook
- '(lambda ()
- (local-set-key (kbd "TAB") #'company-indent-or-complete-common)
- (electric-pair-mode 1)))
-#+END_SRC
-
-*** Scheme
-:PROPERTIES:
-:CUSTOM_ID: User_Configuration-Scheme-e35aa50a
-:END:
-The Scheme configuration will be very short, I just need to tell Emacs the name
-of the interpreter since it is not the default one:
-#+BEGIN_SRC emacs-lisp
-(setq geiser-chicken-binary "chicken-csi")
-#+END_SRC
-
-** Projectile
-:PROPERTIES:
-:CUSTOM_ID: User_Configuration-Projectile-06e580f0
-:END:
-Projectile is an awesome utility which helps managing projects within Emacs. It
-will automatically detect version controlled directories, and will by default
-assume this is a project I can be working on. However, there are some
-directories that are version controlled that I do not want to see in my list of
-projects, namely all the cached AUR packages from my AUR helper, ~paru~. They
-are all stored in the same parent directory, so let’s ignore that. I will also
-make Emacs ignore all ~node_modules~ directories it could encounter. And for
-some reason, =~/.emacs.spacemacs= is always in my projects list (I now use
-XDG-compliant directories), so let’s also ignore that.
-#+BEGIN_SRC emacs-lisp
-(setq projectile-ignored-projects '("~/.cache/paru" "~/.emacs.spacemacs" "/tmp"))
-(add-to-list 'projectile-globally-ignored-directories "node_modules")
-#+END_SRC
-
-** Readers
-:PROPERTIES:
-:CUSTOM_ID: User-Configuration-Readers-aacb14d4
-:END:
-Thanks to Discord user shanks, I discovered pdf-tools gives us access to a very
-interesting minor mode: ~pdf-view-midnight-minor-mode~. And this is exactly what
-I missed in my Emacs PDF reader from Zathura! I still think Zathura is a
-fantastic tool, but now my PDF reader in Emacs is almost perfect! I just need to
-adjust some colors:
-#+BEGIN_SRC emacs-lisp
-(with-eval-after-load 'pdf-view
- (setq pdf-view-midnight-colors '("#d8dee9" . "#2e3440")))
-#+END_SRC
-
-Let’s also enable dark mode automatically:
-#+BEGIN_SRC emacs-lisp
-(add-hook 'pdf-tools-enabled-hook 'pdf-view-midnight-minor-mode)
-#+END_SRC
-
-And there we go! A beautiful, dark-mode PDF reader inside Emacs! And with
-Spacemacs, I can enable or disable this minor mode anytime with the shortcut
-~, n~.
-
-** Security
-:PROPERTIES:
-:CUSTOM_ID: User_Configuration-Security-21d88555
-:END:
-This paragraph is about making Emacs and GPG as a whole (since Emacs is /always/
-open on my computer) more secure. The first thing I want to make is a function
-that will close any buffer that contains an open ~.gpg~ file –I certainly do not
-want anyone to be able to read such files on my computer if I leave it even for
-a couple of minutes.
-#+BEGIN_SRC emacs-lisp
-(defun phundrak/kill-gpg-buffers ()
- "Kill GPG buffers."
- (interactive)
- (let ((buffers-killed 0))
- (dolist (buffer (buffer-list))
- (with-current-buffer buffer
- (when (string-match ".*\.gpg$" (buffer-name buffer))
- (message "Auto killing .gpg buffer '%s'" (buffer-name buffer))
- (when (buffer-modified-p buffer)
- (save-buffer))
- (kill-buffer buffer)
- (setq buffers-killed (+ buffers-killed 1)))))
- (unless (zerop buffers-killed)
- ;; Kill gpg-agent.
- (shell-command "gpgconf --kill gpg-agent")
- (message "%s .gpg buffers have been autosaved and killed" buffers-killed))))
-#+END_SRC
-
-Notice the ~(shell-command "gpgconf --kill gpg-agent")~ command there: it kills
-~gpg-agent~ which will always respawn each time GPG2 is invoked. That way, I
-know anyone trying to open a GPG file will have to insert my password when
-trying to do so instead of just hoping I entered it not long ago and they won’t
-have to.
-
-But surely, if I only define this function and hope to call it each time I leav
-my computer, surely at one point I will forget to execute it before leaving. I
-can’t trust myself to always call it manually. Which is why I’ll ask Emacs
-itself to call it after it detects a minute of idling. It may become from times
-to times a bit of a pain, but at least I’m now sure I won’t ever have to worry
-about someone reading my GPG files open in Emacs while I’m out for a quick
-break.
-#+BEGIN_SRC emacs-lisp
-(run-with-idle-timer 60 t 'phundrak/kill-gpg-buffers)
-#+END_SRC
-
-** Snippets
-:PROPERTIES:
-:CUSTOM_ID: User_Configuration-Snippets-67a32065
-:HEADER-ARGS:snippet: :padline no :mkdirp yes
-:END:
-Yasnippet’s snippets tool is extremely powerful and allows me to write very
-quickly code. For now, we have snippets for two modes. The files you’ll see
-below are exported to ~$HOME/.emacs.spacemacs/private/snippets/~ and to their
-respective mode directory. For instance, my ~caption~ snippet for org-mode will
-be exported to ~$HOME/.emacs.spacemacs/private/snippets/org-mode/caption~.
-
-Be aware that on top of these custom snippets, I also use the package
-[[file:awesome.org::#Autostart-f2cf42fe][yasnippet-snippets]] which provide plenty of already made snippets.
-
-*** Rust snippets
-:PROPERTIES:
-:CUSTOM_ID: User_Configuration-Snippets-Rust_snippets-b106fad4
-:END:
-I have so far two snippets, the first one is actually just a convenience to make
-it easier to type a ~println!~ macro than the default snippet.
-#+BEGIN_SRC snippet :tangle ~/.emacs.spacemacs/private/snippets/rust-mode/println
-# -*- mode: snippet -*-
-# name: println
-# key: pln
-# --
-println!("${1:{}}", $2);
-#+END_SRC
-
-The second one is more interesting: it is used to create a ~new~ method for a
-struct, and it will try to create a function that will assign each argument
-passed to the method to members of the struct. It relies on the custom function
-[[#Custom-functions-yas-rust-new-assignments-4ad16bde][I wrote here]].
-#+BEGIN_SRC snippet :tangle ~/.emacs.spacemacs/private/snippets/rust-mode/new
-# -*- mode: snippet -*-
-# name: new
-# key: _new
-# --
-fn new(${1:args}) -> Self {
- $0
- Self {
- ${1:$(phundrak-yas-rust-new-assignments yas-text)}
- }
-}
-#+END_SRC
-
-*** Org headers
-:PROPERTIES:
-:CUSTOM_ID: User_Configuration-Snippets-org-mode_snippets-Org_headers-ed14fbac
-:END:
-The first two snippets are used to add HTML or LaTeX attributes to elements in
-org-mode. The third also has a similar usage, inserting a ~#+CAPTION~ header
-before an element, as well as the fourth which inserts a ~#+NAME~ header.
-#+BEGIN_SRC snippet :tangle ~/.emacs.spacemacs/private/snippets/org-mode/attr_html
-# -*- mode: snippet -*-
-# name: ATTR HTML
-# key: >
-
-<>
-
-<>
-
-(let* ((makeface (string= "yes" makeface))
- (headers (cadr input))
- (faces (mapcar (lambda (face)
- (phundrak-filter (lambda (elem)
- (or (numberp (cadr elem))
- (not (string= ""
- (cadr elem)))))
- (phundrak-zip headers face)))
- (cddr input))))
- (mapconcat (lambda (face)
- (concat
- (format (if makeface "`(%s ((t " "(%s `")
- (cadr (assoc "Name" face)))
- (format "(%s %s %s %s)"
- (if (assoc "additional" face)
- (cadr (assoc "additional" face))
- "")
- (let ((result ""))
- (dolist (property '("inherit" "weight" "height" "foreground"
- "background" "underline")
- result)
- (let ((prop (assoc property face)))
- (when prop
- (setf result (format "%s :%s %s"
- result
- property
- (if (numberp (cadr prop))
- (number-to-string (cadr prop))
- (cadr prop))))))))
- (if (assoc "font" face)
- (format ":font \"%s\""
- (cadr (assoc "font" face)))
- "")
- (if (assoc "family" face)
- (format ":family \"%s\""
- (cadr (assoc "family" face)))
- ""))
- (if makeface
- ")) t)"
- ")")))
- faces
- "\n"))
-#+END_SRC
-
-Sometimes, some visual properties just don’t fit right for me and I need to edit
-them. This is the case for example for org-mode for which I want to have a mix
-of fixed and variable pitches. Below you can see the code that does that for me,
-I’ll get into more detail below this code block.
-#+BEGIN_SRC emacs-lisp :noweb yes
-(let (
- <>
- )
- (custom-theme-set-faces
- 'user
- <>
- <>
- <>
- ))
-#+END_SRC
-
-**** Diff and Magit
-:PROPERTIES:
-:CUSTOM_ID: User-Configuration-Visual-configuration-Better-faces-Diff-6ac98986
-:END:
-Apparently, diff and Magit faces do not follow the nord theme’s color scheme, so
-let’s redefine their background and sometimes their foreground.
-#+tblname: diff-faces
-| / | |
-| Name | background |
-|----------------------+------------------|
-| ediff-current-diff-A | ,phundrak-nord11 |
-| ediff-current-diff-C | ,phundrak-nord13 |
-| ediff-current-diff-C | ,phundrak-nord14 |
-
-**** Mu4e
-:PROPERTIES:
-:CUSTOM_ID: User-Configuration-Visual-configuration-Better-faces-Mu4e-7b52d940
-:END:
-The nord theme is great and all, but for some reason some faces in mu4e aren’t
-displayed properly, such as the ~mu4e-highlight-face~. Let’s fix that!
-#+tblname: mu4e-faces
-| / | | |
-| Name | background | foreground |
-|---------------------+-----------------+-----------------|
-| mu4e-highlight-face | ,phundrak-nord9 | ,phundrak-nord0 |
-
-**** Org-mode
-:PROPERTIES:
-:CUSTOM_ID: User-Configuration-Visual-configuration-Better-faces-Org-mode-07754177
-:END:
-Fonts will play an important part in this, but so will colors and font size. The
-following code is largely based on the one found [[https://zzamboni.org/post/beautifying-org-mode-in-emacs/][on this blog post]] and [[https://lepisma.xyz/2017/10/28/ricing-org-mode/][this one]].
-First here are some common properties that will be reused in faces below:
-#+tblname: org-common-faces
-| / | | < | | |
-| Name | inherit | font | height | weight |
-|---------+---------+---------------+--------+--------|
-| orgfont | | Charis SIL | 120 | |
-| head | default | | | bold |
-| fixed | | Cascadia Code | 0.8 | |
-
-#+tblname: org-faces
-| / | < | | | | | | | |
-| Name | additional | inherit | foreground | background | height | weight | italic | underline |
-|---------------------------+------------------+-------------------------------+------------------+-----------------+--------+--------+--------+-----------|
-| org-level-1 | ,@orgfont ,@head | | ,phundrak-nord15 | | 1.75 | | t | |
-| org-level-2 | ,@orgfont ,@head | | ,phundrak-nord10 | | 1.5 | | t | |
-| org-level-3 | ,@orgfont ,@head | | ,phundrak-nord9 | | 1.25 | | t | |
-| org-level-4 | ,@orgfont ,@head | | ,phundrak-nord15 | | 1.1 | | t | |
-| org-level-5 | ,@orgfont ,@head | | ,phundrak-nord8 | | | | t | |
-| org-level-6 | ,@orgfont ,@head | | ,phundrak-nord7 | | | | t | |
-| org-level-7 | ,@orgfont ,@head | | ,phundrak-nord15 | | | | t | |
-| org-level-8 | ,@orgfont ,@head | | ,phundrak-nord6 | | | | t | |
-| org-document-title | ,@orgfont ,@head | | ,phundrak-nord11 | | 2.0 | | t | |
-| variable-pitch | ,@orgfont | | | | | | | |
-| org-block | ,@fixed | | | ,phundrak-nord1 | | | | |
-| org-block-begin-line | ,@fixed | | | ,phundrak-nord1 | | | | |
-| org-block-end-line | ,@fixed | | | ,phundrak-nord1 | | | | |
-| org-indent | ,@fixed | | | | | | | |
-| org-formula | ,@fixed | | | | | | | |
-| org-macro | ,@fixed | | | | | | | |
-| org-target | ,@fixed | | | | | | | |
-| org-property-value | ,@fixed | | | | | | | |
-| org-drawer | ,@fixed | | ,phundrak-nord10 | | | | | |
-| org-table | ,@fixed | | ,phundrak-nord14 | | | | | |
-| org-date | ,@fixed | | ,phundrak-nord13 | | | | | |
-| org-code | ,@fixed | shadow | | | | | | |
-| org-verbatim | ,@fixed | shadow | | | | | | |
-| org-document-info-keyword | ,@fixed | shadow | | | | | | |
-| org-tag | ,@fixed | shadow | | | | bold | | |
-| org-meta-line | ,@fixed | font-lock-comment-face | | | 0.8 | | | |
-| org-special-keyword | ,@fixed | font-lock-comment-face | ,phundrak-nord15 | | 0.8 | | | |
-| org-checkbox | ,@fixed | (org-todo shadow fixed-pitch) | | | | | | |
-| org-document-info | | | ,phundrak-nord12 | | | | | |
-| org-link | | | ,phundrak-nord8 | | | | | t |
-
-*** Info colors
-:PROPERTIES:
-:CUSTOM_ID: User-Configuration-Visual-configuration-Info-colors-ebe3cc81
-:END:
-The package ~info-colors~ adds colors to Emacs’ info mode. Let’s enable it:
-#+BEGIN_SRC emacs-lisp
-(add-hook 'Info-selection-hook 'info-colors-fontify-node)
-#+END_SRC
-
-*** Prettified symbols
-:PROPERTIES:
-:CUSTOM_ID: User_Configuration-Miscellaneous-Prettified_symbols-da50f4a6
-:END:
-Just because it is pleasing to the eye, some symbols in source code get
-prettified into simpler symbols. Here is the list of symbols that are to be
-prettified. You can see in the corresponding comment what symbol will be
-displayed.
-#+BEGIN_SRC emacs-lisp
-(setq prettify-symbols-alist '(("lambda" . 955) ; λ
- ("mapc" . 8614) ; ↦
- ("map" . 8614) ; ↦
- (">>" . 187) ; »
- ("<<" . 171) ; «
- ))
-#+END_SRC
-
-Let’s enable this mode globally.
-#+BEGIN_SRC emacs-lisp
-(global-prettify-symbols-mode 1)
-#+END_SRC
-
-*** Misc
-:PROPERTIES:
-:CUSTOM_ID: User-Configuration-Visual-configuration-Misc-2f4ce585
-:END:
-Emacs is already silent, but let’s set the bell as visible:
-#+BEGIN_SRC emacs-lisp
-(setq visible-bell t)
-#+END_SRC
-
-I would also like to disable the global ~hl-mode~, I find it quite annoying.
-#+BEGIN_SRC emacs-lisp
-(global-hl-line-mode -1)
-#+END_SRC
-
-* Footnotes
-:PROPERTIES:
-:CUSTOM_ID: Footnotes-5ffd05ee
-:END:
-
-[fn:2] [[https://labs.phundrak.com/phundrak/dotfiles/src/branch/master/.spacemacs][labs.phundrak.com/phundrak/dotfiles/src/branch/master/.spacemacs]]
-
-[fn:1] [[https://labs.phundrak.com/phundrak/dotfiles/src/branch/master/org/config/emacs.org][labs.phundrak.com/phundrak/dotfiles/src/branch/master/org/config/emacs.org]]
diff --git a/org/config/LICENSE.md b/org/config/LICENSE.md
deleted file mode 120000
index fdf5433..0000000
--- a/org/config/LICENSE.md
+++ /dev/null
@@ -1 +0,0 @@
-/home/phundrak/LICENSE.md
\ No newline at end of file
diff --git a/org/config/WIP/img/ncmpcpp-directory.png b/org/config/WIP/img/ncmpcpp-directory.png
deleted file mode 100644
index 2a3eb95..0000000
Binary files a/org/config/WIP/img/ncmpcpp-directory.png and /dev/null differ
diff --git a/org/config/WIP/img/ncmpcpp-directory.png.webp b/org/config/WIP/img/ncmpcpp-directory.png.webp
deleted file mode 100644
index 2476bba..0000000
Binary files a/org/config/WIP/img/ncmpcpp-directory.png.webp and /dev/null differ
diff --git a/org/config/WIP/img/ncmpcpp-queue.png b/org/config/WIP/img/ncmpcpp-queue.png
deleted file mode 100644
index 0cc033b..0000000
Binary files a/org/config/WIP/img/ncmpcpp-queue.png and /dev/null differ
diff --git a/org/config/WIP/img/ncmpcpp-queue.png.webp b/org/config/WIP/img/ncmpcpp-queue.png.webp
deleted file mode 100644
index 28d4217..0000000
Binary files a/org/config/WIP/img/ncmpcpp-queue.png.webp and /dev/null differ
diff --git a/org/config/WIP/img/ncmpcpp-visualizer.png b/org/config/WIP/img/ncmpcpp-visualizer.png
deleted file mode 100644
index 633d387..0000000
Binary files a/org/config/WIP/img/ncmpcpp-visualizer.png and /dev/null differ
diff --git a/org/config/WIP/img/ncmpcpp-visualizer.png.webp b/org/config/WIP/img/ncmpcpp-visualizer.png.webp
deleted file mode 100644
index 795f820..0000000
Binary files a/org/config/WIP/img/ncmpcpp-visualizer.png.webp and /dev/null differ
diff --git a/org/config/WIP/ncmpcpp.org b/org/config/WIP/ncmpcpp.org
deleted file mode 100644
index a6806e1..0000000
--- a/org/config/WIP/ncmpcpp.org
+++ /dev/null
@@ -1,56 +0,0 @@
-#+title: Ncmpcpp Configuration
-#+setupfile: ../headers
-#+OPTIONS: unique-id:t
-#+HTML_HEAD_EXTRA:
-#+HTML_HEAD_EXTRA:
-#+HTML_HEAD_EXTRA:
-#+PROPERTY: header-args :tangle ~/.config/ncmpcpp/config2 :exports code
-
-* Introduction
-:PROPERTIES:
-:CUSTOM_ID: Introduction-3e61ecfc
-:END:
-Ncmpcpp is a TUI front-end for MPD, with an UI very similar to Ncmpc. This is
-my main MPD front-end after my i3 shortcuts. You can find below some
-screenshots of how my current ncmpcpp configuration looks like.
-
-[[file:img/ncmpcpp-queue.png]]
-
-[[file:img/ncmpcpp-directory.png]]
-
-[[file:img/ncmpcpp-visualizer.png]]
-
-* Core Ncmpcpp settings
-:PROPERTIES:
-:CUSTOM_ID: Core_Ncmpcpp_settings-8cacae18
-:END:
-#+BEGIN_SRC conf :exports none
- # -*- mode: conf -*-
-#+END_SRC
-
-** Directories
-:PROPERTIES:
-:CUSTOM_ID: Core_Ncmpcpp_settings-Directories-28092c92
-:END:
-Ncmpcpp has two vital directories: the lyrics directory, and its own configuration directory. The configuration for ncmpcpp is generally either in ~$HOME/.ncmpcpp/~ or in ~$XDG_CONFIG_HOME/ncmpcpp/~.
-#+BEGIN_SRC conf
- ncmpcpp_directory = ~/.config/ncmpcpp
-#+END_SRC
-
-When it comes to the lyrics, be sure to set the directory to the same directory pointed at by Mpd.
-#+BEGIN_SRC conf
- lyrics_directory = ~/.lyrics
-#+END_SRC
-
-** MPD
-:PROPERTIES:
-:CUSTOM_ID: Core_Ncmpcpp_settings-MPD-a2a7452e
-:END:
-These settings tell ncmpcpp how to communicate with Mpd. Once again, be sure to follow your own MPD settings. In my case, I am connecting to my local MPD server, hence the ~localhost~ value of the variable below, and I did not change the default port of MPD. My music is located at =~/Music=, and ncmpcpp should connect pretty much immediately, although I allow a five seconds timeout before ncmpcpp treats it as an error. Also, no crossfade please.
-#+BEGIN_SRC conf
- mpd_host = localhost
- mpd_port = 6600
- mpd_music_dir = ~/Music
- mpd_connection_timeout = 5
- mpd_crossfade_time = 0
-#+END_SRC
diff --git a/org/config/bin.org b/org/config/bin.org
deleted file mode 100644
index fbb27c4..0000000
--- a/org/config/bin.org
+++ /dev/null
@@ -1,2269 +0,0 @@
-#+TITLE: Executable scripts
-#+setupfile: headers
-#+OPTIONS: unique-id:t
-#+HTML_HEAD_EXTRA:
-#+HTML_HEAD_EXTRA:
-#+HTML_HEAD_EXTRA:
-#+PROPERTY: header-args :exports code
-#+PROPERTY: header-args:emacs-lisp :exports none :tangle no
-
-* Presentation
-:PROPERTIES:
-:CUSTOM_ID: Presentation-721f3cc4
-:END:
-This file will present all the executable scripts I wrote. It is also their
-original source code, all the following code snippets are exported and tangled
-from this file to the actual executables.
-
-* Autostart
-:PROPERTIES:
-:HEADER-ARGS: :shebang "#!/usr/bin/env bash" :mkdirp yes :tangle ~/.local/bin/autostart
-:CUSTOM_ID: Autostart-a99e99e7
-:END:
-Because I sometimes switch from window manager to window manager, creating a
-script that handles by itself autostarting things for me is way easier than
-rewriting every time the autostart part of my configuration. As you can every
-instance will be launched asynchronously, and only if there is no other instance
-of said command running.
-#+NAME: autostart-table
-| Command | Arguments | Run once? |
-|----------------------+------------------------------------------+-----------|
-| ~pactl~ | ~load-module module-switch-on-connect~ | |
-| ~mpc~ | ~stop~ | no |
-| ~xrdb~ | ~-merge "$XDG_CONFIG_HOME"/X11/Xresources~ | no |
-| ~picom~ | | yes |
-| ~numlockx~ | ~on~ | yes |
-| ~xfce-polkit~ | | yes |
-| ~nm-applet~ | | yes |
-| ~xwallpaper~ | ~--zoom "$(cat "$HOME"/.cache/wallpaper)"~ | no |
-| ~xss-lock~ | ~plock~ | yes |
-| ~/usr/lib/kdeconnectd~ | | yes |
-| ~dunst~ | | yes |
-
-#+NAME: autostart-gen
-#+header: :wrap "src bash :exports code"
-#+BEGIN_SRC emacs-lisp :var table=autostart-table :cache yes
-(mapconcat (lambda (start-command)
- (let* ((clean-string (lambda (str) (replace-regexp-in-string "~" "" str)))
- (command (funcall clean-string (nth 0 start-command)))
- (arguments (funcall clean-string (nth 1 start-command)))
- (oncep (string= "yes" (nth 2 start-command)))
- (full-command (replace-regexp-in-string
- " +"
- " "
- (format "%s %s &" command arguments))))
-
- (concat (format "which %s && %s"
- command
- (if (not oncep)
- full-command
- (format (concat "if pgrep -x %s ; then\n"
- " echo %s already running\n"
- "else\n"
- " %s\n"
- " disown\n"
- "fi")
- command
- command
- full-command))))))
- table
- "\n")
-#+END_SRC
-
-#+RESULTS[8c42a43989020c61050b2930ae60c81248c2dd44]: autostart-gen
-#+begin_src bash :exports code
-which pactl && pactl load-module module-switch-on-connect &
-which mpc && mpc stop &
-which xrdb && xrdb -merge "$XDG_CONFIG_HOME"/X11/Xresources &
-which picom && if pgrep -x picom ; then
- echo picom already running
-else
- picom &
- disown
-fi
-which numlockx && if pgrep -x numlockx ; then
- echo numlockx already running
-else
- numlockx on &
- disown
-fi
-which xfce-polkit && if pgrep -x xfce-polkit ; then
- echo xfce-polkit already running
-else
- xfce-polkit &
- disown
-fi
-which nm-applet && if pgrep -x nm-applet ; then
- echo nm-applet already running
-else
- nm-applet &
- disown
-fi
-which xwallpaper && xwallpaper --zoom "$(cat "$HOME"/.cache/wallpaper)" &
-which xss-lock && if pgrep -x xss-lock ; then
- echo xss-lock already running
-else
- xss-lock plock &
- disown
-fi
-which /usr/lib/kdeconnectd && if pgrep -x /usr/lib/kdeconnectd ; then
- echo /usr/lib/kdeconnectd already running
-else
- /usr/lib/kdeconnectd &
- disown
-fi
-which dunst && if pgrep -x dunst ; then
- echo dunst already running
-else
- dunst &
- disown
-fi
-#+end_src
-
-I also have an external sound card, a Scarlet 2i2 G3, that I would
-like to use as my default audio output. However, it might not be
-always connected, hence the following code:
-#+NAME: default-soundcard
-#+BEGIN_SRC bash
-SOUNDCARD=$(pactl list short sinks | grep "Focusrite")
-if [[ -n $SOUNDCARD ]]; then
- pactl set-default-sink "$(echo "$SOUNDCARD" | awk '{print $2}')"
-fi
-#+END_SRC
-
-* cli utilities
-:PROPERTIES:
-:CUSTOM_ID: cli-utilities-ec2120b0
-:END:
-** Backup
-:PROPERTIES:
-:HEADER-ARGS: :shebang "#!/usr/bin/env fish" :mkdirp yes :tangle ~/.local/bin/backup
-:CUSTOM_ID: Backup-68c7c63e
-:END:
-~backup~ is a very simple, oneliner script that will create a local copy of a
-file and add the date at which it was copied in the filename. You can see its
-source code here:
-#+BEGIN_SRC fish
-cp -r $argv[1] $argv[1].bak.(date +"%Y%m%d%H%M%S")
-#+END_SRC
-
-** CPU Scaling
-:PROPERTIES:
-:HEADER-ARGS: :shebang "#!/usr/bin/env bash" :mkdirp yes :tangle ~/.local/bin/cpu-scaling
-:CUSTOM_ID: cli-utilities-CPU-Scaling-f64iyk608fj0
-:END:
-As I am using a laptop, maximum performance isn’t always what I want.
-Sometimes, it’s just better to have not so great but less
-battery-demanding performance. It is possible to achieve this by
-modifying the CPU governor with ~cpupower~. The [[https://wiki.archlinux.org/title/CPU_frequency_scaling#Scaling_governors][Arch Wiki]] has, as usual,
-some really good documentation on this.
-
-The following script asks the user through ~rofi~ which governor to
-apply, and it relies on [[#Askpass-d0d7a8c0][~askpass~]] to retrieve the user’s password.
-#+begin_src bash
-governors=("performance" "powersave" "userspace" "ondemand" "conservative" "schedutil")
-governor=$(printf "%s\n" "${governors[@]}" | rofi -dmenu)
-sudo -A cpupower frequency-set -g "$governor"
-#+end_src
-
-** docker-running
-:PROPERTIES:
-:CUSTOM_ID: cliutilitiesdockerrunning-awb2jbx09rj0
-:HEADER-ARGS: :shebang "#!/usr/bin/env sh" :tangle ~/.local/bin/docker-running
-:END:
-As with =mu-unread= below, =docker-running= is a small and simple utility
-for my StumpWM configuration which indicates how many Docker
-containers are currently running.
-
-#+begin_src sh
-NB_CONTAINERS=$(docker ps -q | wc -l | tr -d '\n')
-printf "^f3^f0 %d" $NB_CONTAINERS
-#+end_src
-
-** Kamoji Generator
-:PROPERTIES:
-:CUSTOM_ID: cliutilitiesKamojiGenerator-sqvh17015uj0
-:HEADER-ARGS: :shebang "#!/usr/bin/env sh" :tangle ~/.local/bin/kamoji
-:END:
-This script comes straight from [[https://charm.sh/blog/kamoji-generator/][this blog post]] and generates kamoji. I
-modified it a bit in order to work with either =xclipboard= or =wl-copy=
-depending on whether I am in a X.org session or a Wayland session.
-
-Note that it requires the =OPENAI_API_KEY= environment variable to be
-set with a valid OpenAI key.
-#+begin_src bash
-# If the user passes '-h', '--help', or 'help' print out a little bit of help.
-# text.
-case "$1" in
- "-h" | "--help" | "help")
- printf 'Generate kaomojis on request.\n\n'
- printf 'Usage: %s [kind]\n' "$(basename "$0")"
- exit 1
- ;;
-esac
-
-# The user can pass an argument like "bear" or "angry" to specify the general
-# kind of Kaomoji produced.
-sentiment=""
-if [[ $1 != "" ]]; then
- sentiment=" $1"
-fi
-
-# Ask mods to generate Kaomojis. Save the output in a variable.
-kaomoji="$(mods "generate 10${sentiment} kaomojis. number them and put each one on its own line.")"
-if [[ $kaomoji == "" ]]; then
- exit 1
-fi
-
-# Pipe mods output to gum so the user can choose the perfect kaomoji. Save that
-# choice in a variable. Also note that we're using cut to drop the item number
-# in front of the Kaomoji.
-choice="$(echo "$kaomoji" | gum choose | cut -d ' ' -f 2)"
-if [[ $choice == "" ]]; then
- exit 1
-fi
-
-# If the current session is Wayland, copy with wl-copy, otherwise copy with xclipboard
-if [ "$XDG_SESSION_TYPE" = "wayland" ]
-then printf '%s' "$choice" | wc-copy # Wayland
-else printf '%s' "$choice" | xclip -sel clip # X11
-fi
-
-# We're done!
-printf 'Copied %s to the clipboard\n' "$choice"
-#+end_src
-
-** mu-unread
-:PROPERTIES:
-:HEADER-ARGS: :shebang "#!/usr/bin/env sh" :tangle ~/.local/bin/mu-unread
-:CUSTOM_ID: cli-utilities-mu-unread-f8t7tf20o8j0
-:END:
-~mu-unread~ is a very simple utility that simply returns the amount of
-unread emails I have through the use of ~mu~.
-
-As you can see, the output string contains two font switchers for
-StumpWM so I can switch from the main font to Siji for the caracter
-contained between them: U+E072 (an email icon).
-#+begin_src sh
-UNREAD=$(mu find "flag:unread AND (maildir:/Inbox OR maildir:/Junk)" | wc -l)
-printf "^f2^f0%s" "$UNREAD"
-#+end_src
-
-** Post scrot script
-:PROPERTIES:
-:HEADER-ARGS: :shebang "#!/usr/bin/env sh" :tangle ~/.local/bin/post-scrot
-:CUSTOM_ID: cli-utilities-Post-scrot-script-88ccl7t01aj0
-:END:
-It is possible to call a script on the resulting image of a ~scrot~
-command. Not only do I want to move them to a specific directory, I
-also want to be able to see them in ~nsxiv~ (a replacement for ~sxiv~) in
-case I want to edit the image, copy it or simply delete it (sometimes
-I take screenshots by accident).
-#+begin_src sh
-mv "$@" ~/Pictures/Screenshots/
-nsxiv -abfs f "$HOME/Pictures/Screenshots/$*"
-#+end_src
-
-** screenshot
-:PROPERTIES:
-:HEADER-ARGS: :shebang "#!/usr/bin/env sh" :mkdirp yes :tangle ~/.local/bin/screenshot
-:CUSTOM_ID: cliutilitiesscreenshot-3t27a7k0crj0
-:END:
-This is a utility only useful with Wayland for now, using =grim=, =slurp=
-(in order to select which area of the screen I wish to capture) and
-=wl-copy= (from =wl-clipboard=). It saves the screenshot in my
-=$HOME/Pictures/Screenshots= directory with a name formated as
-=Screenshot_20230425_134550.png= if the screenshot was taken on the 25th
-of April 2023 at 1:45:50PM. If the file already exists, the script
-will suffix the name with an underscore followed by an incremental
-number like =Screenshot_20230425_134550_1.png= or
-=Screenshot_20230425_134550_2.png=.
-
-If the argument =select= is passed to =screenshot=, as in =screenshot
-select=, then use =slurp= to select the area to capture.
-#+begin_src sh
-OUTFILE_BASE="$HOME/Pictures/Screenshots/Screenshot_$(date +%Y%m%d)_$(date +%H%M%S)"
-OUTFILE="$OUTFILE_BASE.png"
-SUFFIX=0
-
-while getopts ':cd:gs' OPTION; do
- case "$OPTION" in
- c )
- COPY="yes"
- ;;
- d )
- DELAY="$OPTARG"
- ;;
- g )
- GIMP="yes"
- ;;
- s )
- SELECT="yes"
- ;;
- ? )
- echo "Usage: $(basename "$0") [-c] [-d DELAY] [-g] [-s]"
- exit 1
- ;;
- esac
-done
-
-if [ -n "$DELAY" ]
-then sleep "$DELAY"
-fi
-
-if [ "$SELECT" = "yes" ]
-then grim -g "$(slurp)" "$OUTFILE"
-else grim "$OUTFILE"
-fi
-
-if [ "$GIMP" = "yes" ]
-then gimp "$OUTFILE"
-fi
-
-if [ "$COPY" = "yes" ]
-then wl-copy < "$OUTFILE"
-fi
-
-# wl-copy < "$OUTFILE"
-#+end_src
-
-** sshbind
-:PROPERTIES:
-:HEADER-ARGS: :shebang "#!/usr/bin/env fish" :mkdirp yes :tangle ~/.local/bin/sshbind
-:CUSTOM_ID: sshbind-756fabb1
-:END:
-Something that I did not know for quite some time, but that is
-actually crazy useful about SSH is its ability to bind locally the
-port of a remote machine, and vice versa. The syntax is actually very
-simple, but I prefer a more intuitive way of writing it. Its usage is
-~sshbind PORT FROMHOST TOHOST~.
-#+BEGIN_SRC fish
-ssh -L $argv[1]:$argv[3]:$argv[1] $argv[2] -N
-#+END_SRC
-
-** Nsxiv key handler
-:PROPERTIES:
-:HEADER-ARGS: :mkdirp yes :tangle no :noweb yes
-:CUSTOM_ID: cli-utilities-Sxiv-key-handler-atganx41adj0
-:END:
-One thing I like with ~nsxiv~ is you can trigger different behaviors
-based on keypresses. For instance, with my current nsxiv configuration,
-if I press the space key followed by a character, it can delete to the
-trashcan, delete definitively, or open the current image in GIMP. All
-of that is done through one script file stored in
-~$HOME/.config/nsxiv/exec/key-handler~. The fact it reacts to first the
-spacebar instead of /Ctrl-x/ is because I use a custom version of nsxiv I
-first modified to fit the bépo layout, and then I decided to change
-the prefix to fit how I use Emacs and StumpWM. You can read the
-PKGBUILD and my nsxiv patch [[https://labs.phundrak.com/phundrak/dotfiles/src/branch/master/Documents/code/PKGBUILDs/sxiv][in my dotfiles repo]].
-
-#+header: :shebang "#!/usr/bin/env fish" :tangle ~/.config/nsxiv/exec/key-handler
-#+begin_src fish
-<>
-
-<>
-#+end_src
-
-Here is a step by step explanation of the source code. First, we want
-to store in the variable ~FILES~ all the files marked in nsxiv. This is
-done with a ~while~ loop and the ~read~ command.
-#+name: nsxiv-read-files
-#+begin_src fish
-while read file
- set -g FILES "$file" $FILES
-end
-#+end_src
-
-We can then read from the first member of ~argv~ which key the user
-pressed. Depending on it, we can choose what to execute.
-#+name: nsxiv-switch-statement
-#+begin_src fish
-switch "$argv[1]"
- <>
- <>
- <>
- <>
- <>
- <>
- <>
-end
-#+end_src
-
-The first option with the letter ~d~ is to move the file to the trash
-can. For this, we use the ~trash~ command from ~trash-cli~.
-#+name: nsxiv-trash
-#+begin_src fish
-case "d"
- trash $FILES
-#+end_src
-
-In case we want to definitively delete a file without using the trash
-can, we can use ~rm~ instead when we press the ~D~ key.
-#+name: nsxiv-rm
-#+begin_src fish
-case "D"
- rm $FILES
-#+end_src
-
-It’s not rare I want to modify an image I have open in nsxiv,
-especially since screenshots are automatically open in this image
-viewer aften they are taken. In that case, a simple command will do.
-#+name: nsxiv-gimp
-#+begin_src fish
-case "g"
- gimp $FILES
-#+end_src
-
-Often, I use nsxiv to convert an image to a JPEG file, because my
-internet connection is not that great and JPEG screenshots are faster
-to upload than PNG screenshots. So what I do is for each file
-selected, I take the base name of the file (i.e. remove its
-extension), and then I use the ~convert~ command from ~imagemagik~ to
-convert it from its original format to a JPG format --- ~imagemagik~
-detects the formats based on the extension.
-#+name: nsxiv-jpeg
-#+begin_src fish
-case "j"
- for f in $FILES
- set basename (echo "$f" | sed 's/\.[^.]*$//')
- convert "$f" "$basename.jpg"
- end
-#+end_src
-
-I have two commands to rotate my files, and both only differ by the
-angle of rotation. Once again I rely on ~convert~ in both cases. To
-rotate clockwise, this is the code needed.
-#+name: nsxiv-rotate-clockwise
-#+begin_src fish
-case "r"
- for f in $FILES
- convert -rotate 90 "$f" "$f"
- end
-#+end_src
-
-On the other hand, to rotate counter-clockwise, we need this code:
-#+name: nsxiv-rotate-counter-clockwise
-#+begin_src fish
-case "R"
- for f in $FILES
- convert -rotate 270 "$f" "$f"
- end
-#+end_src
-
-Lastly, when I want to copy a file, I just hit the ~y~ key for “yank”
-(that’s a term from Emacs). For that, I rely on ~file~ to tell me the
-mimetype of the image, then I can pass it to ~xclip~ along with the
-filename to copy it to the clipboard. In this case, we only copy the
-first of the selected files since the clipboard cannot hold several
-files at once.
-#+name: nsxiv-yank
-#+begin_src fish
-case "y"
- set FILE "$FILES[1]"
- set TYPE (file -i "$FILE" | sed -r 's|.*(image/[a-z]+);.*|\1|')
- xclip -sel clip -t "$TYPE" -i "$FILE"
-#+end_src
-
-** Secure key generator
-:PROPERTIES:
-:HEADER-ARGS: :shebang "#!/usr/bin/env sh" :tangle ~/.local/bin/skg
-:CUSTOM_ID: cliutilitiesSecurekeygenerator-obfj0i20mvj0
-:END:
-#+begin_src bash
-tr -cd '[:alnum:]' < /dev/urandom | fold -w 64 | head -n 1 | tr -d '\n'
-#+end_src
-
-** Starwars
-:PROPERTIES:
-:HEADER-ARGS: :shebang "#!/usr/bin/env fish" :mkdirp yes :tangle ~/.local/bin/starwars
-:CUSTOM_ID: Starwars-654f8637
-:END:
-This is a one-liner that allows you to watch Star Wars episode 4 in ASCII art in
-your terminal. Here is the code:
-#+BEGIN_SRC fish
-telnet towel.blinkenlights.nl
-#+END_SRC
-
-** Toggle touchpad tapping
-:PROPERTIES:
-:HEADER-ARGS: :shebang "#!/usr/bin/env fish" :mkdirp yes :tangle ~/.local/bin/tttapping
-:CUSTOM_ID: Toggle_touchpad_tapping-23348b00
-:END:
-For some reasons, my firmware does not recognize the function key for toggling
-the touchpad. I’m not going to really complain about it since it lets me program
-it like I want. Since I often don’t need to completely deactivate the touchpad,
-I’ll instead toggle whether tapping is enabled or not when pressing
-~XF86TouchpadToggle~. And for that, I need this small script that will actually
-toggle it, and it will be used in my window manager configuration.
-
-First let’s declare some variables to make this script more personal. With my
-current computer (a Gazelle by System76), the name of my touchpad is the
-following:
-#+BEGIN_SRC fish
-set TPNAME "ELAN0412:00 04F3:3162 Touchpad"
-#+END_SRC
-
-Let’s now get the identifier of the touchpad for ~xinput~:
-#+BEGIN_SRC fish
-set TPID (xinput list | grep $TPNAME | awk '{print $6}' | sed 's|id=\(.*\)|\1|g')
-#+END_SRC
-
-Now, let’s detect the current status of the touchpad:
-#+BEGIN_SRC fish
-set TPSTATUS (xinput list-props $TPID | grep "Tapping Enabled" | \
- grep -v "Default" | awk '{print $5}')
-#+END_SRC
-
-This will set ~TPSTATUS~ either to ~0~, meaning tapping is disabled, or to ~1~,
-meaning it’s enabled. I will consider any other value as being disabled.
-#+BEGIN_SRC fish
-test [[ $TPSTATUS = "1" ]] && set NEWTPSTATUS 0 || set NEWTPSTATUS 1
-#+END_SRC
-
-Finally, let’s update the touchpad’s options:
-#+BEGIN_SRC fish
-xinput set-prop $TPNAME "libinput Tapping Enabled" $NEWTPSTATUS
-#+END_SRC
-
-** Wacom setup
-:PROPERTIES:
-:HEADER-ARGS: :shebang "#!/usr/bin/env sh" :mkdirp yes :tangle ~/.local/bin/wacom-setup
-:CUSTOM_ID: Wacom_setup-331fb024
-:END:
-I made a small and quick utility to set up my Wacom tablet to bind it
-to one screen when in Xorg. This is quite easy, we simply need to find
-the Wacom stylus’ ID and assign it to the display we want.
-#+begin_src sh
-ID=$(xinput | grep -oPi "wacom.+stylus.+id=\K([0-9]+)")
-SCREEN=$(xrandr -q --current | \
- grep -iPo '^([^ ])+(?= connected)' | \
- rofi -dmenu -i -p 'Select your display' | \
- tr -d '\n')
-xinput map-to-output "$ID" "$SCREEN"
-#+end_src
-
-* Emacs stuff
-:PROPERTIES:
-:CUSTOM_ID: Emacs-stuff-8e76efd4
-:END:
-** Dired
-:PROPERTIES:
-:CUSTOM_ID: Emacs-stuff-Dired-2eeca9da
-:HEADER-ARGS: :shebang "#!/bin/bash" :mkdirp yes :tangle ~/.local/bin/dired
-:END:
-This script allows me to open anything in dired from the command line.
-#+BEGIN_SRC bash
-emacsclient -c -a emacs -e "(dired \"$*\")"
-#+END_SRC
-
-** Ediff
-:PROPERTIES:
-:CUSTOM_ID: EmacsstuffEdiff-a6adcl503uj0
-:HEADER-ARGS: :shebang "#!/bin/bash" :mkdirp yes :tangle ~/.local/bin/ediff
-:END:
-I want Ediff as my merge tool, not just with Git but with other
-programs too such as =pacdiff=.
-#+begin_src bash
-emacsclient -c -a emacs -e "(ediff-files \"$1\" \"$2\")"
-#+end_src
-
-** Emacsmail
-:PROPERTIES:
-:HEADER-ARGS: :shebang "#!/bin/bash" :mkdirp yes :tangle ~/.local/bin/emacsmail
-:CUSTOM_ID: Emacsmail-afffb7cd
-:END:
-This short script is used in my =~/.local/share/applications/mu4e.desktop= file
-in order to send to Emacs any ~mailto:~ requests made in my system.
-#+BEGIN_SRC bash
-emacsclient -c -n -a emacs -e "(browse-url-mail \"$*\")"
-#+END_SRC
-
-* Media
-:PROPERTIES:
-:CUSTOM_ID: Media-f869f942
-:END:
-** mp42webm
-:PROPERTIES:
-:HEADER-ARGS: :shebang "#!/usr/bin/env fish" :mkdirp yes :tangle ~/.local/bin/mp42webm
-:CUSTOM_ID: mp42webm-aeacca58
-:END:
-This function allows me to convert easily a MP4 video to the webm
-format. Nothing too fancy here.
-#+BEGIN_SRC fish
-ffmpeg -i $argv[1] -c:v libvpx -crf 10 -b:v 1M -c:a libvorbis $argv[1].webm
-#+END_SRC
-
-** youtube-dl wrappers
-:PROPERTIES:
-:CUSTOM_ID: Media-youtube-dl-wrappers-8d8f5f71
-:END:
-*** ytplay
-:PROPERTIES:
-:HEADER-ARGS: :shebang "#!/usr/bin/env fish" :mkdirp yes :tangle ~/.local/bin/ytplay
-:CUSTOM_ID: Media-youtube-dl-wrappers-ytplay-z6ka39h0m9j0
-:END:
-~ytplay~ is a simple script I’ve written that allows me to play in mpv any
-YouTube video at the desired resolution. The script relies on ~dmenu~ (or ~rofi~
-in dmenu-mode), ~youtube-dl~ and of course ~mpv~ itself.
-#+BEGIN_SRC fish
-set URL (rofi -dmenu -i -p "Video URL")
-if test -n "$URL"
- set FORMAT \
- (youtube-dl --list-formats "$URL" | \
- egrep "webm.*[0-9]+x[0-9]+" | \
- awk '{print $3 " " $1}' | \
- sort -gu | \
- rofi -dmenu -i -p "Resolution" | \
- string split " ")
- set FCODE $FORMAT[2]
- mpv --ytdl-format=$FCODE+bestaudio/best "$URL"
-end
-#+END_SRC
-
-I’ll even add a ~.desktop~ entry for this script:
-#+BEGIN_SRC conf-desktop :tangle ~/.local/share/applications/ytplay.desktop :mkdirp yes
-[Desktop Entry]
-Type=Application
-Version=1.0
-Name=ytplay (YouTube in mpv)
-Comment=Play YouTube videos in mpv
-Exec=/home/phundrak/.local/bin/ytplay
-Path=/home/phundrak/.local/bin
-Terminal=false
-Categories=Media
-#+END_SRC
-
-*** ytdl - a ~youtube-dl~ wrapper
-:PROPERTIES:
-:HEADER-ARGS: :shebang "#!/usr/bin/env fish" :mkdirp yes :tangle ~/.local/bin/ytdl
-:HEADER-ARGS:EMACS-LISP: :exports none :tangle no
-:CUSTOM_ID: ytdl-a-youtube-dl-wrapper-03bd63e0
-:END:
-This script is a wrapper around ~youtube-dl~ which I use mainly for
-archiving YouTube videos on my NAS (at the time I’m writing this, I
-have already 2.1 TB worth of videos archived). The principle behind
-this script is quite simple: I want to avoid as much as possible to
-redownload any video already downloaded in order to avoid pinging too
-much YouTube’s servers, 429 Too Many Requests errors are really
-annoying, and it comes really early when you have only a couple of new
-videos to download among the few 14k videos already downloaded.
-
-Be aware this script was written for the Fish shell (3.1.0 and above), and makes
-use of youtube-dl 2020.03.24 and above, [[https://github.com/jorgebucaran/fish-getopts][Fish getopts]] and [[https://github.com/BurntSushi/ripgrep][ripgrep]].
-
-**** Setting default values
-:PROPERTIES:
-:CUSTOM_ID: ytdl-a-youtube-dl-wrapper-Setting-default-values-da404639
-:END:
-Some variables in this script will have default values, we do not want to have a
-mile-long command each time we wish to download a single video. We’ll also set
-some global variables that won’t change:
-#+NAME: ytdl-default-vars
-| Variable Name | Default Value | String? |
-|------------------+-----------------------------------------------------------+---------|
-| ~YTDL_SHARED_DIR~ | ~$HOME/.local/share/ytdl~ | no |
-| ~FORMAT_DEFAULT~ | ~%(uploader)s/%(upload_date)s ~- ~%(title)s.%(ext)s~ | yes |
-| ~DOWNFILE_DEFAULT~ | ~$YTDL_SHARED_DIR/downloaded~ | no |
-| ~ERRFILE_DEFAULT~ | ~$YTDL_SHARED_DIR/video-errors~ | no |
-| ~LOGFILE_DEFAULT~ | ~$YTDL_SHARED_DIR/ytdl.log~ | no |
-| ~PREFFERED_FORMAT~ | ~bestvideo[ext=mp4]+bestaudio[ext=m4a]/bestvideo+bestaudio~ | yes |
-| ~VERSION~ | ~0.3~ | yes |
-
-There is one more default variable pointing to ytdl’s root directory which
-depends on whether the videos directory has a French or English name:
-#+NAME: ytdl-default-vars-root
-#+BEGIN_SRC fish :tangle no
-if test -d "$HOME/Vidéos"
- set -g ROOTDIR_DEFAULT "$HOME/Vidéos" # French name
-else
- set -g ROOTDIR_DEFAULT "$HOME/Videos" # English name
-end
-#+END_SRC
-
-#+NAME: ytdl-default-vars-make
-#+header: :wrap "src fish :tangle no"
-#+BEGIN_SRC emacs-lisp :var vars=ytdl-default-vars :exports results
-(let ((clean-string (lambda (str) (replace-regexp-in-string "~" "" str))))
- (mapconcat (lambda (var)
- (let ((varname (funcall clean-string (car var)))
- (varvalue (funcall clean-string (cadr var)))
- (string? (string= (nth 2 var) "yes")))
- (format "set -g %-16s \"%s\"" varname varvalue)))
- vars
- "\n"))
-#+END_SRC
-
-#+RESULTS: ytdl-default-vars-make
-#+begin_src fish :tangle no
-set -g YTDL_SHARED_DIR "$HOME/.local/share/ytdl"
-set -g FORMAT_DEFAULT "%(uploader)s/%(upload_date)s - %(title)s.%(ext)s"
-set -g DOWNFILE_DEFAULT "$YTDL_SHARED_DIR/downloaded"
-set -g ERRFILE_DEFAULT "$YTDL_SHARED_DIR/video-errors"
-set -g LOGFILE_DEFAULT "$YTDL_SHARED_DIR/ytdl.log"
-set -g PREFFERED_FORMAT "bestvideo[ext=mp4]+bestaudio[ext=m4a]/bestvideo+bestaudio"
-set -g VERSION "0.3"
-#+end_src
-
-#+BEGIN_SRC fish :noweb yes
-<>
-<>
-#+END_SRC
-
-We’ll also create the directory pointed at by ~YTDL_SHARED_DIR~ if it doesn’t
-exist already:
-#+BEGIN_SRC fish
-mkdir -p $YTDL_SHARED_DIR
-#+END_SRC
-
-**** Help message
-:PROPERTIES:
-:CUSTOM_ID: ytdl-a-youtube-dl-wrapper-Help-message-3773aacd
-:END:
-The next step is displaying the help message for the script. For that, just a
-long string echo’d will do, wrapped in the function ~_ytdl_help~.
-#+BEGIN_SRC fish
-function _ytdl_help
- echo "Usage: ytdl [OPTION]... URL [URL]...
-
- -4, --ipv4
- Download with forced IPv4
- Default: no
-
- -6, --ipv6
- Download with forced IPv6
- Default: no
-
- -a, --batch-file
- File containing URLs to download, one URL per line. Lines starting with
- '#', ';' or ']' are considered as comments and ignored.
- Default: None
-
- -c, --id-cache
- File containing the video IDs that were already downloaded, one ID per
- line.
- Default: $DOWNFILE_DEFAULT
-
- -d, --directory
- Root directory in which to download videos.
- Default: $ROOTDIR_DEFAULT
-
- -e, --error-file
- File containing the IDs of videos that failed to download, one ID per
- line
- Default: $ERRFILE_DEFAULT
-
- -f, --format
- Format name for downloaded videos, including path relative to root
- directory
- Default: $FORMAT_DEFAULT
-
- -l, --logs
- File in which to store logs.
- Default: $LOGFILE_DEFAULT
-
- -V, --verbose
- Show verbose output
- Default: no
-
- -v, --version
- Show version of ytdl.
-
- -h, --help
- Shows this help message"
-end
-#+END_SRC
-
-We also have the function ~_ytdl_version~ to display the current version of
-~ytdl~:
-#+BEGIN_SRC fish
-function _ytdl_version
- echo "ytdl 0.3, developped for fish 3.1.0 and youtube-dl 2020.03.24 or newer"
- echo "requires Fish getopts "
- echo "and ripgrep "
-end
-#+END_SRC
-
-**** Arguments Handling
-:PROPERTIES:
-:CUSTOM_ID: ytdl-a-youtube-dl-wrapper-Arguments-Handling-1daebbe8
-:END:
-The function ~_ytdl_parse_ops~ is a little bit trickier: we use ~getopts~ to
-parse the arguments passed to the script in order to get some preferences from
-the user. Here is a quick reference on what options are available and what they
-do:
-#+NAME: ytdl-table-arguments
-| Short | Long | Takes a value? | Associated Variable | Default Value | What it does |
-|-------+------------+----------------+---------------------+-------------------+----------------------|
-| 4 | ipv4 | no | ~IPV4~ | None | Force IPv4 |
-| 6 | ipv6 | no | ~IPV6~ | None | Force IPv6 |
-| a | batch-file | yes | ~FILE~ | None | Batch file |
-| c | cache | yes | ~DOWNFILE~ | ~$DOWNFILE_DEFAULT~ | Cache file |
-| d | directory | yes | ~ROOTDIR~ | ~$ROOTDIR_DEFAULT~ | Root directory |
-| e | error-file | yes | ~ERRFILE~ | ~$ERRFILE_DEFAULT~ | Error logs |
-| f | format | yes | ~FORMAT~ | ~$FORMAT_DEFAULT~ | Filename format |
-| l | logs | yes | ~LOGFILE~ | ~$LOGFILE_DEFAULT~ | Logs |
-| V | verbose | no | ~VERBOSE~ | ~1~ | Verbose output |
-| v | version | command | None | None | Script version |
-| h | help | command | None | None | Display this message |
-
-We can also pass individual YouTube URLs without any options or switches
-associated to them, they will be downloaded as part of a single queue.
-
-#+NAME: ytdl-arg-handling-gen
-#+header: :cache yes :wrap "src fish :tangle no :exports code"
-#+BEGIN_SRC emacs-lisp :var args=ytdl-table-arguments :exports results
-(let ((clean-string (lambda (str) (replace-regexp-in-string "~" "" str))))
- (mapconcat (lambda (arg)
- (let* ((short (format "%s" (nth 0 arg)))
- (long (nth 1 arg))
- (arg? (string= "yes" (nth 2 arg)))
- (var (unless (string= "None" (nth 3 arg))
- (funcall clean-string (nth 3 arg)))))
- (format "case %s %s\n\t%s"
- short long
- (if var (format "set -g %s %s" var
- (if arg? "$value" ""))
- (format "_ytdl_%s && exit"
- (if (string= "h" short) "help" "version"))))))
- args
- "\n"))
-#+END_SRC
-
-#+RESULTS[df04709ff17a3d37a20528a5066a2efcda0cad5c]: ytdl-arg-handling-gen
-#+begin_src fish :tangle no :exports code
-case 4 ipv4
- set -g IPV4
-case 6 ipv6
- set -g IPV6
-case a batch-file
- set -g FILE $value
-case c cache
- set -g DOWNFILE $value
-case d directory
- set -g ROOTDIR $value
-case e error-file
- set -g ERRFILE $value
-case f format
- set -g FORMAT $value
-case l logs
- set -g LOGFILE $value
-case V verbose
- set -g VERBOSE
-case v version
- _ytdl_version && exit
-case h help
- _ytdl_help && exit
-#+end_src
-
-The following shows how ~getopts~ is used to catch the options and switches
-passed to the script:
-#+NAME: ytdl-getopts
-#+BEGIN_SRC fish :noweb yes :tangle no
-getopts $argv | while read -l key value
- switch $key
- <>
- case _
- for v in $value
- set -g VIDEOS $VIDEOS $v
- end
- end
-end
-#+END_SRC
-
-#+NAME: ytdl-arg-set-default-value-gen
-#+header: :cache yes :wrap "src fish :tangle no :exports code"
-#+BEGIN_SRC emacs-lisp :var args=ytdl-table-arguments
-(let* ((clean-string (lambda (str) (replace-regexp-in-string "~" "" str)))
- (args (seq-filter (lambda (arg)
- (let* ((var (unless (string= "None" (nth 3 arg))
- (funcall clean-string (nth 3 arg))))
- (default (funcall clean-string (format "%s" (nth 4 arg))))
- (default (unless (string= "None" default)
- default)))
- (and var default)))
- args)))
- (mapconcat (lambda (arg)
- (let* ((var (funcall clean-string (nth 3 arg)))
- (default (funcall clean-string (format "%s" (nth 4 arg)))))
- (format "if set -q $%s\n\tset -g %s %s\nend"
- var var default)))
- args
- "\n"))
-#+END_SRC
-
-#+RESULTS[5a32e875ea434a3522bd2272f4e5fd422d722dca]: ytdl-arg-set-default-value-gen
-#+begin_src fish :tangle no :exports code
-if set -q $DOWNFILE
- set -g DOWNFILE $DOWNFILE_DEFAULT
-end
-if set -q $ROOTDIR
- set -g ROOTDIR $ROOTDIR_DEFAULT
-end
-if set -q $ERRFILE
- set -g ERRFILE $ERRFILE_DEFAULT
-end
-if set -q $FORMAT
- set -g FORMAT $FORMAT_DEFAULT
-end
-if set -q $LOGFILE
- set -g LOGFILE $LOGFILE_DEFAULT
-end
-if set -q $VERBOSE
- set -g VERBOSE 1
-end
-#+end_src
-
-Some values need to be set to their default, so let’s assign them their value if
-no user value was passed:
-#+NAME: ytdl-arg-set-default-value
-#+BEGIN_SRC fish :noweb yes :tangle no
-<>
-set -g FORMAT "$ROOTDIR/$FORMAT"
-#+END_SRC
-
-Both these code blocks are executed in ~_ytdl_parse_ops~:
-#+BEGIN_SRC fish :noweb yes
-function _ytdl_parse_ops
- <>
- <>
-end
-#+END_SRC
-
-**** Logging
-:PROPERTIES:
-:CUSTOM_ID: ytdl-a-youtube-dl-wrapper-Logging-f4b9815e
-:END:
-~_ytdl_log~ is a very simple function used for logging information for the user
-in the file pointed to by ~LOGFILE~. The first argument the function should
-receive is its log level. I generally use either ~"INFO"~ or ~"ERR"~. The second
-argument is the message to log.
-#+BEGIN_SRC fish
-function _ytdl_log
- set -l INFOLEVEL $argv[1]
- set -l MSG $argv[2]
- set -l LOG (printf "[%s] %s %s\n" $INFOLEVEL (date +"%F %T") $MSG)
- printf "%s\n" $LOG >> $LOGFILE
- if test $VERBOSE -eq 1
- echo $LOG
- end
-end
-#+END_SRC
-
-**** Download a Single Video
-:PROPERTIES:
-:CUSTOM_ID: ytdl-a-youtube-dl-wrapper-Download-a-Single-Video-afedf321
-:END:
-In order to download a single video, a simple function has been written for this
-that will display when downloaded how far it is down the list of videos to be
-downloaded and it will add its ID to the file listing all videos downloaded. The
-script will also try to download the video according to the ~PREFFERED_FORMAT~
-variable, but if the download fails it will download the default format selected
-by ~youtube-dl~. If both downloads fail, the ID of the video will be added to
-the list of failed videos. If one of the downloads succeeds, it will remove the
-ID from the list of failed downloads.
-
-The first argument of the function is the video ID from YouTube, the second
-argument is the position of the video in the queue, and the third argument is
-the queue length –can be the amount of videos in a whole YouTube channel, the
-amount of videos in a playlist, or simply the amount of YouTube URLs passed as
-arguments to the script.
-#+BEGIN_SRC fish
-function _ytdl_download_video
- set ID $argv[1]
- _ytdl_log "INFO" (printf "Downloading video with ID $ID (%4d/%4d)" $argv[2] $argv[3])
- if youtube-dl -f $PREFFERED_FORMAT -ciw -o $FORMAT "https://youtube.com/watch?v=$ID"
- echo $ID >> $DOWNFILE
- else if youtube-dl -ciw -o $FORMAT "https://youtube.com/watch?v=$ID"
- echo $ID >> $DOWNFILE
- else
- _ytdl_log "ERR" "Could not download $VIDEO"
- echo $ID >> $ERRFILE
- end
-end
-#+END_SRC
-
-/Note that this function is not meant to be called without any checks before./
-It is meant to be called by ~_ytdl_download_queue~ described below.
-
-**** Download a Queue of Videos
-:PROPERTIES:
-:CUSTOM_ID: ytdl-a-youtube-dl-wrapper-Download-a-Queue-of-Videos-6ef8d51f
-:END:
-One of the main goals of this tool is to check if a video has already been
-downloaded. This is why, as you will see below, we use ripgrep to check if the
-ID of the video we want to download is already present in the list of downloaded
-videos. If not, it will then be downloaded though ~_ytdl_download_video~
-described above.
-#+BEGIN_SRC fish
-function _ytdl_download_queue
- for i in (seq (count $argv))
- rg -- $argv[$i] $DOWNFILE 2&> /dev/null
- if test $status -ne 0
- _ytdl_download_video $argv[$i] $i (count $argv)
- end
- end
-end
-#+END_SRC
-
-**** Download Videos From Arguments
-:PROPERTIES:
-:CUSTOM_ID: ytdl-a-youtube-dl-wrapper-Download-Videos-From-Arguments-57a5dac1
-:END:
-The main aim of this function is to transform the URLs contained in the
-arguments passed to the script to a list of IDs usable later on by ~ytdl~.
-#+BEGIN_SRC fish
-function _ytdl_download_arg_urls
- set -g IDs
- for VIDEO in $argv
- _ytdl_log "Info" "Getting video ID for $VIDEO"
- set -g IDs $IDs (youtube-dl --get-id $VIDEO)
- end
- _ytdl_download_queue $IDs
-end
-#+END_SRC
-
-**** Download Videos From a Batch File
-:PROPERTIES:
-:CUSTOM_ID: ytdl-a-youtube-dl-wrapper-Download-Videos-From-a-Batch-File-0f1382c4
-:END:
-The final function to declare before the main body of the script is
-~_ytdl_download_batch~: it will look for each line, ignoring the ones beginning
-by ~#~, ~;~ and ~]~ (just like ~youtube-dl~) and will download them, assuming
-these are channel URLs or playlist URLs, however it should also work with direct
-video URLs.
-
-What this function does is for each line, it will fetch the entierty of the
-video IDs found in a playlist or channel. Then, it will look each ID up the list
-of already downloaded videos and will add all new IDs to a queue of videos to be
-downloaded. It will then pass each new video ID to ~_ytdl_download_video~
-directly. Beware that if you pass directly the URL of the channel, such as
-~https://www.youtube.com/user/enyay~ if you want to download Tom Scott’s videos,
-it will download everything on the main page of their channel, which means it
-will even download videos from playlists they decided to put on their channel’s
-front page, even if it is not theirs. So in that case, we need to append
-~/videos~ to any channel URL.
-#+BEGIN_SRC fish
-function _ytdl_download_batch
- set -q $FILE
- if test $status -eq 1
- set -g NEW
- set CHANNELS (cat $FILE | grep -vE "#|;|\]")
- for c in $CHANNELS
- _ytdl_log "INFO" "Getting IDs for channel $c"
- if test (egrep '\/c\/|user|channel' (echo $c |psub))
- set -g IDS (youtube-dl --get-id "$c/videos")
- else
- set -g IDS (youtube-dl --get-id $c)
- end
- _ytdl_log "INFO" "Fetching new videos from channel"
- for i in (seq (count $IDS))
- printf "\rsearching (%d/%d)" $IDn (count $IDS)
- rg -- $IDS[$i] $DOWNFILE 2&> /dev/null
- if test $status -ne 0
- set -g NEW $IDS[$i] $NEW
- end
- end
- printf "\n"
- end
- for i in (seq (count $NEW))
- _ytdl_download_video $NEW[$i] $i (count $NEW)
- end
- end
-end
-#+END_SRC
-
-**** Main Body
-:PROPERTIES:
-:CUSTOM_ID: ytdl-a-youtube-dl-wrapper-Main-Body-8a06cb9e
-:END:
-Now that we have all our functions declared, let’s call them! First, we need to
-parse our arguments. We’ll then download all files passed as arguments. Finally,
-we’ll download videos, playlists and channels specified from a batch file.
-#+BEGIN_SRC fish
-_ytdl_parse_ops $argv
-_ytdl_download_arg_urls $VIDEOS
-_ytdl_download_batch
-#+END_SRC
-
-And that’s all! If you’re interested with a very simple interface for
-downloading one video once, I wrote a small [[#rofi-ytdl-ff8f789d][~rofi-ytdl~]] script that calls the
-~rofi~ utility to specify a single link and download it.
-* Plock
-:PROPERTIES:
-:HEADER-ARGS: :shebang "#!/usr/bin/env sh" :mkdirp yes :tangle ~/.local/bin/plock
-:CUSTOM_ID: Lock-635fcb38
-:END:
-~plock~ is a simple script that locks the screen with ~i3lock~ while setting as
-the background image of the locked screen a corrupted screenshot of the screen
-before it was locked.
-#+BEGIN_SRC sh
-TMPBG="/tmp/screen.png"
-if [ "$XDG_SESSION_TYPE" = "wayland" ]
-then
- SCREENER=grim
- LOCKER="swaylock -feF"
-else
- SCREENER=scrot
- LOCKER="i3lock -ef"
-fi
-
-$SCREENER "$TMPBG"
-corrupter -add 0 "$TMPBG" "$TMPBG"
-$LOCKER -ti "$TMPBG"
-rm $TMPBG
-#+END_SRC
-
-* Polybar-launch (Deprecated) :noexport:
-:PROPERTIES:
-:HEADER-ARGS: :shebang "#!/usr/bin/env bash" :mkdirp yes :tangle ~/.local/bin/polybar-launch
-:CUSTOM_ID: Polybar-launch-36789edc
-:END:
-This scripts allows the user to kill polybar and relaunch it, or to simply
-launch it if polybar isn’t launched yet. First thing to do is kill all polybar
-processes.
-#+BEGIN_SRC bash
-killall -q polybar
-#+END_SRC
-
-Now we have to wait untill all polybar processes have been shut down.
-#+BEGIN_SRC bash
-while pgrep -u $UID -x polybar >/dev/null; do sleep 1; done
-#+END_SRC
-
-Now that our system isn’t running polybar anymore, we’ll launch it again on all
-of our screens. By the way, I have two bars, so I’ll have to lauch them both.
-#+BEGIN_SRC bash
-if type "xrandr"; then
- for m in $(xrandr --query | grep " connected" | cut -d" " -f1); do
- MONITOR=$m polybar --reload top &
- MONITOR=$m polybar --reload bottom &
- done
-else
- polybar --reload top &
- polybar --reload bottom &
-fi
-#+END_SRC
-
-And we’re done! Let’s just launch a notification polybar has been relaunched.
-#+BEGIN_SRC bash
-notify-send "Polybar restarted!" -a "polybar-launch"
-#+END_SRC
-
-* Rofi utilities
-:PROPERTIES:
-:CUSTOM_ID: Rofi-utilities-650338d1
-:END:
-** askpass
-:PROPERTIES:
-:HEADER-ARGS: :shebang "#!/usr/bin/env fish" :mkdirp yes :tangle ~/.local/bin/askpass
-:CUSTOM_ID: Askpass-d0d7a8c0
-:END:
-Askpass is a simple script that invokes ~rofi~ as a way to get from a GUI the
-user’s sudo password. It is inspired by [[https://github.com/ODEX-TOS/tools/blob/master/rofi/askpass][this original tool]], rewritten in fish
-and with [[https://wiki.archlinux.org/index.php/Rofi][rofi]] support instead of [[https://wiki.archlinux.org/index.php/Dmenu][dmenu]]. As you can see, this is a oneliner if we
-ignore the initial shebang. This executable is pointed at by the
-#+BEGIN_SRC fish
-rofi -dmenu -password -no-fixed-num-lines -p (printf $argv[1] | sed s/://)
-#+END_SRC
-
-** awiki
-:PROPERTIES:
-:HEADER-ARGS: :shebang "#!/usr/bin/env fish" :mkdirp yes :tangle ~/.local/bin/awiki
-:CUSTOM_ID: awiki-7ac5e1d5
-:END:
-~awiki~ is a simple script used with ~rofi~ that relies on the ~arch-wiki-docs~
-package in order to provide the user a way to quickly find and display any
-English page from the Arch Wiki in a browser. The advantage of using this over
-the ~wiki-search~ utility from the ~arch-wiki-lite~ package is you get instant
-suggestion in rofi using fuzzy-search. The downside is rofi will only help you
-find pages by their title, and it will not help you find keywords in the content
-of said pages.
-
-The first step is to create the list of all the pages that are currently stored
-on disk. ~arch-wiki-docs~ stores them in ~/usr/share/doc/arch-wiki/html/en~. A
-simple ~ls~ piped in three ~sed~ will give us a list of page titles. We then
-pipe that into rofi in dmenu mode in order to choose the page we want to
-display. By the way, setting the location of the HTML files will come in handy
-later.
-#+BEGIN_SRC fish
-set WLOCATION /usr/share/doc/arch-wiki/html/en/
-set WPAGE (/bin/ls $WLOCATION | \
- sed -e 's/_/ /g' -e 's/\.html$//' -e 's|.*/\(.*\)|\1|' | \
- rofi -dmenu -p "Arch Wiki" -i)
-set WPAGE (echo $WPAGE | sed -r 's/\s+/_/g')
-#+END_SRC
-
-Now, all I need to do is to send this list into rofi and tell it to open the
-result with our favorite browser with ~xdg-open~.
-#+BEGIN_SRC fish
-xdg-open $WLOCATION$WPAGE.html
-#+END_SRC
-
-** ConnectWifi :noexport:
-:PROPERTIES:
-:HEADER-ARGS: :shebang "#!/usr/bin/env fish" :mkdirp yes :tangle ~/.local/bin/connect-wifi
-:CUSTOM_ID: ConnectWifi-16e5e24a
-:END:
-~connect-wifi~ is a small utility tool that allows the user to connect to
-available WiFi networks. The first thing to do is to select the WiFi we want to
-connect to. We’ll use the ~nmcli c s~ command to get the list of the available
-networks, and we’ll chose one with ~rofi~.
-#+BEGIN_SRC fish
-set SELECTEDWIFI (nmcli d w l | \
-egrep -o '([0-9A-F]{2}:){5}[0-9A-F]{2}\s*(.*)Infra' | \
-egrep -o '\s+(.*)\s+' | awk '{$1=$1}1' | \
-rofi -dmenu -p "Select your WiFi network")
-#+END_SRC
-Now, if a network was selected, let’s attempt to connect to it. Otherwise, let’s
-just send a notification no network was selected.
-#+BEGIN_SRC fish
-if test -z $SELECTEDWIFI
- notify-send "No WiFi network selected" -u low && exit
-end
-nmcli c u $SELECTEDWIFI
-#+END_SRC
-
-*** TODO fix it
-:PROPERTIES:
-:CUSTOM_ID: ConnectWifi-fix_it-a4b11503
-:END:
-
-** dmenu
-:PROPERTIES:
-:HEADER-ARGS: :shebang "#!/usr/bin/env fish" :mkdirp yes :tangle ~/.local/bin/dmenu
-:CUSTOM_ID: Dmenu-527edf04
-:END:
-I wrote this very simple script in order to replace =dmenu= with rofi’s
-emulation of dmenu, since I prefer rofi’s appearance. It basically calls rofi’s
-dmenu emulation with the arguments initially passed to dmenu.
-#+BEGIN_SRC fish
-rofi -dmenu $argv
-#+END_SRC
-
-** Emoji picker
-:PROPERTIES:
-:HEADER-ARGS: :shebang "#!/usr/bin/env bash" :mkdirp yes :tangle ~/.local/bin/rofi-emoji
-:CUSTOM_ID: Emoji_picker-a1c374ec
-:END:
-The emoji picker is a simple fish script that uses rofi and
-[[file:~/.config/emoji.txt][~/.config/emoji.txt]] to provide a small, local search for emojis. It is
-relatively easy to build this file from the Unicode’s [[https://unicode.org/Public/emoji/15.0/emoji-test.txt][test file]]. Once
-the emoji is selected, it is copied to the clipboard using =xclipboard=
-when in a Xorg session or =wl-copy= from =wl-clipboard= when in a Wayland
-session.
-#+BEGIN_SRC bash
-SELECTED_EMOJI=$(grep -v "#" ~/.config/emoji.txt | rofi -dmenu -p "Select emoji" -i | awk '{print $1}' | tr -d '\n')
-if [ "$XDG_SESSION_TYPE" = "wayland" ]
-then printf "%s" "$SELECTED_EMOJI" | wl-copy
-else printf "%s" "$SELECTED_EMOJI" | xclip -sel clip
-fi
-#+END_SRC
-
-Also, let’s send a notification telling the user the emoji has been copied!
-#+BEGIN_SRC bash
-# EMOJI=$([ "$XDG_SESSION_TYPE" = "wayland" ] && xclip -o -selection clipboard || wl-paste)
-if [ "$XDG_SESSION_TYPE" = "wayland" ]
-then EMOJI=$(wl-paste)
-else EMOJI=$(xclip -o)
-fi
-
-# EMOJI=$(xclip -o -selection clipboard | tr -d '\n')
-test -z "$EMOJI" && notify-send "No emoji copied" -u low && exit
-EMOJI="$EMOJI copied to clipboard"
-notify-send -u low "$EMOJI"
-#+END_SRC
-
-It is inspired from [[https://www.youtube.com/watch?v=UCEXY46t3OA][this video]] from [[https://lukesmith.xyz/][Luke Smith]], rewritten in Fish.
-
-** Partition mounting and unmounting
-:PROPERTIES:
-:CUSTOM_ID: Rofi-utilities-Partition-mounting-and-unmounting-9492ff60
-:END:
-*** rofi-mount
-:PROPERTIES:
-:HEADER-ARGS: :shebang "#!/usr/bin/env fish" :mkdirp yes :tangle ~/.local/bin/rofi-mount
-:CUSTOM_ID: Rofi-mount-ebbebf68
-:END:
-=rofimount= is a script inspired by [[https://github.com/ihebchagra/dotfiles/blob/master/.local/bin/dmount][this one]], based on dmenu, which
-interactively asks the user what to mount, and where to mount it. What I did was
-replace dmenu with rofi, and fix a couple of bugs I encountered in the original
-script.
-
-**** Get the mountable elements
-:PROPERTIES:
-:CUSTOM_ID: Rofi-mount-Get_the_mountable_elements-24db7834
-:END:
-#+BEGIN_SRC fish
-begin
-#+END_SRC
-
-What the script does first is detect everything that can be mounted. Between a
-=begin= and =end=, let’s set =LFS= as a local variable. This si in order to get
-sane variables in the current block.
-#+BEGIN_SRC fish
-set -l LFS
-#+END_SRC
-
-Now, let’s detect the amount of mountable Android filesystems, and if any are
-detected, let’s read them into a global variable.
-#+BEGIN_SRC fish
-set -l a (math (jmtpfs -l | wc -l) - 2)
-test $a -ge 0 && jmtpfs -l 2> /dev/null | tail -n $a | read -zg anddrives
-#+END_SRC
-
-We’ll do the same for external and internal drives and partitions that can be
-mounted here.
-#+BEGIN_SRC fish
-lsblk -rpo "name,type,size,mountpoint" | \
-awk '$2=="part"&&$4==""{printf "%s (%s)\n",$1,$3}' | \
-read -zg usbdrives
-#+END_SRC
-
-Finally, we look for any CD drive that could be mounted on our device.
-#+BEGIN_SRC fish
-blkid /dev/sr0 | awk '{print $1}' | sed 's/://' | read -z cddrives
-#+END_SRC
-
-And that’s the end of our first block!
-#+BEGIN_SRC fish
-end
-#+END_SRC
-
-Alright, we’ll save what kind on drives we can mount in a temporary file called
-=/tmp/drives=. We’ll make sure it’s blank by erasing it then creating it again
-with =touch=, like so. The =-f= flag on =rm= is here so we get no error if we
-try to delete a file that doesn’t exist (yet).
-#+BEGIN_SRC fish
-set -g TMPDRIVES /tmp/drives
-rm -f $TMPDRIVES
-touch $TMPDRIVES
-#+END_SRC
-
-Now, let’s write what type of drives we can mount in this temporary file.
-#+BEGIN_SRC fish
-test -n "$usbdrives" && echo "USB" >> $TMPDRIVES
-test -n "$cddrives" && echo "CD" >> $TMPDRIVES
-test -n "$anddrives" && echo "Android" >> $TMPDRIVES
-#+END_SRC
-
-Now, we want to declare where to look for mount directories. For now, we’ll only
-look in =/media=, but you can add more if you wish.
-#+BEGIN_SRC fish
-set -g basemount /media
-#+END_SRC
-
-**** Get the mount point
-:PROPERTIES:
-:CUSTOM_ID: Rofi-mount-Get_the_mount_point-6c4bac06
-:END:
-Now, let’s declare a function that will allow us to chose the drive we want to
-mount.
-#+BEGIN_SRC fish
-function getmount
-#+END_SRC
-
-First, we want to get our mount point. We’ll run a =find= command on each of the
-directories listed in =$basemount= to look for folders on which our drive could
-be mounted. This list will be passed to rofi from which we will chose our mount
-point.
-#+BEGIN_SRC fish
-set -g mp (for d in $basemount
- find $d -maxdepth 5 -type d
-end | rofi -dmenu -i -p 'Type in mount point.')
-#+END_SRC
-
-We should verify that something has been actually selected, otherwise we should
-abort the script.
-#+BEGIN_SRC fish
-if test -z $mp || test $mp = ""
- return 1
-end
-#+END_SRC
-
-Now, if the selected mount point does not exist, we’ll ask the user whether the
-directory should be created. If no, the script will abort. If yes, an attempt
-will be made at creating the directory as the user; if that fails, a new attempt
-will be made as sudo.
-#+BEGIN_SRC fish
-if test ! -d $mp
- switch (printf "No\\nYes" | rofi -dmenu -i -p "$mp does not exist. Create it?")
- case 'Yes'
- mkdir -p $mp || sudo -A mkdir -p $mp
- case '*'
- return 1
- end
-end
-#+END_SRC
-
-Finally, let’s close the function
-#+BEGIN_SRC fish
-end
-#+END_SRC
-
-**** Mount a USB drive, hard drive or partition
-:PROPERTIES:
-:CUSTOM_ID: Rofi-mount-Mount_a_USB_drive,_hard_drive_or_partition-f5431dbe
-:END:
-Alright, we want to mount a partition that answers by the name of =/dev/sdXX=,
-how do we do that? Let’s create first the function =mountusb= that will take
-care of it for us.
-#+BEGIN_SRC fish
-function mountusb
-#+END_SRC
-
-Now, the first thing we want to do is select the partition we want to mount.
-Remember, we stored those in =$usbdrives= earlier, so let’s pipe them into rofi
-so we can chose from it. Also, =awk= will get their path in =/dev=.
-#+BEGIN_SRC fish
-set -g chosen (echo $usbdrives | \
-rofi -dmenu -i -p "Mount which drive?" | \
-awk '{print $1}')
-#+END_SRC
-
-As usual after a user selection, let’s verify something has actually been
-selected. If not, let’s abort the script.
-#+BEGIN_SRC fish
-test -z $chosen && return 1
-#+END_SRC
-
-Now, let’s select the mount point of our partition. We’ll call the function
-=getmount= described in [[#Rofi-mount-Get_the_mount_point-6c4bac06][Get the mount point]] to select it.
-#+BEGIN_SRC fish
-getmount
-#+END_SRC
-
-Let’s verify the variable =mp= set in =getmount= is not empty, otherwise abort
-the script.
-#+BEGIN_SRC fish
-test -z $mp && return 1
-#+END_SRC
-
-Now, let’s mount it! We’ll use a switch which will detect the filesystem used so
-we know how to mount the partition.
-#+BEGIN_SRC fish
-switch (lsblk -no "fstype" $chosen)
-#+END_SRC
-
-We have two named case: =vfat= filesystems.
-#+BEGIN_SRC fish
-case "vfat"
- sudo -A mount -t vfat $chosen $mp -o rw,umask=0000
-#+END_SRC
-
-And =ntfs= filesystems.
-#+BEGIN_SRC fish
-case "ntfs"
- sudo -A mount -t ntfs $chosen $mp -o rw,umask=0000
-#+END_SRC
-
-Else, we’ll let =mount= determine which filesystem is used by the partition
-(generally =ext4=).
-#+BEGIN_SRC fish
-case '*'
- sudo -A mount $chosen $mp
-#+END_SRC
-
-We’ll also run a =chown= on this newly mounted filesystem so the user can access
-it without any issues.
-#+BEGIN_SRC fish
-sudo -A chown -R $USER:(id -g $USER) $mp
-#+END_SRC
-
-Let’s close the switch block and send a notification the partition has been
-mounted.
-#+BEGIN_SRC fish
-end && notify-send -a "dmount" "💻 USB mounting" "$chosen mounted to $mp."
-#+END_SRC
-
-And let’s close the function.
-#+BEGIN_SRC fish
-end
-#+END_SRC
-
-**** Mount an Android device
-:PROPERTIES:
-:CUSTOM_ID: Rofi-mount-Mount_an_Android_device-5321f9cd
-:END:
-The function that manages to mount Android filesystems is =mountandroid=. Let’s
-declare it.
-#+BEGIN_SRC fish
-function mountandroid -d "Mount an Android device"
-#+END_SRC
-
-We’ll select which Android we want to mount. We will be asked through rofi.
-#+BEGIN_SRC fish
-set chosen (echo $anddrives | rofi -dmenu -i -p "Which Android device?" | awk '{print $1 $2}' | sed 's/,$//')
-#+END_SRC
-
-Now, we need to get the bus of the Android device we want to mount. It will be
-useful later, after we authorized mounting from our device, to get the path to
-our partition.
-#+BEGIN_SRC fish
-set bus (echo $chosen | sed 's/,.*//')
-#+END_SRC
-
-Let’s temporarily mount our device.
-#+BEGIN_SRC fish
-jmtpfs -device=$chosen $mp
-#+END_SRC
-
-Now, we need to allow our computer to mount our Android device. Depending on the
-Android version it is running on, we either need to specify our device is USB
-connected in order to exchange files, or Android will explicitely ask us if it
-is OK for our computer to access it. Let’s inform the user of that.
-#+BEGIN_SRC fish
-echo "OK" | \
-rofi -dmenu -i -p "Press (Allow) on your phone screen, or set your USB settings to allow file transfert"
-#+END_SRC
-
-Now, let’s get the actual path of our Android filesystem we wish to mount, and
-let’s unmount the previous temporary filesystem.
-#+BEGIN_SRC fish
-set newchosen (jmtpfs -l | grep $bus | awk '{print $1 $2}' | sed 's/,$//')
-sudo -A umount $mp
-#+END_SRC
-
-Now we cam mount the new filesystem and send a notification if everything went
-well.
-#+BEGIN_SRC fish
-jmtpfs -device=$newchosen $mp && \
-notify-send -a "dmount" "🤖 Android Mounting" "Android device mounted to $mp."
-#+END_SRC
-
-And now, we can close our function.
-#+BEGIN_SRC fish
-end
-#+END_SRC
-
-**** Mount a CD drive
-:PROPERTIES:
-:CUSTOM_ID: Rofi-mount-Mount_a_CD_drive-27278199
-:END:
-This part is way easier than the previous functions. As we will see, the
-function =mountcd='s body is only three lines long. First, let’s declare the
-function.
-#+BEGIN_SRC fish
-function mountcd
-#+END_SRC
-
-Now, let’s chose the CD drive we want to mount using =rofi=.
-#+BEGIN_SRC fish
-set chosen (echo $cddrives | rofi -dmenu -i -p "Which CD drive?")
-#+END_SRC
-
-We’ll also get the mountpoint thanks to the =getmount= function described
-earlier.
-#+BEGIN_SRC fish
-getmount
-#+END_SRC
-
-And finally, let’s mount it and send the notification everything went well.
-#+BEGIN_SRC fish
-sudo -A mount $chosen $mp && \
-notify-send -a "dmount" "💿 CD mounting" "$chosen mounted."
-#+END_SRC
-
-Finally, let’s close our function.
-#+BEGIN_SRC fish
-end
-#+END_SRC
-
-**** Ask what type of drive we want to mount
-:PROPERTIES:
-:CUSTOM_ID: Rofi-mount-Ask_what_type_of_drive_we_want_to_mount-0c15cffa
-:END:
-The first thing we will be asked if different types of drives are detected is
-which of these types the user wishes to mount. This is done with the function
-=asktype= which is declared below.
-#+BEGIN_SRC fish
-function asktype
-#+END_SRC
-
-We will use a switch statement which will use our anwser to rofi about what we
-wish to mount.
-#+BEGIN_SRC fish
-switch (cat $TMPDRIVES | rofi -dmenu -i -p "Mount which drive?")
-#+END_SRC
-
-If we chose the option "USB", we’ll mount a hard drive, partition or USB drive.
-In which case we’ll call the =mountusb= function.
-#+BEGIN_SRC fish
-case "USB"
- mountusb
-#+END_SRC
-
-If we chose the "Android" option, the =mountandroid= function is called.
-#+BEGIN_SRC fish
-case "Android"
- mountandroid
-#+END_SRC
-
-Else if we chose the "CD" option, we’ll call the =mountcd= function.
-#+BEGIN_SRC fish
-case "CD"
- mountcd
-#+END_SRC
-
-If nothing is selected, the function will naturally exit. Now, let’s close our
-switch statement and our function.
-#+BEGIN_SRC fish
-end
-end
-#+END_SRC
-
-**** Launch the mounting functions
-:PROPERTIES:
-:CUSTOM_ID: Rofi-mount-Launch_the_mounting_functions-218ad001
-:END:
-Now that we have declared our functions and set our variables, we’ll read the
-temporary file described in [[#Rofi-mount-Get_the_mountable_elements-24db7834][Get the mountable elements]]. The amount of lines is
-passed in a switch statement.
-#+BEGIN_SRC fish
-switch (wc -l < $TMPDRIVES)
-#+END_SRC
-
-If the file has no lines, i.e. it is empty, we have no mountable media. Let’s
-inform our user this is the case.
-#+BEGIN_SRC fish
-case 0
- notify-send "No USB drive or Android device or CD detected" -a "dmount"
-#+END_SRC
-
-If we only have one line, we have only one type of mountable media. We’ll pass
-this line to a second switch statement.
-#+BEGIN_SRC fish
-case 1
- switch (cat $TMPDRIVES)
-#+END_SRC
-This will allow the script to automatically detect what type of media it is, and
-mount the corresponding function.
-#+BEGIN_SRC fish
-case "USB"
- mountusb
-case "Android"
- mountandroid
-case "CD"
- mountCD
-#+END_SRC
-Let’s close this nested switch case.
-#+BEGIN_SRC fish
-end
-#+END_SRC
-
-If we have more than one line, we’ll have to ask the user what type of media
-they want to mount.
-#+BEGIN_SRC fish
-case '*'
- asktype
-#+END_SRC
-
-Now, let’s end our switch statement!
-#+BEGIN_SRC fish
-end
-#+END_SRC
-
-Finally, we’ll delete our temporary file.
-#+BEGIN_SRC fish
-rm -f $TMPDRIVES
-#+END_SRC
-
-And with that, this is the end of our script!
-
-*** rofi-umount
-:PROPERTIES:
-:HEADER-ARGS: :shebang "#!/usr/bin/env fish" :mkdirp yes :tangle ~/.local/bin/rofi-umount
-:CUSTOM_ID: Rofi-umount-ddde1667
-:END:
-~rofiumount~ is the counterpart of ~rofimount~ for unmounting our mounted
-partitions.
-
-**** Get the unmountable drives
-:PROPERTIES:
-:CUSTOM_ID: Rofi-umount-Get_the_unmountable_drives-89c71040
-:END:
-First, we will need to list all the drives that can be safely unmounted. Let’s
-run this.
-#+BEGIN_SRC fish
-set -g drives (lsblk -nrpo "name,type,size,mountpoint" | \
-awk '$2=="part"&&$4!~/\/boot|\/home$|SWAP/&&length($4)>1{printf "%s (%s)\n",$4,$3}')
-#+END_SRC
-
-Now, let’s get the android devices that are mounted.
-#+BEGIN_SRC fish
-set -g androids (awk '/jmtpfs/ {print $2}' /etc/mtab)
-#+END_SRC
-
-And let’s get the CD drives that are mounted.
-#+BEGIN_SRC fish
-set -g cds (awk '/sr0/ {print $2}' /etc/mtab)
-#+END_SRC
-
-We’ll store all of our information in a temporary file, =/tmp/undrives=.
-#+BEGIN_SRC fish
-set -g undrivefile /tmp/undrives
-#+END_SRC
-
-Let’s make sure we begin with a clean, empty file.
-#+BEGIN_SRC fish
-rm -f $undrivefile
-touch $undrivefile
-#+END_SRC
-
-Depending on if the related variables are set, write the different types of
-mounted drives in the temporary file.
-#+BEGIN_SRC fish
-test -n "$drives" && echo "USB" >> $undrivefile
-test -n "$cds" && echo "CD" >> $undrivefile
-test -n "$androids" && echo "Android" >> $undrivefile
-#+END_SRC
-
-**** Unmount disk partitions
-:PROPERTIES:
-:CUSTOM_ID: Rofi-umount-Unmount_disk_partitions-0d425a47
-:END:
-The function =unmountusb= will take care of unmounting any drive we can safely
-unmount. First, let’s declare the function.
-#+BEGIN_SRC fish
-function unmountusb
-#+END_SRC
-
-Let’s chose the drive to unmount with rofi.
-#+BEGIN_SRC fish
-set chosen (echo $drives | \
-rofi -dmenu -i -p "Unmount which drive?" | \
-awk '{print $1}')
-#+END_SRC
-
-Let’s verify if the user actually selected any drive. If no, let’s abort the
-script.
-#+BEGIN_SRC fish
-test -z "$chosen" && exit 0
-#+END_SRC
-
-Now, let’s unmount the chosen drive and send a notification if it has been done.
-#+BEGIN_SRC fish
-sudo -A umount $chosen && \
-notify-send "💻 USB unmounting" "$chosen unmounted." -a "dumount"
-#+END_SRC
-
-Now, let’s close the function.
-#+BEGIN_SRC fish
-end
-#+END_SRC
-
-**** Unmount Android device
-:PROPERTIES:
-:CUSTOM_ID: Rofi-umount-Unmount_Android_device-ae1d5904
-:END:
-The function =unmountandroid= will take care of unmounting any mounted Android
-device. First, let’s declare our function.
-#+BEGIN_SRC fish
-function unmountandroid
-#+END_SRC
-
-Let the user choose which Android device to unmount.
-#+BEGIN_SRC fish
-set chosen (echo $androids | rofi -dmenu -i -p "Unmount which device?")
-#+END_SRC
-
-We’ll verify the user chose any device.
-#+BEGIN_SRC fish
-test -z "$chosen" && exit 0
-#+END_SRC
-
-If a device has been chosen, let’s unmount it and send a notification it has
-been successfuly unmounted.
-#+BEGIN_SRC fish
-sudo -A umount -l $chosen && \
-notify-send "🤖 Android unmounting" "$chosen unmounted." -a "dumount"
-#+END_SRC
-
-Finally, let’s close the function.
-#+BEGIN_SRC fish
-end
-#+END_SRC
-
-**** Unmount CD drive
-:PROPERTIES:
-:CUSTOM_ID: Rofi-umount-Unmount_CD_drive-369a2f61
-:END:
-=unmountcd= will take care of unmounting any mounted CD drive. Let’s declare
-this function.
-#+BEGIN_SRC fish
-function unmountcd
-#+END_SRC
-
-As before, let the user chose which CD drive to unmount.
-#+BEGIN_SRC fish
-set chosen (echo "$cds" | rofi -dmenu -i -p "Unmount which CD?")
-#+END_SRC
-
-We’ll verify the user chose any device.
-#+BEGIN_SRC fish
-test -z "$chosen" && exit 0
-#+END_SRC
-
-If a drive has been chosen, let’s unmount it and send a notification it has been
-successfuly unmounted.
-#+BEGIN_SRC fish
-sudo -A umount -l $chosen && \
-notify-send "💿 CD unmounting" "$chosen unmounted." -a "dumount"
-#+END_SRC
-
-Now, let’s close the function.
-#+BEGIN_SRC fish
-end
-#+END_SRC
-
-**** Ask what type of drive to unmount
-:PROPERTIES:
-:CUSTOM_ID: Rofi-umount-Ask_what_type_of_drive_to_unmount-6287af48
-:END:
-If several types of unmountable drives are available, let’s ask the user which
-type to unmount based on the content of the temporary file declared in [[#Rofi-umount-Get_the_unmountable_drives-89c71040][Get the
-unmountable drives]]. First, let’s declare the function.
-#+BEGIN_SRC fish
-function asktype
-#+END_SRC
-
-Let’s create a switch statement to which will be passed the selection of the
-user from rofi.
-#+BEGIN_SRC fish
-switch (cat $undrivefile | rofi -dmenu -i -p "Unmount which type of device?")
-#+END_SRC
-
-Three types of values can be returned: "USB", "CD", or "Android". These values
-will be used to launch their corresponding function.
-#+BEGIN_SRC fish
-case 'USB'
- unmountusb
-case 'CD'
- unmountcd
-case 'Android'
- unmountandroid
-#+END_SRC
-
-Let’s close the switch statement.
-#+BEGIN_SRC fish
-end
-#+END_SRC
-
-Let’s now close the function.
-#+BEGIN_SRC fish
-end
-#+END_SRC
-
-**** Launch the unmounting functions
-:PROPERTIES:
-:CUSTOM_ID: Rofi-umount-Launch_the_unmounting_functions-7c48a928
-:END:
-Now back to the body of our script, let’s input in a switch case the number of
-lines contained in our temporary file.
-#+BEGIN_SRC fish
-switch (wc -l < $undrivefile)
-#+END_SRC
-
-If the file containes no lines. i.e. it is empty, nothing is to be unmounted.
-Let’s inform the user of that.
-#+BEGIN_SRC fish
-case 0
- notify-send "No USB drive or Android device or CD to unmount" -a "dumount"
-#+END_SRC
-
-Else, if there is only one type of drive, we’ll automatically let our script
-choose based on the content of this sole line.
-#+BEGIN_SRC fish
-case 1
- switch (cat $undrivefile)
- case 'USB'
- unmountusb
- case 'CD'
- unmountcd
- case 'Android'
- unmountandroid
- end
-#+END_SRC
-
-And if there are more types than one, let’s ask the user.
-#+BEGIN_SRC fish
-case '*'
- asktype
-#+END_SRC
-
-Let’s close our main switch statement.
-#+BEGIN_SRC fish
-end
-#+END_SRC
-
-And finally, let’s delete our temporary file.
-#+BEGIN_SRC fish
-rm -f $undrivefile
-#+END_SRC
-
-** rofi-pass
-:PROPERTIES:
-:HEADER-ARGS: :shebang "#!/usr/bin/env fish" :mkdirp yes :tangle ~/.local/bin/rofi-pass
-:CUSTOM_ID: Rofi-pass-8335357f
-:END:
-=rofi-pass= is a simple utility that gets a password stored in the [[https://www.passwordstore.org/][=pass=]]
-password manager with rofi as its interface, and then stores the password in the
-clipboard.
-
-Let’s parse all the arguments passed to the script. If one of them is =--type=,
-=-t= or =type=, the script will attempt to type the password to the text area
-already selected without pasting the password to the clipboard.
-#+BEGIN_SRC fish
-for arg in $argv
- switch $arg
- case '--type' '-t' 'type'
- set -g TYPE "yes"
- case '*'
- printf 'Unknown argument: %s\n.' $arg
- exit 1
- end
-end
-#+END_SRC
-
-Now, let’s get the list of the passwords that exist in our =pass= repository.
-#+BEGIN_SRC fish
-set passwords (find $HOME/.password-store -type f -name "*.gpg" | \
-string replace -r ".*.password-store/" "" | \
-string replace -r ".gpg" "" | sort)
-#+END_SRC
-
-Let the user choose which password they wish to select.
-#+BEGIN_SRC fish
-set password (for elem in $passwords
- echo $elem
-end | rofi -dmenu -i -p "Select your password")
-#+END_SRC
-
-Let’s verify we actually selected a password and not just exited. If no password
-was selected, let’s simply exit the script.
-#+BEGIN_SRC fish
-if test -z $password
- exit
-end
-#+END_SRC
-
-Depending on the arguments passed earlier, we might want some different
-behavior.
-#+BEGIN_SRC fish :noweb yes
-if test $TYPE = "yes"
- <>
-else
- <>
-end
-#+END_SRC
-
-The default behavior is to copy the password to the clipboard for 45 seconds, so
-let’s do that.
-#+NAME: rofi-pass-copy
-#+BEGIN_SRC fish :noweb yes :tangle no
-pass show -c $password 2> /dev/null
-#+END_SRC
-
-Else, if we passed =--type=, =-t= or =type= as an argument of the script, we
-want it to attempt to type our password in the currently selected text input.
-Let’s do that.
-#+NAME: rofi-pass-type
-#+BEGIN_SRC fish :noweb yes :tangle no
-set -l IFS
-<>
-printf %s $pass | xvkbd -file -
-#+END_SRC
-
-To correctly get the password from ~pass~, we need to parse the output and only
-get the first line, hence the following command.
-#+NAME: rofi-pass-type-get-password
-#+BEGIN_SRC fish :tangle no
-set pass (pass show $password | string split -n \n)[1]
-#+END_SRC
-
-** rofi-ytdl
-:PROPERTIES:
-:HEADER-ARGS: :shebang "#!/usr/bin/env bash" :mkdirp yes :tangle ~/.local/bin/rofi-ytdl
-:CUSTOM_ID: rofi-ytdl-ff8f789d
-:END:
-This is just a simple wrapper around [[#ytdl-a-youtube-dl-wrapper-03bd63e0][ytdl]] so I can easily download a video from
-rofi, which we’ll use first to retrieve the URL of the video we want to
-download, be it from YouTube or other website supported by ~youtube-dl~.
-#+BEGIN_SRC bash
-URL=$(echo "Video to download:" | rofi -dmenu -i -p "Video to download:")
-#+END_SRC
-
-Now, if the variable ~URL~ is not empty (i.e. the user specified a link and did
-not abort the operation), we’ll proceed to teh download. Before it begins, we’ll
-send a notification saying the download is about to begin. When the ~ytdl~
-process ends, we’ll also send a notification notifying the user on the success
-or failure of the download.
-#+BEGIN_SRC bash
-if [ -n "$URL" ]; then
- notify-send -u normal "YTDL" "Starting downloading\n$URL"
- if [[ $(ytdl "$URL") ]]
- then
- notify-send -u normal "YTDL" "Finished downloading!"
- else
- notify-send -u critical "YTDL" "Failed downloading\n$URL"
- fi
-fi
-#+END_SRC
-
-* Wallpaper utilities
-:PROPERTIES:
-:CUSTOM_ID: Wallpaper-utilities-5c05d470
-:END:
-** pape-update
-:PROPERTIES:
-:HEADER-ARGS: :shebang "#!/usr/bin/env sh" :mkdirp yes :tangle ~/.local/bin/pape-update
-:CUSTOM_ID: pape-update-bdecbadf
-:END:
-This little tool sets a random wallpaper using xwallpaper.
-#+BEGIN_SRC sh
-PAPESDIR=$HOME/Pictures/Wallpapers
-PAPE=$(find "$PAPESDIR" -type f | sort -R | tail -1)
-set-pape "$PAPE"
-#+END_SRC
-
-** Select wallpaper
-:PROPERTIES:
-:CUSTOM_ID: Wallpaper-utilities-Select-wallpaper-42f477a9
-:HEADER-ARGS: :shebang "#!/usr/bin/env sh" :mkdirp yes :tangle ~/.local/bin/select-pape
-:END:
-This script is based on what ~nsxiv~ can do as an image viewer as well as
-xwallpaper.
-#+BEGIN_SRC sh
-PAPE=$(nsxiv -orbft ~/Pictures/Wallpapers/*)
-set-pape "$PAPE"
-#+END_SRC
-
-** Set a wallpaper
-:PROPERTIES:
-:HEADER-ARGS: :shebang "#!/usr/bin/env bash" :mkdirp yes :tangle ~/.local/bin/set-pape
-:CUSTOM_ID: Wallpaper-utilities-Set-a-wallpaper-27eda9e6
-:END:
-This utility is not meant to be called by the user directly, but rather by
-scripts that may be written by the user. Its role is simple: check if the
-provided wallpaper exists and if it is an image. If both requirements are met,
-the path to this image is then stored in ~$XDG_CACHE_HOME/wallpaper~, or if this
-variable is empty in ~$HOME/.cache/wallpaper~.
-#+BEGIN_SRC sh
-CACHEFILE=$([ -n "$XDG_CACHE_HOME" ] && echo "$XDG_CACHE_HOME/wallpaper" || echo "$HOME/.cache/wallpaper")
-[[ -f $1 ]] && \
- grep image <(file -b --mime-type "$1") && \
- echo "$1" > "$CACHEFILE" \
- && xwallpaper --zoom "$1"
-#+END_SRC
-
-* Wayland
-:PROPERTIES:
-:CUSTOM_ID: Wayland-3e7jdch05mj0
-:END:
-** Wayland Environment Variables Setup
-:PROPERTIES:
-:HEADER-ARGS: :shebang "#!/usr/bin/env sh" :mkdirp yes :tangle ~/.local/bin/way-env-setup
-:CUSTOM_ID: WaylandWaylandEnvironmentVariablesSetup-ik05m461rmj0
-:END:
-#+begin_src sh
-#export GDK_BACKEND=wayland # May cause problems with some xorg applications
-export TDESKTOP_DISABLE_GTK_INTEGRATION=1
-export CLUTTER_BACKEND=wayland
-export BEMENU_BACKEND=wayland
-
-# Firefox
-export MOZ_ENABLE_WAYLAND=1
-
-#
-# Qt environment
-#
-export QT_QPA_PLATFORM=wayland-egl #error with apps xcb
-export QT_WAYLAND_FORCE_DPI=physical
-export QT_WAYLAND_DISABLE_WINDOWDECORATION=1
-
-#
-# Elementary environment
-#
-export ELM_DISPLAY=wl
-export ECORE_EVAS_ENGINE=wayland_egl
-export ELM_ENGINE=wayland_egl
-export ELM_ACCEL=opengl
-# export ELM_SCALE=1
-
-#
-# SDL environment
-#
-export SDL_VIDEODRIVER=wayland
-
-#
-# Java environment
-#
-export _JAVA_AWT_WM_NONREPARENTING=1
-
-export NO_AT_BRIDGE=1
-export WINIT_UNIX_BACKEND=wayland
-export DBUS_SESSION_BUS_ADDRESS
-export DBUS_SESSION_BUS_PID
-#+end_src
-*** Hyprland VNC
-:PROPERTIES:
-:CUSTOM_ID: WaylandWaylandEnvironmentVariablesSetupHyprlandVNC-m3o4g3w0i0k0
-:END:
-**** Get Hyprland signature
-:PROPERTIES:
-:HEADER-ARGS: :shebang "#!/usr/bin/env fish" :mkdirp yes :tangle ~/.local/bin/hyprland-signature
-:CUSTOM_ID: WaylandGetHyprlandsignature-0uwezmv0i0k0
-:END:
-#+begin_src fish
-if test ! -e /tmp/hypr
- exit 1
-end
-set LOCKFILES (ls -1 /tmp/hypr/*.lock)
-if test (count $LOCKFILES) -lt 1
- exit 1
-end
-set LOCKFILE (basename $LOCKFILES[1] ".lock")
-echo $LOCKFILE
-#+end_src
-
-**** Prepare monitors for VNC connection
-:PROPERTIES:
-:HEADER-ARGS: :shebang "#!/usr/bin/env sh" :mkdirp yes :tangle ~/.local/bin/hyprland-set-vnc-monitors
-:CUSTOM_ID: WaylandPreparemonitorsforVNCconnection-pttgzov0i0k0
-:END:
-#+begin_src sh
-export HYPRLAND_INSTANCE_SIGNATURE=$(hyprland-signature)
-hyprctl keyword monitor eDP-1,disable
-hyprctl keyword monitor HDMI-A-1,1280x720,0x0,1
-#+end_src
-
-**** Launch wayvnc if it isn’t already
-:PROPERTIES:
-:HEADER-ARGS: :shebang "#!/usr/bin/env sh" :mkdirp yes :tangle ~/.local/bin/hyprland-launch-vnc
-:CUSTOM_ID: WaylandWaylandEnvironmentVariablesSetupHyprlandVNCLaunchwayvncifitisntalready-jd2025w0i0k0
-:END:
-#+begin_src sh
-export HYPRLAND_INSTANCE_SIGNATURE=$(hyprland-signature)
-hyprctl dispatch -- exec "pidof wayvnc || wayvnc -k fr-bepo_afnor"
-hyprland-set-vnc-monitors
-#+end_src
-
-** Newm
-:PROPERTIES:
-:CUSTOM_ID: WaylandNewm-t3hjdch05mj0
-:HEADER-ARGS: :shebang "#!/usr/bin/env sh" :mkdirp yes :tangle ~/.local/bin/launch-newm
-:END:
-#+begin_src sh
-export SDL_VIDEODRIVER=wayland
-export XDG_SESSION_TYPE=wayland
-export XDG_SESSION_DESKTOP=wlroots
-export XDG_CURRENT_TYPE=wlroots
-export XDG_CURRENT_DESKTOP=wlroots
-. /etc/X11/xinit/xinitrc.d/50-systemd-user.sh
-. way-env-setup
-systemctl --user import-environment DISPLAY WAYLAND_DISPLAY XDG_CURRENT_DESKTOP
-exec start-newm
-#+end_src
-
-** Qtile
-:PROPERTIES:
-:HEADER-ARGS: :shebang "#!/usr/bin/env sh" :mkdirp yes :tangle ~/.local/bin/launch-qtile
-:CUSTOM_ID: WaylandQtile-v5l2wdx03nj0
-:END:
-#+begin_src sh
-export SDL_VIDEODRIVER=wayland
-export XDG_SESSION_TYPE=wayland
-export XDG_SESSION_DESKTOP=wlroots
-export XDG_CURRENT_TYPE=wlroots
-export XDG_CURRENT_DESKTOP=wlroots
-. /etc/X11/xinit/xinitrc.d/50-systemd-user.sh
-. way-env-setup
-systemctl --user import-environment DISPLAY WAYLAND_DISPLAY XDG_CURRENT_DESKTOP
-exec qtile start -b wayland
-#+end_src
-
-** Sway
-:PROPERTIES:
-:HEADER-ARGS: :shebang "#!/usr/bin/env sh" :mkdirp yes :tangle ~/.local/bin/swaybar-cmd
-:CUSTOM_ID: WaylandSway-a8lge8m0arj0
-:END:
-#+begin_src sh :tangle ~/.local/bin/launch-sway
-export SDL_VIDEODRIVER=wayland
-# export XDG_SESSION_TYPE=wayland
-# export XDG_SESSION_DESKTOP=wlroots
-# export XDG_CURRENT_TYPE=wlroots
-export XDG_CURRENT_DESKTOP=sway
-. /etc/X11/xinit/xinitrc.d/50-systemd-user.sh
-. way-env-setup
-systemctl --user import-environment DISPLAY WAYLAND_DISPLAY XDG_CURRENT_DESKTOP
-exec sway --unsupported-gpu
-#+end_src
-
-Below is the script I use to display information in sway’s bar. It is
-divided by functions that are then called all together. First, getting
-the date is quite straightforward.
-#+begin_src sh
-sb_date() {
- echo "$(date +'%Y-%m-%d %H:%M:%S') | "
-}
-#+end_src
-
-Then we can get what piece of audio is playing. Note however that
-something will be displayed only if something is playing.
-#+begin_src sh
-sb_playerctl() {
- PLAYING=""
- if [ "$(playerctl status)" = "Playing" ]; then
- PLAYING_ARTIST="$(playerctl metadata xesam:artist)"
- PLAYING_TITLE="$(playerctl metadata xesam:title)"
- PLAYING=" $PLAYING_ARTIST - $PLAYING_TITLE | "
- fi
- echo "$PLAYING"
-}
-#+end_src
-
-The battery is relatively straightforward too. I should however find
-how to get estimates of battery time. I’m sure I can come up with
-something, but for now I’m just too lazy.
-#+begin_src sh
-sb_battery() {
- CAPACITY="$(cat /sys/class/power_supply/BAT0/capacity)%"
- STATE="$(cat /sys/class/power_supply/BAT0/status)"
- echo "$CAPACITY ($STATE)"
-}
-#+end_src
-
-Now comes an indicator for Docker containers which will be displayed
-only if at least one is running.
-#+begin_src sh
-sb_docker() {
- DOCKER_RUNNING="$(docker ps -q | wc -l)"
- # echo "Docker: $DOCKER_RUNNING"
- if [ "$DOCKER_RUNNING" = "0" ]
- then echo ""
- else echo "Docker: $DOCKER_RUNNING | "
- fi
-}
-#+end_src
-
-Finally, let’s display everything.
-#+begin_src sh
-echo "$(sb_docker)$(sb_playerctl)$(sb_date)$(sb_battery) "
-#+end_src
-
-* Weather
-:PROPERTIES:
-:HEADER-ARGS: :shebang "#!/usr/bin/env fish" :mkdirp yes :tangle ~/.local/bin/we
-:CUSTOM_ID: Weather-4ed00bb0
-:END:
-A quick and useful script I often use is a ~curl~ request to [[http://v2.wttr.in/][v2.wttr.in]] to get a
-weather forecast in the terminal. By default, I want the request to be about the
-city I live in, but it is also possible for the script to accept as its
-arguments a search inquiry.
-#+BEGIN_SRC fish
-if count $argv > /dev/null
- set -l SEARCH (string join '+' $argv)
- curl http://v2.wttr.in/~$SEARCH
-else
- curl http://v2.wttr.in/Aubervilliers
-end
-#+END_SRC
diff --git a/org/config/bootstrap.org b/org/config/bootstrap.org
deleted file mode 100644
index d563299..0000000
--- a/org/config/bootstrap.org
+++ /dev/null
@@ -1,1039 +0,0 @@
-#+TITLE: Arch Linux, Phundrak-flavored
-#+setupfile: headers
-#+OPTIONS: unique-id:t
-#+HTML_HEAD_EXTRA:
-#+HTML_HEAD_EXTRA:
-#+HTML_HEAD_EXTRA:
-#+PROPERTY: header-args :tangle no :exports none
-#+PROPERTY: header-args:sh :tangle no :exports code
-#+PROPERTY: header-args:fish :exports code :noweb yes
-#+PROPERTY: header-args:emacs-lisp :exports none :noweb yes :tangle no :cache yes
-
-* Introduction
-:PROPERTIES:
-:CUSTOM_ID: Introduction-cd5792cd
-:END:
-Here will be presented what I do to get my system up and running on a fresh Arch
-Linux install. These installation instructions were written in order to get an
-Arch Linux distribution up and running with the same configuration as my main
-computer’s and my travelling laptop’s configuration.
-
-* Install Arch Linux
-:PROPERTIES:
-:CUSTOM_ID: Install_Arch_Linux-ac7ad3b2
-:END:
-I usually install Arch from the [[https://www.archlinux.org/download/][vanilla ISO]], however I began using [[https://github.com/MatMoul/archfi][archfi]] to
-install easily the distro (I’ve done it so many times, I know how it works now).
-Usually, my distros will be installed on two partitions: ~/home~ and ~/~ (root).
-
-If the computer supports EFI bootloaders, the EFI partition will be mounted on
-~/boot/efi~. I generally use ~systemd-boot~ as my boot manager, but if you are
-more comfortable with another one, just install what you want. Be aware that if
-you format your ~/boot~ partition, you will delete all boot managers that
-already exist; so, if you are dual-booting, *DO NOT FORMAT IT*. Yes, I made the
-mistake of wiping the Windows boot manager when I used to dual-boot.
-
-In order to use the ~suspend-then-hibernate~ systemd command, it is necessary to
-have a swap partition at least twice the size of your installed RAM. That is
-because when this command will be run, the system will try to save the current
-state of your machine, stored in your RAM, to the swap filesystem. If there is
-not enough space, the command will fail, and you won’t be able to use this
-command. For instance, my current computer has 32 GB of RAM, hence my SWAP
-partition is 16 GB large.
-
-** Get the latest, fastest mirrors
-:PROPERTIES:
-:CUSTOM_ID: Install_Arch_Linux-Get_the_latest_fastest_mirrors-765401c9
-:END:
-When you boot into the live ISO, execute the following command:
-#+BEGIN_SRC sh
-pacman -Sy reflector
-reflector -c FR -c DE -c BE -l 200 -p http -p https --sort rate \
- --save /etc/pacman.d/mirrorlist --verbose
-#+END_SRC
-
-This will update the packages from your live ISO, and you will get the best
-mirrors for your installation. Of course, change the countries accordingly to
-your location. In my case, I am only interested in French, German, and Belgian
-mirrors.
-
-** Install the system
-:PROPERTIES:
-:CUSTOM_ID: Install_Arch_Linux-Install_the_system-3ff49aa6
-:END:
-Then you can use a custom script to ease your installation of Arch if you do not
-wish to do it manually. Personally, I’ve done it several times already, I know
-how the distro works, I just want to be able to install my distro quickly now.
-I’ll need to download the script with ~wget~, but apparently it isn’t installed
-by default on Arch ISOs anymore, so I’ll need to install it.
-#+BEGIN_SRC sh
-pacman -S wget
-#+END_SRC
-
-Now, let’s grab the script. You can check it on [[https://github.com/matmoul/archfi][GitHub]].
-#+BEGIN_SRC sh
-wget archfi.sf.net/archfi
-# Or from matmoul.github.io/archfi if SourceForge is down
-sh archfi
-#+END_SRC
-
-Then, follow the instructions and install Arch Linux. Take the opportunity to
-install as many packages as you need, mainly ~paru~ which I use as my package
-manager (it is just a wrapper for ~pacman~) and AUR helper, and ~pacman-contrib~
-which will help us to install some packages later.
-
-Once your system is installed, reboot and remove your installation media from
-your computer.
-
-* Execute bootstrap
-:PROPERTIES:
-:HEADER-ARGS:fish: :tangle ~/.config/yadm/bootstrap :shebang "#!/usr/bin/fish" :exports code :mkdirp yes
-:CUSTOM_ID: Execute_bootstrap-e37054ef
-:END:
-The first thing I will do is add the [[https://aur.chaotic.cx/][Chaotic AUR]] repository to get
-access to ~paru~ as well as some AUR packages without the need of an AUR
-helper (ironic considering ~paru~ is one). We can then install ~fish~,
-~git~, and ~paru~:
-#+BEGIN_SRC sh
-sudo pacman -S fish git paru
-#+END_SRC
-
-And now that ~paru~ is available, we can install ~yadm~:
-#+BEGIN_SRC sh
-paru -S yadm
-#+END_SRC
-
-~yadm~ comes with a very handy feature: its bootstrap script. It can be executed
-automatically once the dotfiles are cloned with yadm:
-#+BEGIN_SRC sh
-yadm clone https://labs.phundrak.com/phundrak/dotfiles
-# or if labs.phundrak.com is down or too slow for you
-#yadm clone https://github.com/phundrak/dotfiles
-#+END_SRC
-
-Let’s take a look at what it does.
-
-** Decrypt private yadm files
-:PROPERTIES:
-:CUSTOM_ID: Execute_bootstrap-Decrypt_private_yadm_files-68af7157
-:END:
-Some private files are stored encrypted in the repository of my yadm dotfiles. I
-will need them later on during the bootstrap execution.
-#+BEGIN_SRC fish
-if test "$USER" = 'phundrak'
- yadm decrypt
-else
- whiptail --yesno "Decrypt private files?" 8 40 && yadm decrypt
-end
-#+END_SRC
-
-** Get a correct keyboard layout
-:PROPERTIES:
-:CUSTOM_ID: Execute_bootstrap-Get_a_correct_keyboard_layout-77d24b30
-:END:
-I use mainly the [[https://bepo.fr/wiki/Accueil][bépo]] layout, a French keyboard layout inspired by Dvorak
-layouts, however I sometimes need to switch back to the standard French AZERTY
-or the American QWERTY layout, so I make it so the Menu key switches for me my
-layout between these three. This makes it so my xorg configuration of my
-keyboard looks like this:
-#+BEGIN_SRC fish
-set keyboardconf \
-'Section "InputClass"
- Identifier "system-keyboard"
- MatchIsKeyboard "on"
- Option "XkbLayout" "fr"
- Option "XkbModel" "pc104"
- Option "XkbVariant" "bepo_afnor"
- Option "XkbOptions" "caps:ctrl_modifier"
-EndSection'
-#+END_SRC
-
-So, let’s ask the user if they want to set it as their keyboard configuration.
-#+BEGIN_SRC fish
-printf "\n# Set keyboard layout #########################################################\n\n"
-whiptail --yesno "Would you like to set your keyboard layout to the bépo layout?" 8 55
-if test $status -eq 0
- echo $keyboardconf | sudo tee /etc/X11/xorg.conf.d/00-keyboard.conf
-end
-#+END_SRC
-
-** Set our locale
-:PROPERTIES:
-:CUSTOM_ID: Execute_bootstrap-Set_our_locale-e74d772a
-:END:
-I use two main locales, the French and US UTF-8 locales, and I like to keep the
-Japanese locale activated just in case.
-#+BEGIN_SRC fish
-set mylocales "en_US.UTF-8 UTF-8" "fr_FR.UTF-8 UTF-8" "ja_JP.UTF-8 UTF-8"
-#+END_SRC
-
-I’ll let the user accept them one by one.
-#+BEGIN_SRC fish
-printf "\n# Set locale ##################################################################\n\n"
-for item in $mylocales
- whiptail --yesno "Set the \"$item\" locale?" 8 40
- if test $status -eq 0 -a (grep -e "#$item" /etc/locale.gen)
- sudo sed -i "/$item/s/^#//g" /etc/locale.gen
- end
-end
-#+END_SRC
-
-This is my configuration I usually use when it comes to my locale.
-#+BEGIN_SRC fish
-set localeconf "LANG=en_DK.UTF-8
-LC_COLLATE=C
-LC_NAME=fr_FR.UTF-8
-LC_IDENTIFICATION=fr_FR.UTF-8
-LC_TELEPHONE=fr_FR.UTF-8
-LC_MONETARY=fr_FR.UTF-8
-LC_PAPER=fr_FR.UTF-8
-LC_ADDRESS=fr_FR.UTF-8
-LC_MEASUREMENT=fr_FR.UTF-8"
-#+END_SRC
-
-Let’s set it as our system’s locale if the user whishes to.
-#+BEGIN_SRC fish
-whiptail --yesno "Do you agree to have the following locale set?\n\n $localeconf" 20 43
-if test $status -eq 0
- echo $localeconf | sudo tee /etc/locale.conf
-end
-#+END_SRC
-
-Now we can generate our locale!
-#+BEGIN_SRC fish
-printf "\n# Generate locale #############################################################\n\n"
-sudo locale-gen
-#+END_SRC
-
-** Create some folders
-:PROPERTIES:
-:CUSTOM_ID: Execute_bootstrap-Create_some_folders-bf701387
-:END:
-Let’s create some folders we might need for mounting our drives, Android devices
-and CDs.
-#+BEGIN_SRC fish
-printf "\n# Create directories for mounting #############################################\n\n"
-sudo mkdir -p /mnt/{USB,CD,Android}
-sudo chown $USER:(id -g $USER) /mnt/{USB,CD,Android}
-#+END_SRC
-
-** Set user’s shell to fish
-:PROPERTIES:
-:CUSTOM_ID: Execute_bootstrap-Set_user’s_shell_to_fish-1a794be2
-:END:
-First, the bootstrap shell will set the user’s shell to fish.
-#+BEGIN_SRC fish
-printf "\n# Set fish as the default shell ###############################################\n\n"
-whiptail --yesno "Set the current user’s default shell to fish?" 8 50
-if test $status -eq 0 -a ! "$SHELL" = '/usr/bin/fish'
- chsh -s /usr/bin/fish
-end
-#+END_SRC
-
-** Install basic packages
-:PROPERTIES:
-:CUSTOM_ID: Execute_bootstrap-Install_basic_packages-17173316
-:END:
-Ok, let’s list all the packages that I need. First, let’s begin with
-system packages.
-#+name: packages-system
-| Package name | Why I need it |
-|-----------------------------+--------------------------------------------------------------|
-| acpi | Battery, power, and thermal readings |
-| acpilight | To modify the monitors’ brightness |
-| bluez-firmware | Firmware for my bluetooth device |
-| bluez-utils | To interact with bluez through custom tools |
-| bzip2 | A compression algorithm and program |
-| cpupower | Examine and tune power saving related features of the CPU |
-| exfat-utils | Utilities for exFAT filesystems |
-| ffmpegthumbnailer | Create thumbnails with ffmpeg |
-| freeglut | A small OpenGL library |
-| gcc-libs | Runtime libraries for GCC |
-| gdb | The GCC debugger |
-| gnome-disk-utility | To manage easily my disks and partitions |
-| gnome-epub-thumbnailer | Thumbnailer for Epub files |
-| i3lock-color | My screen locker |
-| corrupter-git | A script for my script using also i3lock-color |
-| inetutils | Common network programs |
-| jfsutils | JFS utilities to interact with Android |
-| jmtpfs | FUSE filesystem for the MTP protocol |
-| kitty | My current terminal emulator, works with Xorg and Wayland |
-| logrotate | Rotate system logs automatically |
-| man-pages | Linux's man pages |
-| man-db | Read the Linux man pages |
-| netctl | Profile based systemd network management |
-| network-manager-applet | System tray applet for NetworkManager |
-| networkmanager-openvpn | Connect to OpenVPN servers with NetworkManager |
-| nm-connection-editor | Manager NetworkManager connections |
-| ntfs-3g | Utilities to access NTFS filesystems |
-| openssh | SSH. Do I need to say anything more than that? |
-| pavucontrol | Graphical interface to PulseAudio settings |
-| wireplumber | Session manager for PipeWire |
-| pipewire-pulse | PipeWire replacement for ~pulseaudio~ and ~pulseaudio-bluetooth~ |
-| gst-plugin-pipewire | PipeWire plugin for GStreamer |
-| noise-suppression-for-voice | Realtime noise suppression plugin for voice |
-| raw-thumbnailer | thumbnailer for RAW images |
-| reflector | Sort pacman mirrors |
-| shadow | Password & account management tools |
-| sshfs | Mount remote filesystems through SSH |
-| usbutils | USB utilities |
-| xdg-user-dirs-gtk | Creates user dirs and asks to relocalize them |
-| xfce-polkit | XFCE’s policy kit |
-| xidlehook | xautolock with extra features |
-| xfsprogs | Access XFS filesystems |
-| xorg-xinit | xorg init program |
-| xss-lock | Use an external program as X lock screen |
-| xwallpaper | Set my Xorg session’s wallpaper |
-
-For development purposes, I need the following packages:
-#+name: packages-devel
-| Package name | Why I need it |
-|----------------------------------+-----------------------------------------------------------|
-| asar | Package needed by some Electron programs |
-| base-devel | Metapackage providing lots of basic tools for development |
-| clang | LLVM’s C/C++ compiler |
-| cppcheck | Static code analysis for C/C++ |
-| cppreference | The cppreference wiki offline |
-| cppreference-devhelp | Access cppreference through devhelp |
-| docker | VMs are too heavy, get a better virtualization engine! |
-| docker-compose | Docker from the CLI? I prefer through a Yaml file. |
-| dockerfile-language-server-bin | Dockerfile LSP server |
-| doxygen | A great tool for writing code documentation for C/C++ |
-| emacs | The best +text editor+ OS, hands down |
-| farbfeld | Lossless image format |
-| flake8 | Code checker for python |
-| gnuplot | An awesome plotting tool |
-| go | The Go programming language |
-| go-tools | Go’s tooling |
-| graphviz | Graph visualization |
-| hugo | Static website generator |
-| javascript-typescript-langserver | LSP server for Javascript |
-| js-beautify | Formatter for Javascript |
-| linux-headers | Development with the Linux kernel |
-| lldb | The LLVM debugger |
-| meson | Meson build system |
-| mupdf-tools | Tools for PDF and XPS viewers |
-| npm | Javascript package manager |
-| pacman-contrib | Create and install custom ArchLinux packages |
-| pandoc-bin | Convert documents of various formats into other formats |
-| prettier | Format various web files formats |
-| python-autoflake | Remove unused imports and variables in Python |
-| python-epc | EPC (RPC stack for Emacs Lisp) for Python |
-| python-importmagic | Automatically manage imports in Python |
-| pyright | Python LSP server |
-| python-nose | A discovery-based test extension for Python |
-| python-pip | The Python package manager |
-| python-poetry | Python dependency management and packaging made easy |
-| python-ptvsd | Python debugger |
-| python-pytest | Python testing suite |
-| qemu | Machine emulator and virtualizer |
-| r | The R programming langugae |
-| rustup | The Rust toolchain installer |
-| sbcl | My favorite CommonLisp implementation |
-| typescript | Better Javascript |
-| typescript-language-server-bin | LSP server for Typescript |
-| valgrind | Our lord and saviour when writing C code |
-| vscode-css-languageserver-bin | LSP server for CSS |
-| vscode-html-languageserver-bin | LSP server for HTML |
-| yaml-language-server-bin | LSP server for Yaml |
-| zeal | Offline documentation browser |
-
-A couple of packages need to be installed to make LaTeX usable.
-#+name: packages-latex
-| Package name | Why I need it |
-|----------------------+----------------------------------------------------------------------|
-| biber | A BibTex replacement, for citations in papers |
-| minted | Syntax highlight for LaTeX |
-| texlive-bibtexextra | Additional BibTeX styles and bibliography databases |
-| texlive-fontsextra | All sorts of extra fonts |
-| texlive-formatsextra | Collection of extra TeX 'formats' |
-| texlive-humanities | LaTeX packages for law, linguistics, social sciences, and humanities |
-| texlive-langjapanese | Fonts and macro packages to typeset Japanese texts |
-| texlive-pictures | Packages for drawings graphics |
-| texlive-pstricks | Additional PSTricks packages |
-| texlive-publishers | LaTeX classes and packages for specific publishers |
-| texlive-science | Typesetting for mathematics, natural and computer sciences |
-
-Some visual packages:
-#+name: packages-font
-| Package name | Why I need it |
-|--------------------------------+-------------------------------------|
-| adobe-source-han-sans-jp-fonts | Japanese fonts |
-| inter-font | I’m not sure why I have these fonts |
-| nordic-theme-git | Nord theme for GTK |
-| noto-fonts-emoji | Font with emojis |
-| otf-ipafont | Japanese font |
-| picom | See [[file:picom.org]] |
-| powerline-fonts | Powerline fonts |
-| siji-git | Siji font |
-| ttf-arphic-uming | CJK font Ming style |
-| ttf-baekmuk | Korean font |
-| ttf-charis-sil | API font |
-| ttf-dejavu | DejaVu font |
-| ttf-hanazono | Japanese kanji font |
-| ttf-joypixels | Emoji font |
-| ttf-koruri | Japanese Truetype font |
-| ttf-liberation | Liberation font |
-| ttf-monapo | Japanese font |
-| ttf-sazanami | Japanese fonts |
-| ttf-unifont | The font I use in StumpWM |
-| ttf-tibetan-machine | Tibetan font |
-| unicode-emoji | Unicode emoji data files |
-
-Terminal utilities
-#+name: packages-terminal
-| Package name | Why I need it |
-|-----------------+-----------------------------------------------------------------|
-| ascii | Work with ASCII |
-| aspell-en | Aspell’s dictionary for English |
-| aspell-fr | Aspell’s dictionary for French |
-| bat | A better cat with syntax highlighting |
-| bitwarden-cli | CLI application for my password manager |
-| bpytop | A very beautiful htop alternative |
-| exa | A great ~ls~ replacement |
-| fd | ~find~, but better |
-| findutils | ~find~ files on the system |
-| fzf | Command-line fuzzy finder |
-| htop | ~top~, but better |
-| isync | Gives access to ~mbsync~ so I can check my mails |
-| mpc | Dead simple MPD client |
-| mpd | Music Player Daemon |
-| mpv | The best video player in existance |
-| nano | Simple text editor |
-| ncdu | Graphical representation of disk usage |
-| ncmpcpp | TUI for MPD |
-| neofetch | System info in the terminal |
-| nordvpn-bin | Connect to NordVPN on Linux |
-| numlockx | Turn on the numpad in Xorg |
-| p7zip | 7zip on Linux |
-| pass | The standard UNIX password manager |
-| pdfpc | PDF presentation tool in the console with multi-monitor support |
-| ripgrep | ~grep~ but better |
-| rsync | ~scp~ is dead, long live ~rsync~! |
-| flameshot | To take screenshots |
-| tealdeer | ~tldr~ but faster, great cheatsheets in the terminal |
-| tmux | Terminal multiplexer |
-| tree | See files and directories as a tree |
-| unrar | Support for rar file format |
-| w3m | Terminal web browser |
-| wget | Retrieve files from the web |
-| x11-ssh-askpass | Passphrase dialog over SSH |
-| xclip | Interact with the X11 clipboard |
-| yt-dlp-drop-in | ~yt-dlp~ but it also replaces ~youtube-dl~ |
-
-Let’s install some desktop applications too, shall we?
-#+name: packages-apps
-| Package name | Why I need it |
-|-----------------+---------------------------------------------------------|
-| bitwarden | Desktop application for my password manager |
-| discord | For messaging friends |
-| firefox | Because I need a good browser |
-| gimp | GIMP Is Mbetter than Photoshop |
-| helvum | Pipewire patchbay |
-| nemo | One of the best graphical file managers |
-| nemo-fileroller | Add compression options to Nemo |
-| nemo-preview | Quick file previewer for Nemo |
-| obs-studio | Simply the best screen recording and streaming software |
-| rofi | A beautiful ~dmenu~ replacement |
-
-All these packages will be installed with the command ~paru -S
---skipreview --needed~ to prevent it from nagging me about the PKGBUILD
-when I want to install something from the AUR, and if something is
-already installed it paru won’t try to reinstall it.
-
-#+name: gen-package-list
-#+header: :wrap "src fish :exports none :tangle no"
-#+header: :exports none
-#+begin_src emacs-lisp :var packages=packages-apps[,0] varname="APPS"
-(format "set %s %s"
- varname
- (mapconcat #'identity packages " \\\n"))
-#+end_src
-
-#+RESULTS[53aa8b22c675edad2d6d21c0095ff233bb5e26c4]: gen-package-list
-#+begin_src fish :exports none :tangle no
-set APPS bitwarden \
-discord \
-firefox \
-gimp \
-helvum \
-nemo \
-nemo-fileroller \
-nemo-preview \
-obs-studio \
-rofi
-#+end_src
-
-#+name: gen-package-install
-#+header: :wrap "src fish :exports none :tangle no"
-#+header: :exports none
-#+begin_src emacs-lisp :var varname="APPS"
-(concat
- (format "%s %s %s"
- "printf \"\\n# Installing"
- varname
- "##################################################\\n\\n\"")
- "\n"
- (format "for pkg in $%s\n paru -S --skipreview --needed $pkg\nend" varname))
-#+end_src
-
-#+RESULTS[8fc00f530b704dc6900087d5b91082e9fa1bb429]: gen-package-install
-#+begin_src fish :exports none :tangle no
-printf "\n# Installing APPS ##################################################\n\n"
-for pkg in $APPS
- paru -S --skipreview --needed $pkg
-end
-#+end_src
-
-#+begin_src fish :noweb yes
-<>
-
-<>
-
-
-<>
-
-<>
-
-
-<>
-
-<>
-
-
-<>
-
-<>
-
-
-<>
-
-<>
-#+end_src
-
-Finally, I wish to install some custom packages for which I’ve written
-a ~PKGBUILD~ file myself. I store all of them in a dedicated directory
-located in ~$HOME/Documents/code/PKGBUILDs~. I want to install some of
-them immediately.
-#+name: packages-pkgbuild
-| Package Name | What it is |
-|--------------+------------------------------------------------------------------|
-| emacs | My custom Emacs build, it will replace the one already installed |
-| nsxiv | The best image viewer after Emacs |
-| pumopm-git | My very simple battery manager |
-| sent | A very simple presentation tool |
-
-#+name: gen-package-pkgbuild
-#+header: :wrap "src fish :exports none"
-#+header: :exports none
-#+begin_src emacs-lisp :var packages=packages-pkgbuild[,0]
-(let ((base-dir "~/Documents/code/PKGBUILDs"))
- (mapconcat (lambda (dir)
- (format "cd %s && makepkg -si; cd .."
- (expand-file-name dir base-dir)))
- packages
- "\n"))
-#+end_src
-
-#+RESULTS[82db1c3f1b9c80b3c24075d1a20933be59baac47]: gen-package-pkgbuild
-#+begin_src fish :exports none
-cd /home/phundrak/Documents/code/PKGBUILDs/emacs && makepkg -si; cd ..
-cd /home/phundrak/Documents/code/PKGBUILDs/nsxiv && makepkg -si; cd ..
-cd /home/phundrak/Documents/code/PKGBUILDs/pumopm-git && makepkg -si; cd ..
-cd /home/phundrak/Documents/code/PKGBUILDs/sent && makepkg -si; cd ..
-#+end_src
-
-** Tangle configuration files from Org files
-:PROPERTIES:
-:CUSTOM_ID: Execute_bootstrap-Tangle_configuration_files_from_Org_files-cc524361
-:END:
-Before tangling our configuration files, we need to create some
-directories first to make sure our files can be properly tangled.
-Here’s the list of directories we need to create:
-#+NAME: dirs-tangled-files
-| $HOME/.config/fish |
-| $HOME/.config/gtk-2.0 |
-| $HOME/.config/gtk-3.0 |
-| $HOME/.config/ncmpcpp |
-| $HOME/.config/neofetch |
-| $HOME/.config/picom |
-| $HOME/.config/yadm |
-| $HOME/.local/bin |
-| $HOME/.stumpwm.d |
-| $HOME/org/capture |
-
-#+NAME: gen-dirs-tangle
-#+BEGIN_SRC emacs-lisp :var dirs=dirs-tangled-files
-(mapconcat (lambda (x) (format "mkdir -p %s" (car x)))
- dirs
- "\n")
-#+END_SRC
-
-#+RESULTS[250efd14cab8a0f03e5520e0d0bd96aa311aa45f]: gen-dirs-tangle
-#+begin_example
-mkdir -p $HOME/.config/fish
-mkdir -p $HOME/.config/gtk-2.0
-mkdir -p $HOME/.config/gtk-3.0
-mkdir -p $HOME/.config/ncmpcpp
-mkdir -p $HOME/.config/neofetch
-mkdir -p $HOME/.config/picom
-mkdir -p $HOME/.config/yadm
-mkdir -p $HOME/.local/bin
-mkdir -p $HOME/.stumpwm.d
-mkdir -p $HOME/org/capture
-#+end_example
-
-Our code to generate such directories looks like this:
-#+BEGIN_SRC fish :noweb yes
-<>
-#+END_SRC
-
-The next step is to tangle all the Org files. Here is the list of files that are
-to be tangled:
-#+NAME: tangled-files
-| filename |
-|--------------|
-| bin.org |
-| emacs.org |
-| fish.org |
-| index.org |
-| mpd.org |
-| neofetch.org |
-| picom.org |
-| rustfmt.org |
-| stumpwm.org |
-| tmux.org |
-
-#+NAME: generate-tangle
-#+BEGIN_SRC emacs-lisp :var files=tangled-files[,0]
-(mapconcat (lambda (x) (concat
- (format "printf '\\n\\n==== Tangling %s\\n\\n' && \\\n" x)
- (concat "emacs -q --batch --eval '(require \\'ob-tangle)' \\\n"
- "--eval '(setq org-confirm-babel-evaluate nil)' \\\n"
- (format "--eval '(org-babel-tangle-file \"~/org/config/%s\")'\n" x))))
- files
- "\n")
-#+END_SRC
-
-#+RESULTS[127dafd79461dab55296163e57fadb7b355a205a]: generate-tangle
-#+begin_example
-printf '\n\n==== Tangling bin.org\n\n' && \
-emacs -q --batch --eval '(require \'ob-tangle)' \
---eval '(setq org-confirm-babel-evaluate nil)' \
---eval '(org-babel-tangle-file "~/org/config/bin.org")'
-
-printf '\n\n==== Tangling emacs.org\n\n' && \
-emacs -q --batch --eval '(require \'ob-tangle)' \
---eval '(setq org-confirm-babel-evaluate nil)' \
---eval '(org-babel-tangle-file "~/org/config/emacs.org")'
-
-printf '\n\n==== Tangling fish.org\n\n' && \
-emacs -q --batch --eval '(require \'ob-tangle)' \
---eval '(setq org-confirm-babel-evaluate nil)' \
---eval '(org-babel-tangle-file "~/org/config/fish.org")'
-
-printf '\n\n==== Tangling index.org\n\n' && \
-emacs -q --batch --eval '(require \'ob-tangle)' \
---eval '(setq org-confirm-babel-evaluate nil)' \
---eval '(org-babel-tangle-file "~/org/config/index.org")'
-
-printf '\n\n==== Tangling mpd.org\n\n' && \
-emacs -q --batch --eval '(require \'ob-tangle)' \
---eval '(setq org-confirm-babel-evaluate nil)' \
---eval '(org-babel-tangle-file "~/org/config/mpd.org")'
-
-printf '\n\n==== Tangling neofetch.org\n\n' && \
-emacs -q --batch --eval '(require \'ob-tangle)' \
---eval '(setq org-confirm-babel-evaluate nil)' \
---eval '(org-babel-tangle-file "~/org/config/neofetch.org")'
-
-printf '\n\n==== Tangling picom.org\n\n' && \
-emacs -q --batch --eval '(require \'ob-tangle)' \
---eval '(setq org-confirm-babel-evaluate nil)' \
---eval '(org-babel-tangle-file "~/org/config/picom.org")'
-
-printf '\n\n==== Tangling rustfmt.org\n\n' && \
-emacs -q --batch --eval '(require \'ob-tangle)' \
---eval '(setq org-confirm-babel-evaluate nil)' \
---eval '(org-babel-tangle-file "~/org/config/rustfmt.org")'
-
-printf '\n\n==== Tangling stumpwm.org\n\n' && \
-emacs -q --batch --eval '(require \'ob-tangle)' \
---eval '(setq org-confirm-babel-evaluate nil)' \
---eval '(org-babel-tangle-file "~/org/config/stumpwm.org")'
-
-printf '\n\n==== Tangling tmux.org\n\n' && \
-emacs -q --batch --eval '(require \'ob-tangle)' \
---eval '(setq org-confirm-babel-evaluate nil)' \
---eval '(org-babel-tangle-file "~/org/config/tmux.org")'
-#+end_example
-
-#+BEGIN_SRC fish :noweb yes
-printf "\n# Tangling org files ##########################################################\n\n"
-<>
-#+END_SRC
-
-** Set up dotfiles’ git repository
-:PROPERTIES:
-:CUSTOM_ID: Execute_bootstrap-Set_up_dotfiles-ab372bd9
-:END:
-*** Update our dotfiles’ remotes
-:PROPERTIES:
-:CUSTOM_ID: Execute_bootstrap-Set_up_dotfiles-Update_our_dotfiles’_remotes-5a0fe6f7
-:END:
-This line in the bootstrap script will test if the current user is using my
-username. If yes, it’s probably me.
-#+BEGIN_SRC fish
-if test "$USER" = 'phundrak'
-#+END_SRC
-
-If it is me installing and using these dotfiles, I want the remotes of my
-dotfiles to be set to ssh remotes using my ssh keys.
-#+BEGIN_SRC fish
-printf "\n# Update yadm’s remotes #######################################################\n\n"
-yadm remote set-url origin git@labs.phundrak.com:phundrak/dotfiles.git
-#+END_SRC
-
-I will also want to decrypt my encrypted files, such as said ssh keys.
-#+BEGIN_SRC fish
-printf "\n# Decrypt encrypted dotfiles ##################################################\n\n"
-yadm decrypt
-#+END_SRC
-
-Finally, let’s close this ~if~ statement.
-#+BEGIN_SRC fish
-end
-#+END_SRC
-
-*** Update our submodules
-:PROPERTIES:
-:CUSTOM_ID: Execute_bootstrap-Set_up_dotfiles-Update_our_submodules-3e921579
-:END:
-Now we can download the various dependencies of our dotfiles. To do so, let’s
-run the following command:
-#+BEGIN_SRC fish
-printf "\n# Getting yadm susbmodules ####################################################\n\n"
-yadm submodule update --init --recursive
-#+END_SRC
-
-** Enable some services
-:PROPERTIES:
-:CUSTOM_ID: Execute_bootstrap-Enable_some_services-3d38d98e
-:END:
-We have installed some packages which require some services to run. Let’s enable
-them.
-
-*** Systemd-timesyncd
-:PROPERTIES:
-:CUSTOM_ID: Execute_bootstrap-Enable_some_services-Systemd-timesyncd-d887e45b
-:END:
-This service enables time syncing with the NTP protocol, so I can be sure my
-computer’s time is correct. The service first needs to be enabled:
-#+BEGIN_SRC fish
-printf "\n# Enabling timesync ###########################################################\n\n"
-sudo systemctl enable --now systemd-timesyncd
-#+END_SRC
-
-Now, let systemd know I want to use the NTP protocol to keep my computer’s time
-synced.
-#+BEGIN_SRC fish
-sudo timedatectl set-ntp true
-#+END_SRC
-
-*** Acpilight
-:PROPERTIES:
-:CUSTOM_ID: Execute_bootstrap-Enable_some_services-Acpilight-39152794
-:END:
-~acpilight~ is our utility managing the brightness of our screen. There
-is actually no service to enable here, but we must ensure the user is
-part of the ~video~ group to enable the user modifying the brightness of
-our screen without using ~sudo~.
-#+BEGIN_SRC fish
-sudo usermod -aG video $USER
-#+END_SRC
-
-*** Docker
-:PROPERTIES:
-:CUSTOM_ID: Execute_bootstrap-Enable_some_services-Docker-305e8309
-:END:
-First, let’s activate Docker on startup.
-#+BEGIN_SRC fish
-printf "\n# Enabling and starting Docker ################################################\n\n"
-sudo systemctl enable --now docker
-#+END_SRC
-
-Now, if we wish it, we can add ourselves to the =docker= group to avoid
-typing =sudo= each time we call Docker or Docker Compose.
-#+BEGIN_SRC fish
-read --prompt "echo 'Do you wish to be added to the `docker` group? (Y/n): ' " -l adddockergroup
-if test $adddockergroup = 'y' || test $adddockergroup = "Y" || test $adddockergroup = ''
- sudo usermod -aG docker $USER
-end
-#+END_SRC
-
-*** Emacs
-:PROPERTIES:
-:CUSTOM_ID: Execute_bootstrap-Enable_some_services-Emacs-c7785c21
-:END:
-Emacs will run as a user service, which means it won’t be launched until we log
-in. However, the service won’t be started immediately, I personally prefer to
-start a standalone instance in which installing and compiling the Emacs packages
-will happen, and then once that is done I will start the service.
-#+BEGIN_SRC fish
-printf "\n# Enabling Emacs as user service ##############################################\n\n"
-systemctl --user enable emacs
-#+END_SRC
-
-I don’t want to activate it immediately however, since the first
-startup might require some interactivity with the main Emacs frame,
-not with emacsclient. When Emacs will be ready, its service can be
-started like so (command not tangled in the bootstrap):
-#+begin_src fish :tangle no
-systemctl --user start emacs
-#+end_src
-
-*** Mpd
-:PROPERTIES:
-:CUSTOM_ID: Execute_bootstrap-Enable_some_services-Mpd-f0f5b9b7
-:END:
-Mpd will also use as a user service in order to get rid of some lines of code in
-my configuration.
-#+BEGIN_SRC fish
-printf "\n# Enabling Mpd as a user service ##############################################\n\n"
-mkdir -p ~/.config/mpd/playlists
-systemctl --user enable --now mpd
-#+END_SRC
-
-*** NordVPN
-:PROPERTIES:
-:CUSTOM_ID: Execute_bootstrap-Enable_some_services-NordVPN-75c1bd88
-:END:
-Thanks to the AUR package ~nordvpn-bin~, I no longer have to manually maintain
-my VPN connections with OpenVPN. However, it requires a service that we should
-activate:
-#+BEGIN_SRC fish
-sudo systemctl enable --now nordvpnd
-#+END_SRC
-
-Let’s also set its default protocol to UDP. This will allow me to use
-any port while connected to any Wi-Fi as long as the 443 port is
-available. Because yes, I do connect to a Wi-Fi that blocks some
-important ports, such as the IMAP and SMTP ports. Thanks University of
-Paris 8 for being SO paranoid.
-#+BEGIN_SRC fish
-nordvpn s protocol tcp
-#+END_SRC
-
-Note that this change in protocol is only valid when using the OpenVPN
-technology. If we want to use the Wireguard technology through [[https://nordvpn.com/blog/nordlynx-protocol-wireguard/][Project
-NordLynx]], this option will no longer be available. To set NordVPN to
-use WireGuard, we can run this command (not tangled in the bootstrap).
-#+begin_src fish :tangle no
-nordvpn set technology NordLynx
-#+end_src
-
-Why WireGuard? Well, it can achieve better performances than OpenVPN
-with physically nearby servers, and according to [[https://restoreprivacy.com/vpn/wireguard-vs-openvpn/][this article]] the
-former can be more than half as fast as the latter. It is also much
-more auditable than OpenVPN (only a few thousands lines of code
-against some hundred of thousands). Oh, and WireGuard is part of the
-Linux kernel since its version 5.6. And Windows’ since August 2021,
-but I don’t really care about Windows.
-
-*But*, WireGuard is less privacy-oriented than OpenVPN. So, if I ever
-need to use my VPN for privacy reasons, I can simply revert to the
-OpenVPN technology like shown with this command (not tangled in the
-bootstrap):
-#+begin_src fish :tangle no
-nordvpn set technology OpenVPN
-#+end_src
-
-Finally, I want to be notified of NordVPN’s actions, and I want to be
-able to use IPv6.
-#+begin_src fish
-nordvpn set notify enabled
-nordvpn set ipv6 enabled
-#+end_src
-
-*** PipeWire
-:PROPERTIES:
-:CUSTOM_ID: Execute-bootstrap-Enable-some-services-PipeWire-sihc11b0mdj0
-:END:
-PipeWire is a replacement for PulseAudio, ALSA and the likes, and it
-is /*much*/ better in terms of security and performance. However, unlike
-PulseAudio, Pipewire is a user service that needs to be enabled per
-user.
-#+begin_src fish
-systemctl --user enable --now pipewire-pulse.service
-#+end_src
-
-I also installed ~noise-suppression-for-voice~ which is a plugin usable
-by PipeWire to remove all noise the microphone might record save for
-the voice. It is damn effective, and it can be activated as a user
-service! In fact, I have in my dotfiles the service saved, so let’s
-activate it right away:
-#+begin_src fish
-systemctl --user enable --now pipewire-input-filter-chain.service
-#+end_src
-
-Just make sure afterwards the microphone is redirected to the
-noise-canceling source. The same source should be your input device
-where you want to use your microphone. The only downside is this is
-ony a mono input, but it shouldn’t matter for most people.
-
-*** SSH server
-:PROPERTIES:
-:CUSTOM_ID: Execute_bootstrap-Enable_some_services-SSH_server-204f5997
-:END:
-Maybe we want to activate an SSH server on our machine. If so, we can enable it.
-Let’s ask the question.
-#+BEGIN_SRC fish
-whiptail --yesno 'Do you want to activate the ssh server?' 8 50
-if test $status -eq 0
- printf "\n# Enabling ssh server #########################################################\n\n"
- sudo systemctl enable --now sshd
-end
-#+END_SRC
-
-** Symlink some system config files
-:PROPERTIES:
-:CUSTOM_ID: Execute_bootstrap-Symlink_some_system_config_files-1dd95175
-:END:
-Let’s symlink the ~plock~ script ([[file:bin.org::#Lock-635fcb38][source here]]) to ~/usr/bin~ so ~xss-lock~
-can find it.
-#+BEGIN_SRC fish
-sudo ln -s ~/.local/bin/plock /usr/bin/plock
-#+END_SRC
-
-** Install packages from git
-:PROPERTIES:
-:CUSTOM_ID: Execute_bootstrap-Install_packages_from_git-7c6a6ea4
-:END:
-Now, let’s install some packages from git directly.
-#+BEGIN_SRC fish
-mkdir -p ~/fromGIT
-#+END_SRC
-
-*** Reveal.JS
-:PROPERTIES:
-:CUSTOM_ID: Execute_bootstrap-Install_packages_from_git-Reveal.JS-bb4da0bf
-:END:
-I sometimes use Reveal.JS to make presentations, and I set its
-location in my [[file:emacs.org][Emacs config]] to be in =~/fromGIT=, so let’s clone it
-there.
-#+BEGIN_SRC fish
-printf "\n# Install Reveal.JS ###########################################################\n\n"
-cd ~/fromGIT
-git clone https://github.com/hakimel/reveal.js.git
-#+END_SRC
-
-** Install Rust
-:PROPERTIES:
-:CUSTOM_ID: Execute_bootstrap-Install_Rust-1839c4d0
-:END:
-*** Install the toolchains
-:PROPERTIES:
-:CUSTOM_ID: Execute_bootstrap-Install_Rust-Install_the_toolchains-3480764a
-:END:
-When using Rust, I bounce between two toolchains, the ~stable~ toolchain and the
-~nightly~ toolchain, although I try to stick with Rust Stable. To install them,
-I will use ~rustup~ which has already been installed previously.
-#+BEGIN_SRC fish
-printf "\n# Install the rust toolchains, nightly is the default one #####################\n\n"
-rustup default stable
-#+END_SRC
-
-This will both download the stable toolchain and set it as the default one. Now
-to install the nightly toolchain, let’s run this:
-#+BEGIN_SRC fish
-rustup toolchain install nightly
-#+END_SRC
-
-*** Install some utilities
-:PROPERTIES:
-:CUSTOM_ID: Execute_bootstrap-Install_Rust-Install_some_utilities-c4a7c785
-:END:
-We’ll need some utilities when developing Rust from Emacs, namely ~rustfmt~ and
-~racer~. Let’s install them with ~cargo~.
-#+BEGIN_SRC fish
-printf "\n# Add rust utilities ##########################################################\n\n"
-cargo install rustfmt racer
-#+END_SRC
-
-We will also need some components for development purposes.
-#+NAME: rust-components-table
-| Component | Why |
-|-----------+-------------------------------------------|
-| rust-src | Rust documentation in Emacs |
-| rls | LSP backend for Emacs |
-| clippy | A better version of cargo’s ~check~ command |
-
-#+NAME: rust-components-gen
-#+BEGIN_SRC emacs-lisp :var components=rust-components-table[,0]
-(mapconcat (lambda (x) (format "rustup component add %s" x))
- components
- "\n")
-#+END_SRC
-
-#+RESULTS[b3935b1c09d86fe506b43670f52960306a1e9809]: rust-components-gen
-: rustup component add rust-src
-: rustup component add rls
-: rustup component add clippy
-
-Here is the code to do so:
-#+BEGIN_SRC fish :noweb yes
-<>
-#+END_SRC
-
-** Set up our fish shell
-:PROPERTIES:
-:CUSTOM_ID: Execute_bootstrap-Set_up_our_fish_shell-f0741c22
-:END:
-The last thing we want to do is to set up our fish shell with some extensions in
-order to improve the user experience.
-
-*** Install ~fisher~
-:PROPERTIES:
-:CUSTOM_ID: Execute_bootstrap-Set_up_our_fish_shell-Install_=fisher=-3a44531b
-:END:
-We will be using ~fisher~ as our extension manager for Fish. Let’s install it.
-#+BEGIN_SRC fish
-printf "\n# Installing fisher ###########################################################\n\n"
-curl -sL https://git.io/fisher | source && fisher install jorgebucaran/fisher
-#+END_SRC
-
-*** Install our extensions
-:PROPERTIES:
-:CUSTOM_ID: Execute_bootstrap-Set_up_our_fish_shell-Install_our_extensions-188e4566
-:END:
-I generally use the following extensions in my Fish shell.
-#+NAME: fish-extensions-table
-#+CAPTION: Fish extensions managed by Fisher
-| Package name | Description |
-|-----------------------------+------------------------------------------------------------------|
-| decors/fish-colored-man | Color man pages to make them more readable |
-| franciscolourenco/done | Automatically receive notifications when a long process finishes |
-| jethrokuan/fzf | Improved key bindings for [[https://github.com/junegunn/fzf][junegunn/fzf]] |
-| jorgebucaran/fish-bax | Run bash scripts, replaying environment changes in fish |
-| jorgebucaran/fish-getopts | CLI options parser; alternative to the [[https://fishshell.com/docs/current/commands.html#argparse][argparse]] fish builtin |
-| laughedelic/pisces | Autoclose parentheses, braces, quotes and other paired symbols |
-
-#+NAME: fish-extensions-gen
-#+BEGIN_SRC emacs-lisp :var extensions=fish-extensions-table[,0]
-(mapconcat (lambda (x) (format "fisher install %s" x))
- extensions
- "\n")
-#+END_SRC
-
-#+RESULTS[d424f363a3c11c8598a20da525de5ba9dcfbe7e7]: fish-extensions-gen
-: fisher install decors/fish-colored-man
-: fisher install franciscolourenco/done
-: fisher install jethrokuan/fzf
-: fisher install jorgebucaran/fish-bax
-: fisher install jorgebucaran/fish-getopts
-: fisher install laughedelic/pisces
-
-#+BEGIN_SRC fish :noweb yes
-printf "\n# Installing Fisher Extensions ################################################\n\n"
-<>
-#+END_SRC
diff --git a/org/config/desktop.org b/org/config/desktop.org
deleted file mode 100644
index 84de665..0000000
--- a/org/config/desktop.org
+++ /dev/null
@@ -1,798 +0,0 @@
-#+title: Desktop settings
-#+setupfile: headers
-#+options: unique-id:t
-#+html_head:
-#+html_head:
-#+html_head:
-#+property: header-args:emacs-lisp :mkdirp yes :lexical t :exports code
-#+property: header-args:emacs-lisp+ :tangle ~/.config/emacs/desktop.el
-#+property: header-args:emacs-lisp+ :mkdirp yes :noweb no-export
-#+property: header-args:lisp :mkdirp :tangle ~/.stumpwm.d/desktop.lisp :noweb yes
-
-* Introduction
-:PROPERTIES:
-:CUSTOM_ID: Introduction-w831x4a0l9j0
-:END:
-Many settings formerly present in this website’s index are related to
-my desktop settings, while some others are not.
-
-# Also, since I switched to StumpWM, many of my keybinds from Emacs need
-# to be kept up to date with my StumpWM keybinds, and /vice versa/. This
-# document aims to regroup all settings related to the desktop in order
-# to have an easier time managing them.
-
-* Common Emacs and StumpWM settings :noexport:
-:PROPERTIES:
-:CUSTOM_ID: Common-Emacs-and-StumpWM-settings-neseiaa0l9j0
-:END:
-Both Emacs and StumpWM work on the same principle of keychords
-powering a function or command. With both of them I have a prefix key,
-~SPC~ in the case of Emacs (or ~C-SPC~ when in insert-mode, see the
-relevant config) and ~s-SPC~ in the case of StumpWM. That means I can
-give them the same keychord following this, for instance ~w/~ to create
-a new vertically split frame to the right of the current one.
-
-All the keybinds will be presented in the form of tables, with on the
-first column the keychord following the leader key, on the second
-column the EmacsLisp function to be called, and on the third the
-StumpWM command. If one of the ELisp or StumpWM case’s is empty, it
-means there is no equivalence. If it’s ~nil~, then it means it is a
-prefix key. The fourth column is for now reserved for Emacs’
-which-key, so I can give it a better name. If its value is ~nil~, then
-it should not show up. Hopefully this can be implemented someday in
-StumpWM.
-
-** Generating Code :noexport:
-:PROPERTIES:
-:CUSTOM_ID: Common-Emacs-and-StumpWM-settings-Generating-Code-ngnclyk0l9j0
-:END:
-*** Elisp
-:PROPERTIES:
-:CUSTOM_ID: Common-Emacs-and-StumpWM-settings-Generating-Code-Elisp-oeqclyk0l9j0
-:END:
-#+name: emacs-keybinds-gen
-#+header: :var keymap=emacs-stumpwm-media-control
-#+begin_src emacs-lisp :exports none :tangle no :wrap "src emacs-lisp :tangle no"
-(mapconcat (lambda (keybind)
- (let* ((keychord (replace-regexp-in-string (rx (or (seq line-start "~")
- (seq "~" line-end)))
- ""
- (car keybind)))
- (function (replace-regexp-in-string (rx (or (seq line-start "~")
- (seq "~" line-end)))
- ""
- (nth 1 keybind)))
- (which (nth 3 keybind)))
- (format "\"%s\" %s"
- keychord
- (if (string= "nil" function)
- (format "%S"
- `(:ignore :which-key ,which))
- (if (string= "" which)
- (concat "#'" function)
- (format "%S"
- `'(,(intern function) :which-key ,which)))))))
- (seq-filter (lambda (elem)
- (not (string= "" (nth 1 elem))))
- keymap)
- "\n")
-#+end_src
-
-#+RESULTS: emacs-keybinds-gen
-#+begin_src emacs-lisp :tangle no
-"m" (:ignore :which-key "media")
-"m«" #'emms-player-mpd-previous
-"m»" #'emms-player-mpd-next
-"ma" '(hydra-media/body :which-key "MPD add")
-"mb" (:ignore :which-key "browse")
-"mba" #'emms-browse-by-artist
-"mbA" #'emms-browse-by-album
-"mbg" #'emms-browse-by-genre
-"mbp" #'emms-playlists-mode-go
-"mbs" #'emms-smart-browse
-"mby" #'emms-browse-by-year
-"mc" #'emms-player-mpd-clear
-"mp" #'emms-player-toggle-pause
-"ms" #'emms-player-mpd-show
-"mu" (:ignore :which-key "update")
-"mum" #'emms-player-mpd-update-all
-"muc" #'emms-cache-set-from-mpd-all
-#+end_src
-
-#+name: emacs-hydra-keybinds-gen
-#+header: :var keymap=emacs-stumpwm-resize-frame
-#+begin_src emacs-lisp :exports none :tangle no :wrap "src emacs-lisp :tangle no"
-(mapconcat (lambda (keybind)
- (let ((keychord (replace-regexp-in-string "^~\\|~$"
- ""
- (car keybind)))
- (function (replace-regexp-in-string "^~\\|~$"
- ""
- (nth 1 keybind)))
- (which (nth 3 keybind)))
- (format "%S" (if (string= "" which)
- `(,keychord ,(intern function))
- `(,keychord ,(intern function) ,which)))))
- keymap
- "\n")
-#+end_src
-
-#+RESULTS: emacs-hydra-keybinds-gen
-#+begin_src emacs-lisp :tangle no
-("c" shrink-window-horizontally)
-("t" enlarge-window)
-("s" shrink-window)
-("r" enlarge-window-horizontally)
-#+end_src
-
-*** Lisp
-:PROPERTIES:
-:CUSTOM_ID: Common-Emacs-and-StumpWM-settings-Generating-Code-Lisp-qntclyk0l9j0
-:END:
-#+name: stumpwm-filter-keybinds
-#+begin_src emacs-lisp :exports none :tangle no
-(let ((no-tilde (lambda (string)
- (replace-regexp-in-string "^~\\|~$" "" string))))
- (seq-filter (lambda (elem)
- (= 1 (length (car elem))))
- (mapcar (lambda (elem)
- `(,(replace-regexp-in-string (format "^%s" prefix) "" (car elem))
- .
- ,(cdr elem)))
- (seq-filter (lambda (elem)
- (and (not (string= "" (cdr elem)))
- (not (string= prefix (car elem)))
- (string-prefix-p prefix (car elem))))
- (mapcar (lambda (elem)
- (let ((keychord (apply no-tilde (list (car elem))))
- (function (apply no-tilde (list (nth 2 elem)))))
- `(,keychord . ,function)))
- keymap)))))
-#+end_src
-
-#+name: stumpwm-keybinds-gen
-#+header: :var keymap=emacs-stumpwm-media-control keymap-name="my-mpd-add-map" prefix="m"
-#+begin_src emacs-lisp :exports none :tangle no :wrap "src lisp :tangle no" :noweb yes
-(require 'seq)
-(format "(defvar *%s*
- (let %S
- %s
- m))"
- keymap-name
- `((m (make-sparse-keymap)))
- (mapconcat (lambda (keybind)
- (let ((keychord (replace-regexp-in-string (format "^%s" prefix)
- ""
- (car keybind)))
- (function (cdr keybind)))
- (format "%S" `(define-key m (kbd ,keychord) ,function))))
- <>
- "\n "))
-#+end_src
-
-#+RESULTS: stumpwm-keybinds-gen
-#+begin_src lisp :tangle no
-(defvar *my-mpd-add-map*
- (let ((m (make-sparse-keymap)))
- (define-key m (kbd ".") "media-interactive")
- (define-key m (kbd "«") "mpd-prev")
- (define-key m (kbd "»") "mpd-next")
- (define-key m (kbd "a") "'*my-mpd-add-keymap*")
- (define-key m (kbd "b") "'*my-mpd-browse-keymap*")
- (define-key m (kbd "c") "mpd-clear")
- (define-key m (kbd "p") "mpd-toggle-pause")
- m))
-#+end_src
-
-#+name: stumpwm-interactive-keybinds-gen
-#+header: :var keymap=emacs-stumpwm-resize-frame prefix=""
-#+header: :wrap "src lisp :exports none"
-#+begin_src emacs-lisp :noweb yes
-(format "(%s)"
- (mapconcat (lambda (keybind)
- (let ((keychord (car keybind))
- (function (cdr keybind)))
- (format "%S" `((kbd ,keychord) ,function))))
- <>
- "\n "))
-#+end_src
-
-#+RESULTS: stumpwm-interactive-keybinds-gen
-#+begin_src lisp :exports none
-(((kbd "c") "resize-direction left")
- ((kbd "t") "resize-direction down")
- ((kbd "s") "resize-direction up")
- ((kbd "r") "resize-direction right"))
-#+end_src
-
-#+name: stumpwm-interactive-gen
-#+header: :var keymap=emacs-stumpwm-resize-frame keymap-name="my-mpd-add-map" prefix=""
-#+begin_src emacs-lisp :exports none :tangle no :wrap "src lisp :tangle no"
-(format "%S"
- `(define-interactive-keymap ,(intern keymap-name)
- (:exit-on '((kbd "RET")
- (kbd "ESC")
- (kbd "C-g")
- (kbd "q")))
- ,@
- <>
- ))
-#+end_src
-
-#+RESULTS: stumpwm-interactive-gen
-#+begin_src lisp :tangle no
-(define-interactive-keymap my-mpd-add-map (:exit-on '((kbd "RET") (kbd "ESC") (kbd "C-g") (kbd "q"))) ((kbd "c") "resize-direction left" (kbd "t") "resize-direction down" (kbd "s") "resize-direction up" (kbd "r") "resize-direction right"))
-#+end_src
-
-** Frames Management
-:PROPERTIES:
-:CUSTOM_ID: Common-Emacs-and-StumpWM-settings-Frames-Management-5zhea5c0l9j0
-:END:
-In StumpWM, I’ll consider my various windows the same as Emacs’
-buffers.
-#+name: emacs-stumpwm-frames-management
-| Keychord | Emacs | StumpWM | which-key |
-|----------+---------------------------+-------------------------+-----------|
-| ~b~ | ~nil~ | ~'*my-buffers-keymap*~ | buffers |
-| ~bb~ | ~buflers-switch-buffer~ | ~windowlist~ | |
-| ~bB~ | ~bury-buffer~ | | |
-| ~bd~ | ~kill-this-buffer~ | ~delete-window~ | |
-| ~bD~ | ~kill-buffer~ | ~window-window-and-frame~ | |
-| ~bh~ | ~dashboard-refresh-buffer~ | | |
-| ~bk~ | | ~kill-window~ | |
-| ~bl~ | ~bufler~ | | |
-| ~bm~ | ~switch-to-messages-buffer~ | | |
-| ~bn~ | ~evil-next-buffer~ | ~next~ | |
-| ~bp~ | ~evil-prev-buffer~ | ~prev~ | |
-| ~br~ | ~counsel-buffer-or-recentf~ | | |
-| ~bs~ | ~switch-to-scratch-buffer~ | | |
-
-EmacsLisp code:
-#+begin_src emacs-lisp
-(phundrak/leader-key
- <>
- )
-#+end_src
-
-StumpWM’s Lisp code:
-#+begin_src lisp
-<>
-(define-key *root-map (kbd "b") '*my-buffers-keymap*)
-#+end_src
-
-** Window Management
-:PROPERTIES:
-:CUSTOM_ID: Common-Emacs-and-StumpWM-settings-Window-Management-8kt59fa0l9j0
-:END:
-The following allows to have an interactive keymap for resizing the
-current frame. In Emacs, it will be translated as a hydra while in
-StumpWM it will be an interactive keymap.
-#+name: emacs-stumpwm-resize-frame
-| Keychord | Emacs | StumpWM | which-key |
-|----------+-----------------------------+------------------------+-----------|
-| ~c~ | ~shrink-window-horizontally~ | ~resize-direction left~ | |
-| ~t~ | ~enlarge-window~ | ~resize-direction down~ | |
-| ~s~ | ~shrink-window~ | ~resize-direction up~ | |
-| ~r~ | ~enlarge-window-horizontally~ | ~resize-direction right~ | |
-
-This translates into the following hydra in EmacsLisp:
-#+begin_src emacs-lisp
-(defhydra windows-adjust-size ()
- "
-^Zoom^ ^Other
-^^^^^^^-----------------------------------------
-[_t_/_s_] shrink/enlarge vertically [_q_] quit
-[_c_/_r_] shrink/enlarge horizontally
-"
- <>
- ("q" nil :exit t))
-#+end_src
-
-While the following Lisp code is used with StumpWM.
-#+begin_src lisp
-(define-interactive-keymap (iresize tile-group) (:on-enter #'setup-iresize
- :on-exit #'resize-unhide
- :abort-if #'abort-resize-p
- :exit-on '((kbd "RET")
- (kbd "ESC")
- (kbd "C-g")
- (kbd "q")))
- <>
- )
-#+end_src
-
-Below you will find my window management keybinds.
-#+name: emacs-stump-window-management
-| Keychord | Emacs | StumpWM | which-key |
-|----------+-------------------------------+--------------------------+------------------|
-| ~w~ | ~nil~ | ~'*my-windows-keymap*~ | windows |
-| ~w.~ | ~windows-adjust-size/body~ | ~iresize~ | resize windows |
-| ~w-~ | ~split-window-below-and-focus~ | ~vsplit-and-focus~ | |
-| ~w+~ | | ~balance-frames~ | |
-| ~wv~ | ~split-window-below~ | ~vsplit~ | |
-| ~wV~ | | ~vsplit-equally~ | |
-| ~w/~ | ~split-window-right-and-focus~ | ~hsplit-and-focus~ | |
-| ~wh~ | ~split-window-right~ | ~hsplit~ | |
-| ~wH~ | | ~hsplit-equally~ | |
-| ~wc~ | ~evil-window-left~ | ~move-focus left~ | |
-| ~wt~ | ~evil-window-down~ | ~move-focus down~ | |
-| ~ws~ | ~evil-window-up~ | ~move-focus up~ | |
-| ~wr~ | ~evil-window-right~ | ~move-focus right~ | |
-| ~wC~ | | ~move-window left~ | |
-| ~wT~ | | ~move-window down~ | |
-| ~wS~ | | ~move-window up~ | |
-| ~wR~ | | ~move-window right~ | |
-| ~w C-c~ | | ~exchange-direction right~ | |
-| ~w C-s~ | | ~exchange-direction down~ | |
-| ~w C-t~ | | ~exchange-direction up~ | |
-| ~w C-r~ | | ~exchange-direction right~ | |
-| ~wb~ | ~kill-buffer-and-delete-window~ | | |
-| ~we~ | ~winum-select-window-by-number~ | ~expose~ | |
-| ~wf~ | | ~fullscreen~ | |
-| ~wF~ | | ~'*my-floating-keymap*~ | floating windows |
-| ~wFf~ | | ~float-this~ | |
-| ~wFF~ | | ~flatten-floats~ | |
-| ~wFu~ | | ~unfloat-this~ | |
-| ~wi~ | | ~info~ | |
-| ~wd~ | ~delete-window~ | ~remove-split~ | |
-| ~wD~ | ~delete-other-windows~ | ~only~ | |
-| ~wm~ | | ~meta~ | |
-| ~wo~ | ~other-window~ | ~other-window~ | |
-| ~ws~ | | ~sibling~ | |
-| ~wu~ | | ~next-urgent~ | |
-| ~wU~ | | ~unmaximize~ | |
-| ~ww~ | ~nil~ | | writeroom |
-| ~ww.~ | ~writeroom-buffer-width/body~ | | |
-| ~www~ | ~writeroom-mode~ | | |
-
-** Media Control
-:PROPERTIES:
-:CUSTOM_ID: Common-Emacs-and-StumpWM-settings-Media-Control-r56g2hc0l9j0
-:END:
-#+name: emacs-stumpwm-media-interactive
-| Keychord | Emacs | StumpWM | which-key |
-|----------+-------------------------------------------------------------+-----------------+-----------|
-| ~c~ | ~emms-player-mpd-previous~ | ~mpd-prev~ | |
-| ~t~ | ~(shell-command-and-echo "mpc volume -2" "mpc volume" "mpc")~ | ~mpd-volume-down~ | |
-| ~s~ | ~(shell-command-and-echo "mpc volume +2" "mpc volume" "mpc")~ | ~mpd-volume-up~ | |
-| ~r~ | ~emms-player-mpd-next~ | ~mpd-next~ | |
-| ~s~ | ~emms-player-mpd-stop~ | ~mpd-stop~ | |
-
-#+name: emacs-stumpwm-general-media
-| Keychord | Emacs | StumpWM | which-key |
-|----------+-------+--------------------------------------+----------------|
-| ~c~ | | ~exec xbacklight -dec 2~ | backlight down |
-| ~t~ | | ~exec amixer -q set Master 2%- unmute~ | volume down |
-| ~s~ | | ~exec amixer -q set Master 2%+ unmute~ | volume up |
-| ~r~ | | ~exec xbacklight -inc 2~ | backlight up |
-| ~m~ | | ~exec amixer -q set Master 1+ toggle~ | toggle mute |
-
-#+name: emacs-stumpwm-media-control
-| Keychord | Emacs | StumpWM | which-key |
-|----------+-----------------------------+---------------------------+-----------|
-| ~m~ | ~nil~ | ~'*my-media-keymap*~ | media |
-| ~m.~ | | ~media-interactive~ | |
-| ~m«~ | ~emms-player-mpd-previous~ | ~mpd-prev~ | |
-| ~m»~ | ~emms-player-mpd-next~ | ~mpd-next~ | |
-| ~ma~ | ~hydra-media/body~ | ~'*my-mpd-add-keymap*~ | MPD add |
-| ~maa~ | | ~mpd-serach-and-add-artist~ | |
-| ~maA~ | | ~mpd-serach-and-add-album~ | |
-| ~maf~ | | ~mpd-search-and-add-file~ | |
-| ~maF~ | | ~mpd-add-file~ | |
-| ~mag~ | | ~mpd-search-and-add-genre~ | |
-| ~mat~ | | ~mpd-search-and-add-title~ | |
-| ~mb~ | ~nil~ | ~'*my-mpd-browse-keymap*~ | browse |
-| ~mba~ | ~emms-browse-by-artist~ | ~mpd-browse-artists~ | |
-| ~mbA~ | ~emms-browse-by-album~ | ~mpd-browse-albums~ | |
-| ~mbg~ | ~emms-browse-by-genre~ | ~mpd-browse-genres~ | |
-| ~mbp~ | ~emms-playlists-mode-go~ | ~mpd-browse-playlist~ | |
-| ~mbs~ | ~emms-smart-browse~ | | |
-| ~mbt~ | | ~mpd-browse-tracks~ | |
-| ~mby~ | ~emms-browse-by-year~ | | |
-| ~mc~ | ~emms-player-mpd-clear~ | ~mpd-clear~ | |
-| ~mp~ | ~emms-player-toggle-pause~ | ~mpd-toggle-pause~ | |
-| ~ms~ | ~emms-player-mpd-show~ | | |
-| ~mu~ | ~nil~ | | update |
-| ~mum~ | ~emms-player-mpd-update-all~ | | |
-| ~muc~ | ~emms-cache-set-from-mpd-all~ | | |
-
-* Theme and graphical tweaks
-:PROPERTIES:
-:CUSTOM_ID: Theme-and-graphical-tweaks-ukp6gbc0l9j0
-:END:
-** GTK Settings
-:PROPERTIES:
-:CUSTOM_ID: Theme-and-graphical-tweaks-GTK-Settings-2307gbc0l9j0
-:END:
-*** GTK2
-:PROPERTIES:
-:CUSTOM_ID: Theme-and-graphical-tweaks-GTK-Settings-GTK2-fq77gbc0l9j0
-:END:
-**** General configuration
-:PROPERTIES:
-:HEADER-ARGS: :mkdirp yes :tangle ~/.config/gtk-2.0/gtkrc
-:CUSTOM_ID: Theme-and-graphical-tweaks-GTK-Settings-GTK2-General-configuration-xod7gbc0l9j0
-:END:
-This file is tangled at ~$HOME/.config/gtk-2.0/gtkrc~. This is an
-equivalent for the GTK3 configuration file you will see below, and it
-shares most of its settings. First, let’s select the Nordic theme for
-GTK2. Let’s also set the icon theme.
-#+BEGIN_SRC conf-unix
-# -*- mode: unix-config -*-
-gtk-theme-name="Nordic"
-gtk-icon-theme-name="Flat-Remix-Dark"
-#+END_SRC
-
-#+BEGIN_SRC conf-unix
-gtk-xft-antialias=1
-gtk-xft-hinting=1
-gtk-xft-hintstyle="hintslight"
-#+END_SRC
-
-This changes the shortcuts in menu, let’s also make the menus snappier.
-#+BEGIN_SRC conf-unix
-gtk-can-change-accels=1
-gtk-menu-bar-popup-delay=0
-gtk-menu-popdown-delay=0
-gtk-menu-popup-delay=0
-#+END_SRC
-
-**** Filechooser
-:PROPERTIES:
-:HEADER-ARGS: :mkdirp yes :tangle ~/.config/gtk-2.0/gtkfilechooser.ini
-:CUSTOM_ID: Theme-and-graphical-tweaks-GTK-Settings-GTK2-Filechooser-nmh7gbc0l9j0
-:END:
-#+BEGIN_SRC conf-unix
-[Filechooser Settings]
-#+END_SRC
-
-The first option alows me to open the file chooser in the current working
-directory:
-#+BEGIN_SRC conf-unix
-StartupMode=cwd
-#+END_SRC
-
-Next, setting the location mode to ~path-bar~ will show the path as buttons that
-can be clicked rather than the full path.
-#+BEGIN_SRC conf-unix
-LocationMode=path-bar
-#+END_SRC
-
-With this configuration, by default we won’t see hidden files.
-#+BEGIN_SRC conf-unix
-ShowHidden=true
-#+END_SRC
-
-And we'll also see the size of the visible files.
-#+BEGIN_SRC conf-unix
-ShowSizeColumn=true
-#+END_SRC
-
-Now, let’s choose the geometry of our file picker. These two first lines set
-where the file picker appears:
-#+BEGIN_SRC conf-unix
-GeometryX=566
-GeometryY=202
-#+END_SRC
-
-And these two describe the size of the window:
-#+BEGIN_SRC conf-unix
-GeometryWidth=800
-GeometryHeight=400
-#+END_SRC
-
-With these two lines, we set how our files are sorted: by name, and in the
-ascending order.
-#+BEGIN_SRC conf-unix
-SortColumn=name
-SortOrder=ascending
-#+END_SRC
-
-Our default view mode is a list of files:
-#+BEGIN_SRC conf-unix
-ViewMode=list-view
-#+END_SRC
-
-And finally, setting our icon view scale to ~-1~ sets the icon view to the max
-size.
-#+BEGIN_SRC conf-unix
-IconViewScale=-1
-#+END_SRC
-
-*** GTK3
-:PROPERTIES:
-:HEADER-ARGS: :mkdirp yes :tangle ~/.config/gtk-3.0/settings.ini
-:CUSTOM_ID: Theme-and-graphical-tweaks-GTK-Settings-GTK3-ojl7gbc0l9j0
-:END:
-The following file helps me to choose the aspect of various GTK+ 3
-software, including their theme and icons. First, let’s declare the
-header:
-#+BEGIN_SRC conf-unix
-[Settings]
-#+END_SRC
-
-Now, let’s hint to GTK that I prefer dark themes. This can have an influence
-also on some websites that can detect this preference and therefore set their
-own theme to dark by themselves.
-#+BEGIN_SRC conf-unix
-gtk-application-prefer-dark-theme = true
-#+END_SRC
-
-Next, the icon theme is the Flat Remix Dark icon theme:
-#+BEGIN_SRC conf-unix
-gtk-icon-theme-name = Nordzy
-#+END_SRC
-
-Now, the general theme for GTK3 is Nordic.
-#+BEGIN_SRC conf-unix
-gtk-theme-name = Nordic
-#+END_SRC
-
-#+BEGIN_SRC conf-unix
-gtk-can-change-accels=1
-gtk-menu-bar-popup-delay=0
-gtk-menu-popdown-delay=0
-gtk-menu-popup-delay=0
-#+END_SRC
-
-#+BEGIN_SRC conf-unix
-gtk-xft-antialias=1
-gtk-xft-hinting=1
-gtk-xft-hintstyle=hintslight
-# gtk-xft-rgba=rgb
-#+END_SRC
-
-Since window decorations are handled by my WMs, I will leave this variable
-empty.
-#+BEGIN_SRC conf-unix
-gtk-decoration-layout=
-#+END_SRC
-
-** Picom (Compton)
-:PROPERTIES:
-:CUSTOM_ID: Theme-and-graphical-tweaks-Picom-Compton-uko7gbc0l9j0
-:END:
-Picom is a standalone compositor for Xorg, and the successor to
-Compton, itself successor to xcompmgr-dana, itself a fork of xcompmgr.
-You can find my Picom configuration [[file:picom.org][here]].
-
-** Xresources
-:PROPERTIES:
-:HEADER-ARGS: :mkdirp yes :tangle ~/.config/X11/Xresources :exports code
-:CUSTOM_ID: Theme-and-graphical-tweaks-Xresources-4dr7gbc0l9j0
-:END:
-The main body in my Xresources declaration is the declaration of my
-color theme. It is based on the [[https://www.nordtheme.com/][Nord]] theme, from their [[https://github.com/arcticicestudio/nord-xresources/][Git repository]].
-#+BEGIN_SRC conf
-#define nord0 #2E3440
-#define nord1 #3B4252
-#define nord2 #434C5E
-#define nord3 #4C566A
-#define nord4 #D8DEE9
-#define nord5 #E5E9F0
-#define nord6 #ECEFF4
-#define nord7 #8FBCBB
-#define nord8 #88C0D0
-#define nord9 #81A1C1
-#define nord10 #5E81AC
-#define nord11 #BF616A
-#define nord12 #D08770
-#define nord13 #EBCB8B
-#define nord14 #A3BE8C
-#define nord15 #B48EAD
-
-,*.foreground: nord4
-,*.background: nord0
-,*.cursorColor: nord4
-,*fading: 35
-,*fadeColor: nord3
-
-,*.color0: nord1
-,*.color1: nord11
-,*.color2: nord14
-,*.color3: nord13
-,*.color4: nord9
-,*.color5: nord15
-,*.color6: nord8
-,*.color7: nord5
-,*.color8: nord3
-,*.color9: nord11
-,*.color10: nord14
-,*.color11: nord13
-,*.color12: nord9
-,*.color13: nord15
-,*.color14: nord7
-,*.color15: nord6
-#+END_SRC
-
-* Gpg configuration
-:PROPERTIES:
-:CUSTOM_ID: Gpg-configuration-6i2ip6l0m9j0
-:END:
-#+begin_src conf :tangle ~/.gnupg/gpg.conf
-keyserver hkp://keys.gnupg.net
-keyserver-options auto-key-retrieve
-keyserver hkp://pgp.mit.edu:11371
-#+end_src
-
-* Email signature
-:PROPERTIES:
-:HEADER-ARGS: :mkdirp yes :tangle ~/.signature
-:CUSTOM_ID: Email-signature-jnn75ac0l9j0
-:END:
-This file gets inserted automatically at the end of my emails.
-#+BEGIN_SRC text
-Lucien “Phundrak” Cartier-Tilet
-https://phundrak.com (Français)
-https://phundrak.com/en (English)
-Sent from GNU/Emacs
-#+END_SRC
-
-* ~.desktop~ files for custom applications
-:PROPERTIES:
-:CUSTOM_ID: -desktop-files-for-custom-applications-cksiyhg0m9j0
-:END:
-Some software I use are not packaged (yet) on my system. Therefore, in
-order to make them available in ~rofi~, I need to write a ~.desktop~ file
-to launch them.
-
-** Emacs
-:PROPERTIES:
-:CUSTOM_ID: -desktop-files-for-custom-applications-Emacs-6e9actg0m9j0
-:END:
-Emacs does have a default ~.desktop~ file, but I want to override it to
-just “open with Emacs” from other software (such as Nemo) and it will
-open with ~emacsclient~ instead of just =emacs=.
-#+begin_src conf-desktop :tangle ~/.local/share/applications/emacs.desktop
-[Desktop Entry]
-Name=Emacs
-GenericName=Text Editor
-Comment=Edit text
-MimeType=text/english;text/plain;text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascal;text/x-tcl;text/x-tex;application/x-shellscript;text/x-c;text/x-c++;
-Exec=emacsclient -c %F
-Icon=emacs
-Type=Application
-Terminal=false
-Categories=Development;TextEditor;
-StartupWMClass=Emacs
-Keywords=Text;Editor;
-#+end_src
-
-I also have ~mu4e.desktop~ which is used to set my default email client.
-It relies on ~emacsmail~ defined in [[file:bin.org::#Emacsmail-afffb7cd][this document]].
-#+begin_src conf-desktop :tangle ~/.local/share/applications/mu4e.desktop
-[Desktop Entry]
-Name=Mu4e
-GenericName=Mu4e
-Comment=Maildir Utils for Emacs
-MimeType=x-scheme-handler/mailto;
-Exec=/home/phundrak/.local/bin/emacsmail %U
-Icon=emacs
-Type=Application
-Terminal=false
-Categories=Network;Email;TextEditor
-StartupWMClass=Gnus
-Keywords=Text;Editor;
-#+end_src
-
-Then I also have ~org-protocol.desktop~ that helps capture elements from
-other software, mainly web pages from Firefox through the [[https://github.com/sprig/org-capture-extension][org-capture
-extension]].
-#+begin_src conf-desktop :tangle ~/.local/share/applications/org-protocol.desktop
-[Desktop Entry]
-Name=org-protocol
-Exec=emacsclient %u
-Type=Application
-Terminal=false
-Categories=System;
-MimeType=x-scheme-handler/org-protocol;
-#+end_src
-
-** FlowScape
-:PROPERTIES:
-:CUSTOM_ID: -desktop-files-for-custom-applications-FlowScape-7zelglg0m9j0
-:END:
-[[https://pixelforest.itch.io/flowscape][FlowScape]] is a nice 3D compositing software I sometimes use to create
-landscapes. I always install it in =~/.local/opt/Flowscape=, so the
-~.desktop~ file is relatively straightforward.
-#+begin_src conf-desktop :tangle ~/.local/share/applications/FlowScape.desktop
-[Desktop Entry]
-Version=1.5
-Name=FlowScape
-Comment=Create gorgeous 3D landscapes with ease.
-Exec=/usr/bin/prime-run /home/phundrak/.local/opt/FlowScape/FlowScape.x86_64
-Path=/home/phundrak/.local/opt/FlowScape
-Icon=/home/phundrak/.local/opt/FlowScape/icon.jpg
-Terminal=false
-Type=Application
-Categories=Graphics
-#+end_src
-
-** macOS
-:PROPERTIES:
-:CUSTOM_ID: -desktop-files-for-custom-applications-macOS-yb1dmyg0m9j0
-:END:
-You did not read wrong! Yes I have an entry for macOS, but this is for
-a virtual machine located in ~~/VMs/macOS~.
-#+begin_src conf-desktop :tangle ~/.local/share/applications/macos.desktop
-[Desktop Entry]
-Version=1
-Name=macOS
-Comment=macOS in a virtual machine
-Exec=/usr/bin/prime-run /home/phundrak/VMs/macOS/basic.sh
-Path=/home/phundrak/VMs/macOS
-Icon=/home/phundrak/VMs/macOS/macOS.png
-Terminal=false
-Type=Application
-Categories=Development
-#+end_src
-
-** Minecraft
-:PROPERTIES:
-:CUSTOM_ID: -desktop-files-for-custom-applications-Minecraft-tds7ddh0m9j0
-:END:
-Yup, I play Minecraft. And yes, it does have a default ~.desktop~ file,
-but this one overrides it to launch automatically Minecraft with
-[[https://wiki.archlinux.org/title/PRIME][prime-run]], using my Nvidia GPU instead of my integrated GPU.
-#+begin_src conf-desktop :tangle ~/.local/share/applications/minecraft-launcher.desktop
-[Desktop Entry]
-Type=Application
-Version=1.0
-Name=Minecraft Launcher (Nvidia)
-Comment=Official Minecraft Launcher
-Exec=/usr/bin/prime-run /usr/bin/minecraft-launcher
-Path=/usr/bin/
-Icon=minecraft-launcher
-Terminal=false
-Categories=Game;Application;
-#+end_src
-
-** OtherWorldMapper
-:PROPERTIES:
-:CUSTOM_ID: -desktop-files-for-custom-applications-OtherWorldMapper-rnh4omg0m9j0
-:END:
-OtherWorldMapper is a map creation software. It is always installed in
-~~/.local/opt/OtherWorldMapper~.
-#+begin_src conf-desktop :tangle ~/.local/share/applications/OWM.desktop
-[Desktop Entry]
-Version=1.0.4
-Name=OtherWorldMapper
-Comment=OtherWorldMapper is a powerful yet intuitive fantasy map creation tool.
-Exec=/usr/bin/prime-run /home/phundrak/.local/opt/OtherWorldMapper/OWM
-Path=/home/phundrak/.local/opt/OtherWorldMapper
-Icon=/home/phundrak/.local/opt/OtherWorldMapper/owm.ico
-Terminal=false
-Type=Application
-Categories=Graphics
-#+end_src
-
-** YouTube ~.desktop~ files
-:PROPERTIES:
-:CUSTOM_ID: -desktop-files-for-custom-applications-YouTube-desktop-files-0pw918h0m9j0
-:END:
-The first ~.desktop~ file related to YouTube is ~ytdl.desktop~ which runs
-~ytdl~ defined in [[file:bin.org::#ytdl-a-youtube-dl-wrapper-03bd63e0][this document]].
-#+begin_src conf-desktop :tangle ~/.local/share/applications/ytdl.desktop
-[Desktop Entry]
-Version=0.3
-Name=YTDL
-Comment=YouTube (and more) video downloader
-Exec=/home/phundrak/.local/bin/rofi-ytdl
-Path=/home/phundrak/.local/bin
-Terminal=false
-Type=Application
-Categories=Network;Video
-#+end_src
-
-There is also ~ytplay.desktop~ for ~ytplay~ defined in [[file:bin.org::#Media-youtube-dl-wrappers-ytplay-z6ka39h0m9j0][this document]].
-#+begin_src conf-desktop
-[Desktop Entry]
-Type=Application
-Version=1.0
-Name=ytplay (YouTube in mpv)
-Comment=Play YouTube videos in mpv
-Exec=/home/phundrak/.local/bin/ytplay
-Path=/home/phundrak/.local/bin
-Terminal=false
-Categories=Media
-#+end_src
diff --git a/org/config/emacs.org b/org/config/emacs.org
deleted file mode 100644
index 13f2a1a..0000000
--- a/org/config/emacs.org
+++ /dev/null
@@ -1,8955 +0,0 @@
-#+title: Emacs Configuration
-#+setupfile: headers
-#+options: unique-id:t
-#+html_head:
-#+html_head:
-#+html_head:
-#+property: header-args:emacs-lisp :mkdirp yes :lexical t :exports code
-#+property: header-args:emacs-lisp+ :tangle ~/.config/emacs/init.el
-#+property: header-args:emacs-lisp+ :mkdirp yes :noweb no-export
-
-#+include: img/emacs.svg export html
-
-* Introduction
-:PROPERTIES:
-:CUSTOM_ID: Introduction7gzhel6184j0
-:END:
-After a couple of years using Spacemacs and a failed attempt at
-switching to DoomEmacs, I’m finally switching back to a vanilla
-configuration! Why? Because I got tired of the framework getting in my
-way when I wanted to do stuff. I’m sure this is more applicable to
-Spacemacs than DoomEmacs since the latter has nice macros written to
-easily add new packages and configure them, such as ~package!~, ~after!~,
-and others. But ultimately, I wanted to have a system I designed
-entirely, with the keybinds I want, the packages I want.
-
-Aso, why Emacs? You know this famous quote:
-#+begin_quote
-Emacs is a great operating system, it just lacks a good text editor.
-#+end_quote
-
-It’s actually pretty true in my opinion. Emacs is basically a Lisp
-machine with a default text editor, programmed with EmacsLisp, a
-general-purpose programming language. Therefore, if you want to do
-something in Emacs, with enough Elisp you can do it --- if it’s not in
-Emacs already, that is.
-
-#+attr_html: :alt Dammit Emacs… :loading lazy
-#+caption: [[https://xkcd.com/378/][XKCD n°378]]: Real Programmers
-[[file:./img/real_programmers.png]]
-
-* A Warning Before You Proceed
-:PROPERTIES:
-:CUSTOM_ID: A-Warning-Before-You-Proceed-mgyar9i0ucj0
-:header-args:emacs-lisp: :tangle no
-:END:
-This configuration makes heavy use of the [[https://orgmode.org/manual/Noweb-Reference-Syntax.html][noweb]] syntax. This means if
-you encounter some code that looks ~<>~, org-mode will
-replace this snippet with another code snippet declared elsewhere in
-my configuration. If you see some code that looks ~<>~,
-some generating code will run and replace this piece of text with the
-text generated. A quick example:
-#+begin_src elisp
-(defun hello ()
- <>
- <>)
-#+end_src
-
-Will instead appear as
-#+begin_src emacs-lisp :noweb yes
-(defun hello ()
- <>
- <>)
-#+end_src
-
-This is because I have the block of code below named
-~generate-docstring~ which generates an output, which replaces its noweb
-tag. You can recognize noweb snippets generating code with the
-parenthesis. Often, such blocks aren’t visible in my HTML exports, but
-you can still see them if you open the actual org source file.
-#+name: generate-docstring
-#+begin_src emacs-lisp
-(concat "\""
- "Print \\\"Hello World!\\\" in the minibuffer."
- "\"")
-#+end_src
-
-On the other hand, noweb snippets without parenthesis simply replace
-the snippet with the equivalent named code block. For instance the one
-below is named ~print-hello~ and is placed as-is in the target source
-block.
-#+name: print-hello
-#+begin_src emacs-lisp
-(message "Hello World!")
-#+end_src
-
-* Basic Configuration
-:PROPERTIES:
-:CUSTOM_ID: Basic-configurationzt3iel6184j0
-:END:
-** Early Init
-:PROPERTIES:
-:CUSTOM_ID: Basic-configuration-Early-Inityj7iel6184j0
-:header-args:emacs-lisp: :tangle ~/.config/emacs/early-init.el :mkdirp yes
-:header-args:emacs-lisp+: :exports code :results silent :lexical t
-:END:
-The early init file is the file loaded before anything else in
-Emacs. This is where I put some options in order to disable as quickly
-as possible some built-in features of Emacs before they can be even
-loaded, speeding Emacs up a bit.
-#+begin_src emacs-lisp :mkdirp yes
-(setq package-enable-at-startup nil
- inhibit-startup-message t
- frame-resize-pixelwise t ; fine resize
- package-native-compile t) ; native compile packages
-(scroll-bar-mode -1) ; disable scrollbar
-(tool-bar-mode -1) ; disable toolbar
-(tooltip-mode -1) ; disable tooltips
-(set-fringe-mode 10) ; give some breathing room
-(menu-bar-mode -1) ; disable menubar
-(blink-cursor-mode 0) ; disable blinking cursor
-(setq gc-cons-threshold (* 1024 1024 1024))
-#+end_src
-
-** Emacs Behavior
-:PROPERTIES:
-:CUSTOM_ID: Basic-configuration-Emacs-Behavior6gbiel6184j0
-:END:
-*** Editing Text in Emacs
-:PROPERTIES:
-:CUSTOM_ID: Basic-configuration-Emacs-Behavior-Editing-Text-in-Emacsy2fiel6184j0
-:END:
-I *never* want to keep trailing spaces in my files, which is why I’m
-doing this:
-#+begin_src emacs-lisp
-(add-hook 'before-save-hook #'whitespace-cleanup)
-#+end_src
-
-I don’t understand why some people add two spaces behind a full stop,
-I sure don’t. Let’s tell Emacs.
-#+begin_src emacs-lisp
-(setq-default sentence-end-double-space nil)
-#+end_src
-
-There is a minor mode in Emacs which allows to have a finer way of
-jumping from word to word: ~global-subword-mode~. It detects if what
-Emacs usually considers a word can be understood as several words, as
-in camelCase words, and allows us to jump words on this finer level.
-#+begin_src emacs-lisp
-(global-subword-mode 1)
-#+end_src
-
-Changing half my screen each time my cursor goes too high or too low
-is not exactly ideal. Fortunately, if we set ~scroll-conservatively~
-high enough we can have the cursor stay on top or at the bottom of the
-screen while the text scrolls progressively.
-#+begin_src emacs-lisp
-(setq scroll-conservatively 1000)
-#+end_src
-
-Lastly, I want the default mode for Emacs to be Emacs Lisp.
-#+begin_src emacs-lisp
-(setq-default initial-major-mode 'emacs-lisp-mode)
-#+end_src
-
-**** Indentation
-:PROPERTIES:
-:CUSTOM_ID: Basic-configuration-Emacs-Behavior-Editing-Text-in-Emacs-Indentationauiiel6184j0
-:END:
-I don’t like tabs. They rarely look good, and if I need it I can
-almost always tell Emacs to use them through a ~.dir-locals.el~ file or
-through the config file of my code formatter. So by default, let’s
-disable them:
-#+begin_src emacs-lisp
-(setq-default indent-tabs-mode nil)
-(add-hook 'prog-mode-hook (lambda () (setq indent-tabs-mode nil)))
-#+end_src
-
-Just to go on a little tangent here: I don’t exactly /hate/ tabs, but I
-find them really annoying when your text editor knows only them. Sure,
-for indentation they work great, and they allow different people
-getting different settings in their text editor depending on their
-preferred tastes —some may prefer 2 spaces tabs, some may prefer 4
-spaces tabs, some deranged people prefer 8 spaces tabs, and some
-monsters prefer 3!
-
-But the thing is, once you indented your code, and then you need
-alignment, tabs don’t work anymore! Or they may on *your* text editor
-but not on your coworker’s! (He’s the one using 3 spaces tabs by the
-way).
-
-So, is the answer to use spaces instead of tabs, and screw peoples’
-preferences in terms of tabs width? No, I say the answer is more
-moderate than that, and it might frighten or anger some of you at
-first: use both spaces and tabs. Now, before you lynch me on the main
-avenue in front of everyone, let me tell you absolutely no one should
-ever be mixing spaces and tabs for indentation, that would be
-absolutely terrible and would bring the worst of both worlds. What’s
-the best of both worlds then?
-#+begin_center
-/Tabs for indentation/
-
-/Spaces for alignment/
-#+end_center
-
-I haven’t found a way to automate that in Emacs yet aside from
-formatters’ config file, and tabs look bat in EmacsLisp anyway, so
-I’ll stick with spaces by default and change it where needed.
-
-*** Programming Modes
-:PROPERTIES:
-:CUSTOM_ID: Basic-configuration-Emacs-Behavior-Programming-Modesfnmiel6184j0
-:END:
-First off, my definition of what makes a “programming mode” doesn’t exactly
-fit mine, so on top of ~prog-mode~, let’s add a few other modes.
-#+name: line-number-modes-table
-| Modes |
-|------------|
-| prog-mode |
-| latex-mode |
-
-#+name: prog-modes-gen
-#+header: :cache yes :exports none :tangle no
-#+begin_src emacs-lisp :var modes=line-number-modes-table
-(mapconcat (lambda (mode) (format "%s-hook" (car mode)))
- modes
- " ")
-#+end_src
-
-**** Line Number
-:PROPERTIES:
-:CUSTOM_ID: Basic-configuration-Emacs-Behavior-Programming-Modes-Line-Numbermcqiel6184j0
-:END:
-Since version 26, Emacs has a built-in capacity of displaying line
-numbers on the left-side of the buffer. This is a fantastic feature
-that should actually be the default for all programming modes.
-
-#+begin_src emacs-lisp
-(dolist (mode '(<>))
- (add-hook mode #'display-line-numbers-mode))
-#+end_src
-
-**** Folding code
-:PROPERTIES:
-:CUSTOM_ID: Basic-configuration-Emacs-Behavior-Programming-Modes-Folding-code16uiel6184j0
-:END:
-Most programming languages can usually have their code folded, be it
-code between curly braces, chunks of comments or code on another level
-of indentation (Python, why…?). The minor-mode that enables that is
-~hs-minor-mode~, let’s enable it for all of these programming modes:
-#+begin_src emacs-lisp
-(dolist (mode '(<>))
- (add-hook mode #'hs-minor-mode))
-#+end_src
-
-*** Stay Clean, Emacs!
-:PROPERTIES:
-:CUSTOM_ID: Basic-configuration-Emacs-Behavior-Stay-Clean-Emacs7wxiel6184j0
-:END:
-As nice as Emacs is, it isn’t very polite or clean by default: open a
-file, and it will create backup files in the same directory. But then,
-when you open your directory with your favorite file manager and see
-almost all of your files duplicated with a =~= appended to the filename,
-it looks really uncomfortable! This is why I prefer to tell Emacs to
-keep its backup files to itself in a directory it only will access.
-#+begin_src emacs-lisp
-(setq backup-directory-alist `(("." . ,(expand-file-name ".tmp/backups/"
- user-emacs-directory))))
-#+end_src
-
-It also loves to litter its ~init.el~ with custom variables here and
-there, but the thing is: I regenerate my ~init.el~ each time I tangle
-this file! How can I keep Emacs from adding stuff that will be almost
-immediately lost? Did someone say /custom file/?
-#+begin_src emacs-lisp
-(setq-default custom-file (expand-file-name ".custom.el" user-emacs-directory))
-(when (file-exists-p custom-file) ; Don’t forget to load it, we still need it
- (load custom-file))
-#+end_src
-
-If we delete a file, we want it moved to the trash, not simply deleted.
-#+begin_src emacs-lisp
-(setq delete-by-moving-to-trash t)
-#+end_src
-
-Finally, the scatch buffer always has some message at its beginning, I
-don’t want it!
-#+begin_src emacs-lisp
-(setq-default initial-scratch-message nil)
-#+end_src
-
-*** Stay Polite, Emacs!
-:PROPERTIES:
-:CUSTOM_ID: Basic-configuration-Emacs-Behavior-Stay-Polite-Emacszp1jel6184j0
-:END:
-When asking for our opinion on something, Emacs loves asking us to
-answer by “yes” or “no”, but *in full*! That’s very rude! Fortunately,
-we can fix this.
-#+begin_src emacs-lisp
-(defalias 'yes-or-no-p 'y-or-n-p)
-#+end_src
-
-This will make Emacs ask us for either hitting the ~y~ key for “yes”, or
-the ~n~ key for “no”. Much more polite!
-
-It is also very impolite to keep a certain version of a file in its
-buffer when said file has changed on disk. Let’s change this behavior:
-#+begin_src emacs-lisp
-(global-auto-revert-mode 1)
-#+end_src
-
-Much more polite! Note that if the buffer is modified and its changes
-haven’t been saved, it will not automatically revert the buffer and
-your unsaved changes won’t be lost. Very polite!
-
-*** Misc
-:PROPERTIES:
-:CUSTOM_ID: Basic-configuration-Emacs-Behavior-Misc9j5jel6184j0
-:END:
-Let’s raise Emacs undo memory to 10 MB, and make Emacs auto-save our
-files by default.
-#+begin_src emacs-lisp
-(setq undo-limit 100000000
- auto-save-default t)
-#+end_src
-
-#+begin_src emacs-lisp
-(setq window-combination-resize t) ; take new window space from all other windows
-#+end_src
-
-** Personal Information
-:PROPERTIES:
-:CUSTOM_ID: Basic-configuration-Personal-Informationi59jel6184j0
-:END:
-Emacs needs to know its master! For various reasons by the way, some
-packages rely on these variables to know who it is talking to or
-dealing with, such as ~mu4e~ which will guess who you are if you haven’t
-set it up correctly.
-#+begin_src emacs-lisp
-(setq user-full-name "Lucien Cartier-Tilet"
- user-real-login-name "Lucien Cartier-Tilet"
- user-login-name "phundrak"
- user-mail-address "lucien@phundrak.com")
-#+end_src
-
-** Visual Configuration
-:PROPERTIES:
-:CUSTOM_ID: Basic-configuration-Visual-Configurationzvcjel6184j0
-:END:
-The first visual setting in this section will activate the visible
-bell. What it does is I get a visual feedback each time I do something
-Emacs doesn’t agree with, like tring to go up a line when I’m already
-at the top of the buffer.
-#+begin_src emacs-lisp
-(setq visible-bell t)
-#+end_src
-
-It is nicer to see a cursor cover the actual space of a character.
-#+begin_src emacs-lisp
-(setq x-stretch-cursor t)
-#+end_src
-
-When text is ellipsed, I want the ellipsis marker to be a single
-character of three dots. Let’s make it so:
-#+begin_src emacs-lisp
-(with-eval-after-load 'mule-util
- (setq truncate-string-ellipsis "…"))
-#+end_src
-
-With Emacs 29.0.50 onwards, a new frame parameter exists:
-~alpha-background~. Unlike ~alpha~, this frame parameter only makes Emacs’
-background transparent, excluding images and text.
-#+begin_src emacs-lisp
-(add-to-list 'default-frame-alist '(alpha-background . 0.9))
-#+end_src
-
-*** Modeline Modules
-:PROPERTIES:
-:CUSTOM_ID: Basic-configuration-Visual-Configuration-Modeline-Modules9kgjel6184j0
-:END:
-I sometimes use Emacs in fullscreen, meaning my usual taskbar will be
-hidden. This is why I want the current date and time to be displayed,
-in an ISO-8601 style, although not exactly ISO-8601 (this is the best
-time format, fight me).
-#+begin_src emacs-lisp
-(require 'time)
-(setq display-time-format "%Y-%m-%d %H:%M")
-(display-time-mode 1) ; display time in modeline
-#+end_src
-
-Something my taskbar doesn’t have is a battery indicator. However, I
-want it enabled only if I am on a laptop or if a battery is available.
-#+begin_src emacs-lisp
-(let ((battery-str (battery)))
- (unless (or (equal "Battery status not available" battery-str)
- (string-match-p (regexp-quote "N/A") battery-str))
- (display-battery-mode 1)))
-#+end_src
-
-This isn’t a modeline module per se, but we have an indicator of the
-current line in Emacs. And although it is useful, I also often wish to
-know which column I’m on. This can be activated like so:
-#+begin_src emacs-lisp
-(column-number-mode)
-#+end_src
-
-The following code is, as will several chunks of code in this config,
-borrowed from [[https://tecosaur.github.io/emacs-config/#theme-modeline][TEC’s configuration]]. It hides the encoding information
-of the file if the file itself is a regular UTF-8 file with ~\n~ line
-ending. Be aware the ~doom-modeline-buffer-encoding~ variable is usabel
-here only because I use the Doom modeline as seen below.
-#+begin_src emacs-lisp
-(defun modeline-contitional-buffer-encoding ()
- "Hide \"LF UTF-8\" in modeline.
-
-It is expected of files to be encoded with LF UTF-8, so only show
-the encoding in the modeline if the encoding is worth notifying
-the user."
- (setq-local doom-modeline-buffer-encoding
- (unless (and (memq (plist-get (coding-system-plist buffer-file-coding-system) :category)
- '(coding-category-undecided coding-category-utf-8))
- (not (memq (coding-system-eol-type buffer-file-coding-system) '(1 2))))
- t)))
-#+end_src
-
-Now, let’s automate the call to this function in order to apply the
-modifications to the modeline each time we open a new file.
-#+begin_src emacs-lisp
-(add-hook 'after-change-major-mode-hook #'modeline-contitional-buffer-encoding)
-#+end_src
-
-*** Fonts
-:PROPERTIES:
-:CUSTOM_ID: Basic-configuration-Visual-Configuration-Fontsxfkjel6184j0
-:END:
-I don’t like the default font I usually have on my machines, I really
-don’t. I prefer [[https://github.com/microsoft/cascadia-code][Cascadia Code]], as it also somewhat supports the [[https://www.internationalphoneticassociation.org/][IPA]].
-#+begin_src emacs-lisp
-(defvar phundrak/default-font-size 90
- "Default font size.")
-
-(defvar phundrak/default-font-name "Cascadia Code"
- "Default font.")
-
-(defun my/set-font ()
- (when (find-font (font-spec :name phundrak/default-font-name))
- (set-face-attribute 'default nil
- :font phundrak/default-font-name
- :height phundrak/default-font-size)))
-
-(my/set-font)
-(add-hook 'server-after-make-frame-hook #'my/set-font)
-#+end_src
-
-*** Frame Title
-:PROPERTIES:
-:CUSTOM_ID: Basic-configuration-Visual-Configuration-Frame-Titlej7ojel6184j0
-:END:
-This is straight-up copied from [[https://tecosaur.github.io/emacs-config/config.html#window-title][TEC]]’s configuration. See their comment
-on the matter.
-#+begin_src emacs-lisp
-(setq frame-title-format
- '(""
- "%b"
- (:eval
- (let ((project-name (projectile-project-name)))
- (unless (string= "-" project-name)
- (format (if (buffer-modified-p) " ◉ %s" " ● %s - Emacs") project-name))))))
-#+end_src
-
-** A better custom variable setter
-:PROPERTIES:
-:CUSTOM_ID: Basic-Configuration-A-better-custom-variable-setter-56z4ni61lhj0
-:END:
-Something people often forget about custom variables in Elisp is they
-can have a custom setter that will run some code if we set the
-variable properly with ~customize-set-variable~, so ~setq~ shouldn’t be
-the user’s choice by default. But repeatedly writing
-~customize-set-variable~ can get tiring and boring. So why not take the
-best of both world and create ~csetq~, a ~setq~ that uses
-~customize-set-variable~ under the hood while it keeps a syntax similar
-to the one ~setq~ uses?
-#+begin_src emacs-lisp
-(defmacro csetq (&rest forms)
- "Bind each custom variable FORM to the value of its VAL.
-
-FORMS is a list of pairs of values [FORM VAL].
-`customize-set-variable' is called sequentially on each pairs
-contained in FORMS. This means `csetq' has a similar behaviour as
-`setq': each VAL expression are evaluated sequentially, i.e. the
-first VAL is evaluated before the second, and so on. This means
-the value of the first FORM can be used to set the second FORM.
-
-The return value of `csetq' is the value of the last VAL.
-
-\(fn [FORM VAL]...)"
- (declare (debug (&rest sexp form))
- (indent 1))
- ;; Check if we have an even number of arguments
- (when (= (mod (length forms) 2) 1)
- (signal 'wrong-number-of-arguments (list 'csetq (1+ (length forms)))))
- ;; Transform FORMS into a list of pairs (FORM . VALUE)
- (let (sexps)
- (while forms
- (let ((form (pop forms))
- (value (pop forms)))
- (push `(customize-set-variable ',form ,value)
- sexps)))
- `(progn ,@(nreverse sexps))))
-#+end_src
-
-I first got inspired by [[https://oremacs.com/2015/01/17/setting-up-ediff/][this blog article]] (archived article, just in
-case) but it seems the code snippet no longer works properly, so not
-only did I have to modify it to make it work with an arbitrary amount
-of arguments (as long as it’s pairs of variables and their value), but
-I also had to make the code simply work.
-
-* Custom Elisp
-:PROPERTIES:
-:CUSTOM_ID: Custom-Elispksvjel6184j0
-:END:
-** Dired functions
-:PROPERTIES:
-:CUSTOM_ID: Custom-Elisp-Dired-functionsm8zjel6184j0
-:END:
-*** ~phundrak/open-marked-files~
-:PROPERTIES:
-:CUSTOM_ID: Custom-Elisp-Dired-functions-phundrak-open-marked-filesdw2kel6184j0
-:END:
-This function allows the user to open all marked files from a dired
-buffer in new Emacs buffers.
-#+begin_src emacs-lisp
-(defun phundrak/open-marked-files (&optional files)
- "Open all marked FILES in Dired buffer as new Emacs buffers."
- (interactive)
- (let* ((file-list (if files
- (list files)
- (if (equal major-mode "dired-mode")
- (dired-get-marked-files)
- (list (buffer-file-name))))))
- (mapc (lambda (file-path)
- (find-file file-path))
- (file-list))))
-#+end_src
-
-** Switch between buffers
-:PROPERTIES:
-:CUSTOM_ID: Custom-Elisp-Switch-between-buffersp4ekel6184j0
-:END:
-Two default shortcuts I really like from Spacemacs are ~SPC b m~ and ~SPC
-b s~, which bring the user directly to the ~*Messages*~ buffer and the
-~*scratch*~ buffer respectively. These functions do exactly this.
-#+begin_src emacs-lisp
-(defun switch-to-messages-buffer ()
- "Switch to Messages buffer."
- (interactive)
- (switch-to-buffer (messages-buffer)))
-
-(defun switch-to-scratch-buffer ()
- "Switch to Messages buffer."
- (interactive)
- (switch-to-buffer "*scratch*"))
-#+end_src
-
-** Screenshots
-:PROPERTIES:
-:CUSTOM_ID: Custom-Elisp-Screenshots-l9bkib013aj0
-:END:
-Since Emacs27, it is possible for Emacs to take screenshots of itself
-in various formats. I’m mainly interested in the SVG and PNG format,
-so I’ll only write functions for these. It isn’t really redundant with
-the ~screenshot.el~ package used [[#Packages-Configuration-Applications-Screenshot96d1fl6184j0][here]] since these functions take a
-screenshot of Emacs as a whole rather than of a code snippet.
-
-First, we have a general function which is a slight modification of
-the function shared by Alphapapa in [[https://www.reddit.com/r/emacs/comments/idz35e/emacs_27_can_take_svg_screenshots_of_itself/g2c2c6y/][this Reddit comment]]. I modified it
-to make it possible to pass as an argument the format the screenshot
-will be taken as or ask the user which format they would like to save
-it as.
-#+begin_src emacs-lisp
-(defun self-screenshot (&optional type)
- "Save a screenshot of type TYPE of the current Emacs frame.
-As shown by the function `', type can weild the value `svg',
-`png', `pdf'.
-
-This function will output in /tmp a file beginning with \"Emacs\"
-and ending with the extension of the requested TYPE."
- (interactive (list
- (intern (completing-read "Screenshot type: "
- '(png svg pdf postscript)))))
- (let* ((extension (pcase type
- ('png ".png")
- ('svg ".svg")
- ('pdf ".pdf")
- ('postscript ".ps")
- (otherwise (error "Cannot export screenshot of type %s" otherwise))))
- (filename (make-temp-file "Emacs-" nil extension))
- (data (x-export-frames nil type)))
- (with-temp-file filename
- (insert data))
- (kill-new filename)
- (message filename)))
-#+end_src
-
-I used this function to take the screenshots you can see in this
-document.
-
-** Handle new windows
-:PROPERTIES:
-:CUSTOM_ID: Custom-Elisp-Handle-new-windows-f1za1rl02ej0
-:END:
-The two functions below allow the user to not only create a new window
-to the right or below the current window (respectively), but also to
-focus the new window immediately.
-#+begin_src emacs-lisp
-(defun split-window-right-and-focus ()
- "Spawn a new window right of the current one and focus it."
- (interactive)
- (split-window-right)
- (windmove-right))
-
-(defun split-window-below-and-focus ()
- "Spawn a new window below the current one and focus it."
- (interactive)
- (split-window-below)
- (windmove-down))
-
-(defun kill-buffer-and-delete-window ()
- "Kill the current buffer and delete its window."
- (interactive)
- (progn
- (kill-this-buffer)
- (delete-window)))
-#+end_src
-
-** Extend ~add-to-list~
-:PROPERTIES:
-:CUSTOM_ID: Custom-Elisp-Extend-add-to-list-eh2325605gj0
-:END:
-One function I find missing regarding ~add-to-list~ is ~add-all-to-list~
-which enables the user to add multiple elements to a list at once.
-Instead, with vanilla Emacs, I have to repeatedly call ~add-to-list~.
-That’s not very clean. Let’s declare this missing function:
-#+begin_src emacs-lisp
-(defun add-all-to-list (list-var elements &optional append compare-fn)
- "Add ELEMENTS to the value of LIST-VAR if it isn’t there yet.
-
-ELEMENTS is a list of values. For documentation on the variables
-APPEND and COMPARE-FN, see `add-to-list'."
- (let (return)
- (dolist (elt elements return)
- (setq return (add-to-list list-var elt append compare-fn)))))
-#+end_src
-
-* Package Management
-:PROPERTIES:
-:CUSTOM_ID: Package-Managementqpwkel6184j0
-:END:
-** Repositories
-:PROPERTIES:
-:CUSTOM_ID: Package-Management-Repositoriesab0lel6184j0
-:END:
-By default, only GNU’s repositories are available to the package
-managers of Emacs. I also want to use Melpa and org-mode’s repository,
-so let’s add them! Note that the stock /elpa/ repository is renamed to
-/gnu/ due to the addition of another Elpa repository, /nongnu/, which will
-hosts packages that do not conform to the FSF’s copyright assignment.
-Both the /gnu/ and the /nonfree/ repositories are Elpa repositories now,
-and they are renamed here in order to avoid any confusion between the
-two of them. Melpa is a community-maintained repository which contains
-an absurd amount of Emacs packages.
-#+begin_src emacs-lisp
-(setq package-archives '(("melpa" . "https://melpa.org/packages/")
- ("gnu" . "https://elpa.gnu.org/packages/")
- ("nongnu" . "https://elpa.nongnu.org/nongnu/")))
-#+end_src
-
-** Straight
-:PROPERTIES:
-:CUSTOM_ID: Package-Management-Straightry3lel6184j0
-:END:
-For my package management, I prefer to use ~straight~ ([[https://github.com/raxod502/straight.el][GitHub]]). This is
-due to its capacity of integrating nicely with ~use-package~, which also
-supports ~general~ which I use for my keybindings (see below), but also
-because with it, I can specify where to retrieve packages that are not
-on MELPA or ELPA but on GitHub and other online Git repositories too.
-First, let’s bootstrap straight.
-#+begin_src emacs-lisp
-(defvar bootstrap-version)
-(defvar comp-deferred-compilation-deny-list ()) ; workaround, otherwise straight shits itself
-(let ((bootstrap-file
- (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
- (bootstrap-version 5))
- (unless (file-exists-p bootstrap-file)
- (with-current-buffer
- (url-retrieve-synchronously
- "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
- 'silent 'inhibit-cookies)
- (goto-char (point-max))
- (eval-print-last-sexp)))
- (load bootstrap-file nil 'nomessage))
-#+end_src
-
-Now, we can refresh our package list in order to be able to install
-stuff.
-#+begin_src emacs-lisp
-(package-initialize)
-(unless package-archive-contents
- (package-refresh-contents))
-
-#+end_src
-
-From time to time, I fork some packages either because I’m trying to
-implement something new in said package, or because the package is
-unmaintained, and I want to continue developing it a bit more. Straight
-provides a nice feature for using forks of a package with its ~:fork~
-option. If set to ~t~, then straight will attempt to retrieve the
-package with the same name but with a different username on the same
-host. This username is retrieved through the following variable:
-#+begin_src emacs-lisp
-(setq straight-host-usernames
- '((github . "Phundrak")
- (gitlab . "Phundrak")))
-#+end_src
-
-The huge advantage of straight is it clones through git the packages
-it installs. This means development can be done directly on the
-downloaded package. However, Forge (a Magit extension for interacting
-with websites such as GitHub, Gitlab, and such) interacts by default
-with the forge described by the =origin= remote, which isn’t necessarily
-the one I want Forge to interact with by default. Therefore,
-=straight.el= will name all default remotes =straight= to avoid any name
-collision with my regular development flow.
-#+begin_src emacs-lisp
-(setq straight-vc-git-default-remote-name "straight")
-#+end_src
-
-We finally come to the ~use-package~ installation. This is done like so:
-#+begin_src emacs-lisp
-(straight-use-package '(use-package :build t))
-(setq use-package-always-ensure t)
-#+end_src
-
-* Keybinding Management
-:PROPERTIES:
-:CUSTOM_ID: Keybinding-Management728lel6184j0
-:END:
-** Which-key
-:PROPERTIES:
-:CUSTOM_ID: Keybinding-Management-Which-keymsblel6184j0
-:END:
-Which key is, I think, one of my favorite quality of life package.
-When you begin a keybind, Emacs will show you all keybinds you can
-follow the first one with in order to form a full keychord. Very
-useful when you have a lot of keybinds and don’t remember exactly what
-is what.
-#+begin_src emacs-lisp
-(use-package which-key
- :straight (:build t)
- :defer t
- :init (which-key-mode)
- :diminish which-key-mode
- :config
- (setq which-key-idle-delay 1))
-#+end_src
-
-** General
-:PROPERTIES:
-:CUSTOM_ID: Keybinding-Management-Generalycflel6184j0
-:END:
-General is an awesome package for managing keybindings. Not only is it
-oriented towards keychords by default (which I love), but it also
-provides some integration with evil so that we can declare keybindings
-for certain states only! This is a perfect replacement for ~define-key~,
-~evil-define-key~, and any other function for defining keychords. And it
-is also possible to declare a prefix for my keybindings! By default,
-all keybinds will be prefixed with ~SPC~ and keybinds related to a
-specific mode (often major modes) will be prefixed by a comma ~,~ (and
-by ~C-SPC~ and ~M-m~ respectively when in ~insert-mode~ or ~emacs-mode~). You
-can still feel some influence from my Spacemacs years here.
-#+begin_src emacs-lisp
-(use-package general
- :straight (:build t)
- :init
- (general-auto-unbind-keys)
- :config
- (general-create-definer phundrak/undefine
- :keymaps 'override
- :states '(normal emacs))
- (general-create-definer phundrak/evil
- :states '(normal))
- (general-create-definer phundrak/leader-key
- :states '(normal insert visual emacs)
- :keymaps 'override
- :prefix "SPC"
- :global-prefix "C-SPC")
- (general-create-definer phundrak/major-leader-key
- :states '(normal insert visual emacs)
- :keymaps 'override
- :prefix ","
- :global-prefix "M-m"))
-#+end_src
-
-#+name: general-keybindings-gen
-#+header: :tangle no :exports none :results value :cache yes
-#+begin_src emacs-lisp :var table=keybinds-windows prefix=""
-(mapconcat (lambda (line)
- (let* ((key (nth 0 line))
- (function (nth 1 line))
- (comment (or (nth 2 line) ""))
- (package (or (nth 3 line) "")))
- (format "\"%s%s\" %s"
- prefix
- key
- (if (string= "" comment)
- (if (member function '("" "nil")) "nil" (concat "#'" function))
- (format "'(%s :wk %s%s)"
- (if (member function '("" "nil")) ":ignore t" function)
- (if (member function '("none" "nil")) "t" (concat "\"" comment "\""))
- (if (string-blank-p package) "" (concat ":package " package)))))))
- table
- "\n")
-#+end_src
-
-** Evil
-:PROPERTIES:
-:CUSTOM_ID: Keybinding-Management-Eviljg30fl6184j0
-:END:
-Evil emulates most of vim’s keybinds, because let’s be honest here,
-they are much more comfortable than Emacs’.
-#+begin_src emacs-lisp
-(use-package evil
- :straight (:build t)
- :after (general)
- :init
- (setq evil-want-integration t
- evil-want-keybinding nil
- evil-want-C-u-scroll t
- evil-want-C-i-jump nil)
- (require 'evil-vars)
- (evil-set-undo-system 'undo-tree)
- :config
- <>
- <>
- (evil-mode 1)
- (setq evil-want-fine-undo t) ; more granular undo with evil
- (evil-set-initial-state 'messages-buffer-mode 'normal)
- (evil-set-initial-state 'dashboard-mode 'normal))
-#+end_src
-
-I want to undefine some default keybinds of Evil because it does not
-match my workflow. Namely, I use the space key and the comma as
-leaders for my keybinds, and I’m way too used to Emacs’ ~C-t~, ~C-a~, ~C-e~,
-and ~C-y~.
-#+name: evil-undefine-keys
-#+begin_src emacs-lisp :tangle no
-(evil-global-set-key 'motion "t" 'evil-next-visual-line)
-(evil-global-set-key 'motion "s" 'evil-previous-visual-line)
-
-(general-define-key
- :keymaps 'evil-motion-state-map
- "SPC" nil
- "," nil)
-(general-define-key
- :keymaps 'evil-insert-state-map
- "C-t" nil)
-(general-define-key
- :keymaps 'evil-insert-state-map
- "U" nil
- "C-a" nil
- "C-y" nil
- "C-e" nil)
-#+end_src
-
-Something else that really bugs me is I use the bépo layout, which is
-not at all like the qwerty layout. For instance, ~hjkl~ becomes ~ctsr~.
-Thus, I need some bépo-specific changes.
-#+name: evil-bepo
-#+begin_src emacs-lisp :tangle no
-(dolist (key '("c" "C" "t" "T" "s" "S" "r" "R" "h" "H" "j" "J" "k" "K" "l" "L"))
- (general-define-key :states 'normal key nil))
-
-(general-define-key
- :states 'motion
- "h" 'evil-replace
- "H" 'evil-replace-state
- "j" 'evil-find-char-to
- "J" 'evil-find-char-to-backward
- "k" 'evil-substitute
- "K" 'evil-smart-doc-lookup
- "l" 'evil-change
- "L" 'evil-change-line
-
- "c" 'evil-backward-char
- "C" 'evil-window-top
- "t" 'evil-next-visual-line
- "T" 'evil-join
- "s" 'evil-previous-visual-line
- "S" 'evil-lookup
- "r" 'evil-forward-char
- "R" 'evil-window-bottom)
-#+end_src
-
-This package enables and integrates Evil into a lot of different
-modes, such as org-mode, dired, mu4e, etc. Again, I need some
-additional code compared to most people due to the bépo layout.
-#+begin_src emacs-lisp
-(use-package evil-collection
- :after evil
- :straight (:build t)
- :config
- ;; bépo conversion
- (defun my/bépo-rotate-evil-collection (_mode mode-keymaps &rest _rest)
- (evil-collection-translate-key 'normal mode-keymaps
- ;; bépo ctsr is qwerty hjkl
- "c" "h"
- "t" "j"
- "s" "k"
- "r" "l"
- ;; add back ctsr
- "h" "c"
- "j" "t"
- "k" "s"
- "l" "r"))
- (add-hook 'evil-collection-setup-hook #'my/bépo-rotate-evil-collection)
- (evil-collection-init))
-#+end_src
-
-~undo-tree~ is my preferred way of undoing and redoing stuff. The main
-reason is it doesn’t create a linear undo/redo history, but rather a
-complete tree you can navigate to see your complete editing history.
-One of the two obvious things to do are to tell Emacs to save all its
-undo history fies in a dedicated directory, otherwise we’d risk
-littering all of our directories. The second thing is to simply
-globally enable its mode.
-#+begin_src emacs-lisp
-(use-package undo-tree
- :defer t
- :straight (:build t)
- :custom
- (undo-tree-history-directory-alist
- `(("." . ,(expand-file-name (file-name-as-directory "undo-tree-hist")
- user-emacs-directory))))
- :init
- (global-undo-tree-mode)
- :config
- <>
- <>
- (setq undo-tree-visualizer-diff t
- undo-tree-visualizer-timestamps t
- undo-tree-auto-save-history t
- undo-tree-enable-undo-in-region t
- undo-limit (* 800 1024)
- undo-strong-limit (* 12 1024 1024)
- undo-outer-limit (* 128 1024 1024)))
-#+end_src
-
-An interesting behavior from DoomEmacs is to compress the history
-files with ~zstd~ when it is present on the system. Not only do we enjoy
-much smaller files (according to DoomEmacs, we get something like 80%
-file savings), Emacs can load them much faster than the regular files.
-Sure, it uses more CPU time uncompressing these files, but it’s
-insignificant, and it’s still faster than loading a heavier file.
-#+name: undo-tree-compress-files
-#+begin_src emacs-lisp :tangle no
-(when (executable-find "zstd")
- (defun my/undo-tree-append-zst-to-filename (filename)
- "Append .zst to the FILENAME in order to compress it."
- (concat filename ".zst"))
- (advice-add 'undo-tree-make-history-save-file-name
- :filter-return
- #'my/undo-tree-append-zst-to-filename))
-#+end_src
-
-** Hydra
-:PROPERTIES:
-:CUSTOM_ID: Keybinding-Management-Hydra0970fl6184j0
-:END:
-[[https://github.com/abo-abo/hydra][Hydra]] is a simple menu creator for keybindings.
-#+begin_src emacs-lisp
-(use-package hydra
- :straight (:build t)
- :defer t)
-#+end_src
-
-*** Hydras
-:PROPERTIES:
-:CUSTOM_ID: Keybinding-Management-Hydra-Hydrasvya0fl6184j0
-:END:
-The following hydra allows me to quickly zoom in and out in the
-current buffer.
-#+begin_src emacs-lisp
-(defhydra hydra-zoom ()
- "
-^Zoom^ ^Other
-^^^^^^^--------------------------
-[_t_/_s_] zoom in/out [_q_] quit
-[_0_]^^ reset zoom
-"
- ("t" text-scale-increase "zoom in")
- ("s" text-scale-decrease "zoom out")
- ("0" text-scale-adjust "reset")
- ("q" nil "finished" :exit t))
-#+end_src
-
-Similarly, this one is also inspired from Spacemacs and allows the
-user to interact with the width of the buffer in ~writeroom~.
-#+begin_src emacs-lisp
-(defhydra writeroom-buffer-width ()
- "
-^Width^ ^Other
-^^^^^^^^-----------------------
-[_t_] enlarge [_r_/_0_] adjust
-[_s_] shrink [_q_]^^ quit
-"
- ("q" nil :exit t)
- ("t" writeroom-increase-width "enlarge")
- ("s" writeroom-decrease-width "shrink")
- ("r" writeroom-adjust-width "adjust")
- ("0" writeroom-adjust-width "adjust"))
-#+end_src
-
-Another similar one is for ~mu4e-view-mode~ that allows me to shrink or
-grow the ~mu4e-headers~ buffer when viewing an email.
-#+begin_src emacs-lisp
-(defhydra mu4e-headers-split-adjust-width ()
- "
-^Zoom^ ^Other
-^^^^^^^---------------------------------
-[_t_/_s_] shrink/enlarge view [_q_] quit
-"
- ("q" nil :exit t)
- ("t" mu4e-headers-split-view-shrink "shrink")
- ("s" mu4e-headers-split-view-grow "enlarge"))
-#+end_src
-
-Similarly still, this one allows me to manage the size my Emacs
-windows.
-#+begin_src emacs-lisp
-(defhydra windows-adjust-size ()
- "
-^Zoom^ ^Other
-^^^^^^^-----------------------------------------
-[_t_/_s_] shrink/enlarge vertically [_q_] quit
-[_c_/_r_] shrink/enlarge horizontally
-"
- ("q" nil :exit t)
- ("c" shrink-window-horizontally)
- ("t" enlarge-window)
- ("s" shrink-window)
- ("r" enlarge-window-horizontally))
-#+end_src
-
-This one allows me to manipulate my Emacs frames’ background
-transparency.
-#+begin_src emacs-lisp
-(defun my/transparency-round (val)
- "Round VAL to the nearest tenth of an integer."
- (/ (round (* 10 val)) 10.0))
-
-(defun my/increase-frame-alpha-background ()
- "Increase current frame’s alpha background."
- (interactive)
- (set-frame-parameter nil
- 'alpha-background
- (my/transparency-round
- (min 1.0
- (+ (frame-parameter nil 'alpha-background) 0.1))))
- (message "%s" (frame-parameter nil 'alpha-background)))
-
-(defun my/decrease-frame-alpha-background ()
- "Decrease current frame’s alpha background."
- (interactive)
- (set-frame-parameter nil
- 'alpha-background
- (my/transparency-round
- (max 0.0
- (- (frame-parameter nil 'alpha-background) 0.1))))
- (message "%s" (frame-parameter nil 'alpha-background)))
-
-(defhydra my/modify-frame-alpha-background ()
- "
-^Transparency^ ^Other^
-^^^^^^^^^^^^^^------------------------
-[_t_] decrease transparency [_q_] quit
-[_s_] increase transparency
-"
- ("q" nil :exit t)
- ("s" my/decrease-frame-alpha-background)
- ("t" my/increase-frame-alpha-background))
-#+end_src
-
-* Packages Configuration
-:PROPERTIES:
-:CUSTOM_ID: Packages-Configurationije0fl6184j0
-:END:
-** Autocompletion
-:PROPERTIES:
-:CUSTOM_ID: Packages-Configuration-Autocompletionr8n1fl6184j0
-:END:
-*** Code Autocompletion
-:PROPERTIES:
-:CUSTOM_ID: Packages-Configuration-Autocompletion-Code-Autocompletion4no1fl6184j0
-:END:
-Company is, in my opinion, the best autocompleting engine for Emacs,
-and it is one of the most popular if not /the/ most popular.
-#+begin_src emacs-lisp
-(use-package company
- :straight (:build t)
- :defer t
- :hook (company-mode . evil-normalize-keymaps)
- :init (global-company-mode)
- :config
- (setq company-minimum-prefix-length 2
- company-toolsip-limit 14
- company-tooltip-align-annotations t
- company-require-match 'never
- company-global-modes '(not erc-mode message-mode help-mode gud-mode)
- company-frontends
- '(company-pseudo-tooltip-frontend ; always show candidates in overlay tooltip
- company-echo-metadata-frontend) ; show selected candidate docs in echo area
- company-backends '(company-capf)
- company-auto-commit nil
- company-auto-complete-chars nil
- company-dabbrev-other-buffers nil
- company-dabbrev-ignore-case nil
- company-dabbrev-downcase nil))
-#+end_src
-
-This package is a backend for company. It emulates
-~ac-source-dictionary~ by proposing text related to the current
-major-mode.
-#+begin_src emacs-lisp
-(use-package company-dict
- :after company
- :straight (:build t)
- :config
- (setq company-dict-dir (expand-file-name "dicts" user-emacs-directory)))
-#+end_src
-
-On the other hand, ~company-box~ is a Company front-end which offers
-colors, icons, documentation and so on. Very nice.
-
-Declaring all the icons for the variable
-~company-box-icons-all-the-icons~ is quite verbose in Elisp, so I do it
-with an org-table.
-#+name: company-box-icons
-| Type | Icon | Color |
-|---------------+--------------------------+--------|
-| Unknown | find_in_page | purple |
-| Text | text_fields | green |
-| Method | functions | red |
-| Function | functions | red |
-| Constructor | functions | red |
-| Field | functions | red |
-| Variable | adjust | blue |
-| Class | class | red |
-| Interface | settings_input_component | red |
-| Module | view_module | red |
-| Property | settings | red |
-| Unit | straighten | red |
-| Value | filter_1 | red |
-| Enum | plus_one | red |
-| Keyword | filter_center_focus | red |
-| Snippet | short_text | red |
-| Color | color_lens | red |
-| File | insert_drive_file | red |
-| Reference | collections_bookmark | red |
-| Folder | folder | red |
-| EnumMember | people | red |
-| Constant | pause_circle_filled | red |
-| Struct | streetview | red |
-| Event | event | red |
-| Operator | control_point | red |
-| TypeParameter | class | red |
-| Template | short_text | green |
-| ElispFunction | functions | red |
-| ElispVariable | check_circle | blue |
-| ElispFeature | stars | orange |
-| ElispFace | format_paint | pink |
-
-#+name: gen-company-box-icons
-#+headers: :tangle no :noweb yes :exports none :cache yes
-#+header: :wrap "src emacs-lisp :exports none :tangle no"
-#+begin_src emacs-lisp :var table=company-box-icons
-(mapconcat (lambda (row)
- (format "(%s . ,(all-the-icons-material \"%s\" :face 'all-the-icons-%s))"
- (car row)
- (cadr row)
- (caddr row)))
- table
- "\n")
-#+end_src
-
-#+RESULTS[8ebf4bb3f7f354571a5d42cf58f8b9ba847ba028]: gen-company-box-icons
-#+begin_src emacs-lisp :exports none :tangle no
-(Unknown . ,(all-the-icons-material "find_in_page" :face 'all-the-icons-purple))
-(Text . ,(all-the-icons-material "text_fields" :face 'all-the-icons-green))
-(Method . ,(all-the-icons-material "functions" :face 'all-the-icons-red))
-(Function . ,(all-the-icons-material "functions" :face 'all-the-icons-red))
-(Constructor . ,(all-the-icons-material "functions" :face 'all-the-icons-red))
-(Field . ,(all-the-icons-material "functions" :face 'all-the-icons-red))
-(Variable . ,(all-the-icons-material "adjust" :face 'all-the-icons-blue))
-(Class . ,(all-the-icons-material "class" :face 'all-the-icons-red))
-(Interface . ,(all-the-icons-material "settings_input_component" :face 'all-the-icons-red))
-(Module . ,(all-the-icons-material "view_module" :face 'all-the-icons-red))
-(Property . ,(all-the-icons-material "settings" :face 'all-the-icons-red))
-(Unit . ,(all-the-icons-material "straighten" :face 'all-the-icons-red))
-(Value . ,(all-the-icons-material "filter_1" :face 'all-the-icons-red))
-(Enum . ,(all-the-icons-material "plus_one" :face 'all-the-icons-red))
-(Keyword . ,(all-the-icons-material "filter_center_focus" :face 'all-the-icons-red))
-(Snippet . ,(all-the-icons-material "short_text" :face 'all-the-icons-red))
-(Color . ,(all-the-icons-material "color_lens" :face 'all-the-icons-red))
-(File . ,(all-the-icons-material "insert_drive_file" :face 'all-the-icons-red))
-(Reference . ,(all-the-icons-material "collections_bookmark" :face 'all-the-icons-red))
-(Folder . ,(all-the-icons-material "folder" :face 'all-the-icons-red))
-(EnumMember . ,(all-the-icons-material "people" :face 'all-the-icons-red))
-(Constant . ,(all-the-icons-material "pause_circle_filled" :face 'all-the-icons-red))
-(Struct . ,(all-the-icons-material "streetview" :face 'all-the-icons-red))
-(Event . ,(all-the-icons-material "event" :face 'all-the-icons-red))
-(Operator . ,(all-the-icons-material "control_point" :face 'all-the-icons-red))
-(TypeParameter . ,(all-the-icons-material "class" :face 'all-the-icons-red))
-(Template . ,(all-the-icons-material "short_text" :face 'all-the-icons-green))
-(ElispFunction . ,(all-the-icons-material "functions" :face 'all-the-icons-red))
-(ElispVariable . ,(all-the-icons-material "check_circle" :face 'all-the-icons-blue))
-(ElispFeature . ,(all-the-icons-material "stars" :face 'all-the-icons-orange))
-(ElispFace . ,(all-the-icons-material "format_paint" :face 'all-the-icons-pink))
-#+end_src
-
-#+begin_src emacs-lisp
-(use-package company-box
- :straight (:build t)
- :after (company all-the-icons)
- :config
- (setq company-box-show-single-candidate t
- company-box-backends-colors nil
- company-box-max-candidates 50
- company-box-icons-alist 'company-box-icons-all-the-icons
- company-box-icons-all-the-icons
- (let ((all-the-icons-scale-factor 0.8))
- `(
- <>))))
-#+end_src
-
-*** Ivy
-:PROPERTIES:
-:CUSTOM_ID: Packages-Configuration-Autocompletion-Ivy84q1fl6184j0
-:END:
-My main menu package is =ivy= which I use as much as possible –I’ve
-noticed =helm= can be slow, very slow in comparison to =ivy=, so I’ll use
-the latter as much as possible. Actually, only =ivy= is installed for
-now. I could have used =ido= too, but I find it to be a bit too
-restricted in terms of features compared to =ivy=.
-#+begin_src emacs-lisp
-(use-package ivy
- :straight (:build t)
- :defer t
- :diminish
- :bind (("C-s" . swiper)
- :map ivy-minibuffer-map
- ("TAB" . ivy-alt-done)
- ("C-l" . ivy-alt-done)
- ("C-t" . ivy-next-line)
- ("C-s" . ivy-previous-line)
- ("C-u" . ivy-scroll-up-command)
- ("C-d" . ivy-scroll-down-command)
- :map ivy-switch-buffer-map
- ("C-t" . ivy-next-line)
- ("C-s" . ivy-previous-line)
- ("C-l" . ivy-done)
- ("C-d" . ivy-switch-buffer-kill)
- :map ivy-reverse-i-search-map
- ("C-t" . ivy-next-line)
- ("C-s" . ivy-previous-line)
- ("C-d" . ivy-reverse-i-search-kill))
- :config
- (ivy-mode 1)
- (setq ivy-wrap t
- ivy-height 17
- ivy-sort-max-size 50000
- ivy-fixed-height-minibuffer t
- ivy-read-action-functions #'ivy-hydra-read-action
- ivy-read-action-format-function #'ivy-read-action-format-columns
- projectile-completion-system 'ivy
- ivy-on-del-error-function #'ignore
- ivy-use-selectable-prompt t))
-#+end_src
-
-#+begin_src emacs-lisp
-(use-package counsel
- :straight (:build t)
- :defer t)
-#+end_src
-
-There is also [[https://github.com/raxod502/prescient.el][~prescient.el~]] that offers some nice features when
-coupled with ~ivy~, guess what was born out of it? ~ivy-prescient~, of
-course!
-#+begin_src emacs-lisp
-(use-package ivy-prescient
- :after ivy
- :straight (:build t))
-#+end_src
-
-I warned you I’d use too much ~all-the-icons~, I did!
-#+begin_src emacs-lisp
-(use-package all-the-icons-ivy
- :straight (:build t)
- :after (ivy all-the-icons)
- :init (all-the-icons-ivy-setup)
- :hook (after-init . all-the-icons-ivy-setup))
-(all-the-icons-ivy-setup)
-#+end_src
-
-A buffer popping at the bottom of the screen is nice and all, but have
-you considered a floating buffer in the center of your frame?
-#+begin_src emacs-lisp
-(use-package ivy-posframe
- :defer t
- :after (:any ivy helpful)
- :hook (ivy-mode . ivy-posframe-mode)
- :straight (:build t)
- :init
- (ivy-posframe-mode 1)
- :config
- (setq ivy-fixed-height-minibuffer nil
- ivy-posframe-border-width 10
- ivy-posframe-parameters
- `((min-width . 90)
- (min-height . ,ivy-height))))
-#+end_src
-
-Something that can be missing sometimes in Ivy is the ability to
-select multiple entries at once. For instance, when programming in
-Java, LPS can offer you to automatically generate the methods ~equals~
-and ~hashCode~ based on selected members, but with vanilla Ivy, you can
-only select one. Not really useful. ~ivy-hydra~ is a package that offers
-a Hydra interface when in Ivy which allows you to select multiple
-choices among other things.
-#+begin_src emacs-lisp
-(use-package ivy-hydra
- :requires (ivy hydra)
- :after ivy
- :straight (:build t))
-#+end_src
-
-Finally, let’s make ~ivy~ richer:
-#+begin_src emacs-lisp
-(use-package ivy-rich
- :straight (:build t)
- :after ivy
- :init
- (ivy-rich-mode 1))
-#+end_src
-
-*** Counsel
-:PROPERTIES:
-:CUSTOM_ID: Packages-Configuration-Autocompletion-Counselorr1fl6184j0
-:END:
-I could almost merge this chapter with the previous one since counsel
-is a package that provides loads of completion functions for ivy. The
-ones I find most useful are ~counsel-M-x~ and ~counsel-find-file~.
-#+begin_src emacs-lisp
-(use-package counsel
- :straight (:build t)
- :after recentf
- :after ivy
- :bind (("M-x" . counsel-M-x)
- ("C-x b" . counsel-ibuffer)
- ("C-x C-f" . counsel-find-file)
- :map minibuffer-local-map
- ("C-r" . 'counsel-minibuffer-history)))
-#+end_src
-
-*** Yasnippet
-:PROPERTIES:
-:CUSTOM_ID: Packages-Configuration-Autocompletion-Yasnippet68t1fl6184j0
-:END:
-Yasnippet allows you to insert some pre-made code by just typing a few
-characters. It can even generate some string with Elisp expressions
-and ask the user for some input in some precise places.
-#+begin_src emacs-lisp
-(use-package yasnippet
- :defer t
- :straight (:build t)
- :init
- (yas-global-mode)
- :hook ((prog-mode . yas-minor-mode)
- (text-mode . yas-minor-mode)))
-#+end_src
-
-Of course, yasnippet wouldn’t be as awesome as it is without pre-made
-snippets.
-#+begin_src emacs-lisp
-(use-package yasnippet-snippets
- :defer t
- :after yasnippet
- :straight (:build t))
-#+end_src
-
-Similarly, yatemplate offers pre-made files rather than just strings.
-That’s still yasnippet by the way.
-#+begin_src emacs-lisp
-(use-package yatemplate
- :defer t
- :after yasnippet
- :straight (:build t))
-#+end_src
-
-And finally, with ivy you can choose your snippets from a menu if
-you’re not sure or if you don’t remember what your snippet is.
-#+begin_src emacs-lisp
-(use-package ivy-yasnippet
- :defer t
- :after (ivy yasnippet)
- :straight (:build t)
- :general
- (phundrak/leader-key
- :infix "i"
- :packages 'ivy-yasnippet
- "y" #'ivy-yasnippet))
-#+end_src
-
-** Applications
-:PROPERTIES:
-:CUSTOM_ID: Packages-Configuration-Applications94i0fl6184j0
-:END:
-*** Bitwarden
-:PROPERTIES:
-:CUSTOM_ID: Packages-Configuration-Applications-Bitwarden-cjme4wv0rdj0
-:END:
-This package is still a very much work in progress one I’m developing
-in order to interact with Bitwarden in Emacs with the help of the
-[[https://github.com/bitwarden/cli][Bitwarden CLI]]. Use at your own risks.
-#+begin_src emacs-lisp
-(use-package bitwarden
- :defer t
- :straight (bitwarden :build t
- :type git
- :host nil
- :repo "https://labs.phundrak.com/phundrak/bitwarden.el"))
-#+end_src
-
-*** Calendar
-:PROPERTIES:
-:CUSTOM_ID: PackagesConfigurationApplicationsCalendar-u7c4vcb07uj0
-:END:
-I am using the built-in calendar of Emacs, but as I use Evil and the
-bépo layout, many keybindings available by default or through
-=evil-collection= don’t fit my needs perfectly.
-#+begin_src emacs-lisp
-(use-package calendar
- :straight (:type built-in)
- :defer t
- :general
- (:keymaps 'calendar-mode-map
- "»" #'calendar-scroll-left
- "«" #'calendar-scroll-right
- "M-»" #'calendar-scroll-left-three-months
- "M-«" #'calendar-scroll-right-three-months
- "M-r" #'calendar-scroll-left
- "M-c" #'calendar-scroll-right
- "M-S-r" #'calendar-scroll-left-three-months
- "M-S-c" #'calendar-scroll-right-three-months
- "q" #'calendar-exit)
- (phundrak/major-leader-key
- :keymaps 'calendar-mode-map
- "=" #'calendar-count-days-region
- "^" '(:ignore t :wk "beginning")
- "^ w" #'calendar-beginning-of-week
- "^ m" #'calendar-beginning-of-month
- "^ y" #'calendar-beginning-of-year
- "$" '(:ignore t :wk "end")
- "$w" #'calendar-end-of-week
- "$m" #'calendar-end-of-month
- "$y" #'calendar-end-of-year
- "a" '(:ignore t :wk "appointment")
- "aa" #'appt-add
- "ad" #'appt-delete
- "A" #'org-calendar-goto-agenda
- "b" '(:ignore t :wk "go back")
- "bd" '(calendar-backward-day :wk "a day")
- "bw" '(calendar-backward-week :wk "a week")
- "bm" '(calendar-backward-month :wk "a month")
- "by" '(calendar-backward-year :wk "a year")
- "d" '(:ignore t :wk "diary")
- "da" '(diary-show-all-entries :wk "all entries")
- "dd" '(diary-view-entries :wk "entries")
- "dm" #'diary-mark-entries
- "do" #'diary-view-other-diary-entries
- "di" '(:ignore t :wk "insert")
- "die" '(diary-insert-entry :wk "entry")
- "die" '(diary-insert-block-entry :wk "block entry")
- "diw" '(diary-insert-weekly-entry :wk "weekly")
- "dim" '(diary-insert-monthly-entry :wk "monthly")
- "diy" '(diary-insert-yearly-entry :wk "yearly")
- "F" '(:ignore t :wk "files")
- "Fa" #'org-calendar-goto-agenda
- "f" '(:ignore t :wk "go forward")
- "fd" '(calendar-forward-day :wk "a day")
- "fw" '(calendar-forward-week :wk "a week")
- "fm" '(calendar-forward-month :wk "a month")
- "fy" '(calendar-forward-year :wk "a year")
- "g" '(:ignore t :wk "goto")
- "gd" #'calendar-goto-date
- "gm" #'calendar-other-month
- "gt" #'calendar-goto-today
- "h" '(:ignore t :wk "holidays")
- "hl" #'calendar-list-holidays
- "hm" #'calendar-mark-holidays
- "H" '(:ignore t :wk "HTML export")
- "Hm" #'cal-html-cursor-month
- "Hy" #'cal-html-cursor-year
- "M" #'calendar-other-month))
-#+end_src
-
-*** Docker
-:PROPERTIES:
-:CUSTOM_ID: Packages-Configuration-Applications-Docker5ul0fl6184j0
-:END:
-Docker is an awesome tool for reproducible development environments.
-Due to this, I absolutely need a mode for editing Dockerfiles.
-#+begin_src emacs-lisp
-(use-package dockerfile-mode
- :defer t
- :straight (:build t)
- :hook (dockerfile-mode . lsp-deferred)
- :init
- (put 'docker-image-name 'safe-local-variable #'stringp)
- :mode "Dockerfile\\'"
- :general
- (phundrak/major-leader-key
- :keymaps 'general-mode-map
- :packages 'lsp-mode
- "l" '(:keymap lsp-command-map :which-key "lsp")))
-#+end_src
-
-The ~docker~ package also provides interactivity with Docker and
-docker-compose from Emacs.
-#+begin_src emacs-lisp
-(use-package docker
- :defer t
- :straight (:build t))
-#+end_src
-
-*** Elfeed
-:PROPERTIES:
-:CUSTOM_ID: Packages-Configuration-Applications-Elfeedoip0fl6184j0
-:END:
-Elfeed is a nice Atom and RSS reader for Emacs. The only thing I want
-to change for now is the default search filter: I want to see not only
-unread news but read news as well, a bit like my emails; and where the
-database is to be stored.
-#+begin_src emacs-lisp
-(use-package elfeed
- :defer t
- :straight (:build t)
- :config
- <