From 8c0426e4402bb6f9ed6d3516ebefb00956db0878 Mon Sep 17 00:00:00 2001 From: SqrtMinusOne Date: Sun, 26 Jun 2022 19:05:55 +0000 Subject: [PATCH] deploy: 9f0766a9101c4f95b1290a757fe0978f03916058 --- configs/console/index.html | 170 +++- configs/desktop/index.html | 486 +++++++---- configs/emacs/index.html | 1054 ++++++++++++++++-------- configs/guix/index.html | 108 ++- configs/mail/index.html | 77 +- configs/readme/index.html | 46 +- js/dynamic-toc.js | 121 +++ ox-hugo/lisp_cycles.png | Bin 0 -> 37388 bytes posts/2021-02-27-gmail/index.html | 41 +- posts/2021-05-01-org-python/index.html | 52 +- posts/2021-09-07-emms/index.html | 48 +- posts/2021-10-04-emacs-i3/index.html | 34 +- posts/2022-01-03-exwm/index.html | 47 +- posts/2022-02-12-literate/index.html | 36 +- posts/2022-05-09-pdf/index.html | 43 +- posts/hello-world/index.html | 22 +- sass/researcher.min.css | 2 +- 17 files changed, 1787 insertions(+), 600 deletions(-) create mode 100644 js/dynamic-toc.js create mode 100644 ox-hugo/lisp_cycles.png diff --git a/configs/console/index.html b/configs/console/index.html index de5efb8..e11fbc0 100644 --- a/configs/console/index.html +++ b/configs/console/index.html @@ -58,10 +58,13 @@
-
-

Console

-

.profile

-

Environment

+ +
+

Console

+
+

Console

+

.profile

+

Environment

export QT_QPA_PLATFORMTHEME="qt5ct"
 export QT_AUTO_SCREEN_SCALE_FACTOR=0
 

Set ripgrep config path

@@ -73,7 +76,7 @@ export IS_ANDROID=true [[ -f ~/.android_profile ]] && . ~/.android_profile fi -

My paths

+

My paths

My script folders

if [ -d "$HOME/bin" ] ; then
     export PATH="$HOME/bin:$PATH"
@@ -83,7 +86,7 @@
 if [ -d "$HOME/.local/bin" ] ; then
     export PATH="$HOME/.local/bin:$PATH"
 fi
-

Guix settings

+

Guix settings

Enable extra profiles

if [ -z "$IS_ANDROID" ]; then
     GUIX_EXTRA_PROFILES=$HOME/.guix-extra-profiles
@@ -103,7 +106,7 @@
 
export GUIX_PACKAGE_PATH=~/guix-packages
 

Locale settings

export GUIX_LOCPATH=$HOME/.guix-extra-profiles/console/console/lib/locale
-

Other package managers

+

Other package managers

Using other package managers with Guix requires some extra work.

Cask

if [ -d "$HOME/.cask" ]; then
@@ -125,19 +128,19 @@
 
if [ -d "$HOME/.nix-profile" ]; then
     export XDG_DATA_DIRS="$XDG_DATA_DIRS:$HOME/.nix-profile/share/applications"
 fi
-

npm

+

npm

npm is especially cumbersome, for instance because by default it tries to install packages to /gnu/store/.

In principle, one can set a prefix like this:

prefix=/home/pavel/.npm-packages
 

But I also want to use node from conda occasionally, where prefix is already set correctly. So instead of tangling the above to the ~/.npmrc directly, I set an environment variable in the profile:

export NPM_CONFIG_USERCONFIG=$HOME/._npmrc
-

The variable is unset in a script in Guix.org.

+

The variable is unset in a script in Guix.org.

Set PATH & MANPATH

NPM_PACKAGES="${HOME}/.npm-packages"
 
 export PATH="$PATH:$NPM_PACKAGES/bin"
 export MANPATH="${MANPATH-$(manpath)}:$NPM_PACKAGES/share/man"
-

XResources

+

XResources

@@ -153,7 +156,7 @@
if [ -z "$IS_ANDROID" ]; then
     xrdb ~/.Xresources
 fi
-

OFF (OFF) Package manager paths

+

OFF (OFF) Package manager paths

Turned off for now, because probably it won’t be necessary in Guix.

LaTeX

if [ -d "/usr/local/texlive/2020" ]; then
@@ -186,14 +189,14 @@
     PERL_MB_OPT="--install_base \"/home/pavel/perl5\""; export PERL_MB_OPT;
     PERL_MM_OPT="INSTALL_BASE=/home/pavel/perl5"; export PERL_MM_OPT;
 fi
-

Bash

-

.bash_profile

+

Bash

+

.bash_profile

[[ -f ~/.profile ]] && . ~/.profile
 
 [[ -f ~/.bashrc ]] && . ~/.bashrc
-

.bashrc

+

.bashrc

My .bashrc, which has pieces from the default ones in Guix & Manjaro, as well some mine settings.

-

Startup & environment

+

Startup & environment

Export ‘SHELL’ to child processes. Programs such as ‘screen’ honor it and otherwise use /bin/sh.

export SHELL
 

We are being invoked from a non-interactive shell. If this is an SSH session (as in “ssh host command”), source /etc/profile so we get PATH and other essential variables.

@@ -228,7 +231,7 @@
xhost +local:root > /dev/null 2>&1
 

Set manpager to bat

export MANPAGER="sh -c 'sed -e s/.\\\\x08//g | bat -l man -p'"
-

Launch fish

+

Launch fish

Launch fish shell unless bash itself is launched from fish.

use_fish=true
 
@@ -237,7 +240,7 @@
     exec fish
 fi
 

The rest of .bashrc is not executed if fish was launched.

-

Colors

+

Colors

Setting for colors, packed in the default .bashrc in Manjaro

use_color=true
 
@@ -285,7 +288,7 @@
 fi
 
 unset use_color safe_term match_lhs sh
-

Settings

+

Settings

Some general bash settings.

References:

@@ -390,7 +393,7 @@ end

Suppress fish greeting

set fish_greeting
-

Anaconda

+

Anaconda

First, a function to initialize anaconda.

function init_conda
     eval /home/pavel/.guix-extra-profiles/dev/dev/bin/conda "shell.fish" "hook" $argv | source
@@ -403,7 +406,7 @@
 
if test -n "$EMACS_CONDA_ENV";
     conda activate $EMACS_CONDA_ENV
 end
-

Colors

+

Colors

Fish seems to have hardcoded colorcodes in some color settings. I set these to base16 colors so they would match Xresources.

set fish_color_command cyan
 set fish_color_comment green
@@ -414,19 +417,19 @@
 set fish_color_param magenta
 set fish_color_quote brwhite
 set fish_color_redirection yellow
-

Keybindings

+

Keybindings

bind -M insert \el forward-char
 bind -M insert \eh backward-char
 bind -M insert \ew forward-word
 bind -M insert \eb backward-word
-

Functions

+

Functions

A small function to open the file with $EDITOR.

function e
     eval $EDITOR $argv
 end
-

direnv

+

direnv

direnv hook fish | source
-

Nushell

+

Nushell

@@ -465,7 +468,7 @@ primitive_date="r" primitive_int="c" primitive_decimal="c" -

Starship prompt

+

Starship prompt

@@ -561,7 +564,7 @@ [rust] symbol = " " -

Tmux

+

Tmux

@@ -579,13 +582,13 @@

tmux is my terminal multiplexer of choice.

It provides pretty sane defaults, so the config is not too large. I rebind the prefix to C-a though.

-

Term settings

+

Term settings

I have no idea how and why these two work.

set -g default-terminal "screen-256color"
 set -ga terminal-overrides ",*256col*:Tc"
 

History limit.

set -g history-limit 20000
-

Keybindings

+

Keybindings

Enable vi keys and mouse.

set-window-option -g mode-keys vi
 set-option -g xterm-keys on
@@ -609,7 +612,7 @@
 bind-key T previous-window
 

Reload the config.

bind r source-file ~/.tmux.conf
-

Copy to clipboard

+

Copy to clipboard

@@ -625,7 +628,7 @@

Make tmux copying copy to clipboard as well

bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "xclip -selection clipboard -i"
 bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "xclip -selection clipboard -i"
-

UI

+

UI

I generated the following with tmuxline.vim plugin and palenight theme for vim-airline

# This tmux statusbar config was created by tmuxline.vim
 # on Wed, 22 Jan 2020
@@ -650,7 +653,7 @@
 setw -g window-status-current-format "#[fg=#333747,bg=#474b59,nobold,nounderscore,noitalics]#[fg=#bfc7d5,bg=#474b59] #I #W #[fg=#474b59,bg=#333747,nobold,nounderscore,noitalics]"
 

Source the line config:

source ~/.tmux.line.conf
-

Alacritty

+

Alacritty

@@ -741,7 +744,7 @@ - { key: NumpadAdd, mods: Control, action: IncreaseFontSize } - { key: Minus, mods: Control, action: DecreaseFontSize } - { key: NumpadSubtract, mods: Control, action: DecreaseFontSize } -

Various console applications

+

Various console applications

@@ -824,14 +827,14 @@
-

ripgrep config

+

ripgrep config

Occasionally I can’t exclude certain files from ripgrep via the VCS settings, so here is a simple config to ignore certain files globally.

--ignore-file=/home/pavel/.config/ripgrep/ripgrepignore
 

The corresponding ignore file:

*.ts.snap
-

By default ripgrep doesn’t read any configs, so it is necessary to set the RIPGREP_CONFIG_PATH variable in the .profile.

-

Misc scripts

-

nt - exec command with a finished notification

+

By default ripgrep doesn’t read any configs, so it is necessary to set the RIPGREP_CONFIG_PATH variable in the .profile.

+

Misc scripts

+

nt - exec command with a finished notification

Usage:

nt <command>
 
command="$@"
@@ -844,7 +847,7 @@
 else
     notify-send "Terminal" "Command execution complete"
 fi
-

autocommit

+

autocommit

A script to autocommit files in a repository. I use it to sync my org directory and password store. I guess it’s not how git is intended to be used, but it works for me.

Usage:

autocommit <repository> [-F]
@@ -937,13 +940,13 @@
 

mcron job:

(job "0 * * * *" "autocommit ~/Documents/org-mode")
 (job "0,15,30,45 * * * *" "autocommit ~/.password-store")
-

Guix settings

+

Guix settings

(my/format-guix-dependencies)
 
(specifications->manifest
  '(
    <<packages()>>))
-

Android notes

+

Android notes

SSH instructions: https://wiki.termux.com/wiki/Remote_Access

Don’t forget to install the following termux packages:

@@ -981,7 +984,7 @@
  • cleanup $PREFIX/etc/motd to remove hello message.
  • copy the required font at $HOME/.termux/font.ttf and run termux-reload-settings.
  • -

    Installation of DT’s colorscripts:

    +

    Installation of DT’s colorscripts:

    git clone https://gitlab.com/dwt1/shell-color-scripts.git
     cd shell-color-scripts
     

    Apply a patch:

    @@ -1000,6 +1003,85 @@ sudo cp -rf colorscripts/* $PREFIX/opt/shell-color-scripts/colorscripts sudo cp colorscript.sh $PREFIX/bin/colorscript + +
    + + + +

    -
    -

    Desktop

    -

    My general desktop environment configuration.

    + +
    +

    Desktop

    +
    +

    Desktop

    +

    My general desktop environment configuration.

    Parts prefixed with (OFF) are not used, but kept for historic purposes. For some reason GitHub’s org renderer ignores TODO status, hence such a prefix. Round brackets instead of square ones to prevent GitHub’s org renderer from screwing up.

    References:

    -

    Global customization

    -

    Colors

    +

    Global customization

    +

    Colors

    My favorite color theme is Palenight (color codes), and I want to have one source of truth for these colors. Except for Emacs itself, which has doom-palenight (and in which I occasionally switch to doom-one-light, e.g. when reading a long text), it can be done rather nicely with Org Mode.

    First, let’s define a table with all the color codes:

    @@ -176,8 +179,8 @@ color))

    Test:

    <<get-color(name="red", quote=1)>>
    -

    Xresources

    -

    Colors in Xresources

    +

    Xresources

    +

    Colors in Xresources

    However, I’d rather use the Xresources file wherever possible. Here is the code to generate an Xresources file from this table:

    (mapconcat
    @@ -193,7 +196,7 @@
     *background: <<get-color(name="black")>>
     *foreground: <<get-color(name="white")>>
     

    So, whenever a program is capable of reading .Xresources, it will get colors from there, otherwise, it will get colors from noweb expressions in the literate config. Thus, in both cases, the color is set in a single Org Mode table.

    -

    Fonts

    +

    Fonts

    Also, Xresources are used to set Xft settings. Unfortunately, the DPI setting has to be unique for each machine, which means I cannot commit Xresources to the repo.

    (let ((hostname (system-name)))
    @@ -202,7 +205,7 @@
     	((string-equal hostname "indigo") 120)
     	(t 96)))
     
    Xft.dpi: <<get-dpi()>>
    -

    Themes

    +

    Themes

    A few programs I use to customize the apperance are listed below.

    @@ -234,7 +237,7 @@
    -

    xsettingsd is a lightweight daemon which configures X11 applications. It is launched with shepherd in the Services section.

    +

    xsettingsd is a lightweight daemon which configures X11 applications. It is launched with shepherd in the Services section.

    Net/ThemeName "Matcha-dark-azul"
     Net/IconThemeName "Papirus-Dark"
     Gtk/DecorationLayout "menu:minimize,maximize,close"
    @@ -244,7 +247,7 @@
     Xft/Antialias 1
     Xft/Hinting 0
     Xft/HintStyle "hintnone"
    -

    MIME

    +

    MIME

    Setting the default MIME types

    [Default Applications]
     text/html=firefox.desktop
    @@ -261,7 +264,7 @@
     [Added Associations]
     x-scheme-handler/tg=userapp-Telegram Desktop-7PVWF1.desktop;
     application/pdf=org.pwmt.zathura.desktop
    -

    Device-specific settings

    +

    Device-specific settings

    @@ -291,7 +294,7 @@ elif [ "$hostname" = "eminence" ]; then xgamma -gamma 1.25 fi -

    EXWM

    +

    EXWM

    Settings for Emacs X Window Manager, a tiling WM implemented in Emacs Lisp. This part has a few bits copied from my blog post.

    References:

    -

    Startup & UI

    -

    Xsession

    +

    Startup & UI

    +

    Xsession

    First things first, Emacs has to be launched as a window manager. On a more conventional system I’d create a .desktop file in some system folder that can be seen by a login manager, but in the case of Guix it’s a bit more complicated, because all such folders are not meant to be changed manually.

    @@ -348,7 +351,7 @@ # Run the Emacs startup script as a session. # exec dbus-launch --exit-with-session ~/.emacs.d/run-exwm.sh exec dbus-launch --exit-with-session emacs -mm --debug-init -l ~/.emacs.d/desktop.el -

    Startup apps

    +

    Startup apps

    Now that Emacs is launched, it is necessary to set up the EXWM-specific parts of config.

    I want to launch some apps from EXWM instead of the Xsession file for two purposes:

    -

    password-store-ivy

    +

    password-store-ivy

    password-store-ivy is another package of mine, inspired by rofi-pass.

    (use-package password-store-ivy
       :straight (:host github :repo "SqrtMinusOne/password-store-ivy")
       :after (exwm))
    -

    emojis

    +

    emojis

    emojify is an Emacs package that adds emoji display to Emacs. While its primary capacity is no longer necessary in Emacs 28, it a few functions to insert emojis are still handy.

    (use-package emojify
       :straight t)
    @@ -776,8 +779,8 @@
          (list
           (password-store-ivy--get-wait-command 10)
           "xdotool key Shift+Insert"))))
    -

    Keybindings

    -

    EXWM keybindings

    +

    Keybindings

    +

    EXWM keybindings

    Setting keybindings for EXWM. This actually has to be in the :config block of the use-package form, that is it has to be run after EXWM is loaded, so I use noweb to put this block in the correct place.

    First, some prefixes for keybindings that are always passed to EXWM instead of the X application in line-mode:

    (setq exwm-input-prefix-keys
    @@ -901,7 +904,7 @@
         (exwm-input--set-key (car i) (cdr i)))
       (when exwm--connection
         (exwm-input--update-global-prefix-keys)))
    -

    App shortcuts

    +

    App shortcuts

    A transient hydra for shortcuts for the most frequent apps.

    (defun my/run-in-background (command)
       (let ((command-parts (split-string command "[ ]+")))
    @@ -923,13 +926,13 @@
       ("s" (lambda () (interactive) (my/run-in-background "slack-wrapper")))
       ("e" (lambda () (interactive) (my/run-in-background "flatpak run org.telegram.desktop")))
       ("d" (lambda () (interactive) (my/run-in-background "flatpak run com.discordapp.Discord"))))
    -

    Locking up

    +

    Locking up

    Run i3lock.

    (defun my/exwm-lock ()
       (interactive)
       (my/run-in-background "i3lock -f -i /home/pavel/Pictures/lock-wallpaper.png"))
    -

    Fixes

    -

    Catch and report all errors raised when invoking command hooks

    +

    Fixes

    +

    Catch and report all errors raised when invoking command hooks

    @@ -948,7 +951,7 @@ (setq-local standard-output (current-buffer)) (backtrace) (buffer-string)))))) -

    Improve floating windows behavior

    +

    Improve floating windows behavior

    These 3 settings seem to cause particular trouble with floating windows. Setting them to nil improves the stability greatly.

    (defun my/fix-exwm-floating-windows ()
       (setq-local exwm-workspace-warp-cursor nil)
    @@ -956,7 +959,7 @@
       (setq-local focus-follows-mouse nil))
     
     (add-hook 'exwm-floating-setup-hook #'my/fix-exwm-floating-windows)
    -

    EXWM config

    +

    EXWM config

    And the EXWM config itself.

    (defun my/exwm-init ()
       (exwm-workspace-switch 1)
    @@ -997,7 +1000,7 @@
     
       (perspective-exwm-mode)
       (exwm-enable))
    -

    i3wm

    +

    i3wm

    @@ -1024,7 +1027,7 @@
  • i3wm docs
  • i3-gaps wiki
  • -

    General settings

    +

    General settings

    set $mod Mod4
     font pango:monospace 10
     
    @@ -1050,7 +1053,7 @@
     
     # exit i3 (logs you out of your X session)
     bindsym $mod+Shift+e exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -b 'Yes, exit i3' 'i3-msg exit'"
    -

    Managing windows

    +

    Managing windows

    @@ -1064,7 +1067,7 @@

    Some keybindings for managing windows.

    -

    emacs-i3-integration is a script to pass some command to Emacs to get a consistent set of keybindings in both i3 and Emacs. Check out the section in Emacs.org for details.

    +

    emacs-i3-integration is a script to pass some command to Emacs to get a consistent set of keybindings in both i3 and Emacs. Check out the section in Emacs.org for details.

    Kill focused windows

    bindsym $mod+Shift+q exec emacs-i3-integration kill
     

    Change focus

    @@ -1114,7 +1117,7 @@
    bindsym $mod+i sticky toggle
     

    Set windows as floating and sticky, move to the top right.

    bindsym $mod+x floating enable; sticky enable; move position 1220 0; resize set width 700 px
    -

    Workspaces

    +

    Workspaces

    set $w1 "1 🚀"
     set $w2 "2 🌍"
     set $w3 "3 💬"
    @@ -1146,7 +1149,7 @@
     bindsym $mod+Shift+8 move container to workspace $w8
     bindsym $mod+Shift+9 move container to workspace $w9
     bindsym $mod+Shift+0 move container to workspace $w10
    -

    Rules

    +

    Rules

    Rules to automatically assign applications to workspaces and do other stuff, like enable floating.

    Most apps can be distinguished by a WM class (you can get one with xprop), but in some cases it doesn’t work, e.g. for terminal applications. In that case rules can be based on a window title, for instance.

    However, watch out for the following: rule such as for_window [title="ncmpcpp.*"] move to workspace $w9 will move any window with a title starting with ncmpcpp to workspace $w9. For instance, it moves your browser when you google “ncmpcpp”.

    @@ -1180,9 +1183,9 @@ for_window [title="Picture-in-Picture"] sticky enable for_window [window_role="GtkFileChooserDialog"] resize set width 1000 px height 800 px for_window [window_role="GtkFileChooserDialog"] move position center -

    Scratchpad

    +

    Scratchpad

    Scratch terminal, inspired by this Luke Smith’s video.

    -

    Launch script

    +

    Launch script

    First of all, we have to distinguish a scratchpad terminal from a normal one. To do that, one can create st with a required classname.

    Then, it would be cool not to duplicate scratchpads, so the following script first looks for a window with a created classname. If it exists, the script just toggles the scratchpad visibility. Otherwise, a new instance of a window is created.

    CLASSNAME="dropdown_tmux"
    @@ -1193,7 +1196,7 @@
     else
         setsid -f ${COMMAND}
     fi
    -

    i3 config

    +

    i3 config

    # Scratchpad
     for_window [instance="dropdown_*"] floating enable
     for_window [instance="dropdown_*"] move scratchpad
    @@ -1202,7 +1205,7 @@
     for_window [instance="dropdown_*"] move position center
     
     bindsym $mod+u exec ~/bin/scripts/dropdown
    -

    Gaps & borders

    +

    Gaps & borders

    The main reason to use i3-gaps

    # Borders
     # for_window [class=".*"] border pixel 0
    @@ -1217,7 +1220,7 @@
     gaps outer $default_outer
     
     smart_gaps on
    -

    Keybindings

    +

    Keybindings

    mode "inner gaps" {
         bindsym plus gaps inner current plus 5
         bindsym minus gaps inner current minus 5
    @@ -1250,7 +1253,7 @@
     
     bindsym $mod+g mode "inner gaps"
     bindsym $mod+Shift+g mode "outer gaps"
    -

    Move & resize windows

    +

    Move & resize windows

    @@ -1320,7 +1323,7 @@ } bindsym $mod+m mode "move" focus floating -

    OFF (OFF) Intergration with dmenu

    +

    OFF (OFF) Intergration with dmenu

    dmenu is a dynamic menu program for X. I’ve opted out of using it in favour of rofi, but here is a relevant bit of config.

    Scripts are located in the bin/scripts folder.

    # dmenu
    @@ -1338,8 +1341,8 @@
     }
     
     bindsym $mod+b exec --no-startup-id dmenu-buku
    -

    Integration with rofi

    -

    Keybindings to launch rofi. For more detail, look the Rofi section.

    +

    Integration with rofi

    +

    Keybindings to launch rofi. For more detail, look the Rofi section.

    bindsym $mod+d exec "rofi -modi 'drun,run' -show drun"
     bindsym $mod+b exec --no-startup-id rofi-buku-mine
     bindsym $mod+minus exec rofi-pass
    @@ -1354,9 +1357,9 @@
         bindsym k exec rofi-pass; mode default
         bindsym Escape mode "default"
     }
    -

    Launching apps & misc keybindings

    +

    Launching apps & misc keybindings

    I prefer to use a separate mode to launch most of my apps, with some exceptions.

    -

    Apps

    +

    Apps

    # Launch apps
     # start a terminal at workspace 1
     bindsym $mod+Return exec "i3-msg 'workspace 1 🚀; exec alacritty'"
    @@ -1382,7 +1385,7 @@
         # bindsym a exec emacsclient -c; mode default
         # bindsym Shift+a exec emacs; mode default
     }
    -

    Media controls & brightness

    +

    Media controls & brightness

    # Pulse Audio controls
     bindsym XF86AudioRaiseVolume exec --no-startup-id "ponymix increase 5 --max-volume 150"
     bindsym XF86AudioLowerVolume exec --no-startup-id "ponymix decrease 5 --max-volume 150"
    @@ -1401,11 +1404,11 @@
     # Screen brightness
     bindsym XF86MonBrightnessUp exec light -A 5
     bindsym XF86MonBrightnessDown exec light -U 5
    -

    Screenshots

    +

    Screenshots

    # Screenshots
     bindsym --release Print exec "flameshot gui"
     bindsym --release Shift+Print exec "xfce4-screenshooter"
    -

    Colors

    +

    Colors

    Application of the XResources theme to the WM.

    exec xrdb -merge $HOME/.Xresources
     
    @@ -1424,7 +1427,7 @@
     client.unfocused        $bg-color           $inactive-bg-color $inactive-text-color $bg-color       $bg-color
     client.focused_inactive $active-color       $inactive-bg-color $inactive-text-color $bg-color       $bg-color
     client.urgent           $urgent-bg-color    $urgent-bg-color   $urgent-text-color   $bg-color       $urgent-bg-color
    -

    OFF (OFF) i3blocks

    +

    OFF (OFF) i3blocks

    I’ve opted out of i3bar & i3blocks for polybar

    bar {
         status_command i3blocks -c ~/.config/i3/i3blocks.conf
    @@ -1456,7 +1459,7 @@
     	urgent_workspace   $urgent-bg-color   $urgent-bg-color   $urgent-text-color
         }
     }
    -

    Keyboard Layout

    +

    Keyboard Layout

    A script to set Russian-English keyboard layout:

    setxkbmap -layout us,ru
     setxkbmap -model pc105 -option 'grp:win_space_toggle' -option 'grp:alt_shift_toggle'
    @@ -1472,7 +1475,7 @@
     
    # Layout
     exec_always --no-startup-id set_layout
     bindsym $mod+slash exec toggle_layout
    -

    Autostart

    +

    Autostart

    # Polybar
     exec_always --no-startup-id "bash /home/pavel/bin/polybar.sh"
     
    @@ -1495,7 +1498,7 @@
     exec "xmodmap ~/.Xmodmap"
     # exec "xrdb -merge ~/.Xresources"
     # exec "bash ~/bin/autostart.sh"
    -

    Polybar

    +

    Polybar

    @@ -1519,14 +1522,14 @@ -

    General settings

    +

    General settings

    In relation to literate configuration, this is the most crazy advanced case of the former so far in my config.

    My polybar has:

    -

    Colors

    +

    Colors

    The “colors” part is straightforward enough. Polybar can use Xresources, so we just need to generate the appropriate bindings of Xresources to the polybar variables:

    (mapconcat
    @@ -1542,7 +1545,7 @@
     
     background = ${xrdb:background}
     ; foreground = ${xrdb:foreground}
    -

    Glyph settings

    +

    Glyph settings

    As for the module decorations though, I find it ironic that with all this fancy rendering around I have to resort to Unicode glyphs.

    Anyhow, the approach is to put a glyph between two blocks like this:

    block1  block2
    @@ -1575,7 +1578,7 @@
     
    [glyph]
     gleft = 
     gright = 
    -

    Defining modules

    +

    Defining modules

    As we want to interweave polybar modules with these glyphs in the right order and with the right colors, it is reasonable to define a single source of truth:

    @@ -1698,7 +1701,7 @@ (lambda (el) (string-equal (nth 1 el) module)) table)))

    That block is meant to be invoked in each module definition.

    -

    Generating glyphs

    +

    Generating glyphs

    To generate the required set of glyphs, we need a glyph for every possible combination of adjacent colors that can occur in polybar.

    Most of these combinations can be inferred from the polybar_modules table, the rest are defined in another table:

    @@ -1798,7 +1801,7 @@

    As of now, 15 of such modules is generated.

    Include this to the polybar config itself:

    <<polybar-generate-glyphs()>>
    -

    Generating set of modules

    +

    Generating set of modules

    To configure polybar itself, we need to generate a set of modules for each monitor.

    The parameters here, excluding the two required tables, are:

    @@ -2165,7 +2168,7 @@ type = custom/script exec = /home/pavel/bin/polybar/ipstack-vpn.sh interval = 1200 -

    openvpn

    +

    openvpn

    A module to check if openvpn is running.

    vpn=$(pgrep -a openvpn$ | head -n 1 | awk '{print $NF }' | cut -d '.' -f 1)
     if [ -n "$vpn" ]; then
    @@ -2178,7 +2181,7 @@
     exec = /home/pavel/bin/polybar/openvpn.sh
     format-background = <<get-polybar-bg(module="openvpn")>>
     interval = 1200
    -

    xkeyboard

    +

    xkeyboard

    Current keyboard layout

    [module/xkeyboard]
     type = internal/xkeyboard
    @@ -2189,7 +2192,7 @@
     label-layout = %icon%
     layout-icon-0 = ru;RU
     layout-icon-1 = us;US
    -

    battery

    +

    battery

    [module/battery]
     type = internal/battery
     battery = BAT0
    @@ -2208,7 +2211,7 @@
     ramp-capacity-2 = 
     ramp-capacity-3 = 
     ramp-capacity-4 = 
    -

    weather

    +

    weather

    Gets current weather from wttr.in

    bar_format="${BAR_FORMAT:-"%t"}"
     location="${LOCATION:-"Saint-Petersburg"}"
    @@ -2230,7 +2233,7 @@
     ; format-underline = ${colors.red}
     format-background = <<get-polybar-bg(module="weather")>>
     interval = 1200
    -

    sun

    +

    sun

    @@ -2277,7 +2280,7 @@ exec = /home/pavel/bin/polybar/sun.sh format-background = <<get-polybar-bg(module="sun")>> interval = 60 -

    aw-afk

    +

    aw-afk

    Prints out a current uptime and non-AFK time from ActivityWatch server

    @@ -2311,7 +2314,7 @@ exec = /home/pavel/bin/polybar/aw_afk.sh interval = 60 format-background = <<get-polybar-bg(module="aw-afk")>> -

    date

    +

    date

    Current date

    [module/date]
     type = internal/date
    @@ -2325,7 +2328,7 @@
     
     format-background = <<get-polybar-bg(module="date")>>
     label = "%date% %time%"
    -

    pomm

    +

    pomm

    Pomodoro module.

    if ps -e | grep emacs >> /dev/null; then
         emacsclient --eval "(if (boundp 'pomm-current-mode-line-string) pomm-current-mode-line-string \"\") " | xargs echo -e
    @@ -2335,7 +2338,7 @@
     exec = /home/pavel/bin/polybar/pomm.sh
     interval = 1
     format-underline = ${colors.light-green}
    -

    SEP

    +

    SEP

    A simple separator

    [module/SEP]
     type = custom/text
    @@ -2344,7 +2347,7 @@
     content-padding = 0
     content-margin = 0
     interval = 100000
    -

    TSEP

    +

    TSEP

    A separator, which appears only if monitor is set to have a tray in the launch script

    if [ ! -z "$TRAY" ] && [ "$TRAY" != "none" ]; then
         echo "| "
    @@ -2354,7 +2357,7 @@
     exec = /home/pavel/bin/polybar/tray-sep.sh
     format-foreground = ${colors.magenta}
     interval = 100000
    -

    i3

    +

    i3

    Show i3wm workspaces

    [module/i3]
     type = internal/i3
    @@ -2390,7 +2393,7 @@
     label-urgent-background = ${colors.red}
     label-urgent-foreground = ${colors.black}
     label-urgent-padding = 1
    -

    Rofi

    +

    Rofi

    @@ -2406,7 +2409,7 @@

    rofi is another dynamic menu generator. It can act as dmenu replacement but offers a superset of dmenu’s features.

    -

    Theme

    +

    Theme

    A theme, based on dracula theme for rofi, but with palenight colorscheme.

    (apply
    @@ -2552,8 +2555,8 @@
         margin:           0px 0.3000em 0.0000em 0.0000em ;
         text-color:       inherit;
     }
    -

    Scripts

    -

    Buku bookmarks

    +

    Scripts

    +

    Buku bookmarks

    Inspired by the knatsakis/rofi-buku script.

    if [ $(hostname) = 'pdsk' ]; then
         BUKU="/home/pavel/.local/bin/buku"
    @@ -2589,14 +2592,14 @@
         url=$($BUKU -f 10 -p $index)
         echo ${url#"waiting for input"} | cut -d ' ' -f 1 | xargs -I % $COMMAND
     }
    -

    Man pages

    +

    Man pages

    Inspired by this Luke Smith’s video.

    A script to open a man page with zathura. There is no particular reason why one should look through man pages in pdf viewer rather than in console, but why not.

    SELECTED=$(man -k . | rofi -dmenu -l 20 | awk '{print $1}')
     if [[ ! -z $SELECTED ]]; then
         man -Tpdf $SELECTED | zathura -
     fi
    -

    Emojis

    +

    Emojis

    @@ -2611,7 +2614,7 @@
    -

    pass

    +

    pass

    @@ -2635,7 +2638,7 @@ EDITOR=vim default_autotype='username :tab pass' clip=both -

    Flameshot

    +

    Flameshot

    @@ -2692,7 +2695,7 @@ TYPE_TEXT=T TYPE_TOGGLE_PANEL=Space TYPE_UNDO=Ctrl+Z -

    dunst

    +

    dunst

    @@ -3014,7 +3017,7 @@ timeout = 0 # Icon for notifications with critical urgency, uncomment to enable #icon = /path/to/icon -

    keynav

    +

    keynav

    @@ -3048,7 +3051,7 @@ -

    Config

    +

    Config

    # clear all previous keybindings
     clear
     
    @@ -3100,13 +3103,13 @@
     3 click 3
     4 click 4
     5 click 5
    -

    Using with picom

    +

    Using with picom

    I’ve noticed that the program does not play nice with picom’s fade effect. To fix that, add the following to you config:

    fade-exclude = [
       "class_i = 'keynav'",
       "class_g = 'keynav'",
     ]
    -

    Picom

    +

    Picom

    @@ -3128,7 +3131,7 @@
  • Picom on ArchWiki
  • Sample configuration
  • -

    Shadows

    +

    Shadows

    shadow = true;
     shadow-radius = 2;
     shadow-offset-x = -2;
    @@ -3142,7 +3145,7 @@
       "class_g = 'Cairo-clock'",
       "_GTK_FRAME_EXTENTS@:c"
     ];
    -

    Fading

    +

    Fading

    fading = true
     
     fade-in-step = 0.03;
    @@ -3155,7 +3158,7 @@
       "class_i = 'emacs'",
       "class_g = 'emacs'",
     ]
    -

    Opacity

    +

    Opacity

    I don’t use stuff like transparency for inactive windows.

    The first 5 lines of opacity-rule make i3wm’s hidden windows 100% transparent, so I see the background behind the semi-transparent windows in i3wm’s stacked and tabbed layout. Here is StackExchange question about that.

    I also noticed that for some reason it doesn’t play well with Emacs’s built-in transparency, so the last line sets up Emacs transparency at 90%.

    @@ -3173,7 +3176,7 @@ "0:_NET_WM_STATE@[4]:32a = '_NET_WM_STATE_HIDDEN'", "90:class_g = 'Emacs'" ]; -

    General settings

    +

    General settings

    Default general settings. Editing some of these may be neeeded in case of performance issues.

    backend = "xrender";
     vsync = true
    @@ -3195,7 +3198,7 @@
       popup_menu = { opacity = 1; }
       dropdown_menu = { opacity = 1; }
     };
    -

    Zathura

    +

    Zathura

    @@ -3248,9 +3251,9 @@ set notification-error-fg <<get-color(name="color-fg", quote=1)>> set notification-warning-bg <<get-color(name="yellow", quote=1)>> set notification-warning-fg <<get-color(name="color-fg", quote=1)>> -

    Various software

    +

    Various software

    This section generates manifests for various desktop software that I’m using.

    -

    Browsers

    +

    Browsers

    @@ -3269,7 +3272,7 @@
    -

    Office & Multimedia

    +

    Office & Multimedia

    @@ -3308,7 +3311,7 @@
    -

    LaTeX

    +

    LaTeX

    @@ -3339,7 +3342,7 @@
    -

    Dev

    +

    Dev

    @@ -3461,7 +3464,7 @@
    -

    Manifests

    +

    Manifests

    (my/format-guix-dependencies category)
     

    Dev

    @@ -3496,7 +3499,7 @@
    (specifications->manifest
      '(
        <<packages("desktop-rofi")>>))
    -

    Flatpak

    +

    Flatpak

    A lot of proprietary desktop applications can be installed most easily with flatpak & flathub.

    @@ -3550,7 +3553,7 @@ (lambda (c) (concat "flatpak install -y --user " (nth 1 c) " " (nth 0 c))) table "\n") -

    Nix

    +

    Nix

    @@ -3572,10 +3575,10 @@
    nix-channel --update
     

    Installing packages:

    nix-env -i vk-messenger slack
    -

    Services

    +

    Services

    GNU Shepherd is a service management system for GNU Guix.

    I previously used supervisor, but shepherd also seems pretty capable.

    -

    Music

    +

    Music

    @@ -3633,7 +3636,7 @@ #:start (make-forkexec-constructor '("mpd_watcher")) #:stop (make-kill-destructor) #:requires '(mpd))) -

    GNU Mcron

    +

    GNU Mcron

    GNU Mcron is a replacement for cron, written in Scheme.

    (define mcron
       (make <service>
    @@ -3641,7 +3644,7 @@
         #:respawn? #t
         #:start (make-forkexec-constructor '("mcron"))
         #:stop (make-kill-destructor)))
    -

    ActivityWatch

    +

    ActivityWatch

    ActivityWatch is a FOSS time tracker. It tracks screen and application usage and has integrations with browsers, Emacs, etc.

    @@ -3681,28 +3684,28 @@ #:respawn? #t #:start (make-forkexec-constructor '("aw-watcher-window")) #:stop (make-kill-destructor))) -

    PulseEffects

    +

    PulseEffects

    (define pulseeffects
       (make <service>
         #:provides '(pulseeffects)
         #:respawn? #t
         #:start (make-forkexec-constructor '("flatpak" "run" "com.github.wwmm.pulseeffects" "--gapplication-service"))
         #:stop (make-kill-destructor)))
    -

    xsettingsd

    +

    xsettingsd

    (define xsettingsd
       (make <service>
         #:provides '(xsettingsd)
         #:respawn? #t
         #:start (make-forkexec-constructor '("xsettingsd"))
         #:stop (make-kill-destructor)))
    -

    nm-applet

    +

    nm-applet

    (define nm-applet
       (make <service>
         #:provides '(nm-applet)
         #:respawn? #t
         #:start (make-forkexec-constructor '("nm-applet"))
         #:stop (make-kill-destructor)))
    -

    Discord rich presence

    +

    Discord rich presence

    References:

    @@ -3797,7 +3800,7 @@
    -

    Guix settings

    +

    Guix settings

    Other desktop programs I use are listed below.

    @@ -3911,6 +3914,213 @@ '( <<packages()>>)) + +
    +
    + Table of Contents + +
    + + +

    -
    -

    Emacs config

    -
    + +
    +

    Emacs config

    +
    +

    Emacs config

    +

    One day we won’t hate one another, no young boy will march to war and I will clean up my Emacs config. But that day isn’t today.

    -

    Introduction

    +

    Introduction

    My configuration of GNU Emacs, an awesome text editor program that can do almost anything.

    At the moment of this writing, this “almost anything” includes:

      @@ -91,7 +94,7 @@ Emacs is also particularly good at writing Lisp code, e.g. Clojure, Common Lisp,

      Occasionally I save some promising experimentations from scratch buffers without much comment. Or I may not have enough time to describe things in substantial detail. Or, as it is at the moment when I’m writing this, I have the time to write down whatever I consider necessary. Plus I usually incorporate my blog posts back into the config.

      Of course, human minds share many similarities, so if you are an avid Emacs user, you have a chance to extract something of value from this document.

      If however, by some twist of fate, this document is one of the first things you see about Emacs, it won’t be a good resource for you. And you definitely shouldn’t try to launch this config as it is. If I could suggest only one resource, I’d advise David Wilson’s System Crafters YouTube channel.

      -

      Some remarks

      +

      Some remarks

      I decided not to keep configs for features that I do not use anymore because this config is already huge. But here are the last commits that had these features presented.

    @@ -143,12 +146,12 @@ Emacs is also particularly good at writing Lisp code, e.g. Clojure, Common Lisp,
    -

    Bootstrap

    +

    Bootstrap

    Setting up the environment, performance tuning and a few basic settings.

    First things first, lexical binding.

    ;;; -*- lexical-binding: t -*-
    -

    Packages

    -

    straight.el

    +

    Packages

    +

    straight.el

    Straight.el is my Emacs package manager of choice. Its advantages & disadvantages over other options are listed pretty thoroughly in the README file in the repo.

    The following is a straight.el bootstrap script.

    References:

    @@ -168,7 +171,7 @@ Emacs is also particularly good at writing Lisp code, e.g. Clojure, Common Lisp, (goto-char (point-max)) (eval-print-last-sexp))) (load bootstrap-file nil 'nomessage)) -

    use-package

    +

    use-package

    A macro to simplify package specification & configuration. Integrates with straight.el.

    Set use-package-verbose to t to print out loading times for individual packages.

    References:

    @@ -178,9 +181,9 @@ Emacs is also particularly good at writing Lisp code, e.g. Clojure, Common Lisp,
    (straight-use-package 'use-package)
     (eval-when-compile (require 'use-package))
    -

    Variables & environment

    +

    Variables & environment

    This section is about optioning the Emacs config.

    -

    The following is true if Emacs is meant to be used with TRAMP over slow ssh. Take a look at the TRAMP section for more details.

    +

    The following is true if Emacs is meant to be used with TRAMP over slow ssh. Take a look at the TRAMP section for more details.

    (setq my/slow-ssh
           (or
            (string= (getenv "IS_TRAMP") "true")))
    @@ -198,8 +201,8 @@ Emacs is also particularly good at writing Lisp code, e.g. Clojure, Common Lisp,
     
    <<minimal>>
     

    To launch Emacs with this config, run

    emacs -q -l ~/.emacs.d/init-minimal.el
    -

    Performance

    -

    Measure startup speed

    +

    Performance

    +

    Measure startup speed

    A small function to print out the loading time and number of GCs during the loading. Can be useful as a point of data for optimizing Emacs startup time.

    (setq my/emacs-started nil)
     
    @@ -213,11 +216,11 @@ Emacs is also particularly good at writing Lisp code, e.g. Clojure, Common Lisp,
     	  (setq my/emacs-started t))
     

    Set the following to t to print debug information during the startup. This will include the order in which the packages are loaded and the loading time of individual packages.

    ;; (setq use-package-verbose t)
    -

    Garbage collection

    +

    Garbage collection

    Just setting gc-cons-treshold to a larger value.

    (setq gc-cons-threshold 80000000)
     (setq read-process-output-max (* 1024 1024))
    -

    Run garbage collection when Emacs is unfocused

    +

    Run garbage collection when Emacs is unfocused

    Run GC when Emacs loses focus. Time will tell if that’s a good idea.

    Some time has passed, and I still don’t know if there is any quantifiable advantage to this, but it doesn’t hurt.

    (add-hook 'emacs-startup-hook
    @@ -228,10 +231,10 @@ Emacs is also particularly good at writing Lisp code, e.g. Clojure, Common Lisp,
     				(unless (frame-focus-state)
     				  (garbage-collect))))
     	      (add-hook 'after-focus-change-function 'garbage-collect))))
    -

    Anaconda

    -

    Anaconda is a free package and environment manager. I currently use it to manage multiple versions of Python and Node.js. Take a look at the corresponding entry in the Guix config for details about using it on Guix.

    +

    Anaconda

    +

    Anaconda is a free package and environment manager. I currently use it to manage multiple versions of Python and Node.js. Take a look at the corresponding entry in the Guix config for details about using it on Guix.

    The following code uses the conda package to activate the base environment on startup if Emacs is launched outside the environment.

    -

    Also, some strange things are happening if vterm is launched with conda activated from Emacs, so I advise conda-env-activate to set an auxiliary environment variable. This variable is used in the shell config.

    +

    Also, some strange things are happening if vterm is launched with conda activated from Emacs, so I advise conda-env-activate to set an auxiliary environment variable. This variable is used in the shell config.

    References: