50 Commits
0.0.1 ... 0.0.2

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
28 changed files with 660 additions and 224 deletions

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-x86_64 # will compile for more archs other day
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 }}

4
.gitignore vendored
View File

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

View File

@@ -3,17 +3,19 @@ LDIR=lib
IDIR=include
ODIR=dist
CC=gcc
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)
@@ -27,10 +29,14 @@ lidm: $(OBJ)
clean:
rm -f $(ODIR)/*.o *- li $(INCDIR)/*-
# Copy lidm to /usr/bin
# Copy lidm to ${DESTDIR}${PREFIX}/bin (/usr/bin)
install: lidm
install -m755 ./lidm /usr/bin
install -m755 ./themes/default.ini /etc/lidm.ini
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 \

158
README.md
View File

@@ -1,22 +1,29 @@
[![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)
# LiDM
LiDM is a really light display manager made in C, highly customizable and held together by hopes and prayers 🙏.
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 🙏.
![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.*
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).
> *But all colors and strings are fully customizable.*
![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 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`
* 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, 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)
* 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
@@ -24,39 +31,38 @@ LiDM is a really light display manager made in C, highly customizable and held t
* 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
* 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).*
# Backstory
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).
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-->
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).
# Usage
Regarding arguments: If a single argument is provided (don't even do `--` or standard parsing...), it passes that argument to `chvt` on startup, used (at least) by the dinit service.
### 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.
### 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.
@@ -64,16 +70,22 @@ On top of pure intuition:
* 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
# 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).
* PAM, used for user authentication, just what `login` or `su` use internally. Don't worry, it's surely pre-installed.
# Installation
## 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 # 👍
```
# 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).
* Install the files (see [configuration](#configuring) for more themeing info).
```sh
# place binary in /usr/bin and copy
# default theme to /etc
@@ -85,65 +97,43 @@ make install
# and installs service file (for tty7)
make install-service
# There's manual scripts too:
# 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.
# 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)
```
> [!CAUTION]
> [service files](./assets/pkg/aur#services) have to be manually installed by now.
# Configuring
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.
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...)
> [!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.
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.
# Contributing
If you want to contribute check the [CONTRIBUTING.md](docs/CONTRIBUTING.md)
# 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:
* Javalsai, Maintainer and everyone's second favourite penguin!!!
* DeaDvey, the most awesomest of all, did some pretty HARDCORE gramer cheking.
[![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](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).
# 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"
* "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.
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.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 MiB

After

Width:  |  Height:  |  Size: 496 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

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

@@ -173,7 +173,7 @@ bool launch(char *user, char *passwd, struct session session,
execlp(session.exec, session.exec, NULL);
}
perror("execl error");
fprintf(stderr, "failure calling session");
fprintf(stderr, "failure calling session\n");
} else {
waitpid(pid, NULL, 0);

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

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