CachyOS / cachyos-hooks

0 stars 7 forks source link

cachyos-reboot-required: check of $(tty) fails and hangs on notification when run without display manager #9

Closed allergicapple closed 9 hours ago

allergicapple commented 6 months ago

Reference: https://github.com/CachyOS/cachyos-hooks/blob/c6cc94d28cbb0fc3a67bff824543d0bca88c5827/cachyos-reboot-required#L21

Calling $(tty) only returns /dev/tty* when the command is issued manually on the tty console.

This logic fails however when the cachyos-reboot-required.hook gets called when pacman is active inside a script, then tty returns /dev/pts/* because of the i/o redirects.

So the hook thinks it is inside an desktop environment and sends a notification - which doesn't work as there is none because the update script in run from a tty console. This amounts to a hang when dbus tries to send the notification to a nonexisting notification daemon.

ptr1337 commented 6 months ago

Hi, Yes, just had the same issue when recovering my system. We need to overthink and improve it.

allergicapple commented 6 months ago

Great, was just about to create an example:

$ cat > "/tmp/trigger.sh" << EOF
#!/usr/bin/env sh
echo "TTY is $(tty)"
EOF

$ sh /tmp/trigger.sh

Gives:

TTY is /dev/pts/1

even when run from a plain tty.