170 Commits

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

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
tag: ${{ github.ref }}

6
.gitignore vendored
View File

@@ -1,4 +1,8 @@
lidm
/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,24 +3,72 @@ LDIR=lib
IDIR=include
ODIR=dist
CC=gcc
CFLAGS=-O3 -I$(IDIR)
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)
@mkdir -p $(ODIR)
$(CC) -c -o $@ $< $(CFLAGS)
$(CC) -c -o $@ $< $(ALLFLAGS)
lidm: $(OBJ)
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
$(CC) -o $@ $^ $(ALLFLAGS) $(LIBS)
.PHONY: clean
clean:
rm -f $(ODIR)/*.o *- li $(INCDIR)/*-
rm -f $(ODIR)/*.o lidm
# Copy lidm to ${DESTDIR}${PREFIX}/bin (/usr/bin)
install: lidm
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 service install..."; \
fi
install-service-systemd:
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 -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'"

179
README.md
View File

@@ -1,116 +1,131 @@
# lidm
Lidm is a really light display manager made in C, highly customizable and held together by hopes and prayers 🙏
[![GitHub license](https://badgen.net/github/license/javalsai/lidm)](https://github.com/javalsai/lidm/blob/master/LICENSE)
[![GitHub branches](https://badgen.net/github/branches/javalsai/lidm)](https://github.com/javalsai/lidm)
[![Latest Release](https://badgen.net/github/release/javalsai/lidm)](https://github.com/javalsai/lidm/releases)
![demo image](assets/lidm.png)
> *this is shown as in a terminal emulator, actual linux console doesn't support as much color and decorations*
# LiDM
> *but all colors and strings are fully suctomizable*
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 🙏.
> *I'm open if anybody wants to contact me to record a proper demo of the program, my laptop can't handle it and idk how to config obs for hyprland*
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 af
* Works everywhere you can get gcc to compile
* Fast and possibly efficient
* Fully customizable, from strings to colors (I hope you know ansi escape codes), to action buttons
* Builds **FAST**.
* `a32e4a5`:
* `2.830s`: laptop, -O3, -j2, `AMD E-450 APU with Radeon(tm) HD Graphics`
* `0.172s`: desktop, -O3, -j12, `AMD Ryzen 5 5600G with Radeon Graphics`
* `663427e`:
* `0.085s`: desktop, -O0, `AMD Ryzen 5 5600G with Radeon Graphics`
* `0.009s`: desktop, -O0, CC=tcc, `AMD Ryzen 5 5600G with Radeon Graphics`
* Works everywhere you can get gcc to compile.
* Fast and possibly efficient.
* Fully customizable, from strings, including action keys, to colors (I hope you know ansi escape codes)
* Automatically detects xorg and wayland sessions, plus allowing to launch the default user shell (if enabled in config)
* Starts with many init systems (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 f\*ck your terminal, I know it and I don't know if I'll fix it.
## Forget it
* Any kind of arguments
* UTF characters, I'm using `strlen()` and treating characters as per byte basis, UTF-8 chars might work or not actually, might fix it by replacing some `strlen()` with a utflen one.
* 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.
> [!CAUTION]
> (they should add `> [!DISCLAIMER]` fr) I wrote this readme with the same quality as the code, behing this keyboard there's half a brainrotcell left writing what it remembers of this program, so don't take this to seriously, I'm typing as I think without filter lol, but the program works, or should. Also, about any "TODO" in this readme (or the code), I didn't forget finishing it, I actually don't care. And, references to ~~code~~ **anything** are likely to be outdated, check the commit history to know what I was refering to exactly if you care.
# Index
- [LiDM](#lidm)
- [Features](#features)
- [WIP](#wip)
- [Index](#index)
- [Ideology](#ideology)
- [Usage](#usage)
- [Arguments](#arguments)
- [Program](#program)
- [Requirements](#requirements)
- [Installation](#installation)
- [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 went into summer travel to visit family with an old laptop that barely supports x86_64, and ly recently added some avx2 instructions I think (I just get invalid op codes), manually building (any previous commit too) didn't work because of something in the `build.zig` file, so out of boredom I decided to craft up my own simple display manager on the only language this thing can handle, ✨C✨ (I hate this and reserve the right for the rust rewrite, actually solid).
I spedrun it, basically did in in 3 days on the same couch on [unhelty back positions (even worse)](https://i.redd.it/4bkje8amisu61.png) while touching *some* grass (:o), and I'm bad af in C, so this is spaghetti code on **another** level. I think it doesn't do almost anything unsafe, I mean, I didn't check allocations and it's capable of reallocating memory until your username uses all memory and crashes the system due to a off by 1 error, but pretty consistent otherwise (probably).
The name is just ly byt changing "y" with "i", that had a reason but forgot it, (maybe the i in *simple*), so I remembered this sh*tty laptop with a lid, this thing is also a display manager (dm, ly command is also `ly-dm`), so just did lidm due to all that.
![think gif](https://i.giphy.com/media/v1.Y2lkPTc5MGI3NjExcTFzaGVmb3VjN3FnOXV6OG9rMG91a2QwM3c0aDV0NWpoZjFzNDEwayZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/d3mlE7uhX8KFgEmY/giphy.gif) <!--gif's likely broken-->
Btw, this laptop is so bad that I can't even render markdown in reasonable time, I'll just push this and fix render issues live :)
# 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)
> *there's also a [change.org post](https://www.change.org/p/stoppt-die-chatkontrolle-grundrechte-gelten-auch-im-netz).*
# Usage
On top of pure intuition:
* you can change focus of session/user/passwd with up/down arrows
* in case arrow keys do nothing on the focused input (either is empty text or doesn't have more options), it tries to change session and if there's only one session it changes user
* typing anything will allow to put a custom user or shell command too, you can use arrow keys to move
* ESC and then left/right arrows will force to change the option of the focused input, useful if you're editing the current input and arrow keys just move
* editing a predefined option on a user or a shell session, will put you in edit mode preserving the original value, other cases start from scratch
# Compiling
```sh
make # 👍
```
### 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.
# 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)
* 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.
Check the [installation guide](./INSTALL.md) to use your preferred installation source.
# Configuring
Copy `config.ini` (if I haven't moved it) to `/etc/lidm.ini` and configure it to your liking. Also, don't place empty lines (for now).
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.
Btw, the default fg style should disable decorators set up in other elements (cursive, underline... it's just adding 20 to the number btw, so if cursive is 4 (iirc), disabling it is 24).
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).
> [!TIP]
> If you don't like seeing an element, you can change the fg color of it to be the same as the bg, making it invisible.
# Contributing
Don't do this to yourself, but you can ofc, you can also fork or whatever (make sure to comply with GNU's GPLv3), but I want to do the rust rewrite 😡 (after it, I'll leave this around in case somebody with ancient hardware needs it, or if somebody wants to port it for a microwave...)
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.
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:
[![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, 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"
🌟 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)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

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

BIN
assets/media/lidm.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 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.0
pkgrel = 1
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.0/lidm-amd64
source = default-theme.ini::https://raw.githubusercontent.com/javalsai/lidm/v0.2.0/themes/default.ini
source = lidm.1::https://raw.githubusercontent.com/javalsai/lidm/v0.2.0/assets/man/lidm.1
source = lidm-config.5::https://raw.githubusercontent.com/javalsai/lidm/v0.2.0/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.0
pkgrel=1
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.0.r2.g255256b
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.0
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.0.tar.gz
sha256sums = 6d397cf75cafdcb95e5a2623d70f2e07bbb085a07b7c3b743caac06454ed7b16
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.0
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=('6d397cf75cafdcb95e5a2623d70f2e07bbb085a07b7c3b743caac06454ed7b16')
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.

8
assets/services/dinit Normal file
View File

@@ -0,0 +1,8 @@
type = process
command = /sbin/agetty tty7 linux-c -n -l /bin/lidm -o 7
restart = true
depends-on = login.target
termsignal = HUP
smooth-recovery = true
inittab-id = 7
inittab-line = tty7

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

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

View File

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

39
docs/CONTRIBUTING.md Normal file
View File

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

61
flake.lock generated Normal file
View File

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

46
flake.nix Normal file
View File

@@ -0,0 +1,46 @@
{
inputs = {
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
};
outputs =
{ flake-utils, nixpkgs, ... }:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs { inherit system; };
name = "lidm";
version = "0.0.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,31 @@
#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 alloc_len;
uint16_t alloc_size;
void** pages;
};
struct Vector vec_new();
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,19 +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 <stdlib.h>
#include <ui.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 ||
@@ -26,97 +32,226 @@ int pam_conversation(int num_msg, const struct pam_message **msg,
return PAM_SUCCESS;
}
#define CHECK_PAM_RET(call) \
ret = (call); \
if (ret != PAM_SUCCESS) { \
pam_end(pamh, ret); \
return NULL; \
}
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};
int retval;
int ret;
retval = pam_start("login", user, &pamc, &pamh);
if (retval != PAM_SUCCESS) {
return NULL;
}
retval = pam_authenticate(pamh, 0);
if (retval != PAM_SUCCESS) {
pam_end(pamh, retval);
return NULL;
}
retval = pam_acct_mgmt(pamh, 0);
if (retval != PAM_SUCCESS) {
pam_end(pamh, retval);
return NULL;
}
CHECK_PAM_RET(pam_start("login", user, &pamc, &pamh))
CHECK_PAM_RET(pam_authenticate(pamh, 0))
CHECK_PAM_RET(pam_acct_mgmt(pamh, 0))
CHECK_PAM_RET(pam_setcred(pamh, PAM_ESTABLISH_CRED))
CHECK_PAM_RET(pam_open_session(pamh, 0))
CHECK_PAM_RET(pam_setcred(pamh, PAM_REINITIALIZE_CRED))
return pamh;
}
#undef CHECK_PAM_RET
bool launch(char *user, char *passwd, struct session session,
void (*cb)(void)) {
void *shmalloc(size_t size) {
return mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS,
-1, 0);
}
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);
// TERM
setenv("LOGNAME", pw->pw_name, true);
// MAIL?
// PATH?
char *xdg_session_type;
if (session.type == SHELL)
xdg_session_type = "tty";
if (session.type == XORG)
xdg_session_type = "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);*/
/*snprintf(buf, bsize, "/run/user/%d", pw->pw_uid);*/
/*setenv("XDG_RUNTIME_DIR", buf, true);*/
/*setenv("XDG_SESSION_CLASS", "user", true);*/
/*setenv("XDG_SESSION_ID", "1", true);*/
/*setenv("XDG_SESSION_DESKTOP", , true);*/
/*setenv("XDG_SEAT", "seat0", true);*/
}
bool launch(char *user, char *passwd, struct session session, void (*cb)(void),
struct behavior *behavior) {
struct passwd *pw = getpwnam(user);
if (pw == NULL) {
print_err("could not get user info");
return false;
}
gid_t *groups;
int ngroups = 0;
getgrouplist(user, pw->pw_gid, NULL, &ngroups);
groups = malloc(ngroups * sizeof(gid_t));
if (groups == NULL) {
print_err("malloc error");
return false;
}
if (getgrouplist(user, pw->pw_gid, groups, &ngroups) == -1) {
free(groups);
print_err("error fetching groups");
return false;
}
pam_handle_t *pamh = get_pamh(user, passwd);
if (pamh == NULL) {
print_err("error on pam authentication");
return false;
}
char **envlist = pam_getenvlist(pamh);
if (envlist == NULL) {
print_err("error getting pam env");
bool *reach_session = shmalloc(sizeof(bool));
if (reach_session == NULL) {
perror("error allocating shared memory");
return false;
}
*reach_session = false;
// point of no return
int setgrps_ret = setgroups(ngroups, groups);
free(groups);
if (setgrps_ret == -1) {
perror("setgroups");
exit(EXIT_FAILURE);
}
uint pid = fork();
if (pid == 0) { // child
char *TERM = NULL;
char *_GETTERM = getenv("TERM");
if (_GETTERM != NULL)
strcln(&TERM, _GETTERM);
if (clearenv() != 0) {
print_errno("clearenv");
_exit(EXIT_FAILURE);
}
if (setgid(pw->pw_gid) == -1) {
perror("setgid");
exit(EXIT_FAILURE);
}
char **envlist = pam_getenvlist(pamh);
if (envlist == NULL) {
print_errno("pam_getenvlist");
_exit(EXIT_FAILURE);
}
for (size_t i = 0; envlist[i] != NULL; i++) {
putenv(envlist[i]);
}
// FIXME: path hotfix
putenv("PATH=/bin:/usr/bin");
if (TERM != NULL) {
setenv("TERM", TERM, true);
free(TERM);
}
if (setuid(pw->pw_uid) == -1) {
perror("setuid");
exit(EXIT_FAILURE);
}
free(envlist);
moarEnv(user, session, pw, behavior);
for (char **env = envlist; *env != NULL; env++) {
putenv(*env);
}
// TODO: chown stdin to user
// does it inherit stdin from parent and
// does parent need to reclaim it after
// this dies?
if (cb != NULL)
cb();
if (setgid(pw->pw_gid) == -1) {
print_errno("setgid");
_exit(EXIT_FAILURE);
}
if (initgroups(user, pw->pw_gid) == -1) {
print_errno("initgroups");
_exit(EXIT_FAILURE);
}
pam_end(pamh, PAM_SUCCESS);
if (session.type == SHELL) {
system("clear");
execl(session.exec, session.exec, NULL);
} else if (session.type == XORG || session.type == WAYLAND) {
system("clear");
execl(session.exec, session.exec, NULL);
if (setuid(pw->pw_uid) == -1) {
perror("setuid");
_exit(EXIT_FAILURE);
}
if (cb != NULL)
cb();
*reach_session = true;
// TODO: these will be different due to TryExec
// and, Exec/TryExec might contain spaces as args
printf("\x1b[0m");
if (session.type == SHELL) {
clear_screen();
fflush(stdout);
execlp(session.exec, session.exec, NULL);
} else if (session.type == XORG || session.type == WAYLAND) {
clear_screen();
fflush(stdout);
execlp(session.exec, session.exec, NULL);
}
perror("execl error");
fprintf(stderr, "failure calling session\n");
} else {
waitpid(pid, NULL, 0);
pam_setcred(pamh, PAM_DELETE_CRED);
pam_close_session(pamh, 0);
pam_end(pamh, PAM_SUCCESS);
if (*reach_session == false) {
return false;
} else
exit(0);
}
return true;

43
src/chvt.c Normal file
View File

@@ -0,0 +1,43 @@
#include <errno.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include "chvt.h"
static char *vterms[] = {"/dev/tty", "/dev/tty0", "/dev/vc/0", "/dev/systty",
"/dev/console"};
int chvt_str(char *str) {
char *err;
errno = 0;
long i = strtol(str, &err, 10);
if (errno) {
perror("strol");
return -1;
}
// I'm not gonna elaborate on this....
if (i > INT_MAX || i < INT_MIN || *err)
return -1;
return chvt((int)i);
}
int chvt(int n) {
fprintf(stderr, "activating vt %d\n", n);
char c = 0;
for (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,8 +1,8 @@
#include "util.h"
#include <string.h>
#include <sys/stat.h>
#include <config.h>
#include "config.h"
#include "util.h"
bool line_parser(FILE *fd, ssize_t *blksize,
u_char (*cb)(char *key, char *value)) {
@@ -45,72 +45,74 @@ bool line_parser(FILE *fd, ssize_t *blksize,
struct config *__config;
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)
else if (strcmp(k, "functions.reboot") == 0)
__config->functions.reboot = find_keyname(v);
else if(strcmp(k, "functions.refresh") == 0)
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;
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;
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;
@@ -126,9 +128,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) {
memcpy(&field->content[field->pos - 1], &field->content[field->pos],
field->length - field->pos);
memmove(&field->content[field->pos - 1], &field->content[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,23 +4,30 @@
#include <sys/types.h>
#include <unistd.h>
#include <config.h>
#include <sessions.h>
#include <ui.h>
#include <users.h>
#include "chvt.h"
#include "config.h"
#include "sessions.h"
#include "ui.h"
#include "users.h"
#include "util.h"
int main(int argc, char *argv[]) {
struct config* config = parse_config("/etc/lidm.ini");
if(config == NULL) {
if (argc == 2)
chvt_str(argv[1]);
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,28 +30,20 @@ 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 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;
static struct Vector *cb_sessions = NULL;
// NOTE: commented printf's here would be nice to have debug logs if I ever
// implement it
static enum session_type session_type;
static int fn(const char *fpath, const struct stat *sb, int typeflag) {
// practically impossible to reach this
// but will prevent break
if (used_size == 0xffff)
return 0;
if (!S_ISREG(sb->st_mode))
if (sb == NULL || !S_ISREG(sb->st_mode))
return 0;
/*printf("gonna open %s\n", fpath);*/
FILE *fd = fopen(fpath, "r");
if (fd == NULL) {
fprintf(stderr, "error opening file (r) %s", fpath);
perror("fopen");
fprintf(stderr, "error opening file (r) '%s'\n", fpath);
return 0;
}
@@ -62,6 +53,7 @@ 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
while (true) {
char *buf = malloc(sb->st_blksize);
ssize_t read_size = getline(&buf, &alloc_size, fd);
@@ -91,21 +83,16 @@ static int fn(const char *fpath, const struct stat *sb, int typeflag) {
if (found == 0b111)
break;
}
/*printf("\nend parsing...\n");*/
fclose(fd);
// just add this to the list
if (name_buf != NULL && exec_buf != NULL) {
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)
@@ -118,22 +105,17 @@ 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();
for (uint i = 0; i < sources_size; i++) {
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;
}

130
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,7 @@ void ffield_type(char *text) {
print_ffield();
}
int load(struct users_list *users, struct sessions_list *sessions) {
int load(struct Vector *users, struct Vector *sessions) {
/// SETUP
gusers = users;
gsessions = sessions;
@@ -374,11 +378,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,13 +396,12 @@ 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();
continue;
}
}
ffield_type(seq);
} else
ffield_type(seq);
}
if (esc != 0)
@@ -409,12 +412,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
@@ -426,18 +429,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;
}
@@ -455,7 +459,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;
@@ -469,13 +473,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)
@@ -483,48 +487,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);
printf("%s", passwd_prompt);
printf("\r\x1b[%dC\x1b[%sm\x1b[4m", origin.x + 14, pass_color);
fflush(stdout);
write(STDOUT_FILENO, passwd_prompt, 32);
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() {
@@ -533,9 +521,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);
}
@@ -570,7 +558,7 @@ void print_errno(const char *descr) {
origin.x, theme.colors.err, errno, strerror(errno));
else {
fprintf(stderr, "\x1b[%d;%dH\x1b[%sm%s(%d): %s", origin.y - 1, origin.x,
descr, theme.colors.err, errno, strerror(errno));
theme.colors.err, descr, errno, strerror(errno));
}
}

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,19 @@ 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();
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,61 @@ 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_clear(&vec);
return vec;
}
int vec_push(struct Vector* vec, void* item) {
if (vec->length >= vec->alloc_len) {
uint32_t new_size = vec->alloc_len + vec->alloc_size;
void **new_location = realloc(vec->pages, vec->alloc_size);
if (new_location != NULL) {
vec->alloc_size = new_size;
vec->pages = new_location;
} else {
return -1;
}
}
vec->pages[vec->length] = item;
vec->length++;
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->alloc_len = 0;
vec->alloc_size = 4096; // 4KiB page size?
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];
}

37
themes/README.md Normal file
View File

@@ -0,0 +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)
## nothing.ini
![nothing.ini theme](./screenshots/nothing.png)
## tasteless.ini
![tasteless.ini theme](./screenshots/tasteless.png)

35
themes/cherry.ini Normal file
View File

@@ -0,0 +1,35 @@
colors.bg = 48;2;77;33;55
colors.fg = 22;3;24;38;2;245;245;245
colors.err = 1;31
colors.s_wayland = 38;2;255;174;66
colors.s_xorg = 38;2;37;175;255
colors.s_shell = 32
colors.e_hostname = 1;23;38;5;197
colors.e_date = 31
colors.e_box = 31
colors.e_header = 1;4;38;5;204
colors.e_user = 38;5;51
colors.e_passwd = 4;2;38;5;203
colors.e_badpasswd = 4;31
colors.e_key = 1;23;38;5;197
chars.hb =
chars.vb =
chars.ctl =
chars.ctr =
chars.cbl =
chars.cbr =
functions.poweroff = F1
functions.reboot = F2
functions.refresh = F5
strings.f_poweroff = poweroff
strings.f_reboot = reboot
strings.f_refresh = refresh
strings.e_user = user
strings.e_passwd = password
strings.s_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

35
themes/nature.ini Normal file
View File

@@ -0,0 +1,35 @@
colors.bg = 48;2;15;22;15
colors.fg = 22;23;24;38;2;245;245;245
colors.err = 1;31
colors.s_wayland = 38;2;255;174;66
colors.s_xorg = 38;2;37;175;255
colors.s_shell = 32
colors.e_hostname = 38;5;28
colors.e_date = 32
colors.e_box = 32
colors.e_header = 1;4;32
colors.e_user = 38;5;51
colors.e_passwd = 4;2;38;5;83
colors.e_badpasswd = 3;4;31
colors.e_key = 32
chars.hb =
chars.vb =
chars.ctl =
chars.ctr =
chars.cbl =
chars.cbr =
functions.poweroff = F1
functions.reboot = F2
functions.refresh = F5
strings.f_poweroff = poweroff
strings.f_reboot = reboot
strings.f_refresh = refresh
strings.e_user = user
strings.e_passwd = password
strings.s_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/nord.ini Normal file
View File

@@ -0,0 +1,35 @@
colors.bg = 48;2;19;19;22
colors.fg = 22;24;38;2;245;245;245
colors.err = 1;31
colors.s_wayland = 38;2;255;174;66
colors.s_xorg = 38;2;37;175;255
colors.s_shell = 32
colors.e_hostname = 34
colors.e_date = 38;2;66;66;88
colors.e_box = 38;2;122;122;122
colors.e_header = 1;4;36
colors.e_user = 38;5;51
colors.e_passwd = 4;2;38;5;80
colors.e_badpasswd = 3;4;31
colors.e_key = 34
chars.hb =
chars.vb =
chars.ctl =
chars.ctr =
chars.cbl =
chars.cbr =
functions.poweroff = F1
functions.reboot = F2
functions.refresh = F5
strings.f_poweroff = poweroff
strings.f_reboot = reboot
strings.f_refresh = refresh
strings.e_user = user
strings.e_passwd = password
strings.s_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/nothing.ini Normal file
View File

@@ -0,0 +1,35 @@
colors.bg = -
colors.fg = 24;39m[?25l[-
colors.err = -
colors.s_wayland = -
colors.s_xorg = -
colors.s_shell = -
colors.e_hostname = -
colors.e_date = 30
colors.e_box = -
colors.e_header = 30
colors.e_user = -
colors.e_passwd = 24;30
colors.e_badpasswd = -
colors.e_key = -
chars.hb = -
chars.vb = -
chars.ctl = -
chars.ctr = -
chars.cbl = -
chars.cbr = -
functions.poweroff = F1
functions.reboot = F2
functions.refresh = F5
strings.f_poweroff = poweroff
strings.f_reboot = reboot
strings.f_refresh = refresh
strings.e_user = user
strings.e_passwd = password
strings.s_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/old-blue.ini Normal file
View File

@@ -0,0 +1,35 @@
colors.bg = 48;2;0;0;255
colors.fg = 22;24;39;48;2;0;0;255
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;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_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

Binary file not shown.

After

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

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

BIN
themes/screenshots/nord.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

35
themes/tasteless.ini Normal file
View File

@@ -0,0 +1,35 @@
colors.bg = -
colors.fg = 24
colors.err = -
colors.s_wayland = -
colors.s_xorg = -
colors.s_shell = -
colors.e_hostname = -
colors.e_date = -
colors.e_box = -
colors.e_header = -
colors.e_user = -
colors.e_passwd = -
colors.e_badpasswd = -
colors.e_key = -
chars.hb =
chars.vb =
chars.ctl =
chars.ctr =
chars.cbl =
chars.cbr =
functions.poweroff = F1
functions.reboot = F2
functions.refresh = F5
strings.f_poweroff = poweroff
strings.f_reboot = reboot
strings.f_refresh = refresh
strings.e_user = user
strings.e_passwd = password
strings.s_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