From 50c251318a06434d1ceac90e27d36ef9fa1ac6ec Mon Sep 17 00:00:00 2001 From: javalsai Date: Tue, 3 Sep 2024 20:33:47 +0200 Subject: [PATCH] feat: add runit support --- Makefile | 11 ++++++++--- README.md | 5 +++-- assets/pkg/aur/README.md | 1 + assets/services/runit/conf | 5 +++++ assets/services/runit/finish | 5 +++++ assets/services/runit/run | 15 +++++++++++++++ 6 files changed, 37 insertions(+), 5 deletions(-) create mode 100755 assets/services/runit/conf create mode 100755 assets/services/runit/finish create mode 100755 assets/services/runit/run diff --git a/Makefile b/Makefile index c2800a9..a65c8d0 100644 --- a/Makefile +++ b/Makefile @@ -43,13 +43,18 @@ install-service: make install-service-systemd; \ elif command -v dinitctl &> /dev/null; then \ make install-service-dinit; \ + elif command -v sv &> /dev/null; then \ + make install-service-runit; \ else \ - printf '\x1b[1;31m%s\x1b[0m\n' "Unknown init system, skipping install..."; \ + printf '\x1b[1;31m%s\x1b[0m\n' "Unknown init system, skipping service install..."; \ fi install-service-systemd: - install -m755 ./assets/services/systemd.service /etc/systemd/system/lidm.service + install -m655 ./assets/services/systemd.service /etc/systemd/system/lidm.service @printf '\x1b[1m%s\x1b[0m\n\n' " don't forget to run 'systemctl enable lidm'" install-service-dinit: - install -m755 ./assets/services/dinit /etc/dinit.d/lidm + install -m655 ./assets/services/dinit /etc/dinit.d/lidm @printf '\x1b[1m%s\x1b[0m\n\n' " don't forget to run 'dinitctl enable lidm'" +install-service-runit: + rsync -a --no-owner --no-group ./assets/services/runit/. /etc/runit/sv/lidm + @printf '\x1b[1m%s\x1b[0m\n\n' " don't forget to run 'ln -s /etc/runit/sv/lidm /run/runit/service' and 'sv enable lidm'" diff --git a/README.md b/README.md index 57042c5..2d20e64 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ LiDM is like any [X Display Manager](https://en.wikipedia.org/wiki/X_display_man * Fast and possibly efficient. * Fully customizable, from strings, including action keys, to colors (I hope you know ansi escape codes) * Automatically detects xorg and wayland sessions, plus allowing to launch the default user shell (if enabled in config) -* Starts with many init systems eg: systemd and dinit. +* Starts with many init systems (systemd, dinit and runit). ## WIP * Desktop's file `TryExec` key. @@ -60,7 +60,7 @@ We all know that the most important thing in a project is the ideology of the au # Usage ### Arguments -If a single argument is provided (don't even do `--` or standard parsing...), it passes that argument to `chvt` on startup, used (at least) by the dinit service. +If a single argument is provided (don't even do `--` or standard parsing...), it passes that argument to `chvt` on startup, used (at least) by the dinit and runit services. ### Program On top of pure intuition: @@ -100,6 +100,7 @@ make install-service # or if you don't like autodetection make install-service-systemd # systemd make install-service-dinit # dinit +# ...other supported init systems.... ``` ## AUR diff --git a/assets/pkg/aur/README.md b/assets/pkg/aur/README.md index 7df5f1a..2002ad9 100644 --- a/assets/pkg/aur/README.md +++ b/assets/pkg/aur/README.md @@ -15,3 +15,4 @@ There are three packages that follow standard conventions: Summary of what to do to install service files anyways: * **systemd:** Copy `assets/services/systemd.service` to `/etc/systemd/system/lidm.service` and enable the service (`systemctl enable lidm`) * **dinit:** Copy `assets/services/dinit` to `/etc/dinit.d/lidm` and enable the service (`dinitctl enable lidm`) +* **runit:** Copy `assets/services/runit/` to `/etc/runit/sv/lidm/`, add the service (`ln -s /etc/runit/sv/lidm /run/runit/service`) and enable it (`sv enable lidm`) diff --git a/assets/services/runit/conf b/assets/services/runit/conf new file mode 100755 index 0000000..f746645 --- /dev/null +++ b/assets/services/runit/conf @@ -0,0 +1,5 @@ +BAUD_RATE=38400 +TERM_NAME=linux + +TTY=tty7 +EXEC_PATH=/bin/lidm diff --git a/assets/services/runit/finish b/assets/services/runit/finish new file mode 100755 index 0000000..1fc9229 --- /dev/null +++ b/assets/services/runit/finish @@ -0,0 +1,5 @@ +#!/bin/sh + +[ -r conf ] && . ./conf + +exec utmpset -w $TTY diff --git a/assets/services/runit/run b/assets/services/runit/run new file mode 100755 index 0000000..1601cef --- /dev/null +++ b/assets/services/runit/run @@ -0,0 +1,15 @@ +#!/bin/sh + +[ -r conf ] && . ./conf + +if [ -x /sbin/getty -o -x /bin/getty ]; then + # busybox + GETTY=getty +elif [ -x /sbin/agetty -o -x /bin/agetty ]; then + # util-linux + GETTY=agetty +fi + +exec setsid ${GETTY} ${GETTY_ARGS} \ + "${TTY}" "${TERM_NAME}" \ + -n -l "${EXEC_PATH}" -o 7