From 6d3e4723009c6ec9765eff02a5876cde7e095956 Mon Sep 17 00:00:00 2001 From: Hektor Misplon Date: Thu, 1 Dec 2022 16:38:19 +0100 Subject: [PATCH] Detect & handle alternative boot managers --- .bash_aliases | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.bash_aliases b/.bash_aliases index a427c9e..de4c168 100644 --- a/.bash_aliases +++ b/.bash_aliases @@ -64,7 +64,15 @@ alias xev='xev | grep -A2 ButtonPress' # Ignore mouse movements reboot_to_windows () { - windows_title=$(grep -i windows /boot/grub/grub.cfg | cut -d "'" -f 2) - sudo grub-reboot "$windows_title" && sudo reboot + # Check if grub is installed by checking if the command exists, if it does + # 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'