Detect & handle alternative boot managers

master
Hektor Misplon 2022-12-01 16:38:19 +01:00
parent c48c6bdc7e
commit 6d3e472300
1 changed files with 10 additions and 2 deletions

View File

@ -64,7 +64,15 @@ alias xev='xev | grep -A2 ButtonPress' # Ignore mouse movements
reboot_to_windows () reboot_to_windows ()
{ {
windows_title=$(grep -i windows /boot/grub/grub.cfg | cut -d "'" -f 2) # Check if grub is installed by checking if the command exists, if it does
sudo grub-reboot "$windows_title" && sudo reboot # not, then assume that the system is using systemd-boot
if grub-install --version &>/dev/null; then
windows_title=$(grep -i windows /boot/grub/grub.cfg | cut -d "'" -f 2)
sudo grub-reboot "$windows_title"
echo "Grub set to reboot to Windows"
else
sudo bootctl set-oneshot windows.conf
echo "Systemd set to reboot to Windows"
fi
} }
alias reboot-to-windows='reboot_to_windows' alias reboot-to-windows='reboot_to_windows'