Skip to content

Instantly share code, notes, and snippets.

@thisisignitedoreo
Last active December 27, 2025 22:22
Show Gist options
  • Select an option

  • Save thisisignitedoreo/ffc78ebca45bc38e50fc857fe8b1b1de to your computer and use it in GitHub Desktop.

Select an option

Save thisisignitedoreo/ffc78ebca45bc38e50fc857fe8b1b1de to your computer and use it in GitHub Desktop.
Limine Void Linux (and probably others) config generator script
#!/bin/sh
#
# Kernel post-install hook for Limine configuration.
#
# Arguments passed to this script: $1 pkgname, $2 version.
#
PKGNAME="$1"
VERSION="$2"
if [ ! -x usr/local/bin/gen-limine ]; then
exit 0
fi
usr/local/bin/gen-limine -o boot/limine.conf etc/limine.toml

Limine config generator

Attached python script generates Limine configs by scanning through kernels in the /boot directory and reading in a TOML file with other config info.

Also attached a little XBPS kernel post-install hook script, copy it to /etc/kernel.d/post-install/ and it will update the config every time the kernel updates. Note: it assumes that the script is in /usr/local/bin/gen-limine and the TOML file is in /etc/limine.toml. Edit that if you feel the need for it.

Also note: the code is absolutely janky as hell, but it gets the job done

Run without arguments to see it's usage, should be pretty self-explanatory.

TOML config format

[opts] # options passed as global options to limine - optional
timeout = 5
wallpaper = ["one.png", "two.png"] # lists get passed as the same key with different values
# ...

[os]
cmdline = "BLAH BLAH BLAH" # kernel commandline - probably required to boot
name = "Void Bajingus" # overwrites the /etc/os-release PRETTY_NAME as the os name in the final config - optional
comment = "This is my favourite OS of all time!" # the boot group comment - optional

[os.opts] # other options passed to every boot entry of the kernels - optional
comment = "This is Void Linux with the kernel of the version {}!" # every {} in this sections gets substituted to kernel version
resolution = "1920x1080"
# ...

[oses."Windows 10"] # other oses can be added as keys to the oses category
# everything here gets passed as-is to limine
protocol = "efi"
path = "boot():/EFI/Microsoft/Boot/bootmgfw.efi"
# ...

[oses."Memtest86+"]
protocol = "efi"
path = "boot():/memtest86+/memtest.efi"
# ...

# ...
[os]
cmdline = "root=UUID=ROOTFS_UUID rw" # change this!
[opts]
timeout = 5
#!/usr/bin/env python
import tomllib, sys, glob
def gen_conf(opts, osname, f):
for key, value in opts.get("opts", {}).items():
if isinstance(value, list):
for i in value: f.write(f"{key}: {i}\n")
else:
f.write(f"{key}: {value}\n")
f.write("\n")
f.write(f"/{osname}\n")
if opts.get("os", {}).get("comment"):
f.write(f"\tcomment: {opts.get('os', {}).get('comment')}\n")
f.write("\n")
for kernel in glob.glob("/boot/vmlinuz-*"):
filename = kernel.split("/")[-1]
version = filename[8:]
f.write(f"//{osname} ({version})\n")
f.write("\tprotocol: linux\n")
f.write(f"\tpath: boot():/vmlinuz-{version}\n")
f.write(f"\tmodule_path: boot():/initramfs-{version}.img\n")
f.write(f"\tcmdline: {opts.get('os', {}).get('cmdline', 'rw')}\n")
for key, value in opts.get("os", {}).get("opts", {}).items():
if isinstance(value, list):
for i in value: f.write(f"\t{key}: {str(i).replace('{}', version)}\n")
else:
f.write(f"\t{key}: {str(value).replace('{}', version)}\n")
f.write("\n")
for os, kvs in opts.get("oses", {}).items():
f.write(f"/{os}\n")
for key, value in kvs.items():
if isinstance(value, list):
for i in value: f.write(f"\t{key}: {i}\n")
else:
f.write(f"\t{key}: {value}\n")
f.write("\n")
def get_osname():
with open("/etc/os-release", "r") as f:
kv = f.readline()
while kv:
k, v = kv.split("=")
if k == "PRETTY_NAME":
return v.strip()[1:-1]
kv = f.readline()
def print_help(program):
print(f"Usage: {program} <options>")
print("\nOptions:")
print(" [filename.toml|-] pass an input config")
print(" -o [limine.conf|-] pass an output path")
print(" -O [name] pass an OS name (optional)")
print(" --help print this")
def parse_args(args):
out = {
"osname": None,
"input": None,
"output": None,
}
program = args.pop(0)
while args:
arg = args.pop(0)
if arg == "--help":
print_help(program)
sys.exit(0)
elif arg == "-o":
if not args:
print_help(program)
print("ERROR: Expected a filename")
sys.exit(1)
if out["output"]:
print_help(program)
print("ERROR: Expected one filename")
sys.exit(1)
out["output"] = args.pop(0)
elif arg == "-O":
if not args:
print_help(program)
print("ERROR: Expected an osname")
sys.exit(1)
if out["osname"]:
print_help(program)
print("ERROR: Expected one osname")
sys.exit(1)
out["osname"] = args.pop(0)
else:
out["input"] = arg
if out["output"] is None:
print_help(program)
print("ERROR: Expected one -o [limine.conf|-] flag")
sys.exit(1)
if out["input"] is None:
print_help(program)
print("ERROR: Expected one [filename.toml|-] flag")
sys.exit(1)
return out
if __name__ == "__main__":
args = parse_args(sys.argv)
if args["input"] == "-":
config = tomllib.load(sys.stdin.buffer)
else:
config = tomllib.load(open(args["input"], "rb"))
if args["osname"]:
osname = args["osname"]
elif config.get("os", {}).get("name"):
osname = config.get("os", {}).get("name")
else:
osname = get_osname()
gen_conf(
config,
osname,
sys.stdout if args["output"] == "-" else open(args["output"], "w"),
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment