Reboot reminder gets stuck when updating from tty

If I know I’m going to be updating my system after a cold boot or reboot, I generally like to run it via a tty, especially when there’s a kernel/GRUB update that I already know about. However, when the system checks for a reboot notification, it takes about 2 minutes before it gives up when it can’t find a DE.

Can a check for no DE be added to this part of the script?

You can do it manually if you want. Look for the pacman hook(s) responsible for the notification and identify the script(s) triggered post transaction. Once you have identified the script, just modify it to wrap the call to notify-send in a conditional to check the value of the TERM environment variable.

if ! [ "$TERM" = "linux" ]
then
     notify-send "....." 
fi

Yes, but I don’t want to have to do this every time the responsible package updates.

Yup. I understand. That’s why I said “if you want”. As a temporary fix.

You can also create your own script and pacman hooks (if you want). You don’t even have to change the original hooks/scripts. Just override them by placing a file with the same name in a higher priority hook directory. After that, you can create new scripts and hooks by copy and pasting from the original ones with slight modification.

Thanks for the suggestions. Maybe I should make the change and see if the EOS devs want to pick it up. Can’t be much to it, I wouldn’t think. Mainly checking for no DE, like an SSH connection or tty like I’ve been using.

Thanks for the report! :+1:

I can take a look into it, and any code suggestions are very much appreciated. :sweat_smile:

# Add a function to print reminder in bold.
print_reboot_reminder()
{
    notification_msg="==> Reboot is recommended after an upgrade of core system package(s)!"
    RED_BOLD_ON="\033[1;31m"
    RED_BOLD_OFF="\033[0;97m"
    echo -e "$RED_BOLD_ON""$notification_msg""$RED_BOLD_OFF"
    exit 0
}
if ! ["$TERM" = "linux"]
then
    notify-send
else
     print_reboot_reminder
fi

or

case "$(tty)" in
     /dev/tty*)
         # print reminder to stdout in bold
         print_reboot_reminder
         ;;
     *)
         notify-send
         ;;
esac

or

case "$(tty)" in
    /dev/pts/*)
       notify-send
       ;;
   *)
       # print reboot reminder to stdout in bold
       print_reboot_reminder
       ;;
esac
1 Like

Maybe add a bolded reminder in the terminal as well.

That’s actually how I wrote my reboot reminder script. I ditched dunst and just wrote a script to print a reminder to stdout in red, bold text, which can be implemented through a simple shell function. Instead of calling notify-send, I call that function.

print_reboot_reminder()
{
    notification_msg="==> Reboot is recommended after an upgrade of core system package(s)!"
    RED_BOLD_ON="\033[1;31m"
    RED_BOLD_OFF="\033[0;97m"
    echo -e "$RED_BOLD_ON""$notification_msg""$RED_BOLD_OFF"
    exit 0
}

kernel_in_use()
{
    kernel_version_file="/proc/version"
    if [ -r "$kernel_version_file" ]
    then
        running_kernel="$(sed 's|.*(\([^@]*\)@archlinux).*|\1|' < $kernel_version_file)"
        case "$running_kernel" in
            linux*) echo "$running_kernel" ; return ;;
        esac
    fi
}

cpu_info()
{
    printf "%s" "$(grep -w "^vendor_id" /proc/cpuinfo | head -n 1 | awk '{print $3}')"
}

targets=$(cat) # Read from stdin because pacman will pipe the targets list into this script

for target in $targets
do
    case "$target" in 
        linux | linux-lts | linux-zen | linux-hardened | linux-rt | linux-rt-lts | linux-lts?? | linux-lts???)
            if [ "$target" = "$(kernel_in_use)" ]
            then
                print_reboot_reminder
            fi
            ;;
        nvidia)
            if [ "$(kernel_in_use)" = "linux" ]
            then
                print_reboot_reminder
            fi
            ;;
        nvidia-lts)
            if [ "$(kernel_in_use)" = "linux-lts" ]
            then
                print_reboot_reminder
            fi
            ;;
        amd-ucode)
            if [ "$(cpu_info)" = "AuthenticAMD" ]
            then
                print_reboot_reminder
            fi
            ;;
        intel-ucode)
            if [ "$(cpu_info)" = "GenuineIntel" ]
            then
                print_reboot_reminder
            fi
            ;;
        btrfs-progs)
            if [ -n "$(df -hT | awk '{print $2}' | grep -w btrfs)" ]
            then
                print_reboot_reminder
            fi
            ;;
        wayland | egl-wayland)
            case "$XDG_SESSION_TYPE" in
                x11) ;; # Do nothing if Xorg is in use
                *) print_reboot_reminder ;;
            esac
            ;;
        *)
            print_reboot_reminder
            ;;
    esac
done

Which results in something like this:

Edited my previous post to include the bold reminder.

1 Like

Thanks guys!
I’ll make related changes very soon and appreciate if you can test it and report.