-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add reboot to windows option #3
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ set -e | |
set -u | ||
|
||
# All supported choices | ||
all=(shutdown reboot suspend hibernate logout lockscreen) | ||
all=(shutdown reboot suspend hibernate logout lockscreen windows) | ||
|
||
# By default, show all (i.e., just copy the array) | ||
show=("${all[@]}") | ||
|
@@ -26,6 +26,7 @@ texts[suspend]="suspend" | |
texts[hibernate]="hibernate" | ||
texts[reboot]="reboot" | ||
texts[shutdown]="shut down" | ||
texts[windows]="reboot to Windows" | ||
|
||
declare -A icons | ||
icons[lockscreen]="\uf023" | ||
|
@@ -36,6 +37,7 @@ icons[hibernate]="\uf7c9" | |
icons[reboot]="\ufc07" | ||
icons[shutdown]="\uf011" | ||
icons[cancel]="\u00d7" | ||
icons[windows]="\uf17a" | ||
|
||
declare -A actions | ||
actions[lockscreen]="loginctl lock-session ${XDG_SESSION_ID-}" | ||
|
@@ -45,9 +47,10 @@ actions[suspend]="systemctl suspend" | |
actions[hibernate]="systemctl hibernate" | ||
actions[reboot]="systemctl reboot" | ||
actions[shutdown]="systemctl poweroff" | ||
actions[windows]="systemctl reboot --boot-loader-entry=auto-windows --boot-loader-menu=0.5" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this a generic way to reboot to Windows? Also, why doesn't normal reboot work? I suppose you can choose which OS to launch during the boot time, right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This PR is quite old. I learned a lot since opening this, so I can explain more what would be the right way to do things.
As noted above by Spaxly, this Because setting the next entry is bootloader specific, one would need to add special commands for each bootloader. As I can see it, grub also supports rebooting into another entry. See the manpage. You can specify an entry there. Using another init (i.e. no systemd) completely breaks the entire script, as there is no Covering all the cases would be hard I guess, so a decision needs to be taken on which inits and boot loaders should be supported. I guess we could also just start with some inits and bootloaders and then extend if people are interested.
Yes, you are right. Usually when you use dual booting, your bootloader shows a screen where you can select the boot entry for a few seconds. What this command does though, is that it preselects the chosen entry. No user intervention is needed until the other entry/OS is booted up. That is somewhat convenient. |
||
|
||
# By default, ask for confirmation for actions that are irreversible | ||
confirmations=(reboot shutdown logout) | ||
confirmations=(reboot shutdown logout windows) | ||
|
||
# By default, no dry run | ||
dryrun=false | ||
|
@@ -90,19 +93,19 @@ while true; do | |
echo " --dry-run Don't perform the selected action but print it to stderr." | ||
echo " --choices CHOICES Show only the selected choices in the given order. Use / " | ||
echo " as the separator. Available choices are lockscreen, logout," | ||
echo " suspend, hibernate, reboot and shutdown. By default, all" | ||
echo " suspend, hibernate, reboot, windows and shutdown. By default, all" | ||
echo " available choices are shown." | ||
echo " --confirm CHOICES Require confirmation for the gives choices only. Use / as" | ||
echo " the separator. Available choices are lockscreen, logout," | ||
echo " suspend, hibernate, reboot and shutdown. By default, only" | ||
echo " irreversible actions logout, reboot and shutdown require" | ||
echo " irreversible actions logout, reboot, windows and shutdown require" | ||
echo " confirmation." | ||
echo " --choose CHOICE Preselect the given choice and only ask for a confirmation" | ||
echo " (if confirmation is set to be requested). It is strongly" | ||
echo " recommended to combine this option with --confirm=CHOICE" | ||
echo " if the choice wouldn't require confirmation by default." | ||
echo " Available choices are lockscreen, logout, suspend," | ||
echo " hibernate, reboot and shutdown." | ||
echo " hibernate, reboot, windows and shutdown." | ||
echo " --[no-]symbols Show Unicode symbols or not. Requires a font with support" | ||
echo " for the symbols. Use, for instance, fonts from the" | ||
echo " Nerdfonts collection. By default, they are shown" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, makes sense. Then this windows option should get added to the readme for visibility.