aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorEgor Tensin <egor@tensin.name>2025-08-21 17:10:27 +0200
committerEgor Tensin <egor@tensin.name>2025-08-21 17:10:27 +0200
commitee33f8d172930f506eb423f16720879acd0e4b5d (patch)
tree6520995491357b634f89f160c7c75ae94bd5213c
downloadgrub-reboot-into-windows-ee33f8d172930f506eb423f16720879acd0e4b5d.tar.gz
grub-reboot-into-windows-ee33f8d172930f506eb423f16720879acd0e4b5d.zip
aur: 0.1-1
-rw-r--r--.SRCINFO20
-rw-r--r--.gitattributes3
-rw-r--r--.gitignore3
-rw-r--r--Makefile19
-rw-r--r--PKGBUILD28
-rw-r--r--icon.svg1
-rw-r--r--prelude.mk23
-rwxr-xr-xreboot-into-windows43
-rw-r--r--reboot-into-windows.desktop7
-rw-r--r--sudoers1
10 files changed, 148 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 0000000..2306194
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,20 @@
+pkgbase = reboot-into-windows
+ pkgdesc = Reboot into dual-booted Windows with a Bluetooth keyboard
+ pkgver = 0.1
+ pkgrel = 1
+ arch = any
+ license = MIT
+ depends = bash
+ depends = gawk
+ depends = grep
+ options = !debug
+ source = reboot-into-windows
+ source = reboot-into-windows.desktop
+ source = icon.svg
+ source = sudoers
+ sha256sums = SKIP
+ sha256sums = SKIP
+ sha256sums = SKIP
+ sha256sums = SKIP
+
+pkgname = reboot-into-windows
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..a2f2f07
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,3 @@
+* text=auto
+
+/reboot-into-windows text eol=lf
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..583cae5
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+/src/
+/pkg/
+*.tar.zst
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..a21b0fe
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,19 @@
+include prelude.mk
+
+PKG_NAME := reboot-into-windows
+
+.PHONY: all
+all: build
+
+.PHONY: build
+build:
+ makepkg --clean --cleanbuild --force --syncdeps && makepkg --printsrcinfo > .SRCINFO
+
+.PHONY: commit
+commit:
+ git add .SRCINFO
+ source ./PKGBUILD && git commit -am "aur: $$pkgver-$$pkgrel"
+
+.PHONY: push
+push:
+ git push 'ssh://aur@aur.archlinux.org/$(call escape,$(PKG_NAME)).git' "$$( git symbolic-ref HEAD ):master"
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 0000000..3d08944
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,28 @@
+# Maintainer: Egor Tensin <egor@tensin.name>
+pkgname=reboot-into-windows
+pkgver=0.1
+pkgrel=1
+pkgdesc='Reboot into dual-booted Windows with a Bluetooth keyboard'
+arch=(any)
+license=(MIT)
+depends=(bash gawk grep)
+source=(
+ "$pkgname"
+ "$pkgname.desktop"
+ icon.svg
+ sudoers
+)
+sha256sums=(
+ SKIP
+ SKIP
+ SKIP
+ SKIP
+)
+options=('!debug')
+
+package() {
+ install -D -m 0755 -t "$pkgdir/usr/bin" "$srcdir/$pkgname"
+ install -D -m 0644 -t "$pkgdir/usr/share/applications" "$srcdir/$pkgname.desktop"
+ install -D -m 0644 -t "$pkgdir/usr/share/$pkgname" "$srcdir/icon.svg"
+ install -D -m 0640 -t "$pkgdir/etc/sudoers.d/reboot-into-windows" sudoers
+}
diff --git a/icon.svg b/icon.svg
new file mode 100644
index 0000000..4fbbd4e
--- /dev/null
+++ b/icon.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128"><path fill="#0078d4" d="M67.328 67.331h60.669V128H67.328zm-67.325 0h60.669V128H.003zM67.328 0h60.669v60.669H67.328zM.003 0h60.669v60.669H.003z"/></svg>
diff --git a/prelude.mk b/prelude.mk
new file mode 100644
index 0000000..da836d7
--- /dev/null
+++ b/prelude.mk
@@ -0,0 +1,23 @@
+# Please see https://tensin.name/blog/notes/makefile.html
+
+MAKEFLAGS += --no-builtin-rules --no-builtin-variables --warn-undefined-variables
+unexport MAKEFLAGS
+.DEFAULT_GOAL := all
+.DELETE_ON_ERROR:
+.SUFFIXES:
+SHELL := bash
+.SHELLFLAGS := -eu -o pipefail -c
+
+escape = $(subst ','\'',$(1))
+
+define noexpand
+ifeq ($$(origin $(1)),environment)
+ $(1) := $$(value $(1))
+endif
+ifeq ($$(origin $(1)),environment override)
+ $(1) := $$(value $(1))
+endif
+ifeq ($$(origin $(1)),command line)
+ override $(1) := $$(value $(1))
+endif
+endef
diff --git a/reboot-into-windows b/reboot-into-windows
new file mode 100755
index 0000000..a6584b9
--- /dev/null
+++ b/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/reboot-into-windows.desktop b/reboot-into-windows.desktop
new file mode 100644
index 0000000..05e55ac
--- /dev/null
+++ b/reboot-into-windows.desktop
@@ -0,0 +1,7 @@
+[Desktop Entry]
+Type=Application
+Name=Reboot into Windows
+Terminal=false
+Exec=sudo reboot-into-windows
+Icon=/usr/share/reboot-into-windows/icon.svg
+Categories=System
diff --git a/sudoers b/sudoers
new file mode 100644
index 0000000..4bb7722
--- /dev/null
+++ b/sudoers
@@ -0,0 +1 @@
+ALL ALL=(ALL) NOPASSWD: /usr/bin/reboot-into-windows