38 lines
1.2 KiB
Bash
Executable File
38 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 exact name of the first Windows menuentry in grub.cfg
|
|
WINDOWS_ENTRY=\$(sudo grep menuentry /boot/grub2/grub.cfg | grep -Po "'.*Windows.*?'" | grep -o "[^'].*[^']")
|
|
|
|
# Set next_entry in grubenv to the Windows menuentry
|
|
sudo grub2-reboot "\$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
|