diff --git a/Makefile b/Makefile index 7ad642b..1eee88c 100644 --- a/Makefile +++ b/Makefile @@ -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'" diff --git a/README.md b/README.md index 08fc412..c780012 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/assets/lidm.gif b/assets/media/lidm.gif similarity index 100% rename from assets/lidm.gif rename to assets/media/lidm.gif diff --git a/assets/lidm.png b/assets/media/lidm.png similarity index 100% rename from assets/lidm.png rename to assets/media/lidm.png diff --git a/assets/services/dinit b/assets/services/dinit new file mode 100644 index 0000000..5d6e7d0 --- /dev/null +++ b/assets/services/dinit @@ -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 diff --git a/assets/li.service b/assets/services/systemd.service similarity index 100% rename from assets/li.service rename to assets/services/systemd.service diff --git a/src/main.c b/src/main.c index 1dfe107..8ed7467 100644 --- a/src/main.c +++ b/src/main.c @@ -9,9 +9,20 @@ #include #include +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; }