From 7df8e5e3a3018f4c8583d623ddcf63deba10a237 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Mon, 8 Sep 2025 11:47:32 +0200 Subject: rename to grub-reboot-into-windows --- bin/.gitattributes | 2 +- bin/grub-reboot-into-windows | 43 ++++++++++++++++++++++++++++++++++ bin/reboot-into-windows | 43 ---------------------------------- etc/sudoers | 2 +- share/grub-reboot-into-windows.desktop | 8 +++++++ share/reboot-into-windows.desktop | 8 ------- 6 files changed, 53 insertions(+), 53 deletions(-) create mode 100755 bin/grub-reboot-into-windows delete mode 100755 bin/reboot-into-windows create mode 100644 share/grub-reboot-into-windows.desktop delete mode 100644 share/reboot-into-windows.desktop diff --git a/bin/.gitattributes b/bin/.gitattributes index c9f8ef4..713687e 100644 --- a/bin/.gitattributes +++ b/bin/.gitattributes @@ -1 +1 @@ -reboot-into-windows text eol=lf +grub-reboot-into-windows text eol=lf diff --git a/bin/grub-reboot-into-windows b/bin/grub-reboot-into-windows new file mode 100755 index 0000000..a6584b9 --- /dev/null +++ b/bin/grub-reboot-into-windows @@ -0,0 +1,43 @@ +#!/usr/bin/env bash + +set -o errexit -o nounset -o pipefail +shopt -s inherit_errexit lastpipe + +readonly cfg_path=/boot/grub/grub.cfg + +get_windows_menu_entry() { + local windows_entries + windows_entries="$( awk -F\' '/menuentry / {print $2}' "$cfg_path" | grep -Fi Windows )" + + local numof_entries + numof_entries="$( echo "$windows_entries" | wc -l )" + + if [ "$numof_entries" -ne 1 ]; then + echo "Don't know which one of the following entries to select:" >&2 + echo "$windows_entries" >&2 + return 1 + fi + + echo "$windows_entries" +} + +main() { + local entry + entry="$( get_windows_menu_entry )" + + # grub-reboot returns 0 even if something like a permission error happens. + # It does print something in that case though, and nothing after a + # successful termination. + local output + output="$( grub-reboot "$entry" )" + + if [ -n "$output" ]; then + echo "grub-reboot probably exited with an error:" >&2 + echo "$output" >&2 + return 1 + fi + + reboot +} + +main diff --git a/bin/reboot-into-windows b/bin/reboot-into-windows deleted file mode 100755 index a6584b9..0000000 --- a/bin/reboot-into-windows +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env bash - -set -o errexit -o nounset -o pipefail -shopt -s inherit_errexit lastpipe - -readonly cfg_path=/boot/grub/grub.cfg - -get_windows_menu_entry() { - local windows_entries - windows_entries="$( awk -F\' '/menuentry / {print $2}' "$cfg_path" | grep -Fi Windows )" - - local numof_entries - numof_entries="$( echo "$windows_entries" | wc -l )" - - if [ "$numof_entries" -ne 1 ]; then - echo "Don't know which one of the following entries to select:" >&2 - echo "$windows_entries" >&2 - return 1 - fi - - echo "$windows_entries" -} - -main() { - local entry - entry="$( get_windows_menu_entry )" - - # grub-reboot returns 0 even if something like a permission error happens. - # It does print something in that case though, and nothing after a - # successful termination. - local output - output="$( grub-reboot "$entry" )" - - if [ -n "$output" ]; then - echo "grub-reboot probably exited with an error:" >&2 - echo "$output" >&2 - return 1 - fi - - reboot -} - -main diff --git a/etc/sudoers b/etc/sudoers index 4bb7722..a1fefad 100644 --- a/etc/sudoers +++ b/etc/sudoers @@ -1 +1 @@ -ALL ALL=(ALL) NOPASSWD: /usr/bin/reboot-into-windows +ALL ALL=(ALL) NOPASSWD: /usr/bin/grub-reboot-into-windows diff --git a/share/grub-reboot-into-windows.desktop b/share/grub-reboot-into-windows.desktop new file mode 100644 index 0000000..e0c4d6c --- /dev/null +++ b/share/grub-reboot-into-windows.desktop @@ -0,0 +1,8 @@ +[Desktop Entry] +Type=Application +Name=Reboot into Windows +Comment=Use grub-reboot to reboot into Windows +Terminal=false +Exec=sudo grub-reboot-into-windows +Icon=/usr/share/grub-reboot-into-windows/icon.svg +Categories=System diff --git a/share/reboot-into-windows.desktop b/share/reboot-into-windows.desktop deleted file mode 100644 index 122ed82..0000000 --- a/share/reboot-into-windows.desktop +++ /dev/null @@ -1,8 +0,0 @@ -[Desktop Entry] -Type=Application -Name=Reboot into Windows -Comment=Use grub-reboot to reboot into Windows -Terminal=false -Exec=sudo reboot-into-windows -Icon=/usr/share/reboot-into-windows/icon.svg -Categories=System -- cgit v1.2.3