当PackageKit已经获取用于安装的更新,并且使用Gnome关闭机器时,可以在关闭之前设置一个复选框来安装更新。如何在没有根的命令行中实现这一点?示例用途:在关闭之前自动执行自定义命令。
发布于 2020-11-28 11:48:24
# This will force fetching repository data and updates
pkcon get-updates
pkcon update --only-download
dbus-send --system --type=method_call --print-reply \
--dest=org.freedesktop.PackageKit \
/org/freedesktop/PackageKit \
org.freedesktop.PackageKit.Offline.Trigger \
string:power-off
if pkcon offline-get-prepared; then
systemctl reboot
else
systemctl poweroff
fi如果删除dbus-send命令并将if块替换为systemctl reboot,则系统将重新启动。
https://unix.stackexchange.com/questions/621929
复制相似问题