134 Commits

Author SHA1 Message Date
b22ae6b2cc fix: memory leaks 2025-06-06 19:40:38 +02:00
04a102a7bb perf: better and efficient vec impl 2025-06-06 19:39:44 +02:00
dc6424979e fix: address mem issues 2025-06-06 18:12:45 +02:00
82e92df95c fix(aur): v0.2.1 checksums on the srcfile (again x2) 2025-06-06 17:05:14 +02:00
f2dbeb0236 Merge pull request #34 from AliensInc/master
Fixes the first two lines in the sha256sum

> *Why dont the checks runnnnnnnnnnnn*
2025-06-06 16:58:48 +02:00
Basher52
d72643c030 Fixes the first two lines in the sha256sum 2025-05-27 21:35:05 +02:00
f7139b16b5 Merge pull request #32 from rmntgx/memory-fixes
fix: memory leaks and memory access errors
2025-05-20 17:02:24 +02:00
rmntgx
ee6565d5b4 fix: memory leaks and memory access errors 2025-05-20 19:42:24 +05:00
620d861d8c fix(aur): lidm-bin@0.2.1 checksums 2025-03-22 18:27:15 +01:00
e879561cbd Merge pull request #28 from javalsai/actions/update-aur-0.2.1
[AUR update]: Bump to 0.2.1
2025-03-22 18:01:24 +01:00
GitHub Actions
eecfd7ac4c Update AUR pkgs to v0.2.1 2025-03-22 16:54:29 +00:00
e2014f46a9 Merge pull request #27 from Antiz96/do_not_compress_man_page
Don't compress man page(s) in Makefile

*idk why checks didn't run though, but whatever*
2025-03-22 17:42:05 +01:00
Robin Candau
5d298ea6d8 Don't compress man page(s) in Makefile
Compressing man pages is a distribution / user preference that should be handled on the packaging side of things.

Indeed, compressing man pages by default imposes a compression algorithm / level whereas most package managers handle that already and eventually allow users to choose or customize them if wanted.

Additionally, it can lead to unexpected side effects. For instance, gzip is recording timestamps in metadata by default, which prevents [reproducible builds](https://reproducible-builds.org/):

```
==> ERROR: Package is not reproducible
--- lidm-0.2.0-1-any.pkg.tar.zst
+++ ./build/lidm-0.2.0-1-any.pkg.tar.zst
├── lidm-0.2.0-1-any.pkg.tar
│ ├── file list
│ │ @@ -1,9 +1,9 @@
│ │  -rw-r--r--   0 root         (0) root         (0)     5391 2025-03-10 12:01:53.000000 .BUILDINFO
│ │ --rw-r--r--   0 root         (0) root         (0)      488 2025-03-10 12:01:53.000000 .MTREE
│ │ +-rw-r--r--   0 root         (0) root         (0)      492 2025-03-10 12:01:53.000000 .MTREE
│ │  -rw-r--r--   0 root         (0) root         (0)      427 2025-03-10 12:01:53.000000 .PKGINFO
│ │  drwxr-xr-x   0 root         (0) root         (0)        0 2025-03-10 12:01:53.000000 etc/
│ │  -rw-r--r--   0 root         (0) root         (0)      930 2025-03-10 12:01:53.000000 etc/lidm.ini
│ │  drwxr-xr-x   0 root         (0) root         (0)        0 2025-03-10 12:01:53.000000 usr/
│ │  drwxr-xr-x   0 root         (0) root         (0)        0 2025-03-10 12:01:53.000000 usr/bin/
│ │  -rwxr-xr-x   0 root         (0) root         (0)    39656 2025-03-10 12:01:53.000000 usr/bin/lidm
│ │  drwxr-xr-x   0 root         (0) root         (0)        0 2025-03-10 12:01:53.000000 usr/share/
│ ├── .MTREE
│ │ ├── .MTREE-content
│ │ │ @@ -7,10 +7,10 @@
│ │ │  /set mode=755
│ │ │  ./usr time=1741608113.0 type=dir
│ │ │  ./usr/bin time=1741608113.0 type=dir
│ │ │  ./usr/bin/lidm time=1741608113.0 size=39656 sha256digest=1a27eef50f6caf35d408f7650c362dea788c7a00a2736f0ec4c94ecd38ae6c6f
│ │ │  ./usr/share time=1741608113.0 type=dir
│ │ │  ./usr/share/man time=1741608113.0 type=dir
│ │ │  ./usr/share/man/man1 time=1741608113.0 type=dir
│ │ │ -./usr/share/man/man1/lidm.1.gz time=1741608113.0 mode=644 size=615 sha256digest=7babc0d1e7d84c3ff18db5ea327313cdbe2ba1117c33d733622a916dfd9d8d0e
│ │ │ +./usr/share/man/man1/lidm.1.gz time=1741608113.0 mode=644 size=615 sha256digest=497e49b75ab0d2c3f3edb70967bf189724990c46df23492738254395ec835d8c
│ │ │  ./usr/share/man/man5 time=1741608113.0 type=dir
│ │ │ -./usr/share/man/man5/lidm-config.5.gz time=1741608113.0 mode=644 size=1374 sha256digest=d0b54c3117c417dfdc43a7629f26cf4c64235742f698a0498722a03a4d1c25c2
│ │ │ +./usr/share/man/man5/lidm-config.5.gz time=1741608113.0 mode=644 size=1374 sha256digest=4e16649cb31029b039a594ffa2f2d4d8a624917aaacc865836c5c2d2a92cd3e4
│ ├── usr/share/man/man1/lidm.1.gz
│ │ ├── filetype from file(1)
│ │ │ @@ -1 +1 @@
│ │ │ -gzip compressed data, was "lidm.1", last modified: Mon Mar 10 12:01:59 2025, from Unix
│ │ │ +gzip compressed data, was "lidm.1", last modified: Mon Mar 10 12:15:51 2025, from Unix
│ ├── usr/share/man/man5/lidm-config.5.gz
│ │ ├── filetype from file(1)
│ │ │ @@ -1 +1 @@
│ │ │ -gzip compressed data, was "lidm-config.5", last modified: Mon Mar 10 12:01:59 2025, from Unix
│ │ │ +gzip compressed data, was "lidm-config.5", last modified: Mon Mar 10 12:15:51 2025, from Unix
```

See https://cmpct.info/~sam/blog/posts/automatic-manpage-compression/ for detailed rational.
2025-03-10 13:16:07 +01:00
b003909c3e ci(aur pkgs): fix file checksums generation 2024-12-26 17:06:15 +01:00
47b212019a package[aur]: update aur packages to v0.2.0 2024-12-26 16:47:37 +01:00
255256bb27 oopise: delete accidentally commited binaries
(cant force push, now I detached head and had to clone separately)
2024-12-25 23:03:39 +01:00
874f6f98f1 fix(ci): reallow nobody account 2024-12-25 22:52:26 +01:00
4fb2bb2d62 Merge pull request #26 from javalsai/env-fixes
feat: add behavior.{source,user_source} for custom env
2024-12-25 22:26:52 +01:00
2c283a14fe docs: threaten ppl to star 2024-12-25 20:32:18 +01:00
f34a71195e chore: use size_t for indexing and iterating 2024-12-25 20:22:28 +01:00
e13a8ff79c fix: #includes 👀 2024-12-25 20:16:25 +01:00
4c7d221a17 dev: use #includes according to error's concerns 2024-12-25 20:00:09 +01:00
6d9b02e6de grammer: codespell 🤓 2024-12-25 19:34:40 +01:00
f03656f509 chore: add basic source paths to default themes 2024-12-25 19:30:23 +01:00
9495bd5afe chore: write man pages 2024-12-25 19:28:31 +01:00
0ba5519937 feat: add behavior.{source,user_source} for custom env 2024-12-25 19:25:09 +01:00
1e0ffcdf2f Merge pull request #24 from javalsai/code-quality
Code quality & Fixes
2024-11-01 13:33:20 +01:00
b8caf5b7d7 chore: readable vec_pop 2024-11-01 13:28:32 +01:00
06fa419a6c fix: logic 👍 (tf was i thinking here?) 2024-11-01 13:25:38 +01:00
49e3ad528f add: safety bound checks for vec_get 2024-11-01 13:11:01 +01:00
d7bfa79284 finally fix? 2024-10-19 18:49:26 +02:00
6489df2e41 fix: idk lol, versions again? 2024-10-19 18:31:52 +02:00
ab6703416f fix: still fails (version?) 2024-10-19 18:16:40 +02:00
43447ca415 grammar 👍 (again) 2024-10-19 18:15:55 +02:00
2c606cda2c fix: ci builds (hopefully 🤞)
https://github.com/uraimo/run-on-arch-action/issues/152#issuecomment-2401981347
2024-10-19 18:12:49 +02:00
d30d5a8884 grammar 👍 2024-10-19 17:52:33 +02:00
a0b68491ba chore: implement vectors
also seems to address several of these:
https://github.com/javalsai/lidm/issues/3#issuecomment-2423933131

not sure about the issue itself, might be permission stuff
2024-10-19 17:50:50 +02:00
01ddd62852 chore: make specific vector (heap stack) impl 2024-10-18 21:54:39 +02:00
c586a48320 chore: remove make as it's part of base-devel 2024-10-13 13:54:56 +02:00
c4a996c1e8 ci: add AUR pkg updates PRs on release 2024-09-15 21:12:16 +02:00
9f32ce274b update: bump pkgbuild versions up
also added scripts to automate this better
2024-09-15 21:11:57 +02:00
8071694d1c Merge pull request #22 from javalsai/misc-chores
Misc chores
2024-09-10 02:38:01 +02:00
2ba49042ab chore: better error handling print on chdir 2024-09-07 16:34:13 +02:00
ed80b4b7c4 fix(oops): wayland = wayland and xorg = xorg 2024-09-07 16:31:15 +02:00
4415cca2fe docs: upate index 2024-09-07 16:29:47 +02:00
a223b47777 docs: use bigger theme images (and gif) 2024-09-07 00:04:32 +02:00
e746d6351e feat: update pkgbuilds
hmm, manpages and not much more
untested changes, needs a release
2024-09-06 22:39:12 +02:00
f1f9d6b0a6 ci(feat): add riscv64 build 2024-09-06 22:14:14 +02:00
c9d52d2f96 ci(feat): add armv7 build 2024-09-06 22:09:33 +02:00
69ee14ff92 ci(feat): add aarch64 build 2024-09-06 22:05:08 +02:00
4bb8563e4d ci(feat): add clang-format checks 2024-09-06 21:48:27 +02:00
a2b2434445 ci: lots of ci features 2024-09-06 21:33:49 +02:00
aa70fc8090 fix: shellcheck warnings 2024-09-06 17:58:40 +02:00
d3138aa594 docs: fix typos 2024-09-06 17:32:45 +02:00
286cd01c2d themes: add kanagawa themes and organize themes
removed old-blue-thick and pure-tastelessness

renamed tastelessness to nothing
2024-09-05 22:08:10 +02:00
2284ab017d chore: remove config inconsistencies 2024-09-05 21:20:09 +02:00
dbbab78e23 format: let clang-format run ._.
(won't even talk about clang-tidy)
2024-09-05 20:26:58 +02:00
b34528d1cb format: add clang-format config 2024-09-05 20:26:28 +02:00
72858a9c96 format: markdown files 2024-09-05 19:07:08 +02:00
b18ed23d4d docs: add separate install guide 2024-09-05 19:05:44 +02:00
7ca864f1d9 feat: add LIDM_CONF config path override 2024-09-05 17:36:56 +02:00
730e6db100 fix: grammar (codespell) 2024-09-05 17:23:18 +02:00
462d1fd337 chore: remove unnecessary pam header uses
those actually cause issues when trying to cross-compile
2024-09-05 17:14:42 +02:00
1a8aa1a14e fix: ui bugs introduced in last commit 2024-09-04 22:07:49 +02:00
grialion
64e101eafa fix: compiler warnings
Fix compiler warnings by
- replacing raw write() calls with printf()
- error checking chdir()
- printing '\x1b[H\x1b[J' instead of calling system(clear)
- using sys/reboot.h to power off and reboot instead of using system
2024-09-04 21:15:30 +02:00
aba3b493bc chore: proper default theme strings 😔 2024-09-04 21:04:14 +02:00
f9a3c67c0b fix: sysd service file (moved to tty7) 2024-09-04 20:57:45 +02:00
6d3c3cbb57 feat: add s6 suport 2024-09-04 20:36:50 +02:00
2fb0e0e0de oops: add openrc install detection 2024-09-04 20:30:41 +02:00
ae4e4df7cd feat: add openrc support 2024-09-04 19:40:49 +02:00
grialion
b4fbe68542 fix: Makefile paths on Nix
Makefile installed the binary as /bin instead of copying it to the

folder which was not present.

Also use PREFIX for man pages too.
2024-09-04 17:14:43 +02:00
9de4551f4c feat: add manpages and improve service docs 2024-09-04 16:12:47 +02:00
1bab69f5f4 Merge remote-tracking branch 'origin/fix-warnings' into misc-chores 2024-09-03 20:34:12 +02:00
50c251318a feat: add runit support 2024-09-03 20:33:47 +02:00
2ccfc039d5 fix: unexpected remove on make clean
idk how that ended up there 👀, nobody saw nothing
2024-08-29 16:49:00 +02:00
98ef611434 fix(flake️): ❄️ name mismatch & version dump 2024-08-29 16:44:23 +02:00
43c67ee317 Merge pull request #21 from javalsai/aur-fixes
fix: misc aur pkg fixes
2024-08-29 12:28:29 +02:00
06548710dd update: aur pkgs for 0.0.2 2024-08-29 12:25:50 +02:00
31828c56a7 Merge branch 'master' into aur-fixes 2024-08-29 11:38:20 +02:00
6d85276946 chore: add aur makepkg build test script
and did you know that makepkg updates stuff like the -git pkg version? :o
2024-08-29 11:31:18 +02:00
0ec046740e forgot: make .srcinfo 2024-08-29 11:27:04 +02:00
e4e946a7d1 chore: add aur pkg gitignore 2024-08-29 11:26:15 +02:00
0ec08db8f8 fix: lidm package (tag tarball now) & config permissions 2024-08-29 11:09:25 +02:00
a1167f7f5f fix: make(-Wall) warnings 2024-08-27 14:37:17 +02:00
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
89 changed files with 1872 additions and 731 deletions

View File

@@ -1,11 +0,0 @@
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

2
.clang-format Normal file
View File

@@ -0,0 +1,2 @@
BasedOnStyle: LLVM
IndentWidth: 2

View File

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

2
.codespellrc Normal file
View File

@@ -0,0 +1,2 @@
[codespell]
skip = ./assets/pkg/aur/*/src,./assets/pkg/aur/*/*/objects

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"

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

@@ -0,0 +1,262 @@
name: Check and Build
on:
workflow_call:
inputs:
set-statuses:
required: false
default: true
type: boolean
jobs:
spellcheck:
name: Check Grammar
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: "codespell"
version: 1.0
- run: codespell
shellcheck:
name: Shell Check
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: "shellcheck"
version: 1.0
- run: find . -type f -name '*.sh' -not -path './assets/pkg/aur/*/src/*' | xargs shellcheck
clangcheck:
name: Chang Check
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: "clang-format clang-tidy"
version: 1.0
- run: clang-format -ni src/*.c include/*.h
# TODO: include when the errors/warnings are bearable
#- run: clang-tidy src/*.c include/*.h
build-linux-amd64:
name: Build for amd64
runs-on: ubuntu-24.04
permissions: write-all
needs: [spellcheck, shellcheck, clangcheck]
steps:
- uses: actions/checkout@v4
- uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: "libpam0g-dev"
version: 1.0
- id: build
run: |
make -j$(nproc) 2> /tmp/stderr
cat /tmp/stderr >&2
HSIZE="$(stat --printf="%s" lidm | numfmt --to=iec-i)B"
WARNS="$(cat /tmp/stderr | grep '^[^ ]*\.[ch]:' | wc -l)"
mv lidm lidm-amd64
echo "DESCR='$HSIZE, $WARNS warnings'" >> "$GITHUB_OUTPUT"
- uses: myrotvorets/set-commit-status-action@master
if: inputs.set-statuses
with:
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}
description: ${{ steps.build.outputs.DESCR }}
context: Build for amd64
- uses: actions/upload-artifact@v4
with:
name: build-amd64
path: lidm-amd64
retention-days: 1
build-linux-i386:
name: Build for i386
runs-on: ubuntu-24.04
permissions: write-all
needs: [spellcheck, shellcheck, clangcheck]
steps:
- uses: actions/checkout@v4
- uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: "libpam0g-dev gcc-multilib"
version: 1.0
- run: |
sudo dpkg --add-architecture i386
sudo apt-get update -y
sudo apt-get install -y libpam0g-dev:i386
- id: build
run: |
make -j$(nproc) CFLAGS="-O3 -Wall -m32" 2> /tmp/stderr
cat /tmp/stderr >&2
HSIZE="$(stat --printf="%s" lidm | numfmt --to=iec-i)B"
WARNS="$(cat /tmp/stderr | grep '^[^ ]*\.[ch]:' | wc -l)"
mv lidm lidm-i386
echo "DESCR='$HSIZE, $WARNS warnings'" >> "$GITHUB_OUTPUT"
- uses: myrotvorets/set-commit-status-action@master
if: inputs.set-statuses
with:
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}
description: ${{ steps.build.outputs.DESCR }}
context: Build for i386
- uses: actions/upload-artifact@v4
with:
name: build-i386
path: lidm-i386
retention-days: 1
build-linux-aarch64:
name: Build for aarch64
runs-on: ubuntu-24.04
permissions: write-all
needs: [spellcheck, shellcheck, clangcheck]
steps:
- uses: actions/checkout@v4
- uses: uraimo/run-on-arch-action@v2
with:
arch: none
distro: none
base_image: '--platform=linux/aarch64 ubuntu:22.04'
githubToken: ${{ github.token }}
install: |
apt-get update && \
apt-get install -y make gcc libpam0g-dev
run: |
make -j$(nproc) 2> /tmp/stderr
cat /tmp/stderr >&2
mv lidm lidm-aarch64
- if: inputs.set-statuses
id: status
run: |
HSIZE="$(stat --printf="%s" lidm-aarch64 | numfmt --to=iec-i)B"
WARNS="$(cat /tmp/stderr | grep '^[^ ]*\.[ch]:' | wc -l)"
echo "DESCR='$HSIZE, $WARNS warnings'" >> "$GITHUB_OUTPUT"
- uses: myrotvorets/set-commit-status-action@master
if: inputs.set-statuses
with:
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}
description: ${{ steps.status.outputs.DESCR }}
context: Build for aarch64
- uses: actions/upload-artifact@v4
with:
name: build-aarch64
path: lidm-aarch64
retention-days: 1
build-linux-armv7:
name: Build for armv7
runs-on: ubuntu-24.04
permissions: write-all
needs: [spellcheck, shellcheck, clangcheck]
steps:
- uses: actions/checkout@v4
- uses: uraimo/run-on-arch-action@v2
with:
arch: none
distro: none
base_image: '--platform=linux/arm/v7 ubuntu:22.04'
githubToken: ${{ github.token }}
install: |
apt-get update && \
apt-get install -y make gcc libpam0g-dev
run: |
make -j$(nproc) 2> /tmp/stderr
cat /tmp/stderr >&2
mv lidm lidm-armv7
- if: inputs.set-statuses
id: status
run: |
HSIZE="$(stat --printf="%s" lidm-armv7 | numfmt --to=iec-i)B"
WARNS="$(cat /tmp/stderr | grep '^[^ ]*\.[ch]:' | wc -l)"
echo "DESCR='$HSIZE, $WARNS warnings'" >> "$GITHUB_OUTPUT"
- uses: myrotvorets/set-commit-status-action@master
if: inputs.set-statuses
with:
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}
description: ${{ steps.status.outputs.DESCR }}
context: Build for armv7
- uses: actions/upload-artifact@v4
with:
name: build-armv7
path: lidm-armv7
retention-days: 1
build-linux-riscv64:
name: Build for riscv64
runs-on: ubuntu-24.04
permissions: write-all
needs: [spellcheck, shellcheck, clangcheck]
steps:
- uses: actions/checkout@v4
- uses: uraimo/run-on-arch-action@v2
with:
arch: none
distro: none
base_image: '--platform=linux/riscv64 riscv64/ubuntu:22.04'
githubToken: ${{ github.token }}
install: |
apt-get update && \
apt-get install -y make gcc libpam0g-dev
run: |
make -j$(nproc) 2> /tmp/stderr
cat /tmp/stderr >&2
mv lidm lidm-riscv64
- if: inputs.set-statuses
id: status
run: |
HSIZE="$(stat --printf="%s" lidm-riscv64 | numfmt --to=iec-i)B"
WARNS="$(cat /tmp/stderr | grep '^[^ ]*\.[ch]:' | wc -l)"
echo "DESCR='$HSIZE, $WARNS warnings'" >> "$GITHUB_OUTPUT"
- uses: myrotvorets/set-commit-status-action@master
if: inputs.set-statuses
with:
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}
description: ${{ steps.status.outputs.DESCR }}
context: Build for riscv64
- uses: actions/upload-artifact@v4
with:
name: build-riscv64
path: lidm-riscv64
retention-days: 1

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

72
.github/workflows/make-release.yml vendored Normal file
View File

@@ -0,0 +1,72 @@
name: Check and Build Release
on:
workflow_dispatch:
inputs:
version:
required: true
default: ''
type: string
jobs:
build:
name: Check and Build
uses: ./.github/workflows/check-and-build.yml
permissions: write-all
with:
set-statuses: false
release:
name: Make Release v${{ inputs.version }}
runs-on: ubuntu-24.04
permissions: write-all
needs: build
steps:
- uses: actions/download-artifact@v4
with:
path: builds
pattern: build-*
merge-multiple: true
- uses: ncipollo/release-action@v1
with:
tag: v${{ inputs.version }}
commit: ${{ github.sha }}
artifacts: builds/lidm-*
artifactErrorsFailBuild: true
body: Release notes not generated yet.
aur-update:
name: Update AUR pkgs
runs-on: ubuntu-24.04
container: archlinux:latest
permissions: write-all
needs: release
steps:
- run: pacman -Sy --noconfirm git github-cli base-devel pacman-contrib
- uses: actions/checkout@v4
- run: |
chage -E -1 nobody
passwd -u nobody
cd "assets/pkg/aur"
chown nobody:nobody . -R
su - -s /bin/bash nobody -c "$PWD/update-pkgs.sh ${{ inputs.version }}"
su - -s /bin/bash nobody -c "$PWD/test-makepkg.sh" # This will also update -git pkgver
chown $UID:$(id -g) . -R
- run: |
BRANCH=actions/update-aur-${{ inputs.version }}
git config --global --add safe.directory $GITHUB_WORKSPACE
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
git checkout -b $BRANCH
git commit -am "Update AUR pkgs to v${{ inputs.version }}"
git push -u origin $BRANCH
gh pr create --head $BRANCH \
--title "[AUR update]: Bump to ${{ inputs.version }}" \
--body "*This PR was created automatically*"
env:
GH_TOKEN: ${{ github.token }}

10
.github/workflows/push.yml vendored Normal file
View File

@@ -0,0 +1,10 @@
name: Push Checks
on:
push
jobs:
check-and-build:
name: Check and Build
uses: ./.github/workflows/check-and-build.yml
permissions: write-all

View File

@@ -1,23 +0,0 @@
name: C Make
on:
release:
types: [created]
jobs:
release:
permissions: write-all
runs-on: ubuntu-latest
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 }}

4
.gitignore vendored
View File

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

69
INSTALL.md Normal file
View File

@@ -0,0 +1,69 @@
# Index
- [Index](#index)
- [Installing from Source](#installing-from-source)
- [AUR](#aur)
- [Nix Flake](#nix-flake)
> [!CAUTION]
> I encourage you to read the manual installation steps to understand what will get installed in your computer by this package.
# Installing from Source
Firstly, you'll need to build the package, this also includes man pages, default config, themes and other files you might need.
To build it you only need to have some basic packages (should come pre-installed in almost all distros): `make`, `gcc` or another `gcc`ish compiler, and libpam headers. If it builds, it surely works anyways.
```sh
git clone https://github.com/javalsai/lidm.git
cd lidm
make # 👍
```
> [!NOTE]
> There's pre-built binaries on the [releases tab](https://github.com/javalsai/lidm/releases) too.
Then you can install the files onto your filesystem with:
```sh
make install
```
And additionally, to install service files (start-up behavior). <sup>[more docs](./assets/services/README.md)</sup>
```sh
# automatically detects your init system
# and install service file (for tty7)
make install-service
# or if you don't like autodetection
make install-service-systemd # systemd
make install-service-dinit # dinit
make install-service-runit # runit
make install-service-openrc # openrc
make install-service-s6 # s6
```
# AUR
[AUR packages](https://aur.archlinux.org/packages?K=lidm\&SeB=n) will automatically install most files.
> [!CAUTION]
> [service files](./assets/pkg/aur#services) have to be manually installed by now.
# Nix Flake
You can install by doing
```sh
nix profile install github:javalsai/lidm
```
or try it out without installing by:
```sh
nix run github:javalsai/lidm
```
> [!CAUTION]
> This doesn't include [service files](./assets/pkg/aur#services) neither

View File

@@ -3,17 +3,19 @@ LDIR=lib
IDIR=include
ODIR=dist
CC=gcc
CFLAGS?=-O3
PREFIX=/usr
CC?=gcc
CFLAGS?=-O3 -Wall
_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)
@@ -25,25 +27,48 @@ lidm: $(OBJ)
.PHONY: clean
clean:
rm -f $(ODIR)/*.o *- li $(INCDIR)/*-
rm -f $(ODIR)/*.o lidm
# 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}${PREFIX}/share/man/man{1,5}
install -Dm755 ./lidm ${DESTDIR}${PREFIX}/bin/
install -Dm644 ./themes/default.ini ${DESTDIR}/etc/lidm.ini
install -Dm644 ./assets/man/lidm.1 ${DESTDIR}${PREFIX}/share/man/man1/
install -Dm644 ./assets/man/lidm-config.5 ${DESTDIR}${PREFIX}/share/man/man5/
uninstall:
rm -rf ${DESTDIR}${PREFIX}/bin/lidm ${DESTDIR}/etc/lidm.ini
rm -rf ${DESTDIR}/usr/share/man/man{1/lidm.1,5/lidm-config.5}.gz
rm -rf /etc/systemd/system/lidm.service /etc/dinit.d/lidm /etc/runit/sv/lidm
install-service:
@if command -v systemctl &> /dev/null; then \
make install-service-systemd; \
elif command -v dinitctl &> /dev/null; then \
make install-service-dinit; \
elif command -v sv &> /dev/null; then \
make install-service-runit; \
elif command -v rc-update &> /dev/null; then \
make install-service-openrc; \
elif command -v s6-service &> /dev/null; then \
make install-service-s6; \
else \
printf '\x1b[1;31m%s\x1b[0m\n' "Unknown init system, skipping install..."; \
printf '\x1b[1;31m%s\x1b[0m\n' "Unknown init system, skipping service install..."; \
fi
install-service-systemd:
install -m755 ./assets/services/systemd.service /etc/systemd/system/lidm.service
install -m644 ./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
install -m644 ./assets/services/dinit /etc/dinit.d/lidm
@printf '\x1b[1m%s\x1b[0m\n\n' " don't forget to run 'dinitctl enable lidm'"
install-service-runit:
rsync -a --no-owner --no-group ./assets/services/runit/. /etc/runit/sv/lidm
@printf '\x1b[1m%s\x1b[0m\n\n' " don't forget to run 'ln -s /etc/runit/sv/lidm /run/runit/service' and 'sv enable lidm'"
install-service-openrc:
install -m755 ./assets/services/openrc /etc/init.d/lidm
@printf '\x1b[1m%s\x1b[0m\n\n' " don't forget to run 'rc-update add lidm'"
install-service-s6:
rsync -a --no-owner --no-group ./assets/services/s6/. /etc/s6/sv/lidm
@printf '\x1b[1m%s\x1b[0m\n\n' " don't forget to run 's6-service add default lidm' and 's6-db-reload'"

View File

@@ -1,14 +0,0 @@
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')

184
README.md
View File

@@ -1,149 +1,131 @@
[![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 🙏.
![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 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 customizable.*
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).
# Index
(TODO, VSC(odium) does this automatically, I'm on nvim rn 😎).
![demo gif](assets/media/lidm.gif)
> *shown as in a featured terminal emulator, actual linux console doesn't support as much color and decorations*
> *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)
* Starts with many init systems eg: systemd and dinit.
* 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 (systemd, dinit, runit, openrc and s6).
## WIP
* 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
* 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.
# Index
> [!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.
- [LiDM](#lidm)
- [Features](#features)
- [WIP](#wip)
- [Index](#index)
- [Ideology](#ideology)
- [Usage](#usage)
- [Arguments](#arguments)
- [Program](#program)
- [Requirements](#requirements)
- [Installation](#installation)
- [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 most service files.
### 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.
# Building from source
```sh
git clone https://github.com/javalsai/lidm.git
cd lidm
make # 👍
```
# Requirements
* A computer with unix based system.
* That system should have the resources necessary 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 automatically, 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).
```sh
# place binary in /usr/bin and copy
# default theme to /etc
make install
```
* Make a service file for this if you want it on launch, just check how ly does it, this works pretty much the same way.
```sh
# automatically detects init system
# and installs service file (for tty7)
make install-service
# There's manual scripts too:
make install-service-systemd # systemd
make install-service-dinit # dinit
```
# Disabling other DM's with systemd
You may want to disable your current Display Manager for instance:
```sh
sudo systemctl disable sddm # Disables SDDM (KDE's dm)
sudo systemctl disable lightdm # Disables lightDM (popular lightweight DM)
sudo systemctl disable gdm # Disables GDM (Gnomes DM)
sudo systemctl disable ly # Disables LYDM (tui dm)
```
Check the [installation guide](./INSTALL.md) to use your preferred installation source.
# 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.
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). You can also set `LIDM_CONF` environment variable to specify a config path.
Configured 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 checking. (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.
* [My lack of gf](https://www.instagram.com/reel/C8sa3Gltmtq), 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"
🌟 Finally, consider starring this repo or... 🔪
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.
![star-history](https://api.star-history.com/svg?repos=javalsai/lidm&type=Date)

85
assets/man/lidm-config.5 Normal file
View File

@@ -0,0 +1,85 @@
.\" Manpage for lidm
.\" https://github.com/javalsai/lidm
.TH lidm-config 5
.SH NAME
lidm-config \- Configuration file syntax for lidm
.SH SYNOPSIS
\fB\fI/etc/lidm.ini\fP
.SH DESCRIPTION
The \fI/etc/lidm.ini\fP file specifies all the configuration for lidm, including theme colors.
The config parser is very primitive still, so the file only consists of \fBkey/value\fP pairs separated by \fB' = '\fP (yes, the surrounding spaces are necessary). It will also not warn if the config is invalid.
You can't escape characters with \fB'\\'\fP, but the program reads until the end of line, so you can put any raw bytes there.
.SH KEYS
Similar keys are grouped together to keep this as short as possible.
.SS Colors
All keys under this section are always wrapped inside ansi sequences (\fB\\x1b[...m\fP).
.TP
\fBcolors.bd, colors.fg, colors.err\fP
Background, foreground and error escape sequences. \fB'fg'\fP is also used as reset sequence, so it must remove effects used in other keys (such as bold, underline...) \fBWITHOUT\fP using the \fB'0'\fP sequence, as that would remove the background color.
.TP
\fBcolors.s_wayland, colors.s_xorg, colors.s_shell\fP
Coloring for sessions of such types (Wayland, X.org, Shells)
.TP
.TP
\fBcolors.e_hostname, colors.e_date, colors.e_box\fP
Coloring for the hostname, date and box elements.
.TP
\fBcolors.e_header\fP
Coloring for heading elements (left column)
.TP
\fBcolors.e_user, colors.e_passwd, colors.e_badpasswd\fP
Coloring for the user element, password and bad padssword.
.TP
\fBcolors.e_key\fP
Coloring for key elements (eg: F1, F2, CTRL...)
.SS
Single characters used for some elements (can be longer than a character, but it will likely break UI)
.TP
\fBchars.hb, chars.vb\fP
Character for the horizontal bar (hb) and vertical bar (vb).
.TP
\fBchars.ctl, chars.ctr, chars.cbl, chars.cbr\fP
Characters for the corners of the box (ctl = corner top left, cbr = corner bottom right)
.SS Functions
.TP
\fBfunctions.poweroff, functions.reboot, functions.refresh\fP
Function key to use for such action.
.SS String
Strings to use for some elements.
.TP
\fBstrings.f_poweroff, strings.f_reboot, strings.f_refresh\fP
Text displayed to name such functions.
.TP
\fBstrings.e_user, strings.e_passwd\fP
Text to display for these element headers.
.TP
\fBstrings.s_wayland, strings.s_xorg, strings.s_shell\fP
Text to display as the header for such sessions.
.SS Behavior
.TP
\fBbehavior.include_defshell\fP
"true"/"false" (invalid input defaults to false), if true, includes the user default shell as a session to launch
.TP
\fBbehavior.source\fP
Specify paths to source on login, simple KEY=VALUE format with comments (#) or empty'ish lines, quoting or escape sequences not supported yet. It is NOT an array, but you rather assign to it multiple times.
.TP
\fBbehavior.user_source\fP
Same as \fIbehavior.source\fP but relative to user home (if present).
.SH "SEE ALSO"
.BR lidm (1)

46
assets/man/lidm.1 Normal file
View File

@@ -0,0 +1,46 @@
.\" Manpage for lidm
.\" https://github.com/javalsai/lidm
.TH lidm 1
.SH NAME
lidm \- A text based display manager made in C
.SH SYNOPSIS
\fBlidm\fP [TTY]
.SH DESCRIPTION
\fBlidm\fP is a text based display manager that supports a lot of configuration. Its focus is to be simple, minimal and easy to compile even on really old hardware, while being as customizable as possible.
.SH ARGUMENTS
.TP
\fB[TTY]\fP
TTY to switch to, does not mean that it will run in it.
.SH ENVIRONMENT
.TP
\fBLIDM_CONF\fP
Specify the config to use other than \fI/etc/lidm.ini\fP
.SH FILES
.TP
\fI/etc/lidm.ini\fP
Config file, see
.BR lidm-config (5)
for syntax.
.SH NOTES
.SS "Service Files"
To configure startup behaviour for your init system, see
.BR https://github.com/javalsai/lidm/tree/master/assets/services
(make sure you're on the same version, the link points to the latest commit, small command arguments might have changed).
.SH "SEE ALSO"
.BR lidm-config (5)
.PP
The upstream GitHub repository can be found at
.BR https://github.com/javalsai/lidm

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 MiB

After

Width:  |  Height:  |  Size: 148 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

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

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

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

@@ -0,0 +1,12 @@
# 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. [You have to do this yourself](../../services/README.md).

View File

@@ -0,0 +1,20 @@
pkgbase = lidm-bin
pkgdesc = A fully colorful customizable TUI display manager made in C. (release binary)
pkgver = 0.2.1
pkgrel = 2
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/v0.2.1/lidm-amd64
source = default-theme.ini::https://raw.githubusercontent.com/javalsai/lidm/v0.2.1/themes/default.ini
source = lidm.1::https://raw.githubusercontent.com/javalsai/lidm/v0.2.1/assets/man/lidm.1
source = lidm-config.5::https://raw.githubusercontent.com/javalsai/lidm/v0.2.1/assets/man/lidm-config.5
sha256sums = 65b42f4f7acd970b167fe84d1fa75450b54e01a6f0edddb9d8dd487058a20850
sha256sums = 68662430a6d262b35cc54d9f0e164ed935b7f7f4497a87cc94946c558bbe8a91
sha256sums = a6807a55ff72ec5a5678583156b3efd0d367f0bcb79854094132771f0cb86bce
sha256sums = 3adaae60f79dff1cef2b2aba7dcea04196cd49816759ad36afb9f7331ac9c3e4
pkgname = lidm-bin

3
assets/pkg/aur/lidm-bin/.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
*
!PKGBUILD
!.SRCINFO

View File

@@ -0,0 +1,29 @@
# shellcheck disable=SC2034,SC2148,SC2128,SC2154,SC2164
# Maintainer: javalsai <javalsai@proton.me>
pkgname=lidm-bin
pkgver=0.2.1
pkgrel=2
depends=('pam')
pkgdesc="A fully colorful customizable 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/v$pkgver/lidm-amd64"
"default-theme.ini::https://raw.githubusercontent.com/javalsai/lidm/v$pkgver/themes/default.ini"
"lidm.1::https://raw.githubusercontent.com/javalsai/lidm/v$pkgver/assets/man/lidm.1"
"lidm-config.5::https://raw.githubusercontent.com/javalsai/lidm/v$pkgver/assets/man/lidm-config.5"
)
sha256sums=('65b42f4f7acd970b167fe84d1fa75450b54e01a6f0edddb9d8dd487058a20850'
'68662430a6d262b35cc54d9f0e164ed935b7f7f4497a87cc94946c558bbe8a91'
'a6807a55ff72ec5a5678583156b3efd0d367f0bcb79854094132771f0cb86bce'
'3adaae60f79dff1cef2b2aba7dcea04196cd49816759ad36afb9f7331ac9c3e4')
package() {
install -Dm755 lidm "${pkgdir}/usr/bin/lidm"
install -Dm644 default-theme.ini "${pkgdir}/etc/lidm.ini"
install -Dm644 lidm.1 "${pkgdir}/usr/share/man/man1/lidm.1"
install -Dm644 lidm-config.5 "${pkgdir}/usr/share/man/man5/lidm-config.5"
}

View File

@@ -0,0 +1,17 @@
pkgbase = lidm-git
pkgdesc = A fully colorful customizable TUI display manager made in C. (last git commit)
pkgver = 0.1.0.r0.g8071694
pkgrel = 1
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

3
assets/pkg/aur/lidm-git/.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
*
!PKGBUILD
!.SRCINFO

View File

@@ -0,0 +1,31 @@
# shellcheck disable=SC2034,SC2148,SC2128,SC2154,SC2164
# Maintainer: javalsai <javalsai@proton.me>
pkgname=lidm-git
pkgver=0.2.1.r0.ge2014f4
pkgrel=1
depends=('pam')
makedepends=('git' 'make' 'gcc')
pkgdesc="A fully colorful customizable 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"
make install DESTDIR="${pkgdir}"
}

View File

@@ -0,0 +1,14 @@
pkgbase = lidm
pkgdesc = A fully colorful customizable TUI display manager made in C. (build latest tag)
pkgver = 0.2.1
pkgrel = 1
url = https://github.com/javalsai/lidm
arch = any
license = GPL
makedepends = git
makedepends = gcc
depends = pam
source = tarball.tar.gz::https://github.com/javalsai/lidm/archive/refs/tags/v0.2.1.tar.gz
sha256sums = 56aaf8025fac16f5deef3058274635198fc3bf3f7eadc1de5c6539614f03d84b
pkgname = lidm

3
assets/pkg/aur/lidm/.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
*
!PKGBUILD
!.SRCINFO

View File

@@ -0,0 +1,25 @@
# shellcheck disable=SC2034,SC2148,SC2128,SC2154,SC2164
# Maintainer: javalsai <javalsai@proton.me>
pkgname=lidm
pkgver=0.2.1
pkgrel=1
depends=('pam')
makedepends=('git' 'gcc')
pkgdesc="A fully colorful customizable TUI display manager made in C. (build latest tag)"
arch=('any')
url="https://github.com/javalsai/lidm"
license=('GPL')
source=("tarball.tar.gz::https://github.com/javalsai/lidm/archive/refs/tags/v$pkgver.tar.gz")
sha256sums=('56aaf8025fac16f5deef3058274635198fc3bf3f7eadc1de5c6539614f03d84b')
build() {
tar -xzf "tarball.tar.gz"
cd "lidm-$pkgver"
make CFLAGS="-O3"
}
package() {
cd "lidm-$pkgver"
make install DESTDIR="${pkgdir}"
}

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

15
assets/pkg/aur/test-makepkg.sh Executable file
View File

@@ -0,0 +1,15 @@
#!/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"
rm -rf ./*.{gz,zst} src pkg
makepkg -f .
echo
done

29
assets/pkg/aur/update-pkgs.sh Executable file
View File

@@ -0,0 +1,29 @@
#!/usr/bin/env bash
set -e
MYSELF=$(realpath "$0")
MYDIR=$(dirname "$MYSELF")
if [ -z "$1" ]; then
printf "\x1b[1;31mERR: No version to update provided\x1b[0m\n" >&2
exit 1;
fi
version="$1"
printf "\x1b[34mINF: Using '%s' version\x1b[0m\n" "$version"
for pkg in "$MYDIR"/lidm{,-bin}/; do
cd "$pkg"
printf "\x1b[1mEntering '%s'\x1b[0m\n" "$pkg"
sed -i "s/pkgver=.*/pkgver=$1/" PKGBUILD
sed -i "s/pkgrel=.*/pkgrel=1/" PKGBUILD
grep 'source = ' <.SRCINFO | awk -F'= |::' '{print $2}' | \
while read -r srcfile; do
printf "\x1b[31mDeleting '%s'\x1b[0m\n" "$srcfile"
rm -f "$srcfile"
done
updpkgsums
makepkg --printsrcinfo | tee .SRCINFO
echo
done

39
assets/services/README.md Normal file
View File

@@ -0,0 +1,39 @@
# Service Files
This folder contains the files necessary to set up lidm on start up for the supported init systems, all of them are configured for tty7.
If you don't know what a init system is, you're certainly using `systemd`.
There's make scripts to automatically copy the service files to the proper locations, you just have to run `make install-service-$INIT`. `make install-service` will attempt to detect the init system in use and install for it.
The manual steps for installation are:
## Systemd
* Copy `systemd.service` to `/etc/systemd/system/lidm.service`
* To enable it you can run `systemctl enable lidm`
## Dinit
* Copy `dinit` to `/etc/dinit.d/lidm`
* To enable it, run `dinitctl enable lidm`
## Runit
* Copy `runit/` to `/etc/runit/sv/lidm/`
* Add the service with `ln -s /etc/runit/sv/lidm /run/runit/service`
* And to enable it `sv enable lidm`
## OpenRC
* Copy `openrc` to `/etc/init.d/lidm`
* Enable the service with `rc-update add lidm`
## S6
* Copy `s6/` to `/etc/s6/sv/lidm/`
* Add the service with `s6-service add default lidm`
* Reload the database with `s6-db-reload` (you might have to run this every time the service file changes)
> \[!WARNING]
> Make sure to disable any other service that might run on tty7, such us lightdm or most display managers out there.

31
assets/services/openrc Executable file
View File

@@ -0,0 +1,31 @@
#!/usr/bin/openrc-run
description="start agetty on a terminal line"
supervisor=supervise-daemon
port=tty7
respawn_period="${respawn_period:-60}"
term_type="${term_type:-linux}"
command=/sbin/agetty
command_args_foreground="${agetty_options} ${port} ${baud} ${term_type} -nl /bin/lidm -o 7"
pidfile="/run/${RC_SVCNAME}.pid"
depend() {
after local
keyword -prefix
provide getty
}
start_pre() {
if [ "$port" = "$RC_SVCNAME" ]; then
eerror "${RC_SVCNAME} cannot be started directly. You must create"
eerror "symbolic links to it for the ports you want to start"
eerror "agetty on and add those to the appropriate runlevels."
return 1
else
export EINFO_QUIET="${quiet:-yes}"
fi
}
stop_pre()
{
export EINFO_QUIET="${quiet:-yes}"
}

5
assets/services/runit/conf Executable file
View File

@@ -0,0 +1,5 @@
BAUD_RATE=38400
TERM_NAME=linux
TTY=tty7
EXEC_PATH=/bin/lidm

5
assets/services/runit/finish Executable file
View File

@@ -0,0 +1,5 @@
#!/bin/sh
[ -r conf ] && . ./conf
exec utmpset -w $TTY

15
assets/services/runit/run Executable file
View File

@@ -0,0 +1,15 @@
#!/bin/sh
[ -r conf ] && . ./conf
if [ -x /sbin/getty -o -x /bin/getty ]; then
# busybox
GETTY=getty
elif [ -x /sbin/agetty -o -x /bin/agetty ]; then
# util-linux
GETTY=agetty
fi
exec setsid ${GETTY} ${GETTY_ARGS} \
"${TTY}" "${TERM_NAME}" \
-n -l "${EXEC_PATH}" -o 7

8
assets/services/s6/run Executable file
View File

@@ -0,0 +1,8 @@
#!/bin/execlineb -P
if { pipeline { s6-rc -ba list } grep -qFx mount-filesystems }
importas -uD "yes" SPAWN SPAWN
importas -sCuD "" ARGS ARGS
importas -sCuD "agetty" GETTY GETTY
if -t { test -e /dev/tty7 }
if -t { test ${SPAWN} = "yes" }
exec agetty -8 tty7 115200 ${ARGS} -nl /bin/lidm -o 7

1
assets/services/s6/type Normal file
View File

@@ -0,0 +1 @@
longrun

View File

@@ -1,15 +1,14 @@
[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
ExecStart=/usr/bin/lidm 7
StandardError=journal
StandardInput=tty
TTYPath=/dev/tty3
StandardOutput=tty
TTYPath=/dev/tty7
TTYReset=yes
TTYVHangup=yes

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.2";
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 ]; };
}
);
}

View File

@@ -3,8 +3,9 @@
#include <stdbool.h>
#include <sessions.h>
#include "config.h"
#include "sessions.h"
bool launch(char *user, char *passwd, struct session session, void (*cb)(void));
bool launch(char *user, char *passwd, struct session session, void (*cb)(void), struct behavior* behavior);
#endif

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

@@ -4,9 +4,8 @@
#include <stdbool.h>
#include <stdio.h>
#include <keys.h>
#include <sessions.h>
#include <users.h>
#include "keys.h"
#include "util.h"
// should be ansi escape codes under \x1b[...m
// if not prepared accordingly, it might break
@@ -14,10 +13,9 @@ struct theme_colors {
char *bg;
char *fg;
char *err;
char *s_wl;
char *s_wayland;
char *s_xorg;
char *s_shell;
char *f_other;
char *e_hostname;
char *e_date;
char *e_box;
@@ -57,13 +55,15 @@ struct strings {
char *f_refresh;
char *e_user;
char *e_passwd;
char *s_xorg;
char *s_wayland;
char *s_xorg;
char *s_shell;
};
struct behavior {
bool include_defshell;
struct Vector source;
struct Vector user_source;
};
struct config {
@@ -74,10 +74,9 @@ struct config {
};
bool line_parser(
FILE* fd,
ssize_t* blksize,
FILE *fd, ssize_t *blksize,
u_char (*cb)(char *key,
char *value)); // might use this for parsing .desktop files too
char *value)); // might use this for parsing .desktop files too
struct config *parse_config(char *path);
#endif

View File

@@ -10,9 +10,9 @@ struct editable_field {
char content[255];
};
struct editable_field field_new(char*);
void field_trim(struct editable_field*, u_char);
void field_update(struct editable_field*, char*);
bool field_seek(struct editable_field*, char);
struct editable_field field_new(char *);
void field_trim(struct editable_field *, u_char);
void field_update(struct editable_field *, char *);
bool field_seek(struct editable_field *, char);
#endif

View File

@@ -4,37 +4,37 @@
#include <stdlib.h>
enum keys {
ESC,
F1,
F2,
F3,
F4,
F5,
F6,
F7,
F8,
F9,
F10,
F11,
F12,
A_UP,
A_DOWN,
A_RIGHT,
A_LEFT,
N_CENTER,
N_UP,
N_DOWN,
N_RIGHT,
N_LEFT,
INS,
SUPR,
HOME,
END,
PAGE_UP,
PAGE_DOWN,
ESC,
F1,
F2,
F3,
F4,
F5,
F6,
F7,
F8,
F9,
F10,
F11,
F12,
A_UP,
A_DOWN,
A_RIGHT,
A_LEFT,
N_CENTER,
N_UP,
N_DOWN,
N_RIGHT,
N_LEFT,
INS,
SUPR,
HOME,
END,
PAGE_UP,
PAGE_DOWN,
};
static const char * const key_names[] = {
static const char *const key_names[] = {
[ESC] = "ESC",
[F1] = "F1",
[F2] = "F2",
@@ -66,39 +66,39 @@ static const char * const key_names[] = {
};
struct key_mapping {
enum keys key;
const char *sequences[3];
enum keys key;
const char *sequences[3];
};
static const struct key_mapping key_mappings[] = {
{ ESC, { "\x1b", NULL }},
{ F1, { "\x1bOP", "\x1b[[A", NULL }},
{ F2, { "\x1bOQ", "\x1b[[B", NULL }},
{ F3, { "\x1bOR", "\x1b[[C", NULL }},
{ F4, { "\x1bOS", "\x1b[[D", NULL }},
{ F5, { "\x1b[15~", "\x1b[[E", NULL }},
{ F6, { "\x1b[17~", NULL }},
{ F7, { "\x1b[18~", NULL }},
{ F8, { "\x1b[19~", NULL }},
{ F9, { "\x1b[20~", NULL }},
{ F10, { "\x1b[21~", NULL }},
{ F11, { "\x1b[23~", NULL }},
{ F12, { "\x1b[24~", NULL }},
{ A_UP, { "\x1b[A", NULL }},
{ A_DOWN, { "\x1b[B", NULL }},
{ A_RIGHT, { "\x1b[C", NULL }},
{ A_LEFT, { "\x1b[D", NULL }},
{ N_CENTER, { "\x1b[E", NULL }},
{ N_UP, { "\x1bOA", NULL }},
{ N_DOWN, { "\x1bOB", NULL }},
{ N_RIGHT, { "\x1bOC", NULL }},
{ N_LEFT, { "\x1bOD", NULL }},
{ INS, { "\x1b[2~", NULL }},
{ SUPR, { "\x1b[3~", NULL }},
{ HOME, { "\x1b[H", NULL }},
{ END, { "\x1b[F", NULL }},
{ PAGE_UP, { "\x1b[5~", NULL }},
{ PAGE_DOWN, { "\x1b[6~", NULL }},
{ESC, {"\x1b", NULL}},
{F1, {"\x1bOP", "\x1b[[A", NULL}},
{F2, {"\x1bOQ", "\x1b[[B", NULL}},
{F3, {"\x1bOR", "\x1b[[C", NULL}},
{F4, {"\x1bOS", "\x1b[[D", NULL}},
{F5, {"\x1b[15~", "\x1b[[E", NULL}},
{F6, {"\x1b[17~", NULL}},
{F7, {"\x1b[18~", NULL}},
{F8, {"\x1b[19~", NULL}},
{F9, {"\x1b[20~", NULL}},
{F10, {"\x1b[21~", NULL}},
{F11, {"\x1b[23~", NULL}},
{F12, {"\x1b[24~", NULL}},
{A_UP, {"\x1b[A", NULL}},
{A_DOWN, {"\x1b[B", NULL}},
{A_RIGHT, {"\x1b[C", NULL}},
{A_LEFT, {"\x1b[D", NULL}},
{N_CENTER, {"\x1b[E", NULL}},
{N_UP, {"\x1bOA", NULL}},
{N_DOWN, {"\x1bOB", NULL}},
{N_RIGHT, {"\x1bOC", NULL}},
{N_LEFT, {"\x1bOD", NULL}},
{INS, {"\x1b[2~", NULL}},
{SUPR, {"\x1b[3~", NULL}},
{HOME, {"\x1b[H", NULL}},
{END, {"\x1b[F", NULL}},
{PAGE_UP, {"\x1b[5~", NULL}},
{PAGE_DOWN, {"\x1b[6~", NULL}},
};
#endif

View File

@@ -3,6 +3,8 @@
#include <sys/types.h>
#include "util.h"
enum session_type {
XORG,
WAYLAND,
@@ -16,11 +18,6 @@ struct session {
enum session_type type;
};
struct sessions_list {
u_int16_t length;
struct session *sessions;
};
struct sessions_list *get_avaliable_sessions();
struct Vector get_avaliable_sessions();
#endif

View File

@@ -1,11 +1,12 @@
#ifndef _UIH_
#define _UIH_
#include <config.h>
#include "config.h"
#include "util.h"
void setup(struct config);
int load(struct users_list*, struct sessions_list*);
void print_err(const char*);
void print_errno(const char*);
int load(struct Vector * users, struct Vector * sessions);
void print_err(const char *);
void print_errno(const char *);
#endif

View File

@@ -3,17 +3,14 @@
#include <sys/types.h>
#include "util.h"
struct user {
char *shell;
char *username;
char *display_name;
};
struct users_list {
u_int16_t length;
struct user *users;
};
struct users_list *get_human_users();
struct Vector get_human_users();
#endif

View File

@@ -1,13 +1,33 @@
#ifndef _UTILH_
#define _UTILH_
#include <keys.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <sys/types.h>
enum keys find_keyname(char*);
enum keys find_ansi(char*);
void read_press(u_char*, char*);
#include "keys.h"
enum keys find_keyname(char *);
enum keys find_ansi(char *);
void read_press(u_char *, char *);
void strcln(char **dest, const char *source);
struct Vector {
uint32_t length;
uint32_t capacity;
void **pages;
};
struct Vector vec_new();
int vec_resize(struct Vector *, size_t size);
int vec_reserve(struct Vector *, size_t size);
int vec_reserve_exact(struct Vector *, size_t size);
int vec_push(struct Vector *, void *item);
void vec_free(struct Vector *);
void vec_clear(struct Vector *);
void vec_reset(struct Vector *);
void *vec_pop(struct Vector *); // won't free it, nor shrink vec list space
void *vec_get(struct Vector *, size_t index);
#endif

View File

@@ -1,24 +1,25 @@
#include <grp.h>
#include <pwd.h>
#include <security/_pam_types.h>
#include <security/pam_appl.h>
#include <security/pam_misc.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/wait.h>
#include <auth.h>
#include <sessions.h>
#include <ui.h>
#include <unistd.h>
#include <util.h>
#include "auth.h"
#include "config.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) {
struct pam_response *reply =
(struct pam_response *)malloc(sizeof(struct pam_response) * num_msg);
for (int i = 0; i < num_msg; i++) {
for (size_t i = 0; i < num_msg; i++) {
reply[i].resp = NULL;
reply[i].resp_retcode = 0;
if (msg[i]->msg_style == PAM_PROMPT_ECHO_OFF ||
@@ -37,6 +38,9 @@ int pam_conversation(int num_msg, const struct pam_message **msg,
pam_end(pamh, ret); \
return NULL; \
}
void clear_screen() { printf("\x1b[H\x1b[J"); }
pam_handle_t *get_pamh(char *user, char *passwd) {
pam_handle_t *pamh = NULL;
struct pam_conv pamc = {pam_conversation, (void *)passwd};
@@ -58,8 +62,43 @@ void *shmalloc(size_t size) {
-1, 0);
}
void moarEnv(char *user, struct session session, struct passwd *pw) {
chdir(pw->pw_dir);
void sourceFileTry(char *file) {
FILE *file2source = fopen(file, "r");
if (file2source == NULL)
return;
char *line = NULL;
size_t len = 0;
ssize_t read;
while ((read = getline(&line, &len, file2source)) != -1) {
if (read == 0 || (read > 0 && *line == '#'))
continue;
if (line[read - 1] == '\n')
line[read - 1] = '\0';
/* printf("Retrieved line of length %zu:\n", read); */
/* printf("%s\n", line); */
for (size_t i = 1; i < read; i++) {
if (line[i] == '=') {
/* printf("FOUND '='!\n"); */
line[i] = '\0';
setenv(line, &line[i + 1], 1);
break;
}
}
}
if (line)
free(line);
fclose(file2source);
}
void moarEnv(char *user, struct session session, struct passwd *pw,
struct behavior *behavior) {
if (chdir(pw->pw_dir) == -1)
print_errno("can't chdir to user home");
setenv("HOME", pw->pw_dir, true);
setenv("USER", pw->pw_name, true);
setenv("SHELL", pw->pw_shell, true);
@@ -73,11 +112,36 @@ void moarEnv(char *user, struct session session, struct passwd *pw) {
if (session.type == SHELL)
xdg_session_type = "tty";
if (session.type == XORG)
xdg_session_type = "wayland";
if (session.type == WAYLAND)
xdg_session_type = "x11";
if (session.type == WAYLAND)
xdg_session_type = "wayland";
setenv("XDG_SESSION_TYPE", xdg_session_type, true);
printf("\n\n\n\n\x1b[1m");
for (size_t i = 0; i < behavior->source.length; i++) {
/* printf("DEBUG(source)!!!! %d %s\n", i, (char*)vec_get(&behavior->source,
* i)); */
sourceFileTry((char *)vec_get(&behavior->source, i));
}
/* printf("\n"); */
if (pw->pw_dir) {
uint home_len = strlen(pw->pw_dir);
for (size_t i = 0; i < behavior->user_source.length; i++) {
char *file2sourcepath = (char *)vec_get(&behavior->user_source, i);
char *newbuf =
malloc(home_len + strlen(file2sourcepath) + 2); // nullbyte and slash
if (newbuf == NULL)
continue; // can't bother
strcpy(newbuf, pw->pw_dir);
newbuf[home_len] = '/'; // assume pw_dir doesn't start with '/' :P
strcpy(&newbuf[home_len + 1], file2sourcepath);
/* printf("DEBUG(user_source)!!!! %d %s\n", i, newbuf); */
sourceFileTry(newbuf);
free(newbuf);
}
}
/*char *buf;*/
/*size_t bsize = snprintf(NULL, 0, "/run/user/%d", pw->pw_uid) + 1;*/
/*buf = malloc(bsize);*/
@@ -89,8 +153,8 @@ void moarEnv(char *user, struct session session, struct passwd *pw) {
/*setenv("XDG_SEAT", "seat0", true);*/
}
bool launch(char *user, char *passwd, struct session session,
void (*cb)(void)) {
bool launch(char *user, char *passwd, struct session session, void (*cb)(void),
struct behavior *behavior) {
struct passwd *pw = getpwnam(user);
if (pw == NULL) {
print_err("could not get user info");
@@ -126,7 +190,7 @@ bool launch(char *user, char *passwd, struct session session,
print_errno("pam_getenvlist");
_exit(EXIT_FAILURE);
}
for (uint i = 0; envlist[i] != NULL; i++) {
for (size_t i = 0; envlist[i] != NULL; i++) {
putenv(envlist[i]);
}
// FIXME: path hotfix
@@ -137,7 +201,7 @@ bool launch(char *user, char *passwd, struct session session,
}
free(envlist);
moarEnv(user, session, pw);
moarEnv(user, session, pw, behavior);
// TODO: chown stdin to user
// does it inherit stdin from parent and
@@ -165,15 +229,18 @@ bool launch(char *user, char *passwd, struct session session,
// TODO: these will be different due to TryExec
// and, Exec/TryExec might contain spaces as args
printf("\x1b[0m");
if (session.type == SHELL) {
system("clear");
clear_screen();
fflush(stdout);
execlp(session.exec, session.exec, NULL);
} else if (session.type == XORG || session.type == WAYLAND) {
system("clear");
clear_screen();
fflush(stdout);
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 (size_t 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

@@ -1,9 +1,17 @@
#include "util.h"
#include <string.h>
#include <sys/stat.h>
#include <config.h>
#include "config.h"
#include "util.h"
// Alr so ima explain the bitfield returned by `cb` a bit
// 4 bits:
// 0b0001: break out of parsing (returning true)
// 0b0010: free the value
// 0b0100: free the key
// 0b1000: break out of parsing (returning false)
//
// This would return true if everything goes fine, false otherwise (malloc error, broke parsing, etc)
bool line_parser(FILE *fd, ssize_t *blksize,
u_char (*cb)(char *key, char *value)) {
size_t opt_size = 4096;
@@ -27,94 +35,111 @@ bool line_parser(FILE *fd, ssize_t *blksize,
free(buf);
return false;
}
if ((read = sscanf(buf, "%[^ ] = %[^\n]\n", key, buf)) != 0) {
u_char ret = cb(key, buf);
char *value = malloc(read_size);
if (value == NULL) {
free(buf);
return false;
}
if ((read = sscanf(buf, "%[^ ] = %[^\n]\n", key, value)) != 0) {
u_char ret = cb(key, value);
if (ret & 0b0100)
free(key);
if (ret & 0b0010)
free(value);
if (ret & 0b1000) {
free(buf);
if (ret & 0b1000)
return false;
if (ret & 0b0001)
}
if (ret & 0b0001) {
free(buf);
break;
}
}
free(buf);
}
return true;
}
struct config *__config;
// Yanderedev code (wanna fix this with a table or smth)
u_char config_line_handler(char *k, char *v) {
if(strcmp(k, "colors.bg") == 0)
if (strcmp(k, "colors.bg") == 0)
__config->theme.colors.bg = v;
else if(strcmp(k, "colors.fg") == 0)
else if (strcmp(k, "colors.fg") == 0)
__config->theme.colors.fg = v;
else if(strcmp(k, "colors.err") == 0)
else if (strcmp(k, "colors.err") == 0)
__config->theme.colors.err = v;
else if(strcmp(k, "colors.s_wl") == 0)
__config->theme.colors.s_wl = v;
else if(strcmp(k, "colors.s_xorg") == 0)
else if (strcmp(k, "colors.s_wayland") == 0)
__config->theme.colors.s_wayland = v;
else if (strcmp(k, "colors.s_xorg") == 0)
__config->theme.colors.s_xorg = v;
else if(strcmp(k, "colors.s_shell") == 0)
else if (strcmp(k, "colors.s_shell") == 0)
__config->theme.colors.s_shell = v;
else if(strcmp(k, "colors.f_other") == 0)
__config->theme.colors.f_other = v;
else if(strcmp(k, "colors.e_hostname") == 0)
else if (strcmp(k, "colors.e_hostname") == 0)
__config->theme.colors.e_hostname = v;
else if(strcmp(k, "colors.e_date") == 0)
else if (strcmp(k, "colors.e_date") == 0)
__config->theme.colors.e_date = v;
else if(strcmp(k, "colors.e_box") == 0)
else if (strcmp(k, "colors.e_box") == 0)
__config->theme.colors.e_box = v;
else if(strcmp(k, "colors.e_header") == 0)
else if (strcmp(k, "colors.e_header") == 0)
__config->theme.colors.e_header = v;
else if(strcmp(k, "colors.e_user") == 0)
else if (strcmp(k, "colors.e_user") == 0)
__config->theme.colors.e_user = v;
else if(strcmp(k, "colors.e_passwd") == 0)
else if (strcmp(k, "colors.e_passwd") == 0)
__config->theme.colors.e_passwd = v;
else if(strcmp(k, "colors.e_badpasswd") == 0)
else if (strcmp(k, "colors.e_badpasswd") == 0)
__config->theme.colors.e_badpasswd = v;
else if(strcmp(k, "colors.e_key") == 0)
else if (strcmp(k, "colors.e_key") == 0)
__config->theme.colors.e_key = v;
else if(strcmp(k, "chars.hb") == 0)
else if (strcmp(k, "chars.hb") == 0)
__config->theme.chars.hb = v;
else if(strcmp(k, "chars.vb") == 0)
else if (strcmp(k, "chars.vb") == 0)
__config->theme.chars.vb = v;
else if(strcmp(k, "chars.ctl") == 0)
else if (strcmp(k, "chars.ctl") == 0)
__config->theme.chars.ctl = v;
else if(strcmp(k, "chars.ctr") == 0)
else if (strcmp(k, "chars.ctr") == 0)
__config->theme.chars.ctr = v;
else if(strcmp(k, "chars.cbl") == 0)
else if (strcmp(k, "chars.cbl") == 0)
__config->theme.chars.cbl = v;
else if(strcmp(k, "chars.cbr") == 0)
else if (strcmp(k, "chars.cbr") == 0)
__config->theme.chars.cbr = v;
else if(strcmp(k, "functions.poweroff") == 0)
else if (strcmp(k, "functions.poweroff") == 0) {
__config->functions.poweroff = find_keyname(v);
else if(strcmp(k, "functions.reboot") == 0)
return 0b0110;
} else if (strcmp(k, "functions.reboot") == 0) {
__config->functions.reboot = find_keyname(v);
else if(strcmp(k, "functions.refresh") == 0)
return 0b0110;
} else if (strcmp(k, "functions.refresh") == 0) {
__config->functions.refresh = find_keyname(v);
else if(strcmp(k, "strings.f_poweroff") == 0)
__config->strings.f_poweroff= v;
else if(strcmp(k, "strings.f_reboot") == 0)
__config->strings.f_reboot= v;
else if(strcmp(k, "strings.f_refresh") == 0)
__config->strings.f_refresh= v;
else if(strcmp(k, "strings.e_user") == 0)
__config->strings.e_user= v;
else if(strcmp(k, "strings.e_passwd") == 0)
__config->strings.e_passwd= v;
else if(strcmp(k, "strings.s_xorg") == 0)
__config->strings.s_xorg= v;
else if(strcmp(k, "strings.s_wayland") == 0)
__config->strings.s_wayland= v;
else if(strcmp(k, "strings.s_shell") == 0)
__config->strings.s_shell= v;
else if(strcmp(k, "behavior.include_defshell") == 0)
__config->behavior.include_defshell= strcmp(v, "true") == 0;
return 0b0110;
} else if (strcmp(k, "strings.f_poweroff") == 0)
__config->strings.f_poweroff = v;
else if (strcmp(k, "strings.f_reboot") == 0)
__config->strings.f_reboot = v;
else if (strcmp(k, "strings.f_refresh") == 0)
__config->strings.f_refresh = v;
else if (strcmp(k, "strings.e_user") == 0)
__config->strings.e_user = v;
else if (strcmp(k, "strings.e_passwd") == 0)
__config->strings.e_passwd = v;
else if (strcmp(k, "strings.s_wayland") == 0)
__config->strings.s_wayland = v;
else if (strcmp(k, "strings.s_xorg") == 0)
__config->strings.s_xorg = v;
else if (strcmp(k, "strings.s_shell") == 0)
__config->strings.s_shell = v;
else if (strcmp(k, "behavior.include_defshell") == 0) {
__config->behavior.include_defshell = strcmp(v, "true") == 0;
return 0b0110;
} else if (strcmp(k, "behavior.source") == 0)
vec_push(&__config->behavior.source, v);
else if (strcmp(k, "behavior.user_source") == 0)
vec_push(&__config->behavior.user_source, v);
else
return 0b1111;
return 0b100;
return 0b0100;
}
struct config *parse_config(char *path) {
@@ -126,9 +151,12 @@ struct config *parse_config(char *path) {
}
__config = malloc(sizeof(struct config));
__config->behavior.source = vec_new();
__config->behavior.user_source = vec_new();
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

@@ -1,11 +1,11 @@
#include <string.h>
#include <efield.h>
#include <ui.h>
#include "efield.h"
#include "ui.h"
struct editable_field field_new(char* content) {
struct editable_field field_new(char *content) {
struct editable_field __efield;
if(content != NULL) {
if (content != NULL) {
__efield.length = __efield.pos = strlen(content);
memcpy(__efield.content, content, __efield.length);
} else {
@@ -30,10 +30,11 @@ void field_update(struct editable_field *field, char *update) {
if (insert_len == 1) {
// backspace
if (*update == 127) {
if (field->pos == 0) return;
if (field->pos == 0)
return;
if (field->pos < field->length) {
memmove(&field->content[field->pos - 1], &field->content[field->pos],
field->length - field->pos);
field->length - field->pos);
}
(field->pos)--;
(field->length)--;
@@ -48,8 +49,8 @@ void field_update(struct editable_field *field, char *update) {
}
if (field->pos < field->length) {
// move with immediate buffer
memmove(&field->content[field->pos + insert_len], &field->content[field->pos],
field->length - field->pos);
memmove(&field->content[field->pos + insert_len],
&field->content[field->pos], field->length - field->pos);
}
memcpy(&field->content[field->pos], update, insert_len);
@@ -60,13 +61,18 @@ void field_update(struct editable_field *field, char *update) {
// returns bool depending if it was able to "use" the seek
bool field_seek(struct editable_field *field, char seek) {
if(field->length == 0) return false;
if (field->length == 0)
return false;
if(seek < 0 && -seek > field->pos) field->pos = 0;
else if(seek > 0 && 255 - field->pos < seek) field->pos = 255;
else field->pos += seek;
if (seek < 0 && -seek > field->pos)
field->pos = 0;
else if (seek > 0 && 255 - field->pos < seek)
field->pos = 255;
else
field->pos += seek;
if(field->pos > field->length) field->pos = field->length;
if (field->pos > field->length)
field->pos = field->length;
return true;
}

View File

@@ -4,34 +4,30 @@
#include <sys/types.h>
#include <unistd.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);
}
#include "chvt.h"
#include "config.h"
#include "sessions.h"
#include "ui.h"
#include "users.h"
#include "util.h"
int main(int argc, char *argv[]) {
if (argc == 2)
chvt(argv[1]);
chvt_str(argv[1]);
struct config *config = parse_config("/etc/lidm.ini");
char *conf_override = getenv("LIDM_CONF");
struct config *config =
parse_config(conf_override == NULL ? "/etc/lidm.ini" : conf_override);
if (config == NULL) {
fprintf(stderr, "error parsing config\n");
return 1;
}
setup(*config);
struct users_list *users = get_human_users();
struct sessions_list *sessions = get_avaliable_sessions();
struct Vector users = get_human_users();
struct Vector sessions = get_avaliable_sessions();
int ret = load(users, sessions);
int ret = load(&users, &sessions);
if (ret == 0)
execl(argv[0], argv[0], NULL);
}

View File

@@ -7,8 +7,8 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <sessions.h>
#include <util.h>
#include "sessions.h"
#include "util.h"
struct source_dir {
enum session_type type;
@@ -18,7 +18,6 @@ static const struct source_dir sources[] = {
{XORG, "/usr/share/xsessions"},
{WAYLAND, "/usr/share/wayland-sessions"},
};
static const size_t sources_size = sizeof(sources) / sizeof(sources[0]);
static struct session __new_session(enum session_type type, char *name,
const char *exec, const char *tryexec) {
@@ -31,23 +30,12 @@ static struct session __new_session(enum session_type type, char *name,
return __session;
}
static const u_int8_t bs = 16;
static const u_int8_t unit_size = sizeof(struct session);
static struct Vector *cb_sessions = NULL;
static u_int16_t alloc_size = bs;
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
// 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
// but will prevent break
if (used_size == 0xffff)
return 0;
if (sb == NULL || !S_ISREG(sb->st_mode))
return 0;
@@ -55,7 +43,7 @@ static int fn(const char *fpath, const struct stat *sb, int typeflag) {
FILE *fd = fopen(fpath, "r");
if (fd == NULL) {
perror("fopen");
fprintf(stderr, "error opening file (r) %s\n", fpath);
fprintf(stderr, "error opening file (r) '%s'\n", fpath);
return 0;
}
@@ -65,8 +53,9 @@ static int fn(const char *fpath, const struct stat *sb, int typeflag) {
char *name_buf = NULL;
char *exec_buf = NULL;
char *tryexec_buf = NULL;
// This should be made a specific function
// Emm, if anything goes wrong just free the inner loop and `break;` fd and the rest is handled after
while (true) {
/*printf(".");*/
char *buf = malloc(sb->st_blksize);
ssize_t read_size = getline(&buf, &alloc_size, fd);
if (read_size == -1) {
@@ -75,43 +64,52 @@ static int fn(const char *fpath, const struct stat *sb, int typeflag) {
}
uint read;
char *key = malloc(read_size);
if ((read = sscanf(buf, "%[^=]=%[^\n]\n", key, buf)) != 0) {
char *key = malloc(read_size + sizeof(char));
if(key == NULL) {
free(buf);
// TODO: more sophisticated error handling??
break;
}
char *value = malloc(read_size + sizeof(char));
if(value == NULL) {
free(buf);
free(key);
// TODO: more sophisticated error handling??
break;
}
value[0] = '\0'; // I'm not sure if sscanf would null this string out
if ((read = sscanf(buf, "%[^=]=%[^\n]\n", key, value)) != 0) {
if (strcmp(key, "Name") == 0) {
found &= 0b001;
name_buf = realloc(buf, read);
name_buf = realloc(value, strlen(value) + sizeof(char));
} else if (strcmp(key, "Exec") == 0) {
found &= 0b010;
exec_buf = realloc(buf, read);
exec_buf = realloc(value, strlen(value) + sizeof(char));
} else if (strcmp(key, "TryExec") == 0) {
found &= 0b100;
tryexec_buf = realloc(buf, read);
} else
free(buf);
} else
free(buf);
tryexec_buf = realloc(value, strlen(value) + sizeof(char));
} else {
free(value);
}
} else {
free(value);
}
free(key);
if (found == 0b111)
break;
free(buf);
if (found == 0b111) break;
}
/*printf("\nend parsing...\n");*/
// Generic handling of exit
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);
}
/*printf("n %s\ne %s\nte %s\n", name_buf, exec_buf, tryexec_buf);*/
sessions[used_size] = __new_session(session_type, name_buf, exec_buf,
tryexec_buf == NULL ? "" : tryexec_buf);
used_size++;
struct session *session_i = malloc(sizeof (struct session));
*session_i = __new_session(session_type, name_buf, exec_buf,
tryexec_buf == NULL ? "" : tryexec_buf);
vec_push(cb_sessions, session_i);
}
if (name_buf != NULL)
@@ -124,23 +122,18 @@ static int fn(const char *fpath, const struct stat *sb, int typeflag) {
return 0;
}
static struct sessions_list __list;
// This code is designed to be run purely single threaded
struct sessions_list *get_avaliable_sessions() {
if (sessions != NULL)
return __sessions_list;
else
sessions = malloc(alloc_size * unit_size);
struct Vector get_avaliable_sessions() {
struct Vector sessions = vec_new();
vec_reserve(&sessions, 8);
for (uint i = 0; i < sources_size; i++) {
session_type = sources[i].type;
cb_sessions = &sessions;
for (size_t i = 0; i < (sizeof(sources) / sizeof(sources[0])); i++) {
/*printf("recurring into %s\n", sources[i].dir);*/
session_type = sources[i].type;
ftw(sources[i].dir, &fn, 1);
}
cb_sessions = NULL;
sessions = realloc(sessions, used_size * unit_size);
__list.length = used_size;
__list.sessions = sessions;
return __sessions_list = &__list;
return sessions;
}

128
src/ui.c
View File

@@ -2,23 +2,27 @@
// really sorry
#include <errno.h>
#include <pwd.h>
#include <signal.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/reboot.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <termios.h>
#include <time.h>
#include <unistd.h>
#include <auth.h>
#include <efield.h>
#include <keys.h>
#include <sessions.h>
#include <ui.h>
#include <util.h>
#include "auth.h"
#include "efield.h"
#include "keys.h"
#include "sessions.h"
#include "ui.h"
#include "users.h"
#include "util.h"
static void print_box();
static void print_footer();
@@ -104,7 +108,7 @@ static char *fmt_time() {
// cursor pos...) should just overlap for now
// ugh, this represent a field which might have options
// opts is the ammount of other options possible (0 will behave as a passwd)
// opts is the amount of other options possible (0 will behave as a passwd)
// aaaand (it's an abstract idea, letme think), also holds the status of a
// custom content, like custom launch command or user or smth
struct opt_field {
@@ -177,8 +181,8 @@ struct opt_field of_session;
struct opt_field of_user;
struct opt_field of_passwd;
struct users_list *gusers;
struct sessions_list *gsessions;
struct Vector *gusers;
struct Vector *gsessions;
// not *that* OF tho
struct opt_field *get_of(enum input from) {
@@ -215,7 +219,7 @@ void ffield_cursor_focus() {
struct user get_current_user() {
if (of_user.current_opt != 0)
return gusers->users[of_user.current_opt - 1];
return *(struct user*)vec_get(gusers, of_user.current_opt - 1);
else {
struct user custom_user;
custom_user.shell = "/usr/bin/bash";
@@ -226,8 +230,8 @@ struct user get_current_user() {
struct session get_current_session() {
if (of_session.current_opt != 0) {
// this is for the default user shell :P, not the greatest implementation
// but I want to get his done
// this is for the default user shell :P, not the greatest
// implementation but I want to get his done
if (behavior.include_defshell &&
of_session.current_opt == gsessions->length + 1) {
struct session shell_session;
@@ -235,7 +239,7 @@ struct session get_current_session() {
shell_session.exec = shell_session.name = get_current_user().shell;
return shell_session;
} else
return gsessions->sessions[of_session.current_opt - 1];
return *(struct session*)vec_get(gsessions, of_session.current_opt - 1);
} else {
struct session custom_session;
custom_session.type = SHELL;
@@ -318,7 +322,8 @@ void ffield_type(char *text) {
print_ffield();
}
int load(struct users_list *users, struct sessions_list *sessions) {
static char* unknown_str = "unknown";
int load(struct Vector *users, struct Vector *sessions) {
/// SETUP
gusers = users;
gsessions = sessions;
@@ -327,9 +332,9 @@ int load(struct users_list *users, struct sessions_list *sessions) {
char *hostname = malloc(16);
if (gethostname(hostname, 16) != 0) {
free(hostname);
hostname = "unknown";
hostname = unknown_str;
} else {
hostname = realloc(hostname, strlen(hostname) + 1);
hostname[15] = '\0';
}
of_session = ofield_new(sessions->length + behavior.include_defshell);
@@ -346,12 +351,14 @@ int load(struct users_list *users, struct sessions_list *sessions) {
printf("\x1b[%d;%dH\x1b[%sm%s\x1b[%sm", boxstart.y + 2,
boxstart.x + 12 - (uint)strlen(hostname), theme.colors.e_hostname,
hostname, theme.colors.fg);
if(hostname != unknown_str) free(hostname);
// put date
char *fmtd_time = fmt_time();
printf("\x1b[%d;%dH\x1b[%sm%s\x1b[%sm", boxstart.y + 2,
boxstart.x + boxw - 3 - (uint)strlen(fmtd_time), theme.colors.e_date,
fmtd_time, theme.colors.fg);
free(fmtd_time);
print_field(SESSION);
print_field(USER);
@@ -374,11 +381,11 @@ int load(struct users_list *users, struct sessions_list *sessions) {
return 0;
} else if (ansi_code == functions.reboot) {
restore_all();
system("reboot");
reboot(RB_AUTOBOOT);
exit(0);
} else if (ansi_code == functions.poweroff) {
restore_all();
system("poweroff");
reboot(RB_POWER_OFF);
exit(0);
} else if (ansi_code == A_UP || ansi_code == A_DOWN) {
ffield_move(ansi_code == A_DOWN);
@@ -392,7 +399,7 @@ int load(struct users_list *users, struct sessions_list *sessions) {
} else {
if (len == 1 && *seq == '\n') {
if (!launch(get_current_user().username, of_passwd.efield.content,
get_current_session(), &restore_all)) {
get_current_session(), &restore_all, &behavior)) {
print_passwd(box_start(), of_passwd.efield.length, true);
ffield_cursor_focus();
}
@@ -408,12 +415,12 @@ int load(struct users_list *users, struct sessions_list *sessions) {
static char *line_cleaner = NULL;
static void clean_line(struct uint_point origin, uint line) {
if (line_cleaner == NULL) {
line_cleaner = malloc((boxw - 2) * sizeof(char));
line_cleaner = malloc((boxw - 2) * sizeof(char) + 1);
memset(line_cleaner, 32, boxw - 2);
line_cleaner[boxw - 2] = 0;
}
printf("\x1b[%d;%dH", origin.y + line, origin.x + 1);
fflush(stdout);
write(STDOUT_FILENO, line_cleaner, boxw - 2);
printf("%s", line_cleaner);
}
// TODO: session_len > 32
@@ -425,18 +432,19 @@ static void print_session(struct uint_point origin, struct session session,
session_type = strings.s_xorg;
} else if (session.type == WAYLAND) {
session_type = strings.s_wayland;
} else if (session.type == SHELL) {
} else {
session_type = strings.s_shell;
}
printf("\r\x1b[%luC\x1b[%sm%s\x1b[%sm", origin.x + 11 - strlen(session_type),
theme.colors.e_header, session_type, theme.colors.fg);
printf("\r\x1b[%luC\x1b[%sm%s\x1b[%sm",
(ulong)(origin.x + 11 - strlen(session_type)), theme.colors.e_header,
session_type, theme.colors.fg);
char *session_color;
if (session.type == XORG) {
session_color = theme.colors.s_xorg;
} else if (session.type == WAYLAND) {
session_color = theme.colors.s_wl;
} else if (session.type == SHELL) {
session_color = theme.colors.s_wayland;
} else {
session_color = theme.colors.s_shell;
}
@@ -454,7 +462,7 @@ static void print_user(struct uint_point origin, struct user user,
bool multiple) {
clean_line(origin, 7);
printf("\r\x1b[%luC\x1b[%sm%s\x1b[%sm",
origin.x + 11 - strlen(strings.e_user), theme.colors.e_header,
(ulong)(origin.x + 11 - strlen(strings.e_user)), theme.colors.e_header,
strings.e_user, theme.colors.fg);
char *user_color = theme.colors.e_user;
@@ -468,13 +476,13 @@ static void print_user(struct uint_point origin, struct user user,
}
}
static char *passwd_prompt[32];
static char passwd_prompt[33];
// TODO: passwd_len > 32
static void print_passwd(struct uint_point origin, uint length, bool err) {
clean_line(origin, 9);
printf("\r\x1b[%luC\x1b[%sm%s\x1b[%sm",
origin.x + 11 - strlen(strings.e_passwd), theme.colors.e_header,
strings.e_passwd, theme.colors.fg);
(ulong)(origin.x + 11 - strlen(strings.e_passwd)),
theme.colors.e_header, strings.e_passwd, theme.colors.fg);
char *pass_color;
if (err)
@@ -482,48 +490,32 @@ static void print_passwd(struct uint_point origin, uint length, bool err) {
else
pass_color = theme.colors.e_passwd;
memset(passwd_prompt, 32, 32);
memset(passwd_prompt, '*', length);
ulong prompt_len = sizeof(passwd_prompt);
ulong actual_len = length > prompt_len ? prompt_len : length;
memset(passwd_prompt, ' ', prompt_len);
memset(passwd_prompt, '*', actual_len);
passwd_prompt[32] = 0;
printf("\r\x1b[%dC\x1b[%sm", origin.x + 14, pass_color);
fflush(stdout);
write(STDOUT_FILENO, passwd_prompt, 32);
printf("%s", passwd_prompt);
printf("\x1b[%sm", theme.colors.fg);
}
// ik this code is... *quirky*
// w just accounts for filler
// if filler == NULL, it will just move cursor
static void print_row(uint w, uint n, char *edge1, char *edge2, char **filler) {
char *row;
size_t row_size;
static void print_empty_row(uint w, uint n, char *edge1, char *edge2) {
for (size_t i = 0; i < n; i++) {
printf("%s\x1b[%dC%s\x1b[%dD\x1b[1B", edge1, w, edge2, w + 2);
}
}
uint size;
if (filler == NULL) {
row_size = snprintf(NULL, 0, "%s\x1b[%dC%s\x1b[%dD\x1b[1B", edge1, w, edge2,
w + 2) +
1;
row = malloc(row_size);
snprintf(row, row_size, "%s\x1b[%dC%s\x1b[%dD\x1b[1B", edge1, w, edge2,
w + 2);
} else {
size_t fillersize = strlen(*filler) * w;
size_t nbytes1 = snprintf(NULL, 0, "%s", edge1) + 1;
size_t nbytes2 = snprintf(NULL, 0, "%s\x1b[%dD\x1b[1B", edge2, w + 2) + 1;
row_size = nbytes1 + fillersize + nbytes2;
row = malloc(row_size);
snprintf(row, nbytes1, "%s", edge1);
for (uint i = 0; i < fillersize; i += strlen(*filler)) {
strcpy(&row[nbytes1 + i], *filler);
static void print_row(uint w, uint n, char *edge1, char *edge2, char *filler) {
for (size_t i = 0; i < n; i++) {
printf("%s", edge1);
for (size_t i = 0; i < w; i++) {
printf("%s", filler);
}
snprintf(&row[nbytes1 + fillersize], nbytes2, "%s\x1b[%dD\x1b[1B", edge2,
w + 2);
printf("%s\x1b[%dD\x1b[1B", edge2, w + 2);
}
for (uint i = 0; i < n; i++) {
write(STDOUT_FILENO, row, row_size);
}
free(row);
}
static void print_box() {
@@ -532,9 +524,9 @@ static void print_box() {
printf("\x1b[%d;%dH\x1b[%sm", bstart.y, bstart.x, theme.colors.e_box);
fflush(stdout);
print_row(boxw - 2, 1, theme.chars.ctl, theme.chars.ctr, &theme.chars.hb);
print_row(boxw - 2, boxh - 2, theme.chars.vb, theme.chars.vb, NULL);
print_row(boxw - 2, 1, theme.chars.cbl, theme.chars.cbr, &theme.chars.hb);
print_row(boxw - 2, 1, theme.chars.ctl, theme.chars.ctr, theme.chars.hb);
print_empty_row(boxw - 2, boxh - 2, theme.chars.vb, theme.chars.vb);
print_row(boxw - 2, 1, theme.chars.cbl, theme.chars.cbr, theme.chars.hb);
printf("\x1b[%sm", theme.colors.fg);
fflush(stdout);
}

View File

@@ -5,8 +5,8 @@
#include <string.h>
#include <sys/types.h>
#include <users.h>
#include <util.h>
#include "users.h"
#include "util.h"
static struct user __new_user(struct passwd *p) {
struct user __user;
@@ -20,43 +20,20 @@ static struct user __new_user(struct passwd *p) {
return __user;
}
static const u_int8_t bs = 16;
static const u_int8_t unit_size = sizeof(struct user);
static u_int16_t alloc_size = bs;
static u_int16_t used_size = 0;
static struct user *users = NULL;
static struct users_list *__users_list = NULL;
struct users_list __list;
// This code is designed to be run purely single threaded
struct users_list *get_human_users() {
if (users != NULL)
return __users_list;
else
users = malloc(alloc_size * unit_size);
struct Vector get_human_users() {
struct Vector users = vec_new();
vec_reserve(&users, 4);
struct passwd *pwd;
while ((pwd = getpwent()) != NULL) {
// practically impossible to reach this (== 0xffff)
// but will prevent break
if (used_size == 0xffff ||
!(pwd->pw_dir && strncmp(pwd->pw_dir, "/home/", 6) == 0))
if (!(pwd->pw_dir && strncmp(pwd->pw_dir, "/home/", 6) == 0))
continue;
if (used_size >= alloc_size) {
alloc_size += bs;
users = realloc(users, alloc_size * unit_size);
}
users[used_size] = __new_user(pwd);
used_size++;
struct user *user_i = malloc(sizeof(struct user));
*user_i = __new_user(pwd);
vec_push(&users, user_i);
}
users = realloc(users, used_size * unit_size);
__list.length = used_size;
__list.users = users;
return __users_list = &__list;
return users;
}

View File

@@ -1,12 +1,13 @@
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include <keys.h>
#include <ui.h>
#include <util.h>
#include "keys.h"
#include "ui.h"
#include "util.h"
static int selret_magic();
@@ -15,9 +16,9 @@ void strcln(char **dest, const char *source) {
strcpy(*dest, source);
}
enum keys find_keyname(char* name) {
enum keys find_keyname(char *name) {
for (size_t i = 0; i < sizeof(key_mappings) / sizeof(key_mappings[0]); i++) {
if(strcmp(key_names[i], name) == 0)
if (strcmp(key_names[i], name) == 0)
return (enum keys)i;
}
@@ -66,3 +67,80 @@ static int selret_magic() {
timeout.tv_usec = 0;
return select(1, &set, NULL, NULL, &timeout);
}
// Vector shii
struct Vector vec_new() {
struct Vector vec;
vec_reset(&vec);
return vec;
}
int vec_resize(struct Vector *vec, size_t size) {
void **new_location = realloc(vec->pages, size * sizeof(void*));
if (new_location != NULL) {
if (vec->length > size)
vec->length = size;
vec->capacity = size;
vec->pages = new_location;
} else {
return -1;
}
return 0;
}
int vec_reserve(struct Vector *vec, size_t size) {
uint32_t new_capacity = vec->capacity;
while (vec->length + size > new_capacity) {
new_capacity = new_capacity + (new_capacity >> 1) + 1; // cap * 1.5 + 1; 0 1 2 4 7 11...
}
return vec_resize(vec, new_capacity);
}
int vec_reserve_exact(struct Vector *vec, size_t size) {
uint32_t needed_capacity = vec->length + size;
if (vec->capacity < needed_capacity) {
return vec_resize(vec, needed_capacity);
} else {
return 0;
}
}
int vec_push(struct Vector *vec, void *item) {
int res_ret = vec_reserve(vec, 1);
if(res_ret != 0) return res_ret;
vec->pages[vec->length++] = item;
return 0;
}
void vec_free(struct Vector *vec) {
while (vec->length > 0)
free(vec->pages[--vec->length]);
vec_clear(vec);
}
void vec_clear(struct Vector *vec) {
free(vec->pages);
vec_reset(vec);
}
void vec_reset(struct Vector *vec) {
vec->length = 0;
vec->capacity = 0;
vec->pages = NULL;
}
void *vec_pop(struct Vector *vec) {
if (vec->length == 0)
return NULL;
return vec->pages[--vec->length];
}
void *vec_get(struct Vector *vec, size_t index) {
if (index >= vec->length)
return NULL;
return vec->pages[index];
}

View File

@@ -1,29 +1,37 @@
# Themes
## cherry.ini
![cherry.ini theme](./screenshots/cherry.png)
## default.ini
![default.ini theme](./screenshots/default.png)
## kanagawa-dragon.ini
![kanagawa-dragon.ini theme](./screenshots/kanagawa-dragon.png)
## kanagawa-wave.ini
![kanagawa-wave.ini theme](./screenshots/kanagawa-wave.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)
## nothing.ini
## pure-tastelessness.ini
![pure-tastelessness.ini theme](./screenshots/pure-tastelessness.png)
![nothing.ini theme](./screenshots/nothing.png)
## tasteless.ini
![tasteless.ini theme](./screenshots/tasteless.png)
## tastelessness.ini
![tastelessness.ini theme](./screenshots/tastelessness.png)

View File

@@ -1,10 +1,9 @@
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_wayland = 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
@@ -27,7 +26,10 @@ 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_xorg = xorg
strings.s_shell = shell
behavior.include_defshell = true
behavior.source = /etc/lidm.env
behavior.source = /etc/locale.conf
behavior.user_source = .lidm.env

View File

@@ -1,10 +1,9 @@
colors.bg = 48;2;38;28;28
colors.fg = 22;24;38;2;245;245;245
colors.err = 1;31
colors.s_wl = 38;2;255;174;66
colors.s_wayland = 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 = 38;2;122;122;122
@@ -22,12 +21,15 @@ 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
strings.f_poweroff = poweroff
strings.f_reboot = reboot
strings.f_refresh = refresh
strings.e_user = user
strings.e_passwd = password
strings.s_wayland = wayland
strings.s_xorg = xorg
strings.s_shell = shell
behavior.include_defshell = true
behavior.source = /etc/lidm.env
behavior.source = /etc/locale.conf
behavior.user_source = .lidm.env

View File

@@ -0,0 +1,35 @@
colors.bg = 48;2;24;22;22
colors.fg = 22;24;38;2;185;185;185
colors.err = 1;31
colors.s_wayland = 38;2;255;174;66
colors.s_xorg = 38;2;37;175;255
colors.s_shell = 38;2;34;140;34
colors.e_hostname = 38;2;208;189;156
colors.e_date = 38;2;144;144;144
colors.e_box = 38;2;122;122;122
colors.e_header = 4;38;2;126;146;178
colors.e_user = 38;2;148;89;84
colors.e_passwd = 4;38;2;245;245;205
colors.e_badpasswd = 3;4;31
colors.e_key = 38;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 = poweroff
strings.f_reboot = reboot
strings.f_refresh = refresh
strings.e_user = user
strings.e_passwd = password
strings.s_wayland = wayland
strings.s_xorg = xorg
strings.s_shell = shell
behavior.include_defshell = true
behavior.source = /etc/lidm.env
behavior.source = /etc/locale.conf
behavior.user_source = .lidm.env

35
themes/kanagawa-wave.ini Normal file
View File

@@ -0,0 +1,35 @@
colors.bg = 48;2;28;28;36
colors.fg = 22;24;38;2;168;168;168
colors.err = 1;31
colors.s_wayland = 38;2;255;174;66
colors.s_xorg = 38;2;37;175;255
colors.s_shell = 38;2;34;140;34
colors.e_hostname = 38;2;196;165;112
colors.e_date = 38;2;144;144;144
colors.e_box = 38;2;122;122;122
colors.e_header = 4;38;2;114;133;162
colors.e_user = 38;2;211;137;88
colors.e_passwd = 4;38;2;245;245;205
colors.e_badpasswd = 3;4;31
colors.e_key = 38;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 = poweroff
strings.f_reboot = reboot
strings.f_refresh = refresh
strings.e_user = user
strings.e_passwd = password
strings.s_wayland = wayland
strings.s_xorg = xorg
strings.s_shell = shell
behavior.include_defshell = true
behavior.source = /etc/lidm.env
behavior.source = /etc/locale.conf
behavior.user_source = .lidm.env

View File

@@ -1,10 +1,9 @@
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_wayland = 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
@@ -27,7 +26,10 @@ 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_xorg = xorg
strings.s_shell = shell
behavior.include_defshell = true
behavior.source = /etc/lidm.env
behavior.source = /etc/locale.conf
behavior.user_source = .lidm.env

View File

@@ -1,10 +1,9 @@
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_wayland = 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
@@ -27,7 +26,10 @@ 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_xorg = xorg
strings.s_shell = shell
behavior.include_defshell = true
behavior.source = /etc/lidm.env
behavior.source = /etc/locale.conf
behavior.user_source = .lidm.env

View File

@@ -1,10 +1,9 @@
colors.bg = -
colors.fg = 24;39m[?25l[-
colors.err = -
colors.s_wl = -
colors.s_wayland = -
colors.s_xorg = -
colors.s_shell = -
colors.f_other = -
colors.e_hostname = -
colors.e_date = 30
colors.e_box = -
@@ -27,7 +26,10 @@ 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_xorg = xorg
strings.s_shell = shell
behavior.include_defshell = true
behavior.source = /etc/lidm.env
behavior.source = /etc/locale.conf
behavior.user_source = .lidm.env

View File

@@ -1,33 +0,0 @@
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

@@ -1,10 +1,9 @@
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_wayland = 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
@@ -27,7 +26,10 @@ 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_xorg = xworg
strings.s_shell = swell
behavior.include_defshell = true
behavior.source = /etc/lidm.env
behavior.source = /etc/locale.conf
behavior.user_source = .lidm.env

View File

@@ -1,33 +0,0 @@
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.

Before

Width:  |  Height:  |  Size: 261 KiB

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 267 KiB

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 262 KiB

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 262 KiB

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 273 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 267 KiB

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 333 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 344 KiB

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 347 KiB

View File

@@ -1,10 +1,9 @@
colors.bg = -
colors.fg = 24
colors.err = -
colors.s_wl = -
colors.s_wayland = -
colors.s_xorg = -
colors.s_shell = -
colors.f_other = -
colors.e_hostname = -
colors.e_date = -
colors.e_box = -
@@ -27,7 +26,10 @@ 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_xorg = xorg
strings.s_shell = shell
behavior.include_defshell = true
behavior.source = /etc/lidm.env
behavior.source = /etc/locale.conf
behavior.user_source = .lidm.env