Daily logs and the Sway scratchpad

I maintain a daily code/admin log; when I make decisions I'll document the reasons for it, excerpts from log files and every measurement I take gets copied to it, little facts I learn but am unlikely to remember long-term get documented, etc. Some of this ends up in git commit messages or moved to a structured KB, but it's often been helpful to be able to look back at the past and see what I was doing and why.

Screen space is rather important though, and I don't need the log always in front of me. Vim buffers solve the problem well, except I generally have multiple instances of Vim running across multiple (virtual) desktops, and I don't want to remember which window has the buffer or whether I've saved everything in one buffer before loading the file into another. The proper solution here is probably to become better organized, but since that's unlikely (or at least potentially unreliable) and I use the Sway window manager, I've solved the problem with Sway's scratchpad.

The scratchpad is a holding area for windows; you can throw windows into the scratchpad when you don't need them and then grab them later. By default, Sway cycles through the windows when you need one, but I wanted to create a separate scratchpad just for my daily log so that it's available with a single key combination.

Sway allows us to filter windows by certain criteria; this allows me to create a window and operate solely on that window:

# Elsewhere, set some variables:
set $mod Mod4    # "Super". The Windows key on typical keyboards.
set $term kitty

# When sway starts, run kitty with the daily_log.conf startup session.
exec $term --class=kitty_daily_log --session=$HOME/.config/kitty/daily_log.conf

# Immediately move the window to the scratchpad.
for_window [app_id="kitty_daily_log"] move to scratchpad

# Show the window when I press $mod and the equals key
bindsym $mod+equal [app_id="kitty_daily_log"] scratchpad show

Unfortunately, the behavior of scratchpad show changes when you add criteria; I wanted to change my normal scratchpad key to show everything except the daily log. I assumed that "no criteria" was an implicit "all windows" criteria so that scratchpad show would still cycle through them, but its actual behavior is to show all matching windows at once, right on top of each other. That's not very useful, so my normal scratchpad viewing still contains the daily log.

"Kitty" is my terminal emulator. I keep the word "kitty" in the window's class so that I can continue to match on it in other commands. For example, I remove the border of terminal windows via for_window [app_id="kitty"] border none.

The daily_log.conf file I pass as kitty's startup session starts vim with today's log file. I have to invoke a shell to be able to get the date:

cd ~/notes/journals/code

launch sh -c 'vim $(date --rfc-3339=date).md'

Now, when sway starts it opens today's log and hides it away in the scratchpad. When I want it, I just type Super+=, do my work, then Super+= again to hide it away.

Example of using the log window

I've also discovered that closing vim is deeply ingrained into my psyche, so I've had to bind $mod+Shift+equal to the same exec command that's run on startup:

set $load_daily_log $term --class=kitty_daily_log \

exec $load_daily_log
bindsym $mod+Shift+equal exec $load_daily_log

for_window [app_id="kitty_daily_log"] move to scratchpad
bindsym $mod+equal [app_id="kitty_daily_log"] scratchpad show