feat: add dinit support

This commit is contained in:
javalsai 2024-07-26 16:40:46 +02:00
parent 844687809b
commit a32e4a577f
Signed by: javalsai
SSH Key Fingerprint: SHA256:3G83yKhBUWVABVX/vPWH88xnK4+ptMtHkZGCRXD4Mk8
7 changed files with 55 additions and 10 deletions

View File

@ -27,10 +27,21 @@ clean:
# Copy lidm to /usr/bin
install: lidm
install -m 755 lidm /usr/bin
if command -v systemctl &> /dev/null; then \
echo "Systemd exists, copying service file"; \
cp assets/li.service /etc/systemd/system/; \
install -m755 ./lidm /usr/bin
install -m755 ./themes/default.ini /etc/lidm.ini
install-service:
@if command -v systemctl &> /dev/null; then \
make install-service-systemd; \
elif command -v dinitctl &> /dev/null; then \
make install-service-dinit; \
else \
echo "No systemd"; \
printf '\x1b[1;31m%s\x1b[0m\n' "Unknown init system, skipping install..."; \
fi
install-service-systemd:
install -m755 ./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
@printf '\x1b[1m%s\x1b[0m\n\n' " don't forget to run 'dinitctl enable lidm'"

View File

@ -1,7 +1,7 @@
# LiDM
LiDM is a really light display manager made in C, highly customizable and held together by hopes and prayers 🙏.
![demo image](assets/lidm.gif)
![demo image](assets/media/lidm.gif)
> *This is shown as in a terminal emulator, actual linux console doesn't support as much color and decorations.*
> *But all colors and strings are fully customizable.*
@ -24,7 +24,6 @@ LiDM is a really light display manager made in C, highly customizable and held t
* Long sessions, strings, usernames, passwords... they will just overflow or fuck your terminal, I know it and I don't know if I'll fix it.
## Forget it
* Any kind of arguments.
* UTF characters, I'm using `strlen()` and treating characters as per byte basis, UTF-8 chars might work or not actually, might fix it by replacing some `strlen()` with a utflen one.
> [!CAUTION]
@ -54,6 +53,8 @@ FYI, this laptop is so bad that I can't even render markdown in reasonable time,
* Make (Also optional, but does things atomatically, make sure `gcc` and `mkdir -p` work as expected).
# Usage
Regarding 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.
On top of pure intuition:
* You can change focus of session/user/passwd with up/down arrows.
* In case arrow keys do nothing on the focused input (Either is empty text or doesn't have more options), it tries to change session and if there's only one session it changes user.
@ -66,13 +67,27 @@ On top of pure intuition:
git clone https://github.com/javalsai/lidm.git
cd lidm
make # 👍
sudo make install
```
# Installation
* You can put the compiled binary anywhere you want tbh, you can even setuid it if you want to run it with any user, but code's not too safe 😬.
* Prepare the [configuration](#configuring).
```sh
# place binary in /usr/bin and copy
# default theme to /etc
make install
```
* Make a service file for this if you want it on launch, just check how ly does it, this works pretty much the same way.
```sh
# automatically detects init system
# and installs service file (for tty7)
make install-service
# There's manual scripts too:
make install-service-systemd # systemd
make install-service-dinit # dinit
```
# Disabling other DM's with systemd
You may want to disable your current Display Manager for instance:

View File

Before

Width:  |  Height:  |  Size: 3.3 MiB

After

Width:  |  Height:  |  Size: 3.3 MiB

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

8
assets/services/dinit Normal file
View File

@ -0,0 +1,8 @@
type = process
command = /sbin/agetty tty7 linux-c -n -l /bin/lidm -o 7
restart = true
depends-on = login.target
termsignal = HUP
smooth-recovery = true
inittab-id = 7
inittab-line = tty7

View File

@ -9,9 +9,20 @@
#include <ui.h>
#include <users.h>
void chvt(char *arg) {
size_t bsize = snprintf(NULL, 0, "chvt %s", arg) + 1;
char *buf = malloc(bsize);
snprintf(buf, bsize, "chvt %s", arg);
system(buf);
free(buf);
}
int main(int argc, char *argv[]) {
struct config* config = parse_config("/etc/lidm.ini");
if(config == NULL) {
if (argc == 2)
chvt(argv[1]);
struct config *config = parse_config("/etc/lidm.ini");
if (config == NULL) {
fprintf(stderr, "error parsing config\n");
return 1;
}