97 Commits

Author SHA1 Message Date
e3052ec5bc Merge pull request #20 from javalsai/nix-flake
feat: add Nix flake
2024-08-27 14:06:43 +02:00
grialion
8bdfa7d609 feat: add Nix flake 2024-08-24 15:58:55 +02:00
grialion
528c4538c7 fix(Makefile): use DESTDIR and PREFIX paths 2024-08-24 15:58:18 +02:00
154308dfd7 feat(ci): make build check a check status 2024-08-21 17:13:38 +02:00
c4c358ceef feat(ci): add actions dependabot 2024-08-21 16:03:30 +02:00
57cb0cd9ad fix(ci): workflows 2024-08-21 15:58:22 +02:00
b900701b8f feat(ci): add nicer workflows
between all those changes, now x64 builds should be produced
2024-08-20 23:56:54 +02:00
ca95d390c2 fix: build error on x64 2024-08-20 23:56:46 +02:00
a1f8994c94 mod(actions): add cooldown action 2024-08-20 19:26:50 +02:00
2bcc3f71cc docs: add grialion and cereal to readme#contributors 2024-08-16 19:30:02 +02:00
javalsai
4af0ec545e Merge pull request #14 from cerealexperimentation/added-a-missing-newline
I think there's supposed to be a newline here.
2024-08-16 13:51:20 +02:00
Cereal
e0a0df80c0 added a missing newline to src/auth.c 2024-08-16 03:37:04 +01:00
fe4a52ecfa chore: chvt_str into chvt.c 2024-08-07 00:14:19 +02:00
javalsai
a393cda7e1 Merge pull request #11 from grialion/master
feat(chvt): use custom implementation instead of system()
2024-08-07 00:10:13 +02:00
4de2720bed small changes 2024-08-07 00:07:44 +02:00
javalsai
cbdcccc4ae Merge pull request #13 from DeaDvey/master
....
2024-08-06 23:45:43 +02:00
b7f6cf690b markdown 👍 2024-08-06 23:44:41 +02:00
DeaDvey
d6f19094c1 Update README.md 2024-08-06 21:37:17 +00:00
DeaDvey
48803df2d8 Update README.md 2024-08-06 21:36:33 +00:00
DeaDvey
d97ba068ff Update README.md 2024-08-06 21:36:20 +00:00
javalsai
842f915f41 Merge pull request #10 from DeaDvey/master
deadvey...
2024-08-06 23:35:33 +02:00
DeaDvey
df283109d7 Update README.md 2024-08-06 21:34:18 +00:00
DeaDvey
cbe73ad4ff Update README.md 2024-08-06 21:33:56 +00:00
grialion
e745b27a68 feat(chvt): use custom implementation instead of system()
Calling system() is vulnerable and shouldn't be used.
2024-08-06 17:11:18 +02:00
eeba4a5f39 remove: unnecessary clangd file 2024-08-06 16:29:19 +02:00
57f5f41995 docs: more compile speed flexing 😎 2024-08-06 15:33:42 +02:00
8b1216c232 chore: ignore compile_commands.json 2024-08-06 15:33:13 +02:00
DeaDvey
6ea79edaf4 Update README.md
Fuck markdown
2024-07-30 20:39:25 +01:00
DeaDvey
7529b0365f Update README.md
Added link to what a display manager is
2024-07-30 20:38:32 +01:00
663427ec95 fix: makdepends 2024-07-30 21:37:17 +02:00
DeaDvey
a738a23b75 removed li.service 2024-07-29 20:05:00 +01:00
DeaDvey
e71d2fdd8c whoops 2024-07-29 20:03:02 +01:00
DeaDvey
98598cf490 fixed inconsistent hyphens! 2024-07-29 20:00:57 +01:00
DeaDvey
5eb3cdc7ad moved li.service 2024-07-29 19:55:40 +01:00
9c3b158fb7 whoops 2024-07-28 17:30:02 +02:00
be74e5ef40 add: maintainer to aur packages
close #9
2024-07-28 16:48:22 +02:00
cac037cb48 docs: better gif (gifski)
for the record, `gifski -Q 100 -W 1366 --fps 2 -o all.gif *.png`
2024-07-28 01:01:24 +02:00
dcd26986b2 fix #7 2024-07-28 00:53:42 +02:00
09ce3ef149 feat: add make uninstall script 2024-07-27 22:56:16 +02:00
javalsai
6d13110eed Merge pull request #8 from killertofus/docs
README more readable
2024-07-27 22:52:59 +02:00
fc23510b09 docs: add some badges 2024-07-27 22:50:09 +02:00
a9d3c29ca5 docs: several improvements 2024-07-27 22:39:53 +02:00
javalsai
df38990d8b Merge branch 'master' into docs 2024-07-27 21:52:45 +02:00
killertofus
3efd6e0606 Update CONTRIBUTING.md 2024-07-27 17:59:39 +00:00
killertofus
418096dc4e Add files via upload 2024-07-27 17:57:00 +00:00
killertofus
6f3a69307f made it look better 2024-07-27 17:54:38 +00:00
0d564b9294 fix provide and conflicts 2024-07-27 09:52:17 +02:00
8f471df5bc chore: better aur docs & .gitignores 2024-07-27 03:27:17 +02:00
d85e3f5620 valid markdown :| 2024-07-27 03:04:32 +02:00
9eb059410b feat: aur yayyy! (paru >>>) 2024-07-27 03:02:23 +02:00
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
55 changed files with 1206 additions and 286 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

@@ -1,3 +0,0 @@
CompileFlags:
Add:
- "-Iinclude"

54
.github/actions/build/action.yml vendored Normal file
View File

@@ -0,0 +1,54 @@
name: Build Project
on:
workflow_call:
# TODO: make arch_name optional (dont upload artifact)
inputs:
arch_name:
description: "Architecture Name"
required: true
cc:
description: "The compiler to use"
required: false
default: "gcc"
cflags:
description: "Compiler flags"
required: false
default: ""
runs:
using: "composite"
steps:
- uses: actions/checkout@v4
# cache-apt-pkgs-action try to cache :i386 packages challenge impossible
- if: ${{ inputs.arch_name == 'x86' }}
shell: bash
run: |
sudo dpkg --add-architecture i386
sudo apt-get update -y
sudo apt-get install -y libpam0g-dev:i386
- uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: "libpam0g-dev gcc-multilib"
version: 1.0
- name: Build Code
shell: bash
run: |
make CC=${{ inputs.cc }} CFLAGS="-O3 ${{ inputs.cflags }}" \
2> stderr-${{ inputs.arch_name }}
mv lidm lidm-${{ inputs.arch_name }}
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: build-${{ inputs.arch_name }}
path: |
lidm-${{ inputs.arch_name }}
stderr-${{ inputs.arch_name }}
retention-days: 1

7
.github/dependabot.yml vendored Normal file
View File

@@ -0,0 +1,7 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: ".github/workflows"
schedule:
interval: "daily"

65
.github/workflows/build-check.yml vendored Normal file
View File

@@ -0,0 +1,65 @@
name: Test Build
on: push
jobs:
check_build:
permissions: write-all
strategy:
matrix:
include:
- arch_name: x86_64
cc: gcc
cflags:
- arch_name: x86
cc: gcc
cflags: -m32
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: myrotvorets/set-commit-status-action@master
with:
token: ${{ secrets.GITHUB_TOKEN }}
status: pending
context: Build (${{ matrix.arch_name }})
- name: Attempt Build (${{ matrix.arch_name }})
uses: ./.github/actions/build
with:
arch_name: ${{ matrix.arch_name }}
cc: ${{ matrix.cc }}
cflags: "-Wall ${{ matrix.cflags }}"
- name: Download Build Results
uses: actions/download-artifact@v4
with:
name: build-${{ matrix.arch_name }}
path: build-results
- name: Process Results
id: get-stats
if: always()
run: |
if ! [ -d "build-results" ]; then
# Build failed
echo "DESCR=" >> "$GITHUB_OUTPUT"
else
# Build Succeeded
cd "build-results"
ls -lah
cat stderr-* >&2
WARNS="$(cat stderr-* | grep '^[^ ]*\.[ch]:' | wc -l)"
HSIZE="$(stat --printf="%s" lidm-* | numfmt --to=iec-i)B"
echo "DESCR='$HSIZE, $WARNS warnings'" >> "$GITHUB_OUTPUT"
fi
- name: Set final commit status
uses: myrotvorets/set-commit-status-action@master
if: always()
with:
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}
context: Build (${{ matrix.arch_name }})
description: ${{ steps.get-stats.outputs.DESCR }}

20
.github/workflows/cooldown.yml vendored Normal file
View File

@@ -0,0 +1,20 @@
name: Issues
on:
issue_comment:
types: [created]
issues:
types: [opened]
jobs:
cooldown:
name: Cooldown
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: Cooldown
uses: osy/github-cooldown-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
cooldownMinutes: 15
maxNewIssues: 2
maxNewComments: 15

View File

@@ -1,23 +1,56 @@
name: C Make
name: Build for Release
on:
release:
types: [created]
jobs:
release:
permissions: write-all
build:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- arch_name: x86_64
cc: gcc
cflags:
- arch_name: x86
cc: gcc
cflags: -m32
steps:
- uses: actions/checkout@v4
- name: Install deps
run: sudo apt-get install -y libpam0g-dev
- name: make
run: make
- uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: lidm
asset_name: lidm
tag: ${{ github.ref }}
- uses: actions/checkout@v4
- name: Build Project
uses: ./.github/actions/build
with:
arch_name: ${{ matrix.arch_name }}
cc: ${{ matrix.cc }}
cflags: ${{ matrix.cflags }}
upload:
permissions: write-all
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
- name: Merge Build Artifacts
uses: actions/upload-artifact/merge@v4
with:
name: all-builds
pattern: build-*
delete-merged: true
retention-days: 1
- uses: actions/download-artifact@v4
with:
name: all-builds
path: builds
- name: Upload Builds to Release
run: |
cd builds
for file in ./*; do
echo "Uploading $file..."
gh release upload ${{ github.event.release.tag_name }} "$file" --clobber
done
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

6
.gitignore vendored
View File

@@ -1,4 +1,8 @@
lidm
/lidm
dist/
/compile_commands.json
.cache/
# nix build result
result

View File

@@ -3,24 +3,53 @@ LDIR=lib
IDIR=include
ODIR=dist
CC=gcc
CFLAGS=-O3 -I$(IDIR)
PREFIX=/usr
CC?=gcc
CFLAGS?=-O3
_CFLAGS=-I$(DIR)
ALLFLAGS=$(CFLAGS) -I$(IDIR)
LIBS=-lm -lpam -lpam_misc
_DEPS = util.h ui.h config.h auth.h efield.h keys.h users.h sessions.h
_DEPS = util.h ui.h config.h auth.h efield.h keys.h users.h sessions.h chvt.h
DEPS = $(patsubst %,$(IDIR)/%,$(_DEPS))
_OBJ = main.o util.o ui.o config.o auth.o efield.o users.o sessions.o
_OBJ = main.o util.o ui.o config.o auth.o efield.o users.o sessions.o chvt.o
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 ${DESTDIR}${PREFIX}/bin (/usr/bin)
install: lidm
mkdir -p ${DESTDIR}${PREFIX}/bin ${DESTDIR}/etc
install -m755 ./lidm ${DESTDIR}${PREFIX}/bin
install -m755 ./themes/default.ini ${DESTDIR}/etc/lidm.ini
uninstall:
rm -rf ${DESTDIR}${PREFIX}/bin/lidm ${DESTDIR}/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')

189
README.md
View File

@@ -1,116 +1,139 @@
# lidm
Lidm is a really light display manager made in C, highly customizable and held together by hopes and prayers 🙏
[![GitHub license](https://badgen.net/github/license/javalsai/lidm)](https://github.com/javalsai/lidm/blob/master/LICENSE)
[![GitHub branches](https://badgen.net/github/branches/javalsai/lidm)](https://github.com/javalsai/lidm)
[![Latest Release](https://badgen.net/github/release/javalsai/lidm)](https://github.com/javalsai/lidm/releases)
![demo image](assets/lidm.png)
> *this is shown as in a terminal emulator, actual linux console doesn't support as much color and decorations*
# LiDM
LiDM is a really light UI portion a unix [login manager](https://en.wikipedia.org/wiki/Login_manager) made in C, highly customizable and held together by hopes and prayers 🙏.
> *but all colors and strings are fully suctomizable*
LiDM is like any [X Display Manager](https://en.wikipedia.org/wiki/X_display_manager) you have seen such as SDDM or GDM but without using X org graphics, instead being a purely [text based interface](https://en.wikipedia.org/wiki/Text-based_user_interface).
> *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*
![demo gif](assets/media/lidm.gif)
> *shown as in a featured terminal emulator, actual linux console doesn't support as much color and decorations*
# Index
(TODO, VSC(odium) does this automatically, I'm on nvim rn 😎)
> *however, all colors and strings are fully customizable*
## 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
* Builds **FAST**.
* `a32e4a5`:
* `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`
* `663427e`:
* `0.085s`: desktop, -O0, `AMD Ryzen 5 5600G with Radeon Graphics`
* `0.009s`: desktop, -O0, CC=tcc, `AMD Ryzen 5 5600G with Radeon Graphics`
* Works everywhere you can get gcc to compile.
* 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.
## 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.
* UTF characters or any multi-byte character, not yet supported properly, everything treats characters as a single byte, some chars might work or not depending on the context, but it's not designed to.
## 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.
# Index
- [LiDM](#lidm)
- [Features](#features)
- [WIP](#wip)
- [Index](#index)
- [Ideology](#ideology)
- [Usage](#usage)
- [Arguments](#arguments)
- [Program](#program)
- [Requirements](#requirements)
- [Installation](#installation)
- [Manually](#manually)
- [AUR](#aur)
- [Configuring](#configuring)
- [Contributing](#contributing)
- [Backstory](#backstory)
- [Contributors](#contributors)
# 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 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).
# 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.
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.
![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 :)
### Program
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.
# 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)
# 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
# Compiling
```sh
make # 👍
```
* 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).
* PAM, used for user authentication, just what `login` or `su` use internally. Don't worry, it's surely pre-installed.
# 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)
## Manually
* Build the package (you can download automatic builds from the [releases page](https://github.com/javalsai/lidm/releases)):
```sh
git clone https://github.com/javalsai/lidm.git
cd lidm
make # 👍
```
* Install the files (see [configuration](#configuring) for more themeing info).
```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
# or if you don't like autodetection
make install-service-systemd # systemd
make install-service-dinit # dinit
```
## AUR
[AUR packages](https://aur.archlinux.org/packages?K=lidm&SeB=n) will automatically install the binary and config. But I recommend reading [installing manually](#manually) to understand the install process.
> [!CAUTION]
> [service files](./assets/pkg/aur#services) have to be manually installed by now.
# 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.
Configurated colors are just gonna be put inside `\x1b[...m`, ofc you can add an 'm' to break this and this can f\*ck up really bad or even make some nice UI effect possible, 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. But please, keep in mind this might break easily.
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).
> [!TIP]
> If you don't like seeing an element, you can change the fg color of it to be the same as the bg, making it invisible.
# 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...)
If you want to contribute check the [CONTRIBUTING.md](docs/CONTRIBUTING.md)
This is also GPLv3 bcs I was too lazy to look for the "do anything I don't care" license, also it's funny legally trapping people into FOSS. **EDIT:** just realized ly uses it and I coudl've just copied it :(, idk how bad GPLv3 respect to changing license and I *could* rebase but that never goes well, so I'll consult my lawyer (chatGPT) later.
# Backstory
Summer travelling to visit family with an old laptop that barely supports x86_64, and ly recently added some avx2 instructions I think (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 in roughly 3 days 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, crashing the system due to a off-by-one error, but pretty consistent otherwise (probably).
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.
# Contributors
Special thanks to:
[![GitHub Contributors](https://contrib.rocks/image?repo=javalsai/lidm&max=20)](https://github.com/javalsai/lidm/graphs/contributors)
* KillerTofus, [made the AUR package](https://github.com/javalsai/lidm/pull/2)! Saved me from reading the Arch Wiki 💀.
* DeaDvey, the most awesomest of all, did some pretty HARDCORE gramer cheking. (and trolling, he wrote that, 33 commits of just readme changes ffs)
* grialion, made a simple C implementation of `chvt` instead of insecurely relying on `kbd utils`'s command.
* cerealexperiments_, found a missing newline (had the guts to read the source code, crazy ik)
* 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.
# 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)
# Recommendations
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"
* "Rio Romeo - Nothing's New"
* "ElyOtto - SugarCrash!"
* "The Cranberries - Sunday"
* "Goo Goo Dolls - Iris"
* "Em Beihold - Numb Little Bug"
* "MAGIC! - Rude"
* "The Cranberries - Zombie"
* "Natalie Imbruglia - Torn"
* "Alec Benjamin - I Sent My Therapist To Therapy"
* "The Neighbourhood - Sweater Weather"
* "Cascada - Everytime We Touch" (potentially the sped up versoin if better)
* "Mitski - My Love Mine All Mine"
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.
Congrats if you've managed to read through all this.
* [My lack of gf](https://www.instagram.com/reel/C8sa3Gltmtq), can't imagine this project being possible if somebody actually cared about me daily.

BIN
assets/media/lidm.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 496 KiB

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

4
assets/pkg/aur/.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
*/*
!*/.gitignore
!*/PKGBUILD
!*/.SRCINFO

17
assets/pkg/aur/README.md Normal file
View File

@@ -0,0 +1,17 @@
# AUR Packages
These files are just for reference, I'll manually edit and publish them, at least until I automate it with github actions (like updating version automatically on a release).
There are three packages that follow standard conventions:
* [`lidm`](https://aur.archlinux.org/packages/lidm): Builds latest release (manually updated per release basis)
* [`lidm-bin`](https://aur.archlinux.org/packages/lidm-bin): Fetches latest release binary (compiled by GitHub Actions, also updated per release)
* [`lidm-git`](https://aur.archlinux.org/packages/lidm-git): Fetches latest commit and builds it (should be updated automatically)
> [!IMPORTANT]
> None of those packages include the service files, I'm considering automatically detecting it on the package function or providing it as separate services (standard practice again).
>
> Depending on how good these packages go (my first packages :P) I'll make service ones too.
## Services
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`)

View File

@@ -0,0 +1,16 @@
pkgbase = lidm-bin
pkgdesc = A fully colorful cutomizable TUI display manager made in C. (release binary)
pkgver = 0.0.1
pkgrel = 4
url = https://github.com/javalsai/lidm
arch = x86_64
license = GPL
depends = pam
provides = lidm
conflicts = lidm
source = lidm::https://github.com/javalsai/lidm/releases/download/0.0.1/lidm-x86_64
source = default-theme.ini::https://raw.githubusercontent.com/javalsai/lidm/0.0.1/themes/default.ini
sha256sums = 4969018d527613729336abd51e37283ce77d7c7a2233434642804b88e550e622
sha256sums = 27db9b0cd2da80c0c60dcb13dfad0f9d65e7dddbb7b344b859803b9ac3943cd7
pkgname = lidm-bin

View File

@@ -0,0 +1,24 @@
# Maintainer: javalsai <javalsai@proton.me>
pkgname=lidm-bin
pkgver=0.0.1
pkgrel=4
depends=('pam')
pkgdesc="A fully colorful cutomizable TUI display manager made in C. (release binary)"
arch=('x86_64')
url="https://github.com/javalsai/lidm"
license=('GPL')
provides=('lidm')
conflicts=('lidm')
source=(
"lidm::$url/releases/download/$pkgver/lidm-$arch"
"default-theme.ini::https://raw.githubusercontent.com/javalsai/lidm/$pkgver/themes/default.ini"
)
sha256sums=(
'4969018d527613729336abd51e37283ce77d7c7a2233434642804b88e550e622'
'27db9b0cd2da80c0c60dcb13dfad0f9d65e7dddbb7b344b859803b9ac3943cd7'
)
package() {
install -Dm755 lidm "${pkgdir}/usr/bin/lidm"
install -Dm755 default-theme.ini "${pkgdir}/etc/lidm.ini"
}

View File

@@ -0,0 +1,17 @@
pkgbase = lidm-git
pkgdesc = A fully colorful cutomizable TUI display manager made in C. (last git commit)
pkgver = 0.0.1.r0.gd6b165b
pkgrel = 6
url = https://github.com/javalsai/lidm
arch = any
license = GPL
makedepends = git
makedepends = make
makedepends = gcc
depends = pam
provides = lidm
conflicts = lidm
source = lidm::git+https://github.com/javalsai/lidm
sha256sums = SKIP
pkgname = lidm-git

View File

@@ -0,0 +1,31 @@
# Maintainer: javalsai <javalsai@proton.me>
pkgname=lidm-git
pkgver=0.0.1.r0.gd6b165b
pkgrel=6
depends=('pam')
makedepends=('git' 'make' 'gcc')
pkgdesc="A fully colorful cutomizable TUI display manager made in C. (last git commit)"
arch=('any')
url="https://github.com/javalsai/lidm"
license=('GPL')
provides=('lidm')
conflicts=('lidm')
source=("lidm::git+https://github.com/javalsai/lidm")
sha256sums=('SKIP')
pkgver() {
cd "lidm"
git describe --long --abbrev=7 --tags | \
sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g'
}
build() {
cd "lidm"
make CFLAGS="-O3"
}
package() {
cd "lidm"
install -Dm755 lidm "${pkgdir}/usr/bin/lidm"
install -Dm755 themes/default.ini "${pkgdir}/etc/lidm.ini"
}

View File

@@ -0,0 +1,15 @@
pkgbase = lidm
pkgdesc = A fully colorful cutomizable TUI display manager made in C. (build latest tag)
pkgver = 0.0.1
pkgrel = 5
url = https://github.com/javalsai/lidm
arch = any
license = GPL
makedepends = git
makedepends = make
makedepends = gcc
depends = pam
source = lidm::git+https://github.com/javalsai/lidm
sha256sums = SKIP
pkgname = lidm

View File

@@ -0,0 +1,23 @@
# Maintainer: javalsai <javalsai@proton.me>
pkgname=lidm
pkgver=0.0.1
pkgrel=5
depends=('pam')
makedepends=('git' 'make' 'gcc')
pkgdesc="A fully colorful cutomizable TUI display manager made in C. (build latest tag)"
arch=('any')
url="https://github.com/javalsai/lidm"
license=('GPL')
source=("lidm::git+https://github.com/javalsai/lidm")
sha256sums=('SKIP')
build() {
cd "$pkgname"
make CFLAGS="-O3"
}
package() {
cd "$pkgname"
install -Dm755 lidm "${pkgdir}/usr/bin/lidm"
install -Dm755 themes/default.ini "${pkgdir}/etc/lidm.ini"
}

12
assets/pkg/aur/make-srcinfo.sh Executable file
View File

@@ -0,0 +1,12 @@
#/usr/bin/env bash
set -e
MYSELF=$(realpath "$0")
MYDIR=$(dirname "$MYSELF")
for pkg in "$MYDIR"/*/; do
cd "$pkg"
printf "\x1b[1mEntering '%s'\x1b[0m\n" "$pkg"
makepkg --printsrcinfo | tee .SRCINFO
echo
done

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

@@ -1,106 +0,0 @@
[
{
"directory": "/home/javalsai/coding/lidm",
"arguments": [
"gcc",
"-c",
"-o",
"dist/main.o",
"src/main.c",
"-O3",
"-Iinclude"
],
"file": "src/main.c"
},
{
"directory": "/home/javalsai/coding/lidm",
"arguments": [
"gcc",
"-c",
"-o",
"dist/util.o",
"src/util.c",
"-O3",
"-Iinclude"
],
"file": "src/util.c"
},
{
"directory": "/home/javalsai/coding/lidm",
"arguments": [
"gcc",
"-c",
"-o",
"dist/ui.o",
"src/ui.c",
"-O3",
"-Iinclude"
],
"file": "src/ui.c"
},
{
"directory": "/home/javalsai/coding/lidm",
"arguments": [
"gcc",
"-c",
"-o",
"dist/users.o",
"src/users.c",
"-O3",
"-Iinclude"
],
"file": "src/users.c"
},
{
"directory": "/home/javalsai/coding/lidm",
"arguments": [
"gcc",
"-c",
"-o",
"dist/sessions.o",
"src/sessions.c",
"-O3",
"-Iinclude"
],
"file": "src/sessions.c"
},
{
"directory": "/home/javalsai/coding/lidm",
"arguments": [
"gcc",
"-c",
"-o",
"dist/efield.o",
"src/efield.c",
"-O3",
"-Iinclude"
],
"file": "src/efield.c"
},
{
"directory": "/home/javalsai/coding/lidm",
"arguments": [
"gcc",
"-c",
"-o",
"dist/auth.o",
"src/auth.c",
"-O3",
"-Iinclude"
],
"file": "src/auth.c"
},
{
"directory": "/home/javalsai/coding/lidm",
"arguments": [
"gcc",
"-c",
"-o",
"dist/config.o",
"src/config.c",
"-O3",
"-Iinclude"
],
"file": "src/config.c"
}
]

39
docs/CONTRIBUTING.md Normal file
View File

@@ -0,0 +1,39 @@
# Contributing
Contributions are welcome! Here's how you can help:
- [Contributing code](#code)
- [Reporting issues](#issues)
## Code
For small fixes or incremental improvements simply fork the repo and follow the process below. For larger changes submit an [RFC:](RFC.md)
1. [Fork](https://help.github.com/articles/fork-a-repo/) the repository and [clone](https://help.github.com/articles/cloning-a-repository/) your fork.
2. Start coding!
- Configure clangd LSP by generating `compile_commands.json` (e.g. `bear -- make` or `compiledb make`)
- Implement your feature.
- Check your code works as expected.
- Run the code formatter: `clang-format -i $(git ls-files "*.cpp" "*.h")`
3. Commit your changes to a new branch (not `master`, one change per branch) and push it:
- Commit messages should:
- Header line: explain the commit in one line (use the imperative)
- Be descriptive.
- Have a first line with less than *80 characters* and have a second line that is *empty* if you want to add a description.
4. Once you are happy with your changes, submit a pull request.
- Open the pull request.
- Add a short description explaining briefly what you've done (or if it's a work-in-progress - what you need to do)
## Issues
1. Do a quick search on GitHub to check if the issue has already been reported.
2. [Open an issue](https://github.com//javalsai/lidm/issues/new) and describe the issue you are having - you could include:
- Screenshots.
- Ways to reproduce the issue.
- Your lidm version.
- Your platform (e.g. arch linux or Ubuntu 15.04 x64)
After reporting you should aim to answer questions or clarifications as this helps pinpoint the cause of the issue.

61
flake.lock generated Normal file
View File

@@ -0,0 +1,61 @@
{
"nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1710146030,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1724224976,
"narHash": "sha256-Z/ELQhrSd7bMzTO8r7NZgi9g5emh+aRKoCdaAv5fiO0=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "c374d94f1536013ca8e92341b540eba4c22f9c62",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

46
flake.nix Normal file
View File

@@ -0,0 +1,46 @@
{
inputs = {
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
};
outputs =
{ flake-utils, nixpkgs, ... }:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs { inherit system; };
name = "LiDM";
version = "0.0.1";
lidm = (
pkgs.stdenv.mkDerivation {
pname = name;
version = version;
src = ./.;
nativeBuildInputs = with pkgs; [
gcc
gnumake
linux-pam
];
makeFlags = [
"DESTDIR=$(out)"
"PREFIX="
];
fixupPhase = ''
rm -rf $out/etc
'';
}
);
in
rec {
defaultApp = flake-utils.lib.mkApp { drv = defaultPackage; };
defaultPackage = lidm;
devShell = pkgs.mkShell { buildInputs = lidm.nativeBuildInputs ++ [ pkgs.clang-tools ]; };
}
);
}

25
include/chvt.h Normal file
View File

@@ -0,0 +1,25 @@
#ifndef _CHVTH_
#define _CHVTH_
#include <fcntl.h>
#include <linux/kd.h>
#include <linux/vt.h>
#include <sys/ioctl.h>
#include <unistd.h>
/**
* @brief change foreground virtual terminal to `n`
*
* @param n virtual terminal number
* @return int non-negative value on success
*/
int chvt(int n);
/**
* @brief change foreground virtual terminal to `str`
*
* @param str virtual terminal number (string)
* @return int non-negative value on success
*/
int chvt_str(char* str);
#endif

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\n");
} 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;

43
src/chvt.c Normal file
View File

@@ -0,0 +1,43 @@
#include <errno.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <chvt.h>
static char *vterms[] = {"/dev/tty", "/dev/tty0", "/dev/vc/0", "/dev/systty",
"/dev/console"};
int chvt_str(char *str) {
char *err;
errno = 0;
long i = strtol(str, &err, 10);
if (errno) {
perror("strol");
return -1;
}
// I'm not gonna elaborate on this....
if (i > INT_MAX || i < INT_MIN || *err)
return -1;
return chvt((int)i);
}
int chvt(int n) {
fprintf(stderr, "activating vt %d\n", n);
char c = 0;
for (int i = 0; i < sizeof(vterms) / sizeof(vterms[0]); i++) {
int fd = open(vterms[i], O_RDWR);
if (fd >= 0 && isatty(fd) && ioctl(fd, KDGKBTYPE, &c) == 0 && c < 3) {
if (ioctl(fd, VT_ACTIVATE, n) < 0 || ioctl(fd, VT_WAITACTIVE, n) < 0) {
fprintf(stderr, "Couldn't activate vt %d\n", n);
return -1;
}
return 0;
}
close(fd);
}
fprintf(stderr, "Couldn't get a file descriptor referring to the console.\n");
return -1;
}

View File

@@ -128,7 +128,7 @@ struct config *parse_config(char *path) {
__config = malloc(sizeof(struct config));
if (__config == NULL)
return NULL;
bool ret = line_parser(fd, &sb.st_blksize, config_line_handler);
bool ret = line_parser(fd, (ssize_t*)&sb.st_blksize, config_line_handler);
if (!ret) {
free(__config);
return NULL;

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

@@ -4,14 +4,18 @@
#include <sys/types.h>
#include <unistd.h>
#include <chvt.h>
#include <config.h>
#include <sessions.h>
#include <ui.h>
#include <users.h>
int main(int argc, char *argv[]) {
struct config* config = parse_config("/etc/lidm.ini");
if(config == NULL) {
if (argc == 2)
chvt_str(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