Automate mirrorlist generation with Pacman hook:

Create a file /etc/pacman.d/hooks/mirrorupgrade.hook

$ sudo mkdir /etc/pacman.d/hooks
$ sudo nano /etc/pacman.d/hooks/mirrorupgrade.hook

Add the following lines:

[Trigger]
Operation = Upgrade
Type = Package
Target = pacman-mirrorlist

[Action]
Description = Updating pacman-mirrorlist with reflector and removing pacnew...
When = PostTransaction
Depends = reflector
Exec = /bin/sh -c "reflector -c 'United States' -l 10 --sort rate -p https --save /etc/pacman.d/mirrorlist"

Save and close the file. 

_____
reflector-pacman-hook.txt
# Revision: 2024.03.14 -- by eznix (https://sourceforge.net/projects/ezarch/)
# (GNU/General Public License version 3.0)
