1
dot-files/bin/reboot-windows

39 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
################################################################################
#
# reboot-windows
# Finds and flags a Windows menuentry in GRUB, and then reboots the system
#
################################################################################
########################################
# Reboot command
########################################
REBOOT_CMD=$(cat <<EOF
# Find the ID of the Windows entry in the UEFI boot manager
WINDOWS_ENTRY=\$(efibootmgr | grep -Po "Boot.*Windows" | grep -Po "[[:digit:]]+");
# Set BootNext in the UEFI boot manager to the Windows entry
#sudo grub2-reboot "\$WINDOWS_ENTRY";
sudo efibootmgr --bootnext "\$WINDOWS_ENTRY";
# Copy grubenv to the OpenSUSE grub EFI folder (/boot/grub2/ is not visible on UEFI installs)
#sudo cp /boot/grub2/grubenv /boot/efi/EFI/opensuse/grubenv;
# 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