47 Commits

Author SHA1 Message Date
d6b165ba8b chore: prepare github build ci for multiple archs 2024-07-26 21:59:04 +02:00
178acd07ad fix: gitignore 2024-07-26 20:41:24 +02:00
dcaab5a782 feat: allow add CFLAGS to make 2024-07-26 20:38:27 +02:00
javalsai
3a80aaa663 Merge pull request #6 from DeaDvey/master
Mostly README changes but other shit too.
2024-07-26 20:36:19 +02:00
9d81c9df8b feat: better handling
* setui/setgid/etc errors are recoverable now
* fix small print_errno arguments bug
* send TERM env var to session (if present)
2024-07-26 18:17:17 +02:00
5861b4dc34 "Mostly README changes" 🤓 2024-07-26 17:17:38 +02:00
a32e4a577f feat: add dinit support 2024-07-26 16:40:46 +02:00
844687809b fix: missing \n (added perror too) 2024-07-26 14:25:22 +02:00
DeaDvey
93f14f398e removed systemd guide, no longer needed 2024-07-26 04:18:20 +01:00
DeaDvey
6590a6ed8f Merge branch 'master' of github.com:DeaDvey/lidm 2024-07-26 04:15:35 +01:00
DeaDvey
a15b49ec24 detects if systemd is there 2024-07-26 04:15:11 +01:00
DeaDvey
e1c5122071 Change install instructions 2024-07-26 03:04:10 +00:00
DeaDvey
cb853cb379 Aesthetics 2024-07-26 02:45:17 +00:00
DeaDvey
691996ff7f Spelling 2024-07-26 02:44:45 +00:00
DeaDvey
53da9b70f7 Updated sytemd docs 2024-07-26 02:43:48 +00:00
DeaDvey
117593f5ec moved li.service 2024-07-26 03:41:18 +01:00
DeaDvey
4fb00e46dc Create li.service 2024-07-26 02:35:23 +00:00
DeaDvey
36296c55ec Removed bullet point 2024-07-26 02:33:45 +00:00
DeaDvey
8c108ee8ca Added docs for systemd 2024-07-26 02:33:10 +00:00
DeaDvey
d38ca16477 Removed the beg for help 2024-07-26 02:03:01 +00:00
DeaDvey
5367e697c5 Update README.md 2024-07-26 01:57:05 +00:00
DeaDvey
2891bf855a Update README.md
Capitalised first letter in ()
2024-07-26 01:56:43 +00:00
DeaDvey
589fa928fc Update README.md
Changed "Compiling"
to "Building from source"
2024-07-26 01:51:07 +00:00
DeaDvey
511deb64cd Update README.md
Did it in first person so it looks like you wrote it, like the rest of the readme
2024-07-26 01:43:55 +00:00
DeaDvey
3f2fec5a42 Update README.md 2024-07-26 01:40:31 +00:00
DeaDvey
ea1d2cbdb2 Update README.md 2024-07-26 01:33:47 +00:00
DeaDvey
148575cf38 Merge branch 'javalsai:master' into master 2024-07-26 01:32:17 +00:00
DeaDvey
849cc4c3e5 Update README.md 2024-07-26 01:31:57 +00:00
DeaDvey
8cc8094fc2 Update README.md 2024-07-26 01:30:54 +00:00
javalsai
1c0cf368e9 Merge pull request #5 from DeaDvey/master
Spelling error 🤓☝️
2024-07-26 03:25:43 +02:00
DeaDvey
8188ea1e31 Update README.md 2024-07-26 01:24:15 +00:00
DeaDvey
923aba1db3 Update README.md
Spelling error
2024-07-26 01:18:52 +00:00
DeaDvey
ee2f279fb7 Update README.md 2024-07-25 23:21:05 +00:00
9993d70c6b docs: fix gifs 2024-07-26 00:25:54 +02:00
5b261827f3 docs: add gif & themes screenshots 2024-07-26 00:23:09 +02:00
12207ee4a9 fix: keep pam session alive 2024-07-25 14:25:11 +02:00
javalsai
e8ec94e150 Merge pull request #2 from killertofus/aur
made a aur pkg
2024-07-25 14:25:02 +02:00
killertofus
f89144110c removed the testing code 2024-07-25 03:06:43 +00:00
killertofus
f9515d8453 made a aur pkg 2024-07-25 03:05:26 +00:00
bd6b0a7d8b docs: better 2024-07-25 02:23:59 +02:00
483445007b fix: bug (it overlaps backwards, moving items >:(, why buggy copy sometimes?) 2024-07-25 02:03:17 +02:00
468ebf769e fix: pam env, actually usable now
if ur in dinit, don't forget about turnstiled
2024-07-25 01:54:54 +02:00
6145973cca oopsie: woopsie 2024-07-18 21:59:13 +02:00
080966978c fix: env stuff 2024-07-16 09:21:53 +02:00
0639b8601a themes: MOAR THEMES 2024-07-15 00:41:53 +02:00
a8ec8a8a0e themes: more themes (accidentally pushed in last commit) 2024-07-15 00:18:23 +02:00
18a00ca264 remove: hardcoded ansi sequence 2024-07-15 00:02:35 +02:00
34 changed files with 601 additions and 117 deletions

11
.SRCINFO Normal file
View File

@@ -0,0 +1,11 @@
pkgbase = lidm
pkgdesc = A ✨fully✨ colorful cutomizable TUI display manager made in C for simplicity.
pkgver = 0.0.0
pkgrel = 1
url = https://github.com/javalsai/lidm
arch = any
license = GPL
source = lidm::https://github.com/javalsai/lidm/releases/download/0.0.0/lidm
sha256sums = 2771ca603fb02520cb1ea2dac10400fd4f512d7a8883a7ecffefe6595a93dcf5
pkgname = lidm

View File

@@ -19,5 +19,5 @@ jobs:
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: lidm
asset_name: lidm
asset_name: lidm-x86_64 # will compile for more archs other day
tag: ${{ github.ref }}

2
.gitignore vendored
View File

@@ -1,4 +1,4 @@
lidm
/lidm
dist/
.cache/

View File

@@ -4,7 +4,9 @@ IDIR=include
ODIR=dist
CC=gcc
CFLAGS=-O3 -I$(IDIR)
CFLAGS?=-O3
_CFLAGS=-I$(DIR)
ALLFLAGS=$(CFLAGS) -I$(IDIR)
LIBS=-lm -lpam -lpam_misc
@@ -16,11 +18,32 @@ OBJ = $(patsubst %,$(ODIR)/%,$(_OBJ))
$(ODIR)/%.o: $(CDIR)/%.c $(DEPS)
@mkdir -p $(ODIR)
$(CC) -c -o $@ $< $(CFLAGS)
$(CC) -c -o $@ $< $(ALLFLAGS)
lidm: $(OBJ)
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
$(CC) -o $@ $^ $(ALLFLAGS) $(LIBS)
.PHONY: clean
clean:
rm -f $(ODIR)/*.o *- li $(INCDIR)/*-
# Copy lidm to /usr/bin
install: lidm
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 \
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'"

14
PKGBUILD Normal file
View File

@@ -0,0 +1,14 @@
pkgname=lidm
pkgver=0.0.0
pkgrel=1
pkgdesc="A ✨fully✨ colorful cutomizable TUI display manager made in C for simplicity."
arch=('any')
url="https://github.com/javalsai/lidm"
license=('GPL')
source=("lidm::https://github.com/javalsai/lidm/releases/download/v$pkgver.zip")
sha256sums=('2771ca603fb02520cb1ea2dac10400fd4f512d7a8883a7ecffefe6595a93dcf5')
package() {
install -d "$pkgdir/usr/bin/lidm"
}
sha256sums=('5eb72f7d0425e81f9b42f70159ecc44d1b6ca5cfd4fde845d01348964273ab64')

113
README.md
View File

@@ -1,83 +1,111 @@
# lidm
Lidm is a really light display manager made in C, highly customizable and held together by hopes and prayers 🙏
# LiDM
LiDM is a really light display manager made in C, highly customizable and held together by hopes and prayers 🙏.
![demo image](assets/lidm.png)
> *this is shown as in a terminal emulator, actual linux console doesn't support as much color and decorations*
![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 suctomizable*
> *I'm open if anybody wants to contact me to record a proper demo of the program, my laptop can't handle it and idk how to config obs for hyprland*
> *But all colors and strings are fully customizable.*
# Index
(TODO, VSC(odium) does this automatically, I'm on nvim rn 😎)
(TODO, VSC(odium) does this automatically, I'm on nvim rn 😎).
## Features
* Builds fast af
* Works everywhere you can get gcc to compile
* Fast and possibly efficient
* Fully customizable, from strings to colors (I hope you know ansi escape codes), to action buttons
* Automatically detects xorg and wayland sessions, plus allowing to launch the default user shell (if enabled in config)
* Builds fast as FUCK.
* 2.830s: laptop, -O3, -j2, `AMD E-450 APU with Radeon(tm) HD Graphics`
* 0.172s: desktop, -O3, -j12, `AMD Ryzen 5 5600G with Radeon Graphics`
* Works everywhere you can get gcc to compile.
* Fast and possibly efficient.
* Fully customizable, from strings, through 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.
## WIP
* desktop's file `TryExec` key
* Save last selection
* Show/hide passwd switch
* Long sessions, strings, usernames, passwords... they will just overflow or f\*ck your terminal, I know it and I don't know if I'll fix it.
* Desktop's file `TryExec` key.
* Save last selection.
* Show/hide passwd switch.
* 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]
> (they should add `> [!DISCLAIMER]` fr) I wrote this readme with the same quality as the code, behing this keyboard there's half a brainrotcell left writing what it remembers of this program, so don't take this to seriously, I'm typing as I think without filter lol, but the program works, or should. Also, about any "TODO" in this readme (or the code), I didn't forget finishing it, I actually don't care. And, references to ~~code~~ **anything** are likely to be outdated, check the commit history to know what I was refering to exactly if you care.
> (They should add `> [!DISCLAIMER]` fr) I wrote this readme with the same quality as the code, behing this keyboard there's half a brainrotcell left writing what it remembers of this program, so don't take this to seriously, I'm typing as I think without filter lol, but the program works, or should. Also, about any "TODO" in this readme (Or the code), I didn't forget finishing it, I actually don't care. And, references to ~~code~~ **anything** are likely to be outdated, check the commit history to know what I was refering to exactly if you care.
# Ideology
We all know that the most important thing in a project is the ideology of the author and the movements he wants to support, so [**#stopchatcontrol**](https://stopchatcontrol.eu).
<!-- doubt markdown will allow me to render this properly -->
[ ![stopchatcontrol](https://stopchatcontrol.eu/wp-content/uploads/2023/09/1-1-1024x1024.png) ](https://stopchatcontrol.eu)
> *there's also a [change.org post](https://www.change.org/p/stoppt-die-chatkontrolle-grundrechte-gelten-auch-im-netz)*
> *there's also a [change.org post](https://www.change.org/p/stoppt-die-chatkontrolle-grundrechte-gelten-auch-im-netz).*
# Backstory
I went into summer travel to visit family with an old laptop that barely supports x86_64, and ly recently added some avx2 instructions I think (I just get invalid op codes), manually building (any previous commit too) didn't work because of something in the `build.zig` file, so out of boredom I decided to craft up my own simple display manager on the only language this thing can handle, ✨C✨ (I hate this and reserve the right for the rust rewrite, actually solid).
I travelling in the summer to visit family with an old laptop that barely supports x86_64, and ly recently added some avx2 instructions I think (I just get invalid op codes), manually building (any previous commit too) didn't work because of something in the `build.zig` file, so out of boredom I decided to craft up my own simple display manager on the only language this thing can handle, ✨C✨ (I hate this and reserve the right for the rust rewrite, actually solid).
I spedrun it, basically did in in 3 days on the same couch on [unhelty back positions (even worse)](https://i.redd.it/4bkje8amisu61.png) while touching *some* grass (:o), and I'm bad af in C, so this is spaghetti code on **another** level. I think it doesn't do almost anything unsafe, I mean, I didn't check allocations and it's capable of reallocating memory until your username uses all memory and crashes the system due to a off by 1 error, but pretty consistent otherwise (probably).
I spedrun it, basically did in in 3 days on the same couch on [unhelty back positions (even worse)](https://i.redd.it/4bkje8amisu61.png) while touching *some* grass (:o), and I'm bad af in C, so this is spaghetti code on **another** level. I think it doesn't do almost anything unsafe, I mean, I didn't check allocations and it's capable of reallocating memory until your username uses all memory and crashes the system due to a off by 1 error, but pretty consistent otherwise (Probably).
The name is just ly byt changing "y" with "i", that had a reason but forgot it, (maybe the i in *simple*), so I remembered this sh*tty laptop with a lid, this thing is also a display manager (dm, ly command is also `ly-dm`), so just did lidm due to all that.
The name is just ly but changing "y" with "i", that had a reason but forgot it, (maybe the i in *simple*), so I remembered this sh*tty laptop with a lid, this thing is also a display manager (Dm, ly command is also `ly-dm`), so just did lidm due to all that.
![think gif](https://i.giphy.com/media/v1.Y2lkPTc5MGI3NjExcTFzaGVmb3VjN3FnOXV6OG9rMG91a2QwM3c0aDV0NWpoZjFzNDEwayZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/d3mlE7uhX8KFgEmY/giphy.gif) <!--gif's likely broken-->
Btw, this laptop is so bad that I can't even render markdown in reasonable time, I'll just push this and fix render issues live :)
FYI, this laptop is so bad that I can't even render markdown in reasonable time, I'll just push this and fix render issues live :).
# Requirements
* A computer with unix based system.
* That system should have the resources neccessary for this program to make sense (sessions, users...)
* A compiler (optional, you can compile by hand, but I doubt you want to see the code)
* Make (also optional, but does things atomatically, make sure `gcc` and `mkdir -p` work as expected)
* That system should have the resources neccessary for this program to make sense (Sessions, users...).
* A compiler (optional, you can compile by hand, but I doubt you want to see the code).
* Make (Also optional, but does things atomatically, make sure `gcc` and `mkdir -p` work as expected).
# Usage
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
* typing anything will allow to put a custom user or shell command too, you can use arrow keys to move
* ESC and then left/right arrows will force to change the option of the focused input, useful if you're editing the current input and arrow keys just move
* editing a predefined option on a user or a shell session, will put you in edit mode preserving the original value, other cases start from scratch
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.
# Compiling
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.
* Typing anything will allow to put a custom user or shell command too, you can use arrow keys to move.
* ESC and then left/right arrows will force to change the option of the focused input, useful if you're editing the current input and arrow keys just move.
* Editing a predefined option on a user or a shell session, will put you in edit mode preserving the original value, other cases start from scratch.
# Building from source
```sh
git clone https://github.com/javalsai/lidm.git
cd lidm
make # 👍
```
# 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)
* 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:
```sh
sudo systemctl disable sddm # Disables SDDM (KDE's dm)
sudo systemctl disable lightdm # Disables lightDM (popular lightweight DM)
sudo systemctl disable gdm # Disables GDM (Gnomes DM)
sudo systemctl disable ly # Disables LYDM (tui dm)
```
# Configuring
Copy `config.ini` (if I haven't moved it) to `/etc/lidm.ini` and configure it to your liking. Also, don't place empty lines (for now).
Copy any `.ini` file from [`themes/`](./themes/) (`default.ini` will always be updated) to `/etc/lidm.ini` and/or configure it to your liking. Also, don't place empty lines (for now).
Also configurable colors are just gonna be put inside `\x1b[...m`, ofc you can add an m to break this and this can f* up really bad or even make some nice UI effect possible, but please don't, you should also be able to embed the `\x1b` byte in the config as I won't parse escape codes, I think that the parser is just gonna grab anything in the config file from the space after the `=` (yes, I'ma enforce that space, get good taste if you don't like it) until the newline, you can put any abomination in there.
Btw, the default fg style should disable decorators set up in other elements (cursive, underline... it's just adding 20 to the number btw, so if cursive is 4 (iirc), disabling it is 24).
The default fg style should disable decorators set up in other elements (cursive, underline... it's just adding 20 to the number btw, so if cursive is 4 (iirc), disabling it is 24).
# Contributing
Don't do this to yourself, but you can ofc, you can also fork or whatever (make sure to comply with GNU's GPLv3), but I want to do the rust rewrite 😡 (after it, I'll leave this around in case somebody with ancient hardware needs it, or if somebody wants to port it for a microwave...)
@@ -86,15 +114,18 @@ This is also GPLv3 bcs I was too lazy to look for the "do anything I don't care"
# Contributors
Special thanks to:
* Javalsai, Maintainer and everyone's second favourite penguin!!!
* DeaDvey, the most awesomest of all, did some pretty HARDCORE gramer cheking.
* KillerTofus, [made the AUR package](https://github.com/javalsai/lidm/pull/2)! Saved me from reading the Arch Wiki 💀.
* ChatGPT, in times of slow laptops where pages take ages to load, a single tab connected to a bunch of burning cloud GPUs feeding corporate hype is all you need to get quick answers for your questions, as long as you know how to filter AI crap ofc.
* My lack of gf, can't imagine this project being possible if somebody actually cared about me daily.
* [My lack of gf](https://www.instagram.com/reel/C8sa3Gltmtq/?igsh=NO_ZUCKERBERG__FUCK_OFF_YOUR_FINGERPRINGTING_QUERY__OBVIOUSLY_STANDS_FOR_INSTAGRAM_SHARE_ID_FFS), can't imagine this project being possible if somebody actually cared about me daily.
# Milestones
* If this ~~video~~ **repo** gets to 100 ~~likes~~ **stars**, I'll make an arch aur package and properly document installation on multiple init systems.
* (I might also make a nix flake if yall nix nerds ask me for it)
* (I might also make a nix flake if yall nix nerds ask me for it).
# Recommendations
Hope you didn't expect actual project recommendations, but these songs are 🔥
Hope you didn't expect actual project recommendations, but these songs are 🔥:
* "Sixpence None the Richer - Kiss Me"
* "Avril Lavigne - Complicated"
* "Shawn Mendes - There's Nothing Holdin' Me Back"
@@ -110,6 +141,8 @@ Hope you didn't expect actual project recommendations, but these songs are 🔥
* "The Neighbourhood - Sweater Weather"
* "Cascada - Everytime We Touch" (potentially the sped up versoin if better)
* "Mitski - My Love Mine All Mine"
* "Dutch Melrose - RUNRUNRUN"
* "Bring Me The Horizon - Happy Song"
Oh, an actual recommendation, if you don't like a element you can change the fg color of it to be the same as the bg.

BIN
assets/media/lidm.gif Normal file

Binary file not shown.

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

@@ -0,0 +1,17 @@
[Unit]
Description=TUI display manager
After=systemd-user-sessions.service plymouth-quit-wait.service
After=getty@tty3.service
Conflicts=getty@tty3.service
[Service]
Type=idle
ExecStart=/usr/bin/lidm
StandardError=journal
StandardInput=tty
TTYPath=/dev/tty3
TTYReset=yes
TTYVHangup=yes
[Install]
Alias=display-manager.service

View File

@@ -3,11 +3,16 @@
#include <security/_pam_types.h>
#include <security/pam_appl.h>
#include <security/pam_misc.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <sys/wait.h>
#include <auth.h>
#include <stdlib.h>
#include <sessions.h>
#include <ui.h>
#include <unistd.h>
#include <util.h>
int pam_conversation(int num_msg, const struct pam_message **msg,
struct pam_response **resp, void *appdata_ptr) {
@@ -26,30 +31,63 @@ int pam_conversation(int num_msg, const struct pam_message **msg,
return PAM_SUCCESS;
}
#define CHECK_PAM_RET(call) \
ret = (call); \
if (ret != PAM_SUCCESS) { \
pam_end(pamh, ret); \
return NULL; \
}
pam_handle_t *get_pamh(char *user, char *passwd) {
pam_handle_t *pamh = NULL;
struct pam_conv pamc = {pam_conversation, (void *)passwd};
int retval;
int ret;
retval = pam_start("login", user, &pamc, &pamh);
if (retval != PAM_SUCCESS) {
return NULL;
}
retval = pam_authenticate(pamh, 0);
if (retval != PAM_SUCCESS) {
pam_end(pamh, retval);
return NULL;
}
retval = pam_acct_mgmt(pamh, 0);
if (retval != PAM_SUCCESS) {
pam_end(pamh, retval);
return NULL;
}
CHECK_PAM_RET(pam_start("login", user, &pamc, &pamh))
CHECK_PAM_RET(pam_authenticate(pamh, 0))
CHECK_PAM_RET(pam_acct_mgmt(pamh, 0))
CHECK_PAM_RET(pam_setcred(pamh, PAM_ESTABLISH_CRED))
CHECK_PAM_RET(pam_open_session(pamh, 0))
CHECK_PAM_RET(pam_setcred(pamh, PAM_REINITIALIZE_CRED))
return pamh;
}
#undef CHECK_PAM_RET
void *shmalloc(size_t size) {
return mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS,
-1, 0);
}
void moarEnv(char *user, struct session session, struct passwd *pw) {
chdir(pw->pw_dir);
setenv("HOME", pw->pw_dir, true);
setenv("USER", pw->pw_name, true);
setenv("SHELL", pw->pw_shell, true);
// TERM
setenv("LOGNAME", pw->pw_name, true);
// MAIL?
// PATH?
char *xdg_session_type;
if (session.type == SHELL)
xdg_session_type = "tty";
if (session.type == XORG)
xdg_session_type = "wayland";
if (session.type == WAYLAND)
xdg_session_type = "x11";
setenv("XDG_SESSION_TYPE", xdg_session_type, true);
/*char *buf;*/
/*size_t bsize = snprintf(NULL, 0, "/run/user/%d", pw->pw_uid) + 1;*/
/*buf = malloc(bsize);*/
/*snprintf(buf, bsize, "/run/user/%d", pw->pw_uid);*/
/*setenv("XDG_RUNTIME_DIR", buf, true);*/
/*setenv("XDG_SESSION_CLASS", "user", true);*/
/*setenv("XDG_SESSION_ID", "1", true);*/
/*setenv("XDG_SESSION_DESKTOP", , true);*/
/*setenv("XDG_SEAT", "seat0", true);*/
}
bool launch(char *user, char *passwd, struct session session,
void (*cb)(void)) {
@@ -59,64 +97,94 @@ bool launch(char *user, char *passwd, struct session session,
return false;
}
gid_t *groups;
int ngroups = 0;
getgrouplist(user, pw->pw_gid, NULL, &ngroups);
groups = malloc(ngroups * sizeof(gid_t));
if (groups == NULL) {
print_err("malloc error");
return false;
}
if (getgrouplist(user, pw->pw_gid, groups, &ngroups) == -1) {
free(groups);
print_err("error fetching groups");
return false;
}
pam_handle_t *pamh = get_pamh(user, passwd);
if (pamh == NULL) {
print_err("error on pam authentication");
return false;
}
char **envlist = pam_getenvlist(pamh);
if (envlist == NULL) {
print_err("error getting pam env");
bool *reach_session = shmalloc(sizeof(bool));
if (reach_session == NULL) {
perror("error allocating shared memory");
return false;
}
*reach_session = false;
// point of no return
int setgrps_ret = setgroups(ngroups, groups);
free(groups);
if (setgrps_ret == -1) {
perror("setgroups");
exit(EXIT_FAILURE);
}
uint pid = fork();
if (pid == 0) { // child
char *TERM = NULL;
char *_GETTERM = getenv("TERM");
if (_GETTERM != NULL)
strcln(&TERM, _GETTERM);
if (clearenv() != 0) {
print_errno("clearenv");
_exit(EXIT_FAILURE);
}
if (setgid(pw->pw_gid) == -1) {
perror("setgid");
exit(EXIT_FAILURE);
}
char **envlist = pam_getenvlist(pamh);
if (envlist == NULL) {
print_errno("pam_getenvlist");
_exit(EXIT_FAILURE);
}
for (uint i = 0; envlist[i] != NULL; i++) {
putenv(envlist[i]);
}
// FIXME: path hotfix
putenv("PATH=/bin:/usr/bin");
if (TERM != NULL) {
setenv("TERM", TERM, true);
free(TERM);
}
if (setuid(pw->pw_uid) == -1) {
perror("setuid");
exit(EXIT_FAILURE);
}
free(envlist);
moarEnv(user, session, pw);
for (char **env = envlist; *env != NULL; env++) {
putenv(*env);
}
// TODO: chown stdin to user
// does it inherit stdin from parent and
// does parent need to reclaim it after
// this dies?
if (cb != NULL)
cb();
if (setgid(pw->pw_gid) == -1) {
print_errno("setgid");
_exit(EXIT_FAILURE);
}
if (initgroups(user, pw->pw_gid) == -1) {
print_errno("initgroups");
_exit(EXIT_FAILURE);
}
pam_end(pamh, PAM_SUCCESS);
if (session.type == SHELL) {
system("clear");
execl(session.exec, session.exec, NULL);
} else if (session.type == XORG || session.type == WAYLAND) {
system("clear");
execl(session.exec, session.exec, NULL);
if (setuid(pw->pw_uid) == -1) {
perror("setuid");
_exit(EXIT_FAILURE);
}
if (cb != NULL)
cb();
*reach_session = true;
// TODO: these will be different due to TryExec
// and, Exec/TryExec might contain spaces as args
if (session.type == SHELL) {
system("clear");
execlp(session.exec, session.exec, NULL);
} else if (session.type == XORG || session.type == WAYLAND) {
system("clear");
execlp(session.exec, session.exec, NULL);
}
perror("execl error");
fprintf(stderr, "failure calling session");
} else {
waitpid(pid, NULL, 0);
pam_setcred(pamh, PAM_DELETE_CRED);
pam_close_session(pamh, 0);
pam_end(pamh, PAM_SUCCESS);
if (*reach_session == false) {
return false;
} else
exit(0);
}
return true;

View File

@@ -32,7 +32,7 @@ void field_update(struct editable_field *field, char *update) {
if (*update == 127) {
if (field->pos == 0) return;
if (field->pos < field->length) {
memcpy(&field->content[field->pos - 1], &field->content[field->pos],
memmove(&field->content[field->pos - 1], &field->content[field->pos],
field->length - field->pos);
}
(field->pos)--;

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;
}

View File

@@ -40,6 +40,7 @@ static u_int16_t used_size = 0;
static struct session *sessions = NULL;
static struct sessions_list *__sessions_list = NULL;
// NOTE: commented printf's here would be nice to have debug logs if I ever implement it
static enum session_type session_type;
static int fn(const char *fpath, const struct stat *sb, int typeflag) {
// practically impossible to reach this
@@ -47,12 +48,14 @@ static int fn(const char *fpath, const struct stat *sb, int typeflag) {
if (used_size == 0xffff)
return 0;
if (!S_ISREG(sb->st_mode))
if (sb == NULL || !S_ISREG(sb->st_mode))
return 0;
/*printf("gonna open %s\n", fpath);*/
FILE *fd = fopen(fpath, "r");
if (fd == NULL) {
fprintf(stderr, "error opening file (r) %s", fpath);
perror("fopen");
fprintf(stderr, "error opening file (r) %s\n", fpath);
return 0;
}
@@ -63,6 +66,7 @@ static int fn(const char *fpath, const struct stat *sb, int typeflag) {
char *exec_buf = NULL;
char *tryexec_buf = NULL;
while (true) {
/*printf(".");*/
char *buf = malloc(sb->st_blksize);
ssize_t read_size = getline(&buf, &alloc_size, fd);
if (read_size == -1) {
@@ -91,11 +95,13 @@ static int fn(const char *fpath, const struct stat *sb, int typeflag) {
if (found == 0b111)
break;
}
/*printf("\nend parsing...\n");*/
fclose(fd);
// just add this to the list
if (name_buf != NULL && exec_buf != NULL) {
/*printf("gonna add to session list\n");*/
if (used_size >= alloc_size) {
alloc_size += bs;
sessions = realloc(sessions, alloc_size * unit_size);
@@ -128,6 +134,7 @@ struct sessions_list *get_avaliable_sessions() {
for (uint i = 0; i < sources_size; i++) {
session_type = sources[i].type;
/*printf("recurring into %s\n", sources[i].dir);*/
ftw(sources[i].dir, &fn, 1);
}

View File

@@ -395,10 +395,9 @@ int load(struct users_list *users, struct sessions_list *sessions) {
get_current_session(), &restore_all)) {
print_passwd(box_start(), of_passwd.efield.length, true);
ffield_cursor_focus();
continue;
}
}
ffield_type(seq);
} else
ffield_type(seq);
}
if (esc != 0)
@@ -486,7 +485,7 @@ static void print_passwd(struct uint_point origin, uint length, bool err) {
memset(passwd_prompt, 32, 32);
memset(passwd_prompt, '*', length);
printf("\r\x1b[%dC\x1b[%sm\x1b[4m", origin.x + 14, pass_color);
printf("\r\x1b[%dC\x1b[%sm", origin.x + 14, pass_color);
fflush(stdout);
write(STDOUT_FILENO, passwd_prompt, 32);
printf("\x1b[%sm", theme.colors.fg);
@@ -570,7 +569,7 @@ void print_errno(const char *descr) {
origin.x, theme.colors.err, errno, strerror(errno));
else {
fprintf(stderr, "\x1b[%d;%dH\x1b[%sm%s(%d): %s", origin.y - 1, origin.x,
descr, theme.colors.err, errno, strerror(errno));
theme.colors.err, descr, errno, strerror(errno));
}
}

29
themes/README.md Normal file
View File

@@ -0,0 +1,29 @@
# Themes
## cherry.ini
![cherry.ini theme](./screenshots/cherry.png)
## default.ini
![default.ini theme](./screenshots/default.png)
## nature.ini
![nature.ini theme](./screenshots/nature.png)
## nord.ini
![nord.ini theme](./screenshots/nord.png)
## old-blue.ini
![old-blue.ini theme](./screenshots/old-blue.png)
## old-blue-thick.ini
![old-blue-thick.ini theme](./screenshots/old-blue-thick.png)
## pure-tastelessness.ini
![pure-tastelessness.ini theme](./screenshots/pure-tastelessness.png)
## tasteless.ini
![tasteless.ini theme](./screenshots/tasteless.png)
## tastelessness.ini
![tastelessness.ini theme](./screenshots/tastelessness.png)

33
themes/cherry.ini Normal file
View File

@@ -0,0 +1,33 @@
colors.bg = 48;2;77;33;55
colors.fg = 22;3;24;38;2;245;245;245
colors.err = 1;31
colors.s_wl = 38;2;255;174;66
colors.s_xorg = 38;2;37;175;255
colors.s_shell = 32
colors.f_other = 38;2;255;64;64
colors.e_hostname = 1;23;38;5;197
colors.e_date = 31
colors.e_box = 31
colors.e_header = 1;4;38;5;204
colors.e_user = 38;5;51
colors.e_passwd = 4;2;38;5;203
colors.e_badpasswd = 4;31
colors.e_key = 1;23;38;5;197
chars.hb =
chars.vb =
chars.ctl =
chars.ctr =
chars.cbl =
chars.cbr =
functions.poweroff = F1
functions.reboot = F2
functions.refresh = F5
strings.f_poweroff = poweroff
strings.f_reboot = reboot
strings.f_refresh = refresh
strings.e_user = user
strings.e_passwd = password
strings.s_xorg = xorg
strings.s_wayland = wayland
strings.s_shell = shell
behavior.include_defshell = true

33
themes/nature.ini Normal file
View File

@@ -0,0 +1,33 @@
colors.bg = 48;2;15;22;15
colors.fg = 22;23;24;38;2;245;245;245
colors.err = 1;31
colors.s_wl = 38;2;255;174;66
colors.s_xorg = 38;2;37;175;255
colors.s_shell = 32
colors.f_other = 38;2;255;64;64
colors.e_hostname = 38;5;28
colors.e_date = 32
colors.e_box = 32
colors.e_header = 1;4;32
colors.e_user = 38;5;51
colors.e_passwd = 4;2;38;5;83
colors.e_badpasswd = 3;4;31
colors.e_key = 32
chars.hb =
chars.vb =
chars.ctl =
chars.ctr =
chars.cbl =
chars.cbr =
functions.poweroff = F1
functions.reboot = F2
functions.refresh = F5
strings.f_poweroff = poweroff
strings.f_reboot = reboot
strings.f_refresh = refresh
strings.e_user = user
strings.e_passwd = password
strings.s_xorg = xorg
strings.s_wayland = wayland
strings.s_shell = shell
behavior.include_defshell = true

33
themes/nord.ini Normal file
View File

@@ -0,0 +1,33 @@
colors.bg = 48;2;19;19;22
colors.fg = 22;24;38;2;245;245;245
colors.err = 1;31
colors.s_wl = 38;2;255;174;66
colors.s_xorg = 38;2;37;175;255
colors.s_shell = 32
colors.f_other = 38;2;255;64;64
colors.e_hostname = 34
colors.e_date = 38;2;66;66;88
colors.e_box = 38;2;122;122;122
colors.e_header = 1;4;36
colors.e_user = 38;5;51
colors.e_passwd = 4;2;38;5;80
colors.e_badpasswd = 3;4;31
colors.e_key = 34
chars.hb =
chars.vb =
chars.ctl =
chars.ctr =
chars.cbl =
chars.cbr =
functions.poweroff = F1
functions.reboot = F2
functions.refresh = F5
strings.f_poweroff = poweroff
strings.f_reboot = reboot
strings.f_refresh = refresh
strings.e_user = user
strings.e_passwd = password
strings.s_xorg = xorg
strings.s_wayland = wayland
strings.s_shell = shell
behavior.include_defshell = true

33
themes/old-blue-thick.ini Normal file
View File

@@ -0,0 +1,33 @@
colors.bg = 48;2;0;0;255
colors.fg = 22;24;39;48;2;0;0;255
colors.err = 1;31
colors.s_wl = 38;2;255;174;66
colors.s_xorg = 38;2;37;175;255
colors.s_shell = 38;2;34;140;34
colors.f_other = 38;2;255;64;64
colors.e_hostname = 38;2;255;64;64
colors.e_date = 38;2;144;144;144
colors.e_box = 34
colors.e_header = 4;38;2;0;255;0
colors.e_user = 36
colors.e_passwd = 4;38;2;245;245;205
colors.e_badpasswd = 3;4;31
colors.e_key = 1;31;48;2;255;174;66
chars.hb =
chars.vb = ███
chars.ctl = ███
chars.ctr = ███
chars.cbl = ███
chars.cbr = ███
functions.poweroff = F1
functions.reboot = F2
functions.refresh = F5
strings.f_poweroff = powewoff
strings.f_reboot = rewoot
strings.f_refresh = rewresh
strings.e_user = wuser
strings.e_passwd = passwd
strings.s_xorg = xworg
strings.s_wayland = waywand
strings.s_shell = swell
behavior.include_defshell = true

33
themes/old-blue.ini Normal file
View File

@@ -0,0 +1,33 @@
colors.bg = 48;2;0;0;255
colors.fg = 22;24;39;48;2;0;0;255
colors.err = 1;31
colors.s_wl = 38;2;255;174;66
colors.s_xorg = 38;2;37;175;255
colors.s_shell = 38;2;34;140;34
colors.f_other = 38;2;255;64;64
colors.e_hostname = 38;2;255;64;64
colors.e_date = 38;2;144;144;144
colors.e_box = 34
colors.e_header = 4;38;2;0;255;0
colors.e_user = 36
colors.e_passwd = 4;38;2;245;245;205
colors.e_badpasswd = 3;4;31
colors.e_key = 1;31;48;2;255;174;66
chars.hb =
chars.vb =
chars.ctl =
chars.ctr =
chars.cbl =
chars.cbr =
functions.poweroff = F1
functions.reboot = F2
functions.refresh = F5
strings.f_poweroff = powewoff
strings.f_reboot = rewoot
strings.f_refresh = rewresh
strings.e_user = wuser
strings.e_passwd = passwd
strings.s_xorg = xworg
strings.s_wayland = waywand
strings.s_shell = swell
behavior.include_defshell = true

View File

@@ -0,0 +1,33 @@
colors.bg = -
colors.fg = 24;39m[?25l[-
colors.err = -
colors.s_wl = -
colors.s_xorg = -
colors.s_shell = -
colors.f_other = -
colors.e_hostname = 30
colors.e_date = 30
colors.e_box = -
colors.e_header = 30
colors.e_user = -
colors.e_passwd = 24;30
colors.e_badpasswd = -
colors.e_key = 30
chars.hb = -
chars.vb = -
chars.ctl = -
chars.ctr = -
chars.cbl = -
chars.cbr = -
functions.poweroff = F1
functions.reboot = F2
functions.refresh = F5
strings.f_poweroff = -
strings.f_reboot = -
strings.f_refresh = -
strings.e_user = -
strings.e_passwd = -
strings.s_xorg = -
strings.s_wayland = -
strings.s_shell = -
behavior.include_defshell = false

Binary file not shown.

After

Width:  |  Height:  |  Size: 261 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 267 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 262 KiB

BIN
themes/screenshots/nord.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 262 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 273 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 267 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 333 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 344 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 347 KiB

33
themes/tasteless.ini Normal file
View File

@@ -0,0 +1,33 @@
colors.bg = -
colors.fg = 24
colors.err = -
colors.s_wl = -
colors.s_xorg = -
colors.s_shell = -
colors.f_other = -
colors.e_hostname = -
colors.e_date = -
colors.e_box = -
colors.e_header = -
colors.e_user = -
colors.e_passwd = -
colors.e_badpasswd = -
colors.e_key = -
chars.hb =
chars.vb =
chars.ctl =
chars.ctr =
chars.cbl =
chars.cbr =
functions.poweroff = F1
functions.reboot = F2
functions.refresh = F5
strings.f_poweroff = poweroff
strings.f_reboot = reboot
strings.f_refresh = refresh
strings.e_user = user
strings.e_passwd = password
strings.s_xorg = xorg
strings.s_wayland = wayland
strings.s_shell = shell
behavior.include_defshell = true

33
themes/tastelessness.ini Normal file
View File

@@ -0,0 +1,33 @@
colors.bg = -
colors.fg = 24;39m[?25l[-
colors.err = -
colors.s_wl = -
colors.s_xorg = -
colors.s_shell = -
colors.f_other = -
colors.e_hostname = -
colors.e_date = 30
colors.e_box = -
colors.e_header = 30
colors.e_user = -
colors.e_passwd = 24;30
colors.e_badpasswd = -
colors.e_key = -
chars.hb = -
chars.vb = -
chars.ctl = -
chars.ctr = -
chars.cbl = -
chars.cbr = -
functions.poweroff = F1
functions.reboot = F2
functions.refresh = F5
strings.f_poweroff = poweroff
strings.f_reboot = reboot
strings.f_refresh = refresh
strings.e_user = user
strings.e_passwd = password
strings.s_xorg = xorg
strings.s_wayland = wayland
strings.s_shell = shell
behavior.include_defshell = true