2024-04-11 22:46:41 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
#
|
|
|
|
# reboot-windows
|
|
|
|
# Finds and flags a Windows menuentry in GRUB, and then reboots the system
|
|
|
|
#
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
########################################
|
|
|
|
# Reboot command
|
|
|
|
########################################
|
|
|
|
|
|
|
|
REBOOT_CMD=$(cat <<EOF
|
|
|
|
|
2024-08-20 18:24:30 +00:00
|
|
|
# Find the ID of the Windows entry in the UEFI boot manager
|
|
|
|
WINDOWS_ENTRY=\$(efibootmgr | grep -Po "Boot.*Windows" | grep -Po "[[:digit:]]+");
|
2024-04-11 22:46:41 +00:00
|
|
|
|
2024-08-20 18:24:30 +00:00
|
|
|
# Set BootNext in the UEFI boot manager to the Windows entry
|
|
|
|
#sudo grub2-reboot "\$WINDOWS_ENTRY";
|
|
|
|
sudo efibootmgr --bootnext "\$WINDOWS_ENTRY";
|
2024-04-11 22:46:41 +00:00
|
|
|
|
|
|
|
# Copy grubenv to the OpenSUSE grub EFI folder (/boot/grub2/ is not visible on UEFI installs)
|
2024-08-20 18:24:30 +00:00
|
|
|
#sudo cp /boot/grub2/grubenv /boot/efi/EFI/opensuse/grubenv;
|
2024-04-11 22:46:41 +00:00
|
|
|
|
|
|
|
# Reboot!
|
|
|
|
sudo reboot;
|
|
|
|
EOF
|
|
|
|
)
|
|
|
|
|
|
|
|
########################################
|
|
|
|
# Prompt user and execute reboot seq.
|
|
|
|
########################################
|
|
|
|
|
|
|
|
if zenity --question --icon distributor-logo-windows --text="Reboot to Microsoft Windows?" --title "Windows" --default-cancel --no-wrap --timeout=10
|
|
|
|
then
|
|
|
|
pkexec --disable-internal-agent bash -c "$REBOOT_CMD"
|
|
|
|
fi
|