Package Details: pacman-beep-hook 0.1-1

Git Clone URL: https://aur.archlinux.org/pacman-beep-hook.git (read-only, click to copy)
Package Base: pacman-beep-hook
Description: hook to play Pac-Man theme using pcspkr before and after any transaction
Upstream URL: None
Submitter: 7Ji
Maintainer: 7Ji
Last Packager: 7Ji
Votes: 3
Popularity: 0.000001
First Submitted: 2022-04-06 08:35 (UTC)
Last Updated: 2022-04-13 12:39 (UTC)

Dependencies (2)

Required by (0)

Sources (3)

Latest Comments

7Ji commented on 2022-04-13 12:06 (UTC)

@terminator0821
You can also install beep-sudoable instead of beep, the sudoable one is patched so there will be not such issue anymore:
https://aur.archlinux.org/packages/beep-sudoable

7Ji commented on 2022-04-13 06:14 (UTC) (edited on 2022-04-13 06:19 (UTC) by 7Ji)

@terminator0821
That error is throwed by beep which is running during the hook. A hook erroring out does not stop any installation/upgrading/removal transaction. Which means pacman-beep-hook the package itself is successfully installed even you saw that error. You can confirm it by pacman -Q pacman-beep-hook, and pacman -Ql pacman-beep-hook to confirm the hooks and the beeping script is installed.
How to avoid that error afterwards though, is another question. You got that error because you are running beep as sudo (or sudo pacman, which forks beep), and beep was hard-coded to refuse to actually beep if it detects this:
https://github.com/spkr-beep/beep/blob/41a9eb83fa6b7d173949a965e6b29929025a64da/beep-main.c#L478
Check the other two comments I wrote a week ago to understand how to avoid this error:
https://aur.archlinux.org/packages/pacman-beep-hook#comment-860031
https://aur.archlinux.org/packages/pacman-beep-hook#comment-860131

marcandru commented on 2022-04-13 03:47 (UTC)

Couldn't install it:

:: Running post-transaction hooks... (1/2) Arming ConditionNeedsUpdate... (2/2) Pac-Man beep beep: Error: Running as root under sudo, which is not supported for security reasons. beep: Error: Set up permissions for the pcspkr evdev device file and run as non-root user instead. error: command failed to execute correctly

7Ji commented on 2022-04-07 03:23 (UTC)

@himan You can also patch beep so it will not exit when running with sudo, since beep is in the official repository, I will not create another package just for the sake of being able to beep with sudo. And that is insecure anyway. You can apply the following patch and compile beep yourself:
0001-Yolo-it-when-running-with-sudo.patch

From a00ba438e2354734caf69369124b7e466dc49e36 Mon Sep 17 00:00:00 2001
From: 7Ji <pugokushin@gmail.com>
Date: Thu, 7 Apr 2022 11:04:31 +0800
Subject: [PATCH] Yolo it when running with sudo

---
beep-main.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/beep-main.c b/beep-main.c
index 6b890ff..d31e42a 100644
--- a/beep-main.c
+++ b/beep-main.c
@@ -484,10 +484,8 @@ int main(const int argc, char *const argv[])
        if (getenv("SUDO_COMMAND") || getenv("SUDO_USER") ||
            getenv("SUDO_UID") || getenv("SUDO_GID")) {
            LOG_ERROR("Running as root under sudo, "
-                      "which is not supported for security reasons.");
-            LOG_ERROR("Set up permissions for the pcspkr evdev device "
-                      "file and run as non-root user instead.");
-            exit(EXIT_FAILURE);
+                      "which is not supported for security reasons."
+                      "But we yolo it anyway, pcspkr goes brrr");
        }
    }

--
2.35.1

Basically you can

git clone https://github.com/spkr-beep/beep -b v1.4.10
cd beep
vi 0001-Yolo-it-when-running-with-sudo.patch

(then copy the above content and :wq to save it)

git apply 0001-Yolo-it-when-running-with-sudo.patch
make

(the beep in the current folder is the patched executable, you can then overwrite /usr/bin/beep with it, or pacman -R beep and move it to /usr/bin/beep to have some out-of-tree binaries, or save it seperately and edit the hooks so the modified beep will be invoked)

7Ji commented on 2022-04-06 16:09 (UTC)

@himan According to @EmbarrassedActive4, beep will refuse to actually beep if the environment variables SUDO_* suggests you are running as root under sudo, you can either sudo -s/su root to actually got a root shell then run pacman, or su -c 'pacman' to su to root and run pacman in one go.

himan commented on 2022-04-06 14:14 (UTC) (edited on 2022-04-06 14:15 (UTC) by himan)

(3/5) Pac-Man beep

beep: Error: Running as root under sudo, which is not supported for security reasons.
beep: Error: Set up permissions for the pcspkr evdev device file and run as non-root user instead.

??

7Ji commented on 2022-04-06 13:31 (UTC)

Just figured I wrote wrong pacman-beep.sh path in the hooks, it's fixed now