-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreto
More file actions
executable file
·35 lines (30 loc) · 1.17 KB
/
Copy pathreto
File metadata and controls
executable file
·35 lines (30 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#! /bin/bash
#set -x
# Requirements:
# /etc/default/grub: GRUB_DEFAULT=saved
# visudo: %sudo ALL=(root) NOPASSWD: /usr/sbin/grub-reboot
# Remenber that GRUB_DEFAULT is now saved. If you select Windows manually
# on a boot, it will continue to boot windows until you select something
# else
THINGY_CONSOLEKIT="dbus-send --system --print-reply --dest=org.freedesktop.ConsoleKit /org/freedesktop/ConsoleKit/Manager"
# This will select ubuntus and windowses.
GRUBLIST=$(grep "^menuentry '[UW]" /boot/grub/grub.cfg | cut -d "'" -f2)
echo $DISPLAY
if [ -z "${DISPLAY}" ]; then
# Suggestions for doing this another
# (better) way is (highly) appreciated
TMPFILE=$(mktemp)
exec 3>$TMPFILE
echo "${GRUBLIST}" | awk 'BEGIN { ORS="\0" } {print $0 "\0" }' | xargs --null dialog --output-fd 3 --menu "Select GRUB record" 0 0 3
exec 3>&-
SELECTED=$(cat "${TMPFILE}")
rm "${TMPFILE}"
else
SELECTED=$(echo "${GRUBLIST}" | zenity --list --column='Select GRUB record' 2>/dev/null | cut -d '|' -f1)
fi
if [ -z "${SELECTED}" ]; then
echo "No choice made reboot option, assuming cancel."
exit 1
fi
sudo grub-reboot "${SELECTED}"
$THINGY_CONSOLEKIT org.freedesktop.ConsoleKit.Manager.Restart