Refreshing mirror list with reflector

Firstly you need to install the reflector package. Then save the script below as, for instance, ~/scripts/ref.sh and make executable.

#!/bin/bash
upd=$(/bin/sh -c "reflector -l 5")
if [ ! -z "$upd" ]
then
    echo "$upd"
    sudo mv -f /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.ref
    sudo echo "$upd" >> /etc/pacman.d/mirrorlist
    printf "\n--- /etc/pacman.d/mirrorlist refreshed ---\n\n"
    sudo pacman -Syu
fi

This will save 5 most recently updated mirrors to /etc/pacman/mirrorlist. The previous mirrorlist will be renamed to mirrorlist.ref. Check reflector --help for more options.

Would you like to attach the script to a Tint2 button? Add this to the ~/config/tint2/tint2rc file:

#-------------------------------------
# Button 1
button = new
button_icon = archlinux
button_text = 
button_lclick_command = xfce4-terminal -e 'sh -c "sudo ~/scripts/./ref.sh ; echo Done - press enter to exit; read; "'
button_rclick_command = 
button_mclick_command = 
button_uwheel_command = 
button_dwheel_command = 
button_font_color = #000000 100
button_padding = 0 4
button_background_id = 0
button_centered = 0
button_max_icon_size = 0