Skip to content

Instantly share code, notes, and snippets.

@darkexplosiveqwx
Created December 20, 2024 20:01
Show Gist options
  • Select an option

  • Save darkexplosiveqwx/cc1bb3ecfeaf2bf9e28eb506df01c7ae to your computer and use it in GitHub Desktop.

Select an option

Save darkexplosiveqwx/cc1bb3ecfeaf2bf9e28eb506df01c7ae to your computer and use it in GitHub Desktop.
Adds boot menu entries for Rebooting and Halting to grub
#!/bin/sh
# This script adds "Reboot" and "Shutdown" menu entries to GRUB.
# Make executable by sudo chmod +x /etc/grub.d/40_reboot_shutdown
# Place in /etc/grub.d
set -e
prefix="/usr"
exec_prefix="/usr"
datarootdir="/usr/share"
export TEXTDOMAIN=grub
export TEXTDOMAINDIR="${datarootdir}/locale"
. "$pkgdatadir/grub-mkconfig_lib"
LABEL_REBOOT="Reboot"
LABEL_SHUTDOWN="Shutdown"
gettext_printf "Adding boot menu entries for Reboot and Shutdown ...\n" >&2
# Output the menu entries
cat << EOF
menuentry '$(gettext "$LABEL_REBOOT")' \$menuentry_id_option 'Reboot' {
reboot
}
menuentry '$(gettext "$LABEL_SHUTDOWN")' \$menuentry_id_option 'Shutdown' {
halt
}
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment