#[Solved] How to get pacman hook user input [y/n] interactivity for fwupd hook?

1 messages · Page 1 of 1 (latest)

dusky nymph
#

Hi, I have a pacman hook for fwupd to check and update UEFI & SSD firmware whenever I run yay/paru/pacman -Syu (upgrade operations). For some reason, putting fwupd commands in a pacman hook loses its [y/n] prompt so it automatically updates firmware without confirmation. User input confirmation would be nice, is there a way to make pacman hooks use its original command's user inputs?

/etc/pacman.d/hooks/fwupd-update.hook

[Trigger]
Operation = Upgrade
Type = Package
Target = *

[Action]
Description = Updating system firmware via fwupd
When = PostTransaction
Exec = /bin/sh -c 'fwupdmgr refresh --force && sudo fwupdmgr update'
distant lance
#

-- Eli Schwartz (2020-05-22 16:12:19)

distant lance
#

A viable alternative would be shell alias or function

dusky nymph
#

Ah I see, I just find it convenient to have a single yay (alias of paru) command to handle all updates. I considered aliasing yay = paru; fwupdmgr refresh --force && sudo fwupdmgr update but it prevents me from using yay with others parameters I think

distant lance
#

What are the other requirements?

dusky nymph
# distant lance Functions or scripts can be used instead.

I'm using fish shell (interactive), do you know how to make it that typing yay by itself will do paru; fwupdmgr refresh --force && sudo fwupdmgr update but using yay with parameters etc yay -S, yay <package> will be an alias to paru?

distant lance
# dusky nymph I'm using fish shell (interactive), do you know how to make it that typing `yay`...

Try this script

#!/usr/bin/bash
USAGE="\
Update the system

Usage: yay [--nofw] [pacman arguments]

Flags:
  --nofw    Don't update firmware
"

if ! command -v paru &> /dev/null; then
    echo "Error: paru is required but not installed."
    exit 1
fi

if ! command -v sudo &> /dev/null; then
    echo "Error: sudo is required but not installed."
    exit 1
fi

if ! command -v fwupdmgr &> /dev/null; then
    echo "Error: fwupd is required but not installed."
    exit 1
fi

args=()

# parse
while [[ $# -gt 0 ]]; do
    case "$1" in
    --nofw)
        nofw=1
        shift
        ;;
    --help)
        echo -e "$USAGE"
        exit
        ;;
    *)
        args+=($1)
        shift
        ;;
    esac
done

if [[ $nofw != "1" ]] ; then
    sudo fwupdmgr refresh --force && sudo fwupdmgr update
else
    echo "Skiping firmware updates"
fi

# sudo -v
paru "${args[@]}"
#

Save as ~/.local/bin/yay and then

chmod +x ~/.local/bin/yay
#

You can pass pacman/paru flags, and use the --nofw flag to skip firmware updates.

#

In my humble opinion, it is the more straightforward thing to do than fiddling with fish line-editor

dusky nymph
#

Thanks, will use ur script if I can't get the fish function working!

dusky nymph
#

yay got it working:

function yay --wraps=paru --description 'alias yay paru'  
  if count $argv > /dev/null
        paru $argv
    else
        paru
        fwupdmgr refresh --force
        sudo fwupdmgr update
    end

end
funcsave yay
#

[Solved] How to get pacman hook user input [y/n] interactivity for fwupd hook?