Reinstalling Linux

Because I keep forgetting steps

Files from previous installs

/etc/pam.d/{sudo,greetd,swaylock}
/etc/systemd/{logind,sleep}.conf
/etc/systemd/system/user-suspend@.service
/usr/share/backgrounds/
~/.config/{sway,waybar,foot,zathura}
~/.git-credentials
~/.gitconfig
~/.bashrc
~/.profile
~/.vimrc
~/.vim/Snippets/*
~/.texmf/tex/latex/*
~/.xkb/*
~/mathemeatica
~/Documents/*

Programs to install

Swap and hibernate

In EndeavourOS (or other distros that use dracut)

  1. Swapfile
    # btrfs filesystem mkswapfile --size __G /swapfile
    # swapon /swapfile
    

    to make and enable a swapfile. Swapfiles are easier than swap partitions. Make sure swap is at least 60% of your ram. Or, as I usually do out of paranoia, 120%.

Add the swapfile to fstab

#/etc/fstab
/swapfile none swap defaults 0 0

Then, you need to find this swapfile and tell your computer about it. This can be done by running lsblk and taking the MAJ:MIN of the partition you made the swapfile in. Tell this to linux by running

# echo MAJ:MIN > /sys/power/resume

Finally, btrfs puts the swapfile at a weird offset. you can find it by running

# btrfs inspect-internal map-swapfile -r /swapfile

and passing the result

# echo ___ > /sys/power/resume_offset
  1. Boot Hooks
    #/etc/dracut.conf.d/resume.conf
    add_dracutmodules+=" resume "
    

    then run # dracut-rebuild, or

    #/etc/mkinitcpio.conf
    HOOKS="base udev resume [...]"
    

    where resume is right after udev, then run # mkinitcpio -P, or else your laptop will ignore the hibernated state and do a fresh boot leaving you with broken vim swap files.

  2. Sleep Config
    #/etc/systemd/sleep.conf
    [Sleep]
    AllowSuspend=yes
    AllowSuspendThenHibernate=yes
    AllowHibridSleep=yes
    HibernateMode=shutdown
    HibernaetDelaySec=10min
    SuspendEstimationSec=60min
    
  3. Logind Config
    #/etc/systemd/logind.conf
    HandlePowerKey=suspend-then-hibernate
    HandlePowerKeyLongPress=poweroff
    HandleLidSwitch=suspend-then-hibernate
    HandleLidSwitchExternalPower=ignore
    HoldoffTimeoutSec=3s
    
  4. Lock on sleep
    #/etc/systemd/system/user-suspend@.service
    [Unit]
    Description=Lock screen on sleep
    Before=sleep.target
    [Service]
    User=%I
    Type=forking
    Environment=DISPLAY=:0
    ExecStart/home/user/.config/i3/scripts/blur-lock
    ExecStartPost=/usr/bin/sleep 0.1
    [Install]
    WantedBy=sleep.target
    

    then run systemctl enable user-suspend@user.service and replace @user with your username

##