Compare commits
261 Commits
Author | SHA1 | Date | |
---|---|---|---|
92d3351292 | |||
bae810eb99 | |||
|
4c955053e8 | ||
3bfc2f52f3 | |||
59acddf652 | |||
6c6769b2b3 | |||
99e27dd0c0 | |||
4b6d113bdb | |||
|
4fa400eb06 | ||
11e9257c4a | |||
7d7cf10600 | |||
64e088884d | |||
bceb13b844 | |||
|
f0e962ad50 | ||
|
16d1325f96 | ||
|
1714b477ad | ||
|
a08ffa5a75 | ||
|
4a83e5d825 | ||
|
d9a1bb1e68 | ||
|
8d24924e59 | ||
4361e1d9a2 | |||
|
3d2e5c1a18 | ||
2b1e4691b8 | |||
52c9c9e03b | |||
18fb1417f5 | |||
b2d25198e0 | |||
6ddbb407da | |||
8403bfc26c | |||
002788c693 | |||
e5c1dd5973 | |||
b10d4373d6 | |||
24431383a2 | |||
55e58b46d9 | |||
cd1f44ec41 | |||
a129fa0186 | |||
1645c082bc | |||
7a92035930 | |||
ecfd413108 | |||
938166366f | |||
6d30e889d5 | |||
e7ef64cd16 | |||
787b412005 | |||
d5688f5c5c | |||
7ab0bc31a7 | |||
f8ccc43794 | |||
f9cf8665b2 | |||
fc4367b6f7 | |||
2796078186 | |||
891d6f4783 | |||
7d92c4dd2c | |||
5174f0b2bf | |||
3480393a66 | |||
a95f71f7a5 | |||
c88bdaea06 | |||
7db89e973d | |||
90c0903f25 | |||
cbb3aa3910 | |||
aa1cafe743 | |||
2bdb57390d | |||
4e18df55bf | |||
bb1ca09fd8 | |||
22c3f7c896 | |||
|
d13ebfff4e | ||
a846c1b4c9 | |||
da9118346b | |||
6975c265f0 | |||
511d35a7c0 | |||
d36ef22c9a | |||
|
5263c48fe0 | ||
230c8558a7 | |||
7d76687833 | |||
d6a348c543 | |||
93f007691e | |||
bc8b1104c0 | |||
2f370ab996 | |||
ec00e51696 | |||
|
abad515963 | ||
b22ae6b2cc | |||
04a102a7bb | |||
dc6424979e | |||
82e92df95c | |||
f2dbeb0236 | |||
![]() |
d72643c030 | ||
|
15c7ec3c59 | ||
f7139b16b5 | |||
|
ee6565d5b4 | ||
|
0b02a2cef2 | ||
|
44d7836955 | ||
620d861d8c | |||
e879561cbd | |||
|
eecfd7ac4c | ||
e2014f46a9 | |||
|
5d298ea6d8 | ||
b003909c3e | |||
47b212019a | |||
255256bb27 | |||
874f6f98f1 | |||
4fb2bb2d62 | |||
2c283a14fe | |||
f34a71195e | |||
e13a8ff79c | |||
4c7d221a17 | |||
6d9b02e6de | |||
f03656f509 | |||
9495bd5afe | |||
0ba5519937 | |||
1e0ffcdf2f | |||
b8caf5b7d7 | |||
06fa419a6c | |||
49e3ad528f | |||
d7bfa79284 | |||
6489df2e41 | |||
ab6703416f | |||
43447ca415 | |||
2c606cda2c | |||
d30d5a8884 | |||
a0b68491ba | |||
01ddd62852 | |||
c586a48320 | |||
c4a996c1e8 | |||
9f32ce274b | |||
8071694d1c | |||
2ba49042ab | |||
ed80b4b7c4 | |||
4415cca2fe | |||
a223b47777 | |||
e746d6351e | |||
f1f9d6b0a6 | |||
c9d52d2f96 | |||
69ee14ff92 | |||
4bb8563e4d | |||
a2b2434445 | |||
aa70fc8090 | |||
d3138aa594 | |||
286cd01c2d | |||
2284ab017d | |||
dbbab78e23 | |||
b34528d1cb | |||
72858a9c96 | |||
b18ed23d4d | |||
7ca864f1d9 | |||
730e6db100 | |||
462d1fd337 | |||
1a8aa1a14e | |||
|
64e101eafa | ||
aba3b493bc | |||
f9a3c67c0b | |||
6d3c3cbb57 | |||
2fb0e0e0de | |||
ae4e4df7cd | |||
|
b4fbe68542 | ||
9de4551f4c | |||
1bab69f5f4 | |||
50c251318a | |||
2ccfc039d5 | |||
98ef611434 | |||
43c67ee317 | |||
06548710dd | |||
31828c56a7 | |||
6d85276946 | |||
0ec046740e | |||
e4e946a7d1 | |||
0ec08db8f8 | |||
a1167f7f5f | |||
e3052ec5bc | |||
|
8bdfa7d609 | ||
|
528c4538c7 | ||
154308dfd7 | |||
c4c358ceef | |||
57cb0cd9ad | |||
b900701b8f | |||
ca95d390c2 | |||
a1f8994c94 | |||
2bcc3f71cc | |||
|
4af0ec545e | ||
|
e0a0df80c0 | ||
fe4a52ecfa | |||
|
a393cda7e1 | ||
4de2720bed | |||
|
cbdcccc4ae | ||
b7f6cf690b | |||
|
d6f19094c1 | ||
|
48803df2d8 | ||
|
d97ba068ff | ||
|
842f915f41 | ||
|
df283109d7 | ||
|
cbe73ad4ff | ||
|
e745b27a68 | ||
eeba4a5f39 | |||
57f5f41995 | |||
8b1216c232 | |||
|
6ea79edaf4 | ||
|
7529b0365f | ||
663427ec95 | |||
|
a738a23b75 | ||
|
e71d2fdd8c | ||
|
98598cf490 | ||
|
5eb3cdc7ad | ||
9c3b158fb7 | |||
be74e5ef40 | |||
cac037cb48 | |||
dcd26986b2 | |||
09ce3ef149 | |||
|
6d13110eed | ||
fc23510b09 | |||
a9d3c29ca5 | |||
|
df38990d8b | ||
|
3efd6e0606 | ||
|
418096dc4e | ||
|
6f3a69307f | ||
0d564b9294 | |||
8f471df5bc | |||
d85e3f5620 | |||
9eb059410b | |||
d6b165ba8b | |||
178acd07ad | |||
dcaab5a782 | |||
|
3a80aaa663 | ||
9d81c9df8b | |||
5861b4dc34 | |||
a32e4a577f | |||
844687809b | |||
|
93f14f398e | ||
|
6590a6ed8f | ||
|
a15b49ec24 | ||
|
e1c5122071 | ||
|
cb853cb379 | ||
|
691996ff7f | ||
|
53da9b70f7 | ||
|
117593f5ec | ||
|
4fb00e46dc | ||
|
36296c55ec | ||
|
8c108ee8ca | ||
|
d38ca16477 | ||
|
5367e697c5 | ||
|
2891bf855a | ||
|
589fa928fc | ||
|
511deb64cd | ||
|
3f2fec5a42 | ||
|
ea1d2cbdb2 | ||
|
148575cf38 | ||
|
849cc4c3e5 | ||
|
8cc8094fc2 | ||
|
1c0cf368e9 | ||
|
8188ea1e31 | ||
|
923aba1db3 | ||
|
ee2f279fb7 | ||
9993d70c6b | |||
5b261827f3 | |||
12207ee4a9 | |||
|
e8ec94e150 | ||
|
f89144110c | ||
|
f9515d8453 | ||
bd6b0a7d8b | |||
483445007b | |||
468ebf769e | |||
6145973cca | |||
080966978c | |||
0639b8601a | |||
a8ec8a8a0e | |||
18a00ca264 |
8
.clang-format
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
BasedOnStyle: Chromium
|
||||||
|
IndentWidth: 2
|
||||||
|
SpacesBeforeTrailingComments: 1
|
||||||
|
AllowShortIfStatementsOnASingleLine: WithoutElse
|
||||||
|
|
||||||
|
AlignAfterOpenBracket: Align
|
||||||
|
BinPackParameters: true
|
||||||
|
AllowAllParametersOfDeclarationOnNextLine: true
|
47
.clang-tidy
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
Checks: >
|
||||||
|
clang-analyzer-*,
|
||||||
|
-clang-analyzer-security.insecureAPI.str*,
|
||||||
|
-clang-analyzer-security.insecureAPI.mem*,
|
||||||
|
-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,
|
||||||
|
bugprone-*,
|
||||||
|
-bugprone-easily-swappable-parameters,
|
||||||
|
-bugprone-signal-handler,
|
||||||
|
cert-*,
|
||||||
|
-cert-msc54-cpp,
|
||||||
|
-cert-sig30-c,
|
||||||
|
modernize-*,
|
||||||
|
-modernize-macro-to-enum,
|
||||||
|
performance-*,
|
||||||
|
portability-*,
|
||||||
|
readability-*,
|
||||||
|
-readability-braces-around-statements,
|
||||||
|
|
||||||
|
WarningsAsErrors: ''
|
||||||
|
HeaderFilterRegex: '.*'
|
||||||
|
FormatStyle: file
|
||||||
|
|
||||||
|
CheckOptions:
|
||||||
|
- key: readability-magic-numbers.IgnoredIntegerValues
|
||||||
|
value: '0;1;2;3;10;255'
|
||||||
|
# - key: readability-magic-numbers.IgnoredValues
|
||||||
|
# value: '0;1;2;3;10;255'
|
||||||
|
- key: readability-identifier-naming.VariableCase
|
||||||
|
value: lower_case
|
||||||
|
- key: readability-identifier-naming.ConstantParameterCase
|
||||||
|
value: UPPER_CASE
|
||||||
|
|
||||||
|
- key: readability-identifier-naming.ConstantCase
|
||||||
|
value: "UPPER_CASE"
|
||||||
|
|
||||||
|
- key: readability-identifier-length.VariableThreshold
|
||||||
|
value: '2'
|
||||||
|
- key: readability-identifier-length.ParameterThreshold
|
||||||
|
value: '2'
|
||||||
|
- key: readability-identifier-length.LocalConstantThreshold
|
||||||
|
value: '2'
|
||||||
|
- key: readability-identifier-length.MemberThreshold
|
||||||
|
value: '2'
|
||||||
|
- key: readability-identifier-length.MinimumParameterNameLength
|
||||||
|
value: '2'
|
||||||
|
- key: readability-identifier-length.MinimumVariableNameLength
|
||||||
|
value: '2'
|
2
.codespellrc
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[codespell]
|
||||||
|
skip = ./assets/pkg/aur/*/src,./assets/pkg/aur/*/*/objects
|
7
.github/dependabot.yml
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
version: 2
|
||||||
|
|
||||||
|
updates:
|
||||||
|
- package-ecosystem: "github-actions"
|
||||||
|
directory: ".github/workflows"
|
||||||
|
schedule:
|
||||||
|
interval: "daily"
|
291
.github/workflows/check-and-build.yml
vendored
Normal file
@ -0,0 +1,291 @@
|
|||||||
|
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: Clang 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: myrotvorets/set-commit-status-action@master
|
||||||
|
if: inputs.set-statuses
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
status: pending
|
||||||
|
description: ${{ steps.build.outputs.DESCR }}
|
||||||
|
context: Build for amd64
|
||||||
|
- uses: awalsh128/cache-apt-pkgs-action@latest
|
||||||
|
with:
|
||||||
|
packages: "libpam0g-dev"
|
||||||
|
version: 1.0
|
||||||
|
- id: build
|
||||||
|
run: |
|
||||||
|
make -j$(nproc) 2> /tmp/stderr || (ERR=$?; cat /tmp/stderr >&2; exit $ERR)
|
||||||
|
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: myrotvorets/set-commit-status-action@master
|
||||||
|
if: inputs.set-statuses
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
status: pending
|
||||||
|
description: ${{ steps.build.outputs.DESCR }}
|
||||||
|
context: Build for i386
|
||||||
|
- 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 || (ERR=$?; cat /tmp/stderr >&2; exit $ERR)
|
||||||
|
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: myrotvorets/set-commit-status-action@master
|
||||||
|
if: inputs.set-statuses
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
status: pending
|
||||||
|
description: ${{ steps.status.outputs.DESCR }}
|
||||||
|
context: Build for aarch64
|
||||||
|
- uses: uraimo/run-on-arch-action@v2
|
||||||
|
with:
|
||||||
|
arch: aarch64
|
||||||
|
distro: ubuntu22.04
|
||||||
|
githubToken: ${{ github.token }}
|
||||||
|
install: |
|
||||||
|
apt-get update && \
|
||||||
|
apt-get install -y make gcc libpam0g-dev
|
||||||
|
run: |
|
||||||
|
make -j$(nproc) 2> /tmp/stderr || (ERR=$?; cat /tmp/stderr >&2; exit $ERR)
|
||||||
|
|
||||||
|
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: myrotvorets/set-commit-status-action@master
|
||||||
|
if: inputs.set-statuses
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
status: pending
|
||||||
|
description: ${{ steps.status.outputs.DESCR }}
|
||||||
|
context: Build for armv7
|
||||||
|
- uses: uraimo/run-on-arch-action@v2
|
||||||
|
with:
|
||||||
|
arch: armv7
|
||||||
|
distro: ubuntu22.04
|
||||||
|
githubToken: ${{ github.token }}
|
||||||
|
install: |
|
||||||
|
apt-get update && \
|
||||||
|
apt-get install -y make gcc libpam0g-dev
|
||||||
|
run: |
|
||||||
|
make -j$(nproc) 2> /tmp/stderr || (ERR=$?; cat /tmp/stderr >&2; exit $ERR)
|
||||||
|
|
||||||
|
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: myrotvorets/set-commit-status-action@master
|
||||||
|
if: inputs.set-statuses
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
status: pending
|
||||||
|
description: ${{ steps.status.outputs.DESCR }}
|
||||||
|
context: Build for riscv64
|
||||||
|
- uses: uraimo/run-on-arch-action@v2
|
||||||
|
with:
|
||||||
|
arch: riscv64
|
||||||
|
distro: ubuntu22.04
|
||||||
|
githubToken: ${{ github.token }}
|
||||||
|
install: |
|
||||||
|
apt-get update && \
|
||||||
|
apt-get install -y make gcc libpam0g-dev
|
||||||
|
run: |
|
||||||
|
make -j$(nproc) 2> /tmp/stderr || (ERR=$?; cat /tmp/stderr >&2; exit $ERR)
|
||||||
|
|
||||||
|
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
@ -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
@ -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 }}
|
15
.github/workflows/push.yml
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
# Kinda based by https://github.com/myrotvorets/set-commit-status-action/actions/runs/12344741285/workflow
|
||||||
|
name: Push Checks
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
pull_request:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
check-and-build:
|
||||||
|
name: Check and Build
|
||||||
|
uses: ./.github/workflows/check-and-build.yml
|
||||||
|
permissions: write-all
|
23
.github/workflows/release.yml
vendored
@ -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 }}
|
|
8
.gitignore
vendored
@ -1,4 +1,10 @@
|
|||||||
lidm
|
/lidm
|
||||||
dist/
|
dist/
|
||||||
|
/compile_commands.json
|
||||||
|
|
||||||
.cache/
|
.cache/
|
||||||
|
# just in case, i dont wanna rebase ever again
|
||||||
|
valgrind-out.txt
|
||||||
|
|
||||||
|
# nix build result
|
||||||
|
result
|
||||||
|
69
INSTALL.md
Normal 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
|
70
Makefile
@ -3,24 +3,78 @@ LDIR=lib
|
|||||||
IDIR=include
|
IDIR=include
|
||||||
ODIR=dist
|
ODIR=dist
|
||||||
|
|
||||||
CC=gcc
|
PREFIX=/usr
|
||||||
CFLAGS=-O3 -I$(IDIR)
|
|
||||||
|
|
||||||
LIBS=-lm -lpam -lpam_misc
|
CC?=gcc
|
||||||
|
CFLAGS?=-O3 -Wall
|
||||||
|
_CFLAGS=-I$(DIR)
|
||||||
|
ALLFLAGS=$(CFLAGS) -I$(IDIR)
|
||||||
|
|
||||||
_DEPS = util.h ui.h config.h auth.h efield.h keys.h users.h sessions.h
|
LIBS=-lpam
|
||||||
|
|
||||||
|
_DEPS = log.h util.h ui.h ui_state.h config.h desktop.h auth.h ofield.h efield.h keys.h users.h sessions.h chvt.h macros.h launch_state.h
|
||||||
DEPS = $(patsubst %,$(IDIR)/%,$(_DEPS))
|
DEPS = $(patsubst %,$(IDIR)/%,$(_DEPS))
|
||||||
|
|
||||||
_OBJ = main.o util.o ui.o config.o auth.o efield.o users.o sessions.o
|
_OBJ = main.o log.o util.o ui.o ui_state.o config.o desktop.o auth.o ofield.o efield.o users.o sessions.o chvt.o launch_state.o
|
||||||
OBJ = $(patsubst %,$(ODIR)/%,$(_OBJ))
|
OBJ = $(patsubst %,$(ODIR)/%,$(_OBJ))
|
||||||
|
|
||||||
$(ODIR)/%.o: $(CDIR)/%.c $(DEPS)
|
$(ODIR)/%.o: $(CDIR)/%.c $(DEPS)
|
||||||
@mkdir -p $(ODIR)
|
@mkdir -p $(ODIR)
|
||||||
$(CC) -c -o $@ $< $(CFLAGS)
|
$(CC) -c -o $@ $< $(ALLFLAGS)
|
||||||
|
|
||||||
lidm: $(OBJ)
|
lidm: $(OBJ)
|
||||||
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
|
$(CC) -o $@ $^ $(ALLFLAGS) $(LIBS)
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
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/
|
||||||
|
[ -f ${DESTDIR}/etc/lidm.ini ] || 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'"
|
||||||
|
|
||||||
|
pre-commit:
|
||||||
|
codespell
|
||||||
|
find . -type f -name '*.sh' -not -path './assets/pkg/aur/*/src/*' | xargs shellcheck
|
||||||
|
clang-format -i $$(git ls-files "*.c" "*.h")
|
||||||
|
clang-tidy -p . $$(git ls-files "*.c" "*.h")
|
||||||
|
174
README.md
@ -1,116 +1,122 @@
|
|||||||
# lidm
|
[](https://github.com/javalsai/lidm/blob/master/LICENSE)
|
||||||
Lidm is a really light display manager made in C, highly customizable and held together by hopes and prayers 🙏
|
[](https://github.com/javalsai/lidm)
|
||||||
|
[](https://github.com/javalsai/lidm/releases)
|
||||||
|
|
||||||

|
# LiDM
|
||||||
> *this is shown as in a terminal emulator, actual linux console doesn't support as much color and decorations*
|
|
||||||
|
|
||||||
> *but all colors and strings are fully suctomizable*
|
LiDM is a really light 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 [Display Manager](https://en.wikipedia.org/wiki/X_display_manager) you have seen such as SDDM or GDM but without using any X.org graphics at all. Instead being a purely [text based interface](https://en.wikipedia.org/wiki/Text-based_user_interface) inside your terminal/TTY.
|
||||||
|
|
||||||
# Index
|

|
||||||
(TODO, VSC(odium) does this automatically, I'm on nvim rn 😎)
|
|
||||||
|
> *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
|
## Features
|
||||||
* Builds fast af
|
|
||||||
* Works everywhere you can get gcc to compile
|
* Simple as C, you only need a C compiler and standard unix libraries to build this.
|
||||||
* Fast and possibly efficient
|
* Fully customizable, from strings, including action keys, to colors (I hope you know ansi escape codes)
|
||||||
* Fully customizable, from strings to colors (I hope you know ansi escape codes), to action buttons
|
|
||||||
* Automatically detects xorg and wayland sessions, plus allowing to launch the default user shell (if enabled in config)
|
* 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
|
# Index
|
||||||
* 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
|
* [LiDM](#lidm)
|
||||||
* Any kind of arguments
|
* [Features](#features)
|
||||||
* 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.
|
* [WIP](#wip)
|
||||||
|
* [Index](#index)
|
||||||
> [!CAUTION]
|
* [Ideology](#ideology)
|
||||||
> (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.
|
* [Usage](#usage)
|
||||||
|
* [Arguments](#arguments)
|
||||||
|
* [Program](#program)
|
||||||
|
* [Requirements](#requirements)
|
||||||
|
* [Installation](#installation)
|
||||||
|
* [Configuring](#configuring)
|
||||||
|
* [Contributing](#contributing)
|
||||||
|
* [Inspiration](#inspiration)
|
||||||
|
* [Contributors](#contributors)
|
||||||
|
|
||||||
# Ideology
|
# 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).
|
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 -->
|
|
||||||
[  ](https://stopchatcontrol.eu)
|
[  ](https://stopchatcontrol.eu)
|
||||||
> *there's also a [change.org post](https://www.change.org/p/stoppt-die-chatkontrolle-grundrechte-gelten-auch-im-netz)*
|
|
||||||
|
|
||||||
# Backstory
|
> *there's also a [change.org post](https://www.change.org/p/stoppt-die-chatkontrolle-grundrechte-gelten-auch-im-netz).*
|
||||||
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.
|
|
||||||
|
|
||||||
 <!--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)
|
|
||||||
|
|
||||||
# Usage
|
# 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
|
### Arguments
|
||||||
```sh
|
|
||||||
make # 👍
|
If a single argument is provided (don't even do `--` or standard unix parsing...), it switches to said tty number at startup. Used (at least) by most service files.
|
||||||
```
|
|
||||||
|
### Program
|
||||||
|
|
||||||
|
Base (mostly intuitive):
|
||||||
|
|
||||||
|
* Use arrow keys to navigate the inputs and type over any of them to override the default value.
|
||||||
|
* Enter will just attempt to login.
|
||||||
|
* If you are focused on an edited input, horizontal arrow keys will attempt to move across the text just as expected.
|
||||||
|
|
||||||
|
On top of that:
|
||||||
|
|
||||||
|
* Using the horizontal arrow keys if the focused input is not in text mode or the movement would overflow the input. It will try to change in such direction the option of session or the user.
|
||||||
|
* Pressing <kbd>ESC</kbd> and then horizontal arrows will force to change the option of the focused input even if it's in edit mode.
|
||||||
|
* Editing an option on a user or a shell session will put you in edit mode appending after the original value.
|
||||||
|
|
||||||
|
# Requirements
|
||||||
|
|
||||||
|
* Make (Also optional, but does things automatically, make sure `gcc` and `mkdir -p` work as expected).
|
||||||
|
* A compiler like `cc`, `gcc` or `clang`. Make sure to use the desired `CC=<compiler>` on the `make` command.
|
||||||
|
* PAM library, used for user authentication, just what `login` or `su` use internally. Don't worry, it's surely pre-installed.
|
||||||
|
|
||||||
# Installation
|
# 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)
|
Check the [installation guide](INSTALL.md) to use your preferred installation source.
|
||||||
* 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.
|
|
||||||
|
|
||||||
# Configuring
|
# 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. 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).
|
The format attempts to mimic the TOML format. Escape sequences like `\x1b` are allowed as well as comments and empty lines.
|
||||||
|
|
||||||
|
Colors are gonna be put inside `\x1b[...m`, if you don't know what this is check [an ANSI table](https://gist.github.com/JBlond/2fea43a3049b38287e5e9cefc87b2124). Mind that `\x1b` is the same as `\e`, `\033` and several other representations.
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
|
> The default `fg` style should disable decorators set up in other elements (cursive, underline...). It's just adding 20 to the number, so if an underline is 4, disabling it is done with 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
|
# 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 [contribution guide](docs/CONTRIBUTING.md).
|
||||||
|
|
||||||
|
# Inspiration
|
||||||
|
|
||||||
|
This project was started after facing some issues building [ly](https://github.com/fairyglade/ly) on an ancient laptop, the UI is heavily inspired by it.
|
||||||
|
|
||||||
|
For this reason the project's philosophy is to be simple and minimal, such that even prehistoric hardware is capable of running it.
|
||||||
|
|
||||||
|
I forgot what exactly the name came from, but it surely was a mix of a few things so:
|
||||||
|
|
||||||
|
* Obviously it's inspired by `ly`. `ly-dm` leads to "lydm".
|
||||||
|
* Wow make "lydm" simple with a "y" → "i" transformation.
|
||||||
|
* Associate it with the "i" in s**i**mple and other display managers like **Li**ghtDM.
|
||||||
|
* And the **la**ptop this project started in has a **lid**.
|
||||||
|
|
||||||
# Contributors
|
# Contributors
|
||||||
Special thanks to:
|
|
||||||
* ChatGPT, in times of slow laptops where pages take ages to load, a single tab connected to a bunch of burning cloud GPUs feeding corporate hype is all you need to get quick answers for your questions, as long as you know how to filter AI crap ofc.
|
|
||||||
* My lack of gf, can't imagine this project being possible if somebody actually cared about me daily.
|
|
||||||
|
|
||||||
# Milestones
|
[](https://github.com/javalsai/lidm/graphs/contributors)
|
||||||
* 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
|
[killertofus](https://github.com/killertofus), [deadvey](https://github.com/deadvey), [grialion](https://github.com/grialion/), cerealexperiments\_, [antiz96](https://github.com/Antiz96), [rmntgx](https://github.com/rmntgx) and [more...](https://github.com/javalsai/lidm/graphs/contributors)
|
||||||
Hope you didn't expect actual project recommendations, but these songs are 🔥
|
|
||||||
* "Sixpence None the Richer - Kiss Me"
|
|
||||||
* "Avril Lavigne - Complicated"
|
|
||||||
* "Shawn Mendes - There's Nothing Holdin' Me Back"
|
|
||||||
* "Rio Romeo - Nothing's New"
|
|
||||||
* "ElyOtto - SugarCrash!"
|
|
||||||
* "The Cranberries - Sunday"
|
|
||||||
* "Goo Goo Dolls - Iris"
|
|
||||||
* "Em Beihold - Numb Little Bug"
|
|
||||||
* "MAGIC! - Rude"
|
|
||||||
* "The Cranberries - Zombie"
|
|
||||||
* "Natalie Imbruglia - Torn"
|
|
||||||
* "Alec Benjamin - I Sent My Therapist To Therapy"
|
|
||||||
* "The Neighbourhood - Sweater Weather"
|
|
||||||
* "Cascada - Everytime We Touch" (potentially the sped up versoin if better)
|
|
||||||
* "Mitski - My Love Mine All Mine"
|
|
||||||
|
|
||||||
Oh, an actual recommendation, if you don't like a element you can change the fg color of it to be the same as the bg.
|
With their big or small contributions, every commit has helped in its own way and encouraged me to keep putting my soul into this.
|
||||||
|
|
||||||
Congrats if you've managed to read through all this.
|
***
|
||||||
|
|
||||||
|
🌟 Finally, consider starring this repo [or...](https://www.reddit.com/r/github/comments/1l2mchg/is_this_allowed) 🔪
|
||||||
|
|
||||||
|

|
||||||
|
BIN
assets/lidm.png
Before Width: | Height: | Size: 14 KiB |
105
assets/man/lidm-config.5
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
.\" 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 THEMES
|
||||||
|
There are themes you can take as reference or simply copy in \fBthemes/\fP, no need to tackle the config yourself. It's good to give this a read however.
|
||||||
|
|
||||||
|
.SH DESCRIPTION
|
||||||
|
The \fI/etc/lidm.ini\fP file specifies all the configuration for lidm, including theme colors. It's also possible to override this path with the \fILIDM_CONF\fP environment variable.
|
||||||
|
|
||||||
|
The configuration aims to mimic a toml syntax but it's not 100% compatible with it. It's grouped in tables and takes key/value pairs parsed in different modes depndending on the type. Comments and empty lines are allowed as well as surrounding whitespace at the edges of the line and the equals sign.
|
||||||
|
|
||||||
|
Values can be of these types:
|
||||||
|
.TP
|
||||||
|
\fBSTRING\fP
|
||||||
|
Needs to be quoted with double quotes, allows basic character escaping with a backslash as well as bytes of the form \fB\\xHH\fP, please don't put a nullbyte.
|
||||||
|
.TP
|
||||||
|
\fBBOOL\fP
|
||||||
|
Either \fBtrue\fP or \fBfalse\fP, no quoting.
|
||||||
|
.TP
|
||||||
|
\fBKEY\fP
|
||||||
|
Represents a keyboard key, must be unquoted, possible values are enumerated in \fBinclude/keys.h\fP.
|
||||||
|
.TP
|
||||||
|
\fBSTRING_ARRAY\fP
|
||||||
|
A list of strings, especified as a normal string, but reassigning to the same variable will append to that list.
|
||||||
|
|
||||||
|
|
||||||
|
.SH KEYS
|
||||||
|
In case anything here is outdated, all the config structure is defined in \fBinclude/config.h\fP, you can also find the default values there. This reference is separated by tables.
|
||||||
|
|
||||||
|
.SS colors
|
||||||
|
All these values are of type \fBSTRING\fP.
|
||||||
|
.TP
|
||||||
|
\fBbd, fg, 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
|
||||||
|
\fBs_wayland, s_xorg, s_shell\fP
|
||||||
|
Coloring for sessions of such types (Wayland, X.org, Shells)
|
||||||
|
.TP
|
||||||
|
\fBe_hostname, e_date, e_box\fP
|
||||||
|
Coloring for the hostname, date and box elements.
|
||||||
|
.TP
|
||||||
|
\fB.e_header\fP
|
||||||
|
Coloring for heading elements (left column)
|
||||||
|
.TP
|
||||||
|
\fBe_user, e_passwd, e_badpasswd\fP
|
||||||
|
Coloring for the user element, password and bad padssword.
|
||||||
|
.TP
|
||||||
|
\fBe_key\fP
|
||||||
|
Coloring for key elements (eg: F1, F2, CTRL...)
|
||||||
|
|
||||||
|
.SS chars
|
||||||
|
Single characters used for some elements (could be longer than a character, but it will likely break UI code assumptions), these are also of type \fBSTRING\fP.
|
||||||
|
.TP
|
||||||
|
\fBhb, vb\fP
|
||||||
|
Character for the horizontal bar (hb) and vertical bar (vb).
|
||||||
|
.TP
|
||||||
|
\fBctl, ctr, cbl, cbr\fP
|
||||||
|
Characters for the corners of the box (ctl = corner top left, cbr = corner bottom right)
|
||||||
|
|
||||||
|
.SS functions
|
||||||
|
All these are of type \fBKEY\fP.
|
||||||
|
.TP
|
||||||
|
\fBpoweroff, reboot, refresh\fP
|
||||||
|
Function key to use for such action.
|
||||||
|
|
||||||
|
.SS strings
|
||||||
|
Display strings to use for some elements.
|
||||||
|
.TP
|
||||||
|
\fBf_poweroff, f_reboot, f_refresh\fP
|
||||||
|
Text displayed to name such functions at the bottom of the screen.
|
||||||
|
.TP
|
||||||
|
\fBe_user, e_passwd\fP
|
||||||
|
Text to display for these element headers.
|
||||||
|
.TP
|
||||||
|
\fBs_wayland, s_xorg, s_shell\fP
|
||||||
|
Text to display as the header for such sessions.
|
||||||
|
.TP
|
||||||
|
\fBopts_pre, opts_post\fP
|
||||||
|
To be used for items with multiple options on the left and right sides \fB"< "\fP and \fB" >"\fP.
|
||||||
|
|
||||||
|
.SS behavior
|
||||||
|
Other miscellaneous behavior strings, of mixed types
|
||||||
|
.TP
|
||||||
|
\fBinclude_defshell\fP
|
||||||
|
Type \fBBOOL\fP, specifies if the default user shel should be included as a session.
|
||||||
|
.TP
|
||||||
|
\fBsource, user_source\fP
|
||||||
|
Types \fBSTRING_ARRAY\fP. Specify paths to source on login if they exist, simple KEY=VALUE format with comments (#) or empty'ish lines, quoting or escape sequences not supported yet. \fBuser_source\fP paths are relative to user home.
|
||||||
|
.TP
|
||||||
|
\fBtimefmt\fP
|
||||||
|
Specify the time format string to be displayed. Check \fBstrftime (3)\fP to know the possible formatting variables.
|
||||||
|
|
||||||
|
|
||||||
|
.SH "SEE ALSO"
|
||||||
|
.BR lidm (1)
|
||||||
|
.BR strftime (3)
|
49
assets/man/lidm.1
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
.\" 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
|
||||||
|
.TP
|
||||||
|
\fBLIDM_LOG\fP
|
||||||
|
Optionally, a path to output misc logs and potential silent failures.
|
||||||
|
|
||||||
|
.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
After Width: | Height: | Size: 205 KiB |
4
assets/pkg/aur/.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
*/*
|
||||||
|
!*/.gitignore
|
||||||
|
!*/PKGBUILD
|
||||||
|
!*/.SRCINFO
|
12
assets/pkg/aur/README.md
Normal 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).
|
20
assets/pkg/aur/lidm-bin/.SRCINFO
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
pkgbase = lidm-bin
|
||||||
|
pkgdesc = A fully colorful customizable TUI display manager made in C. (release binary)
|
||||||
|
pkgver = 1.1.1
|
||||||
|
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/v1.1.1/lidm-amd64
|
||||||
|
source = default-theme.ini::https://raw.githubusercontent.com/javalsai/lidm/v1.1.1/themes/default.ini
|
||||||
|
source = lidm.1::https://raw.githubusercontent.com/javalsai/lidm/v1.1.1/assets/man/lidm.1
|
||||||
|
source = lidm-config.5::https://raw.githubusercontent.com/javalsai/lidm/v1.1.1/assets/man/lidm-config.5
|
||||||
|
sha256sums = c4e82ae2c08c223ef417edca50f86f516e3f9154339f67110c87d01855673fcf
|
||||||
|
sha256sums = a8d29e220c23b48b5cd3aac0c0e395e90a9d6c9ca9c9c35a45ad6f3df5f55542
|
||||||
|
sha256sums = 7f2fb91f55088be1a9b1c93ecf5d6c1e437f369b56df2eacc9d10b00c93c39f8
|
||||||
|
sha256sums = 5dbe088ce29c95a400080190560d4308c10519a953e83d2d5020dfdf47dd830f
|
||||||
|
|
||||||
|
pkgname = lidm-bin
|
3
assets/pkg/aur/lidm-bin/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
*
|
||||||
|
!PKGBUILD
|
||||||
|
!.SRCINFO
|
29
assets/pkg/aur/lidm-bin/PKGBUILD
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
# shellcheck disable=SC2034,SC2148,SC2128,SC2154,SC2164
|
||||||
|
# Maintainer: javalsai <javalsai@proton.me>
|
||||||
|
pkgname=lidm-bin
|
||||||
|
pkgver=1.1.1
|
||||||
|
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=('c4e82ae2c08c223ef417edca50f86f516e3f9154339f67110c87d01855673fcf'
|
||||||
|
'a8d29e220c23b48b5cd3aac0c0e395e90a9d6c9ca9c9c35a45ad6f3df5f55542'
|
||||||
|
'7f2fb91f55088be1a9b1c93ecf5d6c1e437f369b56df2eacc9d10b00c93c39f8'
|
||||||
|
'5dbe088ce29c95a400080190560d4308c10519a953e83d2d5020dfdf47dd830f')
|
||||||
|
|
||||||
|
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"
|
||||||
|
}
|
17
assets/pkg/aur/lidm-git/.SRCINFO
Normal 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
@ -0,0 +1,3 @@
|
|||||||
|
*
|
||||||
|
!PKGBUILD
|
||||||
|
!.SRCINFO
|
31
assets/pkg/aur/lidm-git/PKGBUILD
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
# shellcheck disable=SC2034,SC2148,SC2128,SC2154,SC2164
|
||||||
|
# Maintainer: javalsai <javalsai@proton.me>
|
||||||
|
pkgname=lidm-git
|
||||||
|
pkgver=1.1.1.r0.g3bfc2f5
|
||||||
|
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}"
|
||||||
|
}
|
14
assets/pkg/aur/lidm/.SRCINFO
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
pkgbase = lidm
|
||||||
|
pkgdesc = A fully colorful customizable TUI display manager made in C. (build latest tag)
|
||||||
|
pkgver = 1.1.1
|
||||||
|
pkgrel = 1
|
||||||
|
url = https://github.com/javalsai/lidm
|
||||||
|
arch = any
|
||||||
|
license = GPL
|
||||||
|
makedepends = git
|
||||||
|
makedepends = gcc
|
||||||
|
depends = pam
|
||||||
|
source = tarball.tar.gz::https://github.com/javalsai/lidm/archive/refs/tags/v1.1.1.tar.gz
|
||||||
|
sha256sums = 915dc5acce413d5d32bb52c6f9980661a389a0939a49ac31bc250b2d162a5479
|
||||||
|
|
||||||
|
pkgname = lidm
|
3
assets/pkg/aur/lidm/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
*
|
||||||
|
!PKGBUILD
|
||||||
|
!.SRCINFO
|
25
assets/pkg/aur/lidm/PKGBUILD
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
# shellcheck disable=SC2034,SC2148,SC2128,SC2154,SC2164
|
||||||
|
# Maintainer: javalsai <javalsai@proton.me>
|
||||||
|
pkgname=lidm
|
||||||
|
pkgver=1.1.1
|
||||||
|
pkgrel=1
|
||||||
|
depends=('pam')
|
||||||
|
makedepends=('git' 'gcc')
|
||||||
|
pkgdesc="A fully colorful customizable TUI display manager made in C. (build latest tag)"
|
||||||
|
arch=('any')
|
||||||
|
url="https://github.com/javalsai/lidm"
|
||||||
|
license=('GPL')
|
||||||
|
source=("tarball.tar.gz::https://github.com/javalsai/lidm/archive/refs/tags/v$pkgver.tar.gz")
|
||||||
|
sha256sums=('915dc5acce413d5d32bb52c6f9980661a389a0939a49ac31bc250b2d162a5479')
|
||||||
|
|
||||||
|
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
@ -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
|
21
assets/pkg/aur/test-makepkg.sh
Executable file
@ -0,0 +1,21 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
MYSELF=$(realpath "$0")
|
||||||
|
MYDIR=$(dirname "$MYSELF")
|
||||||
|
|
||||||
|
for pkg in "$MYDIR"/*/; do
|
||||||
|
printf "\x1b[1mEntering '%s'\x1b[0m\n" "$pkg"
|
||||||
|
cd "$pkg"
|
||||||
|
|
||||||
|
# shellcheck disable=SC1091
|
||||||
|
source "PKGBUILD"
|
||||||
|
for source in "${source[@]}"; do
|
||||||
|
awk -F'::' '{print $1}' <<<"$source" | xargs rm -rf
|
||||||
|
done
|
||||||
|
|
||||||
|
rm -rf ./*.{gz,zst} src pkg
|
||||||
|
makepkg -f .
|
||||||
|
|
||||||
|
echo
|
||||||
|
done
|
29
assets/pkg/aur/update-pkgs.sh
Executable 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
|
42
assets/services/README.md
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
# 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:
|
||||||
|
|
||||||
|
> [!IMPORTANT]
|
||||||
|
> If you think this should be packaged too, there's [a discussion](https://github.com/javalsai/lidm/discussions/39) to talk about this.
|
||||||
|
|
||||||
|
## 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
@ -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
@ -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
@ -0,0 +1,5 @@
|
|||||||
|
BAUD_RATE=38400
|
||||||
|
TERM_NAME=linux
|
||||||
|
|
||||||
|
TTY=tty7
|
||||||
|
EXEC_PATH=/bin/lidm
|
5
assets/services/runit/finish
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
[ -r conf ] && . ./conf
|
||||||
|
|
||||||
|
exec utmpset -w $TTY
|
15
assets/services/runit/run
Executable 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
|
0
assets/services/s6/dependencies.d/hostname
Normal file
0
assets/services/s6/dependencies.d/mount-devfs
Normal file
8
assets/services/s6/run
Executable 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
@ -0,0 +1 @@
|
|||||||
|
longrun
|
16
assets/services/systemd.service
Normal 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
|
@ -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"
|
|
||||||
}
|
|
||||||
]
|
|
33
config.ini
@ -1,33 +0,0 @@
|
|||||||
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_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
|
|
||||||
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 = 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 = powewoff
|
|
||||||
strings.f_reboot = rewoot
|
|
||||||
strings.f_refresh = rewresh
|
|
||||||
strings.e_user = wuser
|
|
||||||
strings.e_passwd = passwd
|
|
||||||
strings.s_xorg = xworg
|
|
||||||
strings.s_wayland = waywand
|
|
||||||
strings.s_shell = swell
|
|
||||||
behavior.include_defshell = true
|
|
3
debug/README.md
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# Debug
|
||||||
|
|
||||||
|
This folder contains debug utils like gdb scripts. They are not guaranteed to work but can ease some tasks when debugging.
|
59
debug/debug.gdb
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
# this just meant to run in another term, is probably better to attach to another already running window
|
||||||
|
set inferior-tty /dev/pts/7
|
||||||
|
set pagination off
|
||||||
|
|
||||||
|
break *(read_press + 62)
|
||||||
|
define fake_read
|
||||||
|
set *((char*) $rsi) = $al
|
||||||
|
set $rax = 1
|
||||||
|
jump *(read_press + 67)
|
||||||
|
end
|
||||||
|
|
||||||
|
break *(read_press + 108)
|
||||||
|
define fake_magic_cont
|
||||||
|
set $eax = 1
|
||||||
|
jump *(read_press + 113)
|
||||||
|
end
|
||||||
|
define fake_magic_end
|
||||||
|
set $eax = 0
|
||||||
|
jump *(read_press + 113)
|
||||||
|
end
|
||||||
|
|
||||||
|
run
|
||||||
|
set $al = 0x1b
|
||||||
|
fake_read
|
||||||
|
fake_magic_cont
|
||||||
|
set $al = '['
|
||||||
|
fake_read
|
||||||
|
fake_magic_cont
|
||||||
|
set $al = 'D'
|
||||||
|
fake_read
|
||||||
|
fake_magic_end
|
||||||
|
|
||||||
|
set $al = 'p'
|
||||||
|
fake_read
|
||||||
|
fake_magic_end
|
||||||
|
|
||||||
|
set $al = 'a'
|
||||||
|
fake_read
|
||||||
|
fake_magic_end
|
||||||
|
|
||||||
|
set $al = 's'
|
||||||
|
fake_read
|
||||||
|
fake_magic_end
|
||||||
|
|
||||||
|
set $al = 's'
|
||||||
|
fake_read
|
||||||
|
fake_magic_end
|
||||||
|
|
||||||
|
set $al = 'w'
|
||||||
|
fake_read
|
||||||
|
fake_magic_end
|
||||||
|
|
||||||
|
set $al = 'd'
|
||||||
|
fake_read
|
||||||
|
fake_magic_end
|
||||||
|
|
||||||
|
set $al = '\n'
|
||||||
|
fake_read
|
||||||
|
fake_magic_end
|
47
docs/CONTRIBUTING.md
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
# Contributing
|
||||||
|
|
||||||
|
Contributions are welcome! Here's how you can help:
|
||||||
|
|
||||||
|
* [Contributing code](#code)
|
||||||
|
* [Reporting issues](#issues)
|
||||||
|
* [Other](#other)
|
||||||
|
|
||||||
|
## Code
|
||||||
|
|
||||||
|
For small fixes or incremental improvements simply fork the repo and follow the process below.
|
||||||
|
|
||||||
|
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! (it might be helpful to read a [quide on the project structure and conventions](structure.md) before this)
|
||||||
|
* 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 "*.c" "*.h")`
|
||||||
|
* Run the code linter: `clang-tidy -p . $(git ls-files "*.c" "*.h")`. Some checks are pretty pedantic, feel free to ignore or debate some of the rules.
|
||||||
|
* If you prefer, you can run `make pre-commit` to run several code style checks like the avobe along a few extra stuff.
|
||||||
|
|
||||||
|
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) ("feat" for features, "fix", "style", "chore", "docs", etc)
|
||||||
|
* Be descriptive.
|
||||||
|
* Don't make the title too long and add commit descriptions if you think the changes need it.
|
||||||
|
* e.g. "feat: add support for X", "fix(config): config parser segfaulting", "docs(typo): fix a typo in README.md"
|
||||||
|
|
||||||
|
4. Once you are happy with your changes, submit a pull request.
|
||||||
|
* Open the pull request.
|
||||||
|
* Add a short description explaining 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) and init system if you know.
|
||||||
|
|
||||||
|
After reporting you should aim to answer questions or clarifications as this helps pinpoint the cause of the issue.
|
||||||
|
|
||||||
|
## Other
|
||||||
|
|
||||||
|
If you are unsure what category your contribution falls under, feel free to [open an issue](https://github.com//javalsai/lidm/issues/new) or [a discussion](https://github.com//javalsai/lidm/discussions/new) to talk about it.
|
89
docs/structure.md
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
# Introduction
|
||||||
|
|
||||||
|
This file aims to explain the basic project structure and some code conventions
|
||||||
|
and patterns used for contributors. If you plan on contributing a considerable
|
||||||
|
amount of code, please read this thoroughly to keep the project behavior
|
||||||
|
consistent.
|
||||||
|
|
||||||
|
Even if your changes are not very related to the code, this guide can help to
|
||||||
|
understand how they can be related to the rest of the project and what side
|
||||||
|
changes it can require.
|
||||||
|
|
||||||
|
# Structure
|
||||||
|
|
||||||
|
The file structure is very simple, you have `.c` files in `src/` with their
|
||||||
|
header `.h` counterpart in `include/`, they are listed in the `Makefile` and
|
||||||
|
built all together on the same layer.
|
||||||
|
|
||||||
|
Each file contains functions aimed to provide some specialized behavior, they
|
||||||
|
tend to follow a common prefix (like `vec_` for vector functions) to avoid name
|
||||||
|
collisions with themselves.
|
||||||
|
|
||||||
|
## Important Files
|
||||||
|
|
||||||
|
The `main.c` of course provides the entry point of the program, then each file
|
||||||
|
has special functionality, but a special one is `util.h`, is linked with almost
|
||||||
|
every file and provides some shared utilities to dealing with UTF-8, dynamic
|
||||||
|
Vectors and other stuff.
|
||||||
|
|
||||||
|
`log.c` is also an important file as it provides logging utilities for
|
||||||
|
debugging, there's no need to deal with it's initialization, it behaves just
|
||||||
|
like standard printing utilities but integrated into the configured logfile.
|
||||||
|
|
||||||
|
# Debugging
|
||||||
|
|
||||||
|
The log module can be easily used by just setting up the `LIDM_LOG`
|
||||||
|
environmental variable to the logs output path.
|
||||||
|
|
||||||
|
# Header Files
|
||||||
|
|
||||||
|
But what if you create a new file? It's important that the definitions are only
|
||||||
|
evaluated once by the compiler, even if they are included by several files. For
|
||||||
|
this, you can use this simple trick (assume this is for a file named
|
||||||
|
`mylib.h`):
|
||||||
|
|
||||||
|
```h
|
||||||
|
#ifndef MYLIBH_
|
||||||
|
#define MYLIBH_
|
||||||
|
|
||||||
|
// library contents
|
||||||
|
// ...
|
||||||
|
|
||||||
|
#endif
|
||||||
|
```
|
||||||
|
|
||||||
|
It's also a good idea to include brief comments above functions if it's not
|
||||||
|
evident what they do and name all parameters.
|
||||||
|
|
||||||
|
# Nullability Checks
|
||||||
|
|
||||||
|
Nullability checks are not really enforced in the code but it's never a bad
|
||||||
|
idea to include them, however, `gcc` doesn't support them under certain
|
||||||
|
conditions.
|
||||||
|
|
||||||
|
For this you can use `NULLABLE`, `NNULLABLE` and `UNULLABLE` macros from
|
||||||
|
`"macros.h"` to conditionally include `_Nullable`, `_Nonnull` and
|
||||||
|
`_Null-unspecified` respectively.
|
||||||
|
|
||||||
|
# Handling & Support
|
||||||
|
|
||||||
|
Every function should properly handle allocation failures (avoid them with
|
||||||
|
stack arrays where possible), support UTF-8 strings, use the `log` module
|
||||||
|
instead of printing to stdout (messing with the state of the ui) and free all
|
||||||
|
lost memory (if it can be lost before reaching the final stage where it execs
|
||||||
|
another program, I'm fine with not freeing memory still reachable at the end).
|
||||||
|
|
||||||
|
# Code format, style and linting
|
||||||
|
|
||||||
|
Be reasonable and follow `clang-format` and `clang-tidy` rules. `clang-tidy`
|
||||||
|
can be quite pedantic with the current primitive rules, so feel free to use
|
||||||
|
`LINTIGNORE` or discuss if said rule should be enforced in first place.
|
||||||
|
|
||||||
|
Also avoid grammar typos and for shell scripts use `shellcheck`, you can run
|
||||||
|
this checks with `make pre-commit` if you have the required tools.
|
||||||
|
|
||||||
|
# Documentation
|
||||||
|
|
||||||
|
Please, also check if there's documentation related to the feature/changes you
|
||||||
|
are implementing, could be on markdown or manpages, if there is and you have
|
||||||
|
some spare time, it's really helpful to update it; although not enforced.
|
61
flake.lock
generated
Normal 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
@ -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 ]; };
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
@ -1,10 +1,12 @@
|
|||||||
#ifndef _AUTHH_
|
#ifndef AUTHH_
|
||||||
#define _AUTHH_
|
#define AUTHH_
|
||||||
|
|
||||||
#include <stdbool.h>
|
#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 config* config);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
25
include/chvt.h
Normal 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
|
206
include/config.h
@ -1,83 +1,163 @@
|
|||||||
#ifndef _CONFIGH_
|
#ifndef CONFIGH_
|
||||||
#define _CONFIGH_
|
#define CONFIGH_
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
#include <keys.h>
|
#include "keys.h"
|
||||||
#include <sessions.h>
|
#include "macros.h"
|
||||||
#include <users.h>
|
#include "util.h"
|
||||||
|
|
||||||
|
enum introspection_type {
|
||||||
|
STRING,
|
||||||
|
BOOL,
|
||||||
|
KEY,
|
||||||
|
STRING_ARRAY,
|
||||||
|
};
|
||||||
|
static const char* NNULLABLE const INTROS_TYS_NAMES[] = {
|
||||||
|
[STRING] = "STRING",
|
||||||
|
[BOOL] = "BOOL",
|
||||||
|
[KEY] = "KEY",
|
||||||
|
[STRING_ARRAY] = "STRING_ARRAY",
|
||||||
|
};
|
||||||
|
|
||||||
|
struct introspection_item {
|
||||||
|
char* NNULLABLE name;
|
||||||
|
size_t offset;
|
||||||
|
enum introspection_type typ;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define INTROS_ITEM(key, table, ty) \
|
||||||
|
{ \
|
||||||
|
.name = #key, \
|
||||||
|
.offset = offsetof(table, key), \
|
||||||
|
.typ = (ty), \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define STRUCT_BUILDER(cty, name, ty, def, tname) cty name;
|
||||||
|
#define DEFAULT_BUILDER(cty, name, ty, def, tname) .name = (def),
|
||||||
|
#define INTROS_BUILDER(cty, name, ty, def, tname) \
|
||||||
|
INTROS_ITEM(name, struct table_##tname, ty),
|
||||||
|
|
||||||
|
#define BUILD_TABLE(table, TABLE) \
|
||||||
|
struct table_##table { \
|
||||||
|
TABLE(STRUCT_BUILDER, table) \
|
||||||
|
}
|
||||||
|
#define BUILD_DEFAULT(utable, table, TABLE) \
|
||||||
|
static const struct table_##table DEFAULT_TABLE_##utable = { \
|
||||||
|
TABLE(DEFAULT_BUILDER, table)}
|
||||||
|
#define BUILD_INTROS(utable, table, TABLE) \
|
||||||
|
static const struct introspection_item INTROS_TABLE_##utable[] = { \
|
||||||
|
TABLE(INTROS_BUILDER, table)}
|
||||||
|
|
||||||
|
#define BUILD(table, utable, TABLE) \
|
||||||
|
BUILD_TABLE(table, TABLE); \
|
||||||
|
BUILD_DEFAULT(utable, table, TABLE); \
|
||||||
|
BUILD_INTROS(utable, table, TABLE);
|
||||||
|
|
||||||
// should be ansi escape codes under \x1b[...m
|
// should be ansi escape codes under \x1b[...m
|
||||||
// if not prepared accordingly, it might break
|
// if not prepared accordingly, it might break
|
||||||
struct theme_colors {
|
#define TABLE_COLORS(F, name) \
|
||||||
char *bg;
|
F(char* NNULLABLE, bg, STRING, "48;2;38;28;28", name) \
|
||||||
char *fg;
|
F(char* NNULLABLE, fg, STRING, "22;24;38;2;245;245;245", name) \
|
||||||
char *err;
|
F(char* NNULLABLE, err, STRING, "1;31", name) \
|
||||||
char *s_wl;
|
F(char* NNULLABLE, s_wayland, STRING, "38;2;255;174;66", name) \
|
||||||
char *s_xorg;
|
F(char* NNULLABLE, s_xorg, STRING, "38;2;37;175;255", name) \
|
||||||
char *s_shell;
|
F(char* NNULLABLE, s_shell, STRING, "38;2;34;140;34", name) \
|
||||||
char *f_other;
|
F(char* NNULLABLE, e_hostname, STRING, "38;2;255;64;64", name) \
|
||||||
char *e_hostname;
|
F(char* NNULLABLE, e_date, STRING, "38;2;144;144;144", name) \
|
||||||
char *e_date;
|
F(char* NNULLABLE, e_box, STRING, "38;2;122;122;122", name) \
|
||||||
char *e_box;
|
F(char* NNULLABLE, e_header, STRING, "4;38;2;0;255;0", name) \
|
||||||
char *e_header;
|
F(char* NNULLABLE, e_user, STRING, "36", name) \
|
||||||
char *e_user;
|
F(char* NNULLABLE, e_passwd, STRING, "4;38;2;245;245;205", name) \
|
||||||
char *e_passwd;
|
F(char* NNULLABLE, e_badpasswd, STRING, "3;4;31", name) \
|
||||||
char *e_badpasswd;
|
F(char* NNULLABLE, e_key, STRING, "38;2;255;174;66", name)
|
||||||
char *e_key;
|
|
||||||
};
|
BUILD(colors, COLORS, TABLE_COLORS);
|
||||||
|
|
||||||
// even if they're multiple bytes long
|
// even if they're multiple bytes long
|
||||||
// they should only take up 1 char size on display
|
// they should only take up 1 char size on display
|
||||||
struct theme_chars {
|
#define TABLE_CHARS(F, name) \
|
||||||
char *hb;
|
F(char* NNULLABLE, hb, STRING, "─", name) \
|
||||||
char *vb;
|
F(char* NNULLABLE, vb, STRING, "│", name) \
|
||||||
|
F(char* NNULLABLE, ctl, STRING, "┌", name) \
|
||||||
|
F(char* NNULLABLE, ctr, STRING, "┐", name) \
|
||||||
|
F(char* NNULLABLE, cbl, STRING, "└", name) \
|
||||||
|
F(char* NNULLABLE, cbr, STRING, "┘", name)
|
||||||
|
|
||||||
char *ctl;
|
BUILD(chars, CHARS, TABLE_CHARS);
|
||||||
char *ctr;
|
|
||||||
char *cbl;
|
|
||||||
char *cbr;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct theme {
|
#define TABLE_FUNCTIONS(F, name) \
|
||||||
struct theme_colors colors;
|
F(enum keys, poweroff, KEY, F1, name) \
|
||||||
struct theme_chars chars;
|
F(enum keys, reboot, KEY, F2, name) \
|
||||||
};
|
F(enum keys, refresh, KEY, F5, name)
|
||||||
|
|
||||||
struct functions {
|
BUILD(functions, FUNCTIONS, TABLE_FUNCTIONS);
|
||||||
enum keys poweroff;
|
|
||||||
enum keys reboot;
|
|
||||||
enum keys refresh;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct strings {
|
#define TABLE_STRINGS(F, name) \
|
||||||
char *f_poweroff;
|
F(char* NNULLABLE, f_poweroff, STRING, "poweroff", name) \
|
||||||
char *f_reboot;
|
F(char* NNULLABLE, f_reboot, STRING, "reboot", name) \
|
||||||
char *f_refresh;
|
F(char* NNULLABLE, f_refresh, STRING, "refresh", name) \
|
||||||
char *e_user;
|
F(char* NNULLABLE, e_user, STRING, "user", name) \
|
||||||
char *e_passwd;
|
F(char* NNULLABLE, e_passwd, STRING, "password", name) \
|
||||||
char *s_xorg;
|
F(char* NNULLABLE, s_wayland, STRING, "wayland", name) \
|
||||||
char *s_wayland;
|
F(char* NNULLABLE, s_xorg, STRING, "xorg", name) \
|
||||||
char *s_shell;
|
F(char* NNULLABLE, s_shell, STRING, "shell", name) \
|
||||||
};
|
F(char* NNULLABLE, opts_pre, STRING, "< ", name) \
|
||||||
|
F(char* NNULLABLE, opts_post, STRING, " >", name)
|
||||||
|
|
||||||
struct behavior {
|
BUILD(strings, STRINGS, TABLE_STRINGS);
|
||||||
bool include_defshell;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
#define NULL_VEC \
|
||||||
|
(struct Vector) { \
|
||||||
|
0, 0, NULL \
|
||||||
|
}
|
||||||
|
#define TABLE_BEHAVIOR(F, name) \
|
||||||
|
F(bool, include_defshell, BOOL, true, name) \
|
||||||
|
F(struct Vector, source, STRING_ARRAY, NULL_VEC, name) \
|
||||||
|
F(struct Vector, user_source, STRING_ARRAY, NULL_VEC, name) \
|
||||||
|
F(char* NNULLABLE, timefmt, STRING, "%X %x", name)
|
||||||
|
|
||||||
|
BUILD(behavior, BEHAVIOR, TABLE_BEHAVIOR);
|
||||||
|
|
||||||
|
//// CONFIG
|
||||||
struct config {
|
struct config {
|
||||||
struct theme theme;
|
struct table_colors colors;
|
||||||
struct functions functions;
|
struct table_chars chars;
|
||||||
struct strings strings;
|
struct table_functions functions;
|
||||||
struct behavior behavior;
|
struct table_strings strings;
|
||||||
|
struct table_behavior behavior;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool line_parser(
|
static const struct config DEFAULT_CONFIG = {
|
||||||
FILE* fd,
|
.colors = DEFAULT_TABLE_COLORS,
|
||||||
ssize_t* blksize,
|
.chars = DEFAULT_TABLE_CHARS,
|
||||||
u_char (*cb)(char *key,
|
.functions = DEFAULT_TABLE_FUNCTIONS,
|
||||||
char *value)); // might use this for parsing .desktop files too
|
.strings = DEFAULT_TABLE_STRINGS,
|
||||||
struct config *parse_config(char *path);
|
.behavior = DEFAULT_TABLE_BEHAVIOR,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct introspection_table {
|
||||||
|
char* NNULLABLE tname;
|
||||||
|
size_t offset;
|
||||||
|
const struct introspection_item* NNULLABLE intros;
|
||||||
|
size_t len;
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct introspection_table CONFIG_INSTROSPECTION[] = {
|
||||||
|
{"colors", offsetof(struct config, colors), INTROS_TABLE_COLORS,
|
||||||
|
sizeof(INTROS_TABLE_COLORS) / sizeof(INTROS_TABLE_COLORS[0])},
|
||||||
|
{"chars", offsetof(struct config, chars), INTROS_TABLE_CHARS,
|
||||||
|
sizeof(INTROS_TABLE_CHARS) / sizeof(INTROS_TABLE_CHARS[0])},
|
||||||
|
{"functions", offsetof(struct config, functions), INTROS_TABLE_FUNCTIONS,
|
||||||
|
sizeof(INTROS_TABLE_FUNCTIONS) / sizeof(INTROS_TABLE_FUNCTIONS[0])},
|
||||||
|
{"strings", offsetof(struct config, strings), INTROS_TABLE_STRINGS,
|
||||||
|
sizeof(INTROS_TABLE_STRINGS) / sizeof(INTROS_TABLE_STRINGS[0])},
|
||||||
|
{"behavior", offsetof(struct config, behavior), INTROS_TABLE_BEHAVIOR,
|
||||||
|
sizeof(INTROS_TABLE_BEHAVIOR) / sizeof(INTROS_TABLE_BEHAVIOR[0])},
|
||||||
|
};
|
||||||
|
|
||||||
|
//// FUNCTIONS
|
||||||
|
int parse_config(struct config* NNULLABLE config, char* NNULLABLE path);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
20
include/desktop.h
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#ifndef DESKTOPH_
|
||||||
|
#define DESKTOPH_
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "macros.h"
|
||||||
|
|
||||||
|
struct status {
|
||||||
|
bool finish;
|
||||||
|
int ret;
|
||||||
|
};
|
||||||
|
|
||||||
|
int read_desktop(FILE* NNULLABLE fd, void* UNULLABLE ctx,
|
||||||
|
struct status (*NNULLABLE cb)(void* UNULLABLE ctx,
|
||||||
|
char* NULLABLE table,
|
||||||
|
char* NNULLABLE key,
|
||||||
|
char* NNULLABLE value));
|
||||||
|
|
||||||
|
#endif
|
@ -1,18 +1,18 @@
|
|||||||
#ifndef _EFIELDH_
|
#ifndef EFIELDH_
|
||||||
#define _EFIELDH_
|
#define EFIELDH_
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
// holds also the max string buffer in itself, not dynamic
|
||||||
struct editable_field {
|
struct editable_field {
|
||||||
u_char length;
|
|
||||||
u_char pos;
|
u_char pos;
|
||||||
char content[255];
|
char content[255];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct editable_field field_new(char*);
|
struct editable_field efield_new(char* content);
|
||||||
void field_trim(struct editable_field*, u_char);
|
void efield_trim(struct editable_field* self, u_char pos);
|
||||||
void field_update(struct editable_field*, char*);
|
void efield_update(struct editable_field* self, char* update);
|
||||||
bool field_seek(struct editable_field*, char);
|
bool efield_seek(struct editable_field* self, char seek);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
124
include/keys.h
@ -1,40 +1,40 @@
|
|||||||
#ifndef _KEYSH_
|
#ifndef KEYSH_
|
||||||
#define _KEYSH_
|
#define KEYSH_
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
enum keys {
|
enum keys {
|
||||||
ESC,
|
ESC,
|
||||||
F1,
|
F1,
|
||||||
F2,
|
F2,
|
||||||
F3,
|
F3,
|
||||||
F4,
|
F4,
|
||||||
F5,
|
F5,
|
||||||
F6,
|
F6,
|
||||||
F7,
|
F7,
|
||||||
F8,
|
F8,
|
||||||
F9,
|
F9,
|
||||||
F10,
|
F10,
|
||||||
F11,
|
F11,
|
||||||
F12,
|
F12,
|
||||||
A_UP,
|
A_UP,
|
||||||
A_DOWN,
|
A_DOWN,
|
||||||
A_RIGHT,
|
A_RIGHT,
|
||||||
A_LEFT,
|
A_LEFT,
|
||||||
N_CENTER,
|
N_CENTER,
|
||||||
N_UP,
|
N_UP,
|
||||||
N_DOWN,
|
N_DOWN,
|
||||||
N_RIGHT,
|
N_RIGHT,
|
||||||
N_LEFT,
|
N_LEFT,
|
||||||
INS,
|
INS,
|
||||||
SUPR,
|
SUPR,
|
||||||
HOME,
|
HOME,
|
||||||
END,
|
END,
|
||||||
PAGE_UP,
|
PAGE_UP,
|
||||||
PAGE_DOWN,
|
PAGE_DOWN,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char * const key_names[] = {
|
static const char* const KEY_NAMES[] = {
|
||||||
[ESC] = "ESC",
|
[ESC] = "ESC",
|
||||||
[F1] = "F1",
|
[F1] = "F1",
|
||||||
[F2] = "F2",
|
[F2] = "F2",
|
||||||
@ -66,39 +66,39 @@ static const char * const key_names[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct key_mapping {
|
struct key_mapping {
|
||||||
enum keys key;
|
enum keys key;
|
||||||
const char *sequences[3];
|
const char* sequences[3];
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct key_mapping key_mappings[] = {
|
static const struct key_mapping KEY_MAPPINGS[] = {
|
||||||
{ ESC, { "\x1b", NULL }},
|
{ESC, {"\x1b", NULL}},
|
||||||
{ F1, { "\x1bOP", "\x1b[[A", NULL }},
|
{F1, {"\x1bOP", "\x1b[[A", NULL}},
|
||||||
{ F2, { "\x1bOQ", "\x1b[[B", NULL }},
|
{F2, {"\x1bOQ", "\x1b[[B", NULL}},
|
||||||
{ F3, { "\x1bOR", "\x1b[[C", NULL }},
|
{F3, {"\x1bOR", "\x1b[[C", NULL}},
|
||||||
{ F4, { "\x1bOS", "\x1b[[D", NULL }},
|
{F4, {"\x1bOS", "\x1b[[D", NULL}},
|
||||||
{ F5, { "\x1b[15~", "\x1b[[E", NULL }},
|
{F5, {"\x1b[15~", "\x1b[[E", NULL}},
|
||||||
{ F6, { "\x1b[17~", NULL }},
|
{F6, {"\x1b[17~", NULL}},
|
||||||
{ F7, { "\x1b[18~", NULL }},
|
{F7, {"\x1b[18~", NULL}},
|
||||||
{ F8, { "\x1b[19~", NULL }},
|
{F8, {"\x1b[19~", NULL}},
|
||||||
{ F9, { "\x1b[20~", NULL }},
|
{F9, {"\x1b[20~", NULL}},
|
||||||
{ F10, { "\x1b[21~", NULL }},
|
{F10, {"\x1b[21~", NULL}},
|
||||||
{ F11, { "\x1b[23~", NULL }},
|
{F11, {"\x1b[23~", NULL}},
|
||||||
{ F12, { "\x1b[24~", NULL }},
|
{F12, {"\x1b[24~", NULL}},
|
||||||
{ A_UP, { "\x1b[A", NULL }},
|
{A_UP, {"\x1b[A", NULL}},
|
||||||
{ A_DOWN, { "\x1b[B", NULL }},
|
{A_DOWN, {"\x1b[B", NULL}},
|
||||||
{ A_RIGHT, { "\x1b[C", NULL }},
|
{A_RIGHT, {"\x1b[C", NULL}},
|
||||||
{ A_LEFT, { "\x1b[D", NULL }},
|
{A_LEFT, {"\x1b[D", NULL}},
|
||||||
{ N_CENTER, { "\x1b[E", NULL }},
|
{N_CENTER, {"\x1b[E", NULL}},
|
||||||
{ N_UP, { "\x1bOA", NULL }},
|
{N_UP, {"\x1bOA", NULL}},
|
||||||
{ N_DOWN, { "\x1bOB", NULL }},
|
{N_DOWN, {"\x1bOB", NULL}},
|
||||||
{ N_RIGHT, { "\x1bOC", NULL }},
|
{N_RIGHT, {"\x1bOC", NULL}},
|
||||||
{ N_LEFT, { "\x1bOD", NULL }},
|
{N_LEFT, {"\x1bOD", NULL}},
|
||||||
{ INS, { "\x1b[2~", NULL }},
|
{INS, {"\x1b[2~", NULL}},
|
||||||
{ SUPR, { "\x1b[3~", NULL }},
|
{SUPR, {"\x1b[3~", NULL}},
|
||||||
{ HOME, { "\x1b[H", NULL }},
|
{HOME, {"\x1b[H", NULL}},
|
||||||
{ END, { "\x1b[F", NULL }},
|
{END, {"\x1b[F", NULL}},
|
||||||
{ PAGE_UP, { "\x1b[5~", NULL }},
|
{PAGE_UP, {"\x1b[5~", NULL}},
|
||||||
{ PAGE_DOWN, { "\x1b[6~", NULL }},
|
{PAGE_DOWN, {"\x1b[6~", NULL}},
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
17
include/launch_state.h
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#ifndef LAUNCHSTATEH_
|
||||||
|
#define LAUNCHSTATEH_
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
#include "macros.h"
|
||||||
|
|
||||||
|
struct LaunchState {
|
||||||
|
char* NNULLABLE username;
|
||||||
|
char* NNULLABLE session_opt;
|
||||||
|
};
|
||||||
|
|
||||||
|
int read_launch_state(struct LaunchState* NNULLABLE state);
|
||||||
|
bool write_launch_state(struct LaunchState state);
|
||||||
|
|
||||||
|
#endif
|
12
include/log.h
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#ifndef LOGH_
|
||||||
|
#define LOGH_
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
void log_init(FILE* fd);
|
||||||
|
void log_puts(const char* msg);
|
||||||
|
void log_printf(const char* fmt, ...);
|
||||||
|
// NOLINTNEXTLINE(readability-identifier-length)
|
||||||
|
void log_perror(const char* s);
|
||||||
|
|
||||||
|
#endif
|
25
include/macros.h
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#ifndef MACROSH_
|
||||||
|
#define MACROSH_
|
||||||
|
|
||||||
|
// Do we just replace the compiler with clang??
|
||||||
|
#if defined(__clang__)
|
||||||
|
#define NULLABLE _Nullable
|
||||||
|
#else
|
||||||
|
#define NULLABLE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__clang__)
|
||||||
|
#define NNULLABLE _Nonnull
|
||||||
|
#else
|
||||||
|
#define NNULLABLE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__clang__)
|
||||||
|
#define UNULLABLE _Null_unspecified
|
||||||
|
#else
|
||||||
|
#define UNULLABLE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define LEN(X) (sizeof(X) / sizeof((X)[0]))
|
||||||
|
|
||||||
|
#endif
|
23
include/ofield.h
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#ifndef OFIELD_
|
||||||
|
#define OFIELD_
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
#include "efield.h"
|
||||||
|
|
||||||
|
// related vector is external, indexing at 1, 0 means empty and hence points to
|
||||||
|
// the editable_field
|
||||||
|
struct opts_field {
|
||||||
|
size_t opts;
|
||||||
|
size_t current_opt;
|
||||||
|
struct editable_field efield;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct opts_field ofield_new(size_t opts);
|
||||||
|
void ofield_toedit(struct opts_field* self, char* init);
|
||||||
|
void ofield_kbd_type(struct opts_field* self, char* typed, char* empty_default);
|
||||||
|
bool ofield_opts_seek(struct opts_field* self, char seek);
|
||||||
|
bool ofield_seek(struct opts_field* self, char seek);
|
||||||
|
|
||||||
|
u_char ofield_display_cursor_col(struct opts_field* self, u_char maxlen);
|
||||||
|
|
||||||
|
#endif
|
@ -1,8 +1,11 @@
|
|||||||
#ifndef _SESSIONSH_
|
#ifndef SESSIONSH_
|
||||||
#define _SESSIONSH_
|
#define SESSIONSH_
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include "macros.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
enum session_type {
|
enum session_type {
|
||||||
XORG,
|
XORG,
|
||||||
WAYLAND,
|
WAYLAND,
|
||||||
@ -10,17 +13,12 @@ enum session_type {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct session {
|
struct session {
|
||||||
char *name;
|
char* NNULLABLE name;
|
||||||
char *exec;
|
char* NNULLABLE exec;
|
||||||
char *tryexec;
|
char* NULLABLE tryexec;
|
||||||
enum session_type type;
|
enum session_type type;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct sessions_list {
|
struct Vector get_avaliable_sessions();
|
||||||
u_int16_t length;
|
|
||||||
struct session *sessions;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct sessions_list *get_avaliable_sessions();
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
58
include/ui.h
@ -1,11 +1,55 @@
|
|||||||
#ifndef _UIH_
|
#ifndef UIH_
|
||||||
#define _UIH_
|
#define UIH_
|
||||||
|
|
||||||
#include <config.h>
|
#include "config.h"
|
||||||
|
#include "ofield.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
void setup(struct config);
|
// [box_start]
|
||||||
int load(struct users_list*, struct sessions_list*);
|
// ↓
|
||||||
void print_err(const char*);
|
// 0 [┌]───────────────────────────────────────────────┐
|
||||||
void print_errno(const char*);
|
// 1 │ │
|
||||||
|
// 2 │ the-art 2025-06-20 21:40:44 │
|
||||||
|
// 3 │ | │
|
||||||
|
// 4 │ | │
|
||||||
|
// 5 │ xorg < Default > | │
|
||||||
|
// 6 │ | │
|
||||||
|
// 7 │ user javalsai | │
|
||||||
|
// 8 │ | │
|
||||||
|
// 9 │ password ________________________________ │
|
||||||
|
// 10 │ | | │
|
||||||
|
// 11 └────────────────────────────────────────────────┘
|
||||||
|
// 01234567890123456789012345678901234567890123456789
|
||||||
|
// 00000000001111111111222222222233333333334444444444
|
||||||
|
// |--| | ↑ |--|[BOX_HMARGIN]
|
||||||
|
// [BOX_HMARGIN] [VALUES_COL] |
|
||||||
|
// |---|[VALUES_SEPR] |
|
||||||
|
// |--------------------------------|[VALUE_MAXLEN]
|
||||||
|
|
||||||
|
#define HEAD_ROW 2
|
||||||
|
#define SESSION_ROW 5
|
||||||
|
#define USER_ROW 7
|
||||||
|
#define PASSWD_ROW 9
|
||||||
|
|
||||||
|
#define BOX_WIDTH 50
|
||||||
|
#define BOX_HEIGHT 12
|
||||||
|
#define BOX_HMARGIN 2
|
||||||
|
|
||||||
|
#define VALUES_COL 15
|
||||||
|
#define VALUES_SEPR 3
|
||||||
|
#define VALUE_MAXLEN (BOX_WIDTH - VALUES_COL + 1 - BOX_HMARGIN - 2)
|
||||||
|
|
||||||
|
enum input { SESSION, USER, PASSWD };
|
||||||
|
extern const u_char INPUTS_N;
|
||||||
|
|
||||||
|
void setup(struct config* config);
|
||||||
|
int load(struct Vector* users, struct Vector* sessions);
|
||||||
|
void print_err(const char* /*msg*/);
|
||||||
|
void print_errno(const char* /*descr*/);
|
||||||
|
|
||||||
|
void ui_update_field(enum input focused_input);
|
||||||
|
void ui_update_ffield();
|
||||||
|
void ui_update_ofield(struct opts_field* self);
|
||||||
|
void ui_update_cursor_focus();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
29
include/ui_state.h
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
#ifndef UISTATEH_
|
||||||
|
#define UISTATEH_
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
#include "macros.h"
|
||||||
|
#include "ui.h"
|
||||||
|
|
||||||
|
extern enum input focused_input;
|
||||||
|
|
||||||
|
extern struct opts_field of_session;
|
||||||
|
extern struct opts_field of_user;
|
||||||
|
extern struct opts_field of_passwd;
|
||||||
|
|
||||||
|
extern struct Vector* UNULLABLE gusers;
|
||||||
|
extern struct Vector* UNULLABLE gsessions;
|
||||||
|
|
||||||
|
struct opts_field* NNULLABLE get_opts_field(enum input from);
|
||||||
|
struct opts_field* NNULLABLE get_opts_ffield();
|
||||||
|
|
||||||
|
struct user st_user();
|
||||||
|
struct session st_session(bool include_defshell);
|
||||||
|
|
||||||
|
void st_ch_focus(char direction);
|
||||||
|
void st_ch_of_opts(char direction);
|
||||||
|
void st_ch_ef_col(char direction);
|
||||||
|
void st_kbd_type(char* NNULLABLE text, bool cfg_include_defshell);
|
||||||
|
|
||||||
|
#endif
|
@ -1,19 +1,16 @@
|
|||||||
#ifndef _USERSH_
|
#ifndef USERSH_
|
||||||
#define _USERSH_
|
#define USERSH_
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
struct user {
|
struct user {
|
||||||
char *shell;
|
char* shell;
|
||||||
char *username;
|
char* username;
|
||||||
char *display_name;
|
char* display_name;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct users_list {
|
struct Vector get_human_users();
|
||||||
u_int16_t length;
|
|
||||||
struct user *users;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct users_list *get_human_users();
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,13 +1,40 @@
|
|||||||
#ifndef _UTILH_
|
#ifndef UTILH_
|
||||||
#define _UTILH_
|
#define UTILH_
|
||||||
|
|
||||||
#include <keys.h>
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
enum keys find_keyname(char*);
|
#include "keys.h"
|
||||||
enum keys find_ansi(char*);
|
|
||||||
void read_press(u_char*, char*);
|
int find_keyname(enum keys* at, const char* name);
|
||||||
void strcln(char **dest, const char *source);
|
enum keys find_ansi(const char* seq);
|
||||||
|
void read_press(u_char* length, char* out);
|
||||||
|
|
||||||
|
bool utf8_iscont(char byte);
|
||||||
|
size_t utf8len(const char* str);
|
||||||
|
size_t utf8len_until(const char* str, const char* until);
|
||||||
|
const char* utf8back(const char* str);
|
||||||
|
const char* utf8seek(const char* str);
|
||||||
|
const char* utf8seekn(const char* str, size_t n);
|
||||||
|
|
||||||
|
struct Vector {
|
||||||
|
uint32_t length;
|
||||||
|
uint32_t capacity;
|
||||||
|
void** pages;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern const struct Vector VEC_NEW;
|
||||||
|
int vec_resize(struct Vector* self, size_t size);
|
||||||
|
int vec_reserve(struct Vector* self, size_t size);
|
||||||
|
int vec_reserve_exact(struct Vector* self, size_t size);
|
||||||
|
int vec_push(struct Vector* self, void* item);
|
||||||
|
void vec_free(struct Vector* self);
|
||||||
|
void vec_clear(struct Vector* self);
|
||||||
|
void vec_reset(struct Vector* self);
|
||||||
|
void* vec_pop(struct Vector* self); // won't free it, nor shrink vec list space
|
||||||
|
void* vec_get(struct Vector* self, size_t index);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
292
src/auth.c
@ -1,24 +1,33 @@
|
|||||||
#include <grp.h>
|
#include <grp.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <security/_pam_types.h>
|
|
||||||
#include <security/pam_appl.h>
|
|
||||||
#include <security/pam_misc.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 <sys/wait.h>
|
||||||
|
|
||||||
#include <auth.h>
|
#include "auth.h"
|
||||||
#include <stdlib.h>
|
#include "config.h"
|
||||||
#include <ui.h>
|
#include "sessions.h"
|
||||||
|
#include "ui.h"
|
||||||
|
#include "unistd.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
int pam_conversation(int num_msg, const struct pam_message **msg,
|
int pam_conversation(int num_msg, const struct pam_message** msg,
|
||||||
struct pam_response **resp, void *appdata_ptr) {
|
struct pam_response** resp, void* appdata_ptr) {
|
||||||
struct pam_response *reply =
|
struct pam_response* reply =
|
||||||
(struct pam_response *)malloc(sizeof(struct pam_response) * num_msg);
|
(struct pam_response*)malloc(sizeof(struct pam_response) * num_msg);
|
||||||
for (int i = 0; i < num_msg; i++) {
|
if (!reply) {
|
||||||
|
return PAM_BUF_ERR;
|
||||||
|
}
|
||||||
|
for (size_t i = 0; i < num_msg; i++) {
|
||||||
reply[i].resp = NULL;
|
reply[i].resp = NULL;
|
||||||
reply[i].resp_retcode = 0;
|
reply[i].resp_retcode = 0;
|
||||||
if (msg[i]->msg_style == PAM_PROMPT_ECHO_OFF ||
|
if (msg[i]->msg_style == PAM_PROMPT_ECHO_OFF ||
|
||||||
msg[i]->msg_style == PAM_PROMPT_ECHO_ON) {
|
msg[i]->msg_style == PAM_PROMPT_ECHO_ON) {
|
||||||
char *input = (char *)appdata_ptr;
|
char* input = (char*)appdata_ptr;
|
||||||
reply[i].resp = strdup(input);
|
reply[i].resp = strdup(input);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -26,98 +35,227 @@ int pam_conversation(int num_msg, const struct pam_message **msg,
|
|||||||
return PAM_SUCCESS;
|
return PAM_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
pam_handle_t *get_pamh(char *user, char *passwd) {
|
#define CHECK_PAM_RET(call) \
|
||||||
pam_handle_t *pamh = NULL;
|
ret = (call); \
|
||||||
struct pam_conv pamc = {pam_conversation, (void *)passwd};
|
if (ret != PAM_SUCCESS) { \
|
||||||
int retval;
|
pam_end(pamh, ret); \
|
||||||
|
return NULL; \
|
||||||
retval = pam_start("login", user, &pamc, &pamh);
|
|
||||||
if (retval != PAM_SUCCESS) {
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
retval = pam_authenticate(pamh, 0);
|
void clear_screen() {
|
||||||
if (retval != PAM_SUCCESS) {
|
printf("\x1b[H\x1b[J");
|
||||||
pam_end(pamh, retval);
|
}
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
retval = pam_acct_mgmt(pamh, 0);
|
pam_handle_t* get_pamh(char* user, char* passwd) {
|
||||||
if (retval != PAM_SUCCESS) {
|
pam_handle_t* pamh = NULL;
|
||||||
pam_end(pamh, retval);
|
struct pam_conv pamc = {pam_conversation, (void*)passwd};
|
||||||
return NULL;
|
int ret;
|
||||||
}
|
|
||||||
|
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;
|
return pamh;
|
||||||
}
|
}
|
||||||
|
#undef CHECK_PAM_RET
|
||||||
|
|
||||||
bool launch(char *user, char *passwd, struct session session,
|
void* shmalloc(size_t size) {
|
||||||
void (*cb)(void)) {
|
return mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS,
|
||||||
struct passwd *pw = getpwnam(user);
|
-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);
|
||||||
|
(void)fclose(file2source);
|
||||||
|
}
|
||||||
|
|
||||||
|
void moarEnv(char* user, struct session session, struct passwd* pw,
|
||||||
|
struct config* config) {
|
||||||
|
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 = "unknown";
|
||||||
|
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 < config->behavior.source.length; i++) {
|
||||||
|
/* printf("DEBUG(source)!!!! %d %s\n", i, (char*)vec_get(&behavior->source,
|
||||||
|
* i)); */
|
||||||
|
sourceFileTry((char*)vec_get(&config->behavior.source, i));
|
||||||
|
}
|
||||||
|
/* printf("\n"); */
|
||||||
|
|
||||||
|
if (pw->pw_dir) {
|
||||||
|
const char* home = pw->pw_dir;
|
||||||
|
size_t home_len = strlen(home);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < config->behavior.user_source.length; i++) {
|
||||||
|
const char* filename = (char*)vec_get(&config->behavior.user_source, i);
|
||||||
|
size_t filename_len = strlen(filename);
|
||||||
|
|
||||||
|
size_t path_len = home_len + 1 + filename_len + 1; // nullbyte and slash
|
||||||
|
char* path = malloc(path_len);
|
||||||
|
if (!path) continue; // can't bother
|
||||||
|
|
||||||
|
memcpy(path, home, home_len);
|
||||||
|
path[home_len] = '/'; // assume pw_dir doesn't start with '/' :P
|
||||||
|
memcpy(&path[home_len + 1], filename, filename_len);
|
||||||
|
path[path_len - 1] = '\0';
|
||||||
|
|
||||||
|
sourceFileTry(path);
|
||||||
|
free(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*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);*/
|
||||||
|
}
|
||||||
|
|
||||||
|
// NOLINTBEGIN(readability-function-cognitive-complexity)
|
||||||
|
bool launch(char* user, char* passwd, struct session session, void (*cb)(void),
|
||||||
|
struct config* config) {
|
||||||
|
struct passwd* pw = getpwnam(user);
|
||||||
if (pw == NULL) {
|
if (pw == NULL) {
|
||||||
print_err("could not get user info");
|
print_err("could not get user info");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
gid_t *groups;
|
pam_handle_t* pamh = get_pamh(user, passwd);
|
||||||
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) {
|
if (pamh == NULL) {
|
||||||
print_err("error on pam authentication");
|
print_err("error on pam authentication");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
char **envlist = pam_getenvlist(pamh);
|
bool* reach_session = shmalloc(sizeof(bool));
|
||||||
if (envlist == NULL) {
|
if (reach_session == NULL) {
|
||||||
print_err("error getting pam env");
|
perror("error allocating shared memory");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
*reach_session = false;
|
||||||
|
|
||||||
// point of no return
|
uint pid = fork();
|
||||||
int setgrps_ret = setgroups(ngroups, groups);
|
if (pid == 0) { // child
|
||||||
free(groups);
|
char* term = NULL;
|
||||||
if (setgrps_ret == -1) {
|
char* getterm = getenv("TERM");
|
||||||
perror("setgroups");
|
// TODO: handle malloc error
|
||||||
exit(EXIT_FAILURE);
|
if (getterm != NULL) term = strdup(getterm);
|
||||||
}
|
if (clearenv() != 0) {
|
||||||
|
print_errno("clearenv");
|
||||||
|
_exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
if (setgid(pw->pw_gid) == -1) {
|
char** envlist = pam_getenvlist(pamh);
|
||||||
perror("setgid");
|
if (envlist == NULL) {
|
||||||
exit(EXIT_FAILURE);
|
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) {
|
free((void*)envlist);
|
||||||
perror("setuid");
|
moarEnv(user, session, pw, config);
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (char **env = envlist; *env != NULL; env++) {
|
// TODO: chown stdin to user
|
||||||
putenv(*env);
|
// does it inherit stdin from parent and
|
||||||
}
|
// does parent need to reclaim it after
|
||||||
|
// this dies?
|
||||||
|
|
||||||
if (cb != NULL)
|
if (setgid(pw->pw_gid) == -1) {
|
||||||
cb();
|
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 (setuid(pw->pw_uid) == -1) {
|
||||||
if (session.type == SHELL) {
|
perror("setuid");
|
||||||
system("clear");
|
_exit(EXIT_FAILURE);
|
||||||
execl(session.exec, session.exec, NULL);
|
}
|
||||||
} else if (session.type == XORG || session.type == WAYLAND) {
|
|
||||||
system("clear");
|
if (cb != NULL) cb();
|
||||||
execl(session.exec, session.exec, NULL);
|
|
||||||
|
*reach_session = true;
|
||||||
|
|
||||||
|
// TODO: these will be different due to TryExec
|
||||||
|
// and, Exec/TryExec might contain spaces as args
|
||||||
|
printf("\x1b[0m");
|
||||||
|
// NOLINTNEXTLINE(bugprone-branch-clone)
|
||||||
|
if (session.type == SHELL) {
|
||||||
|
clear_screen();
|
||||||
|
(void)fflush(stdout);
|
||||||
|
execlp(session.exec, session.exec, NULL);
|
||||||
|
} else if (session.type == XORG || session.type == WAYLAND) {
|
||||||
|
clear_screen();
|
||||||
|
(void)fflush(stdout);
|
||||||
|
execlp(session.exec, session.exec, NULL);
|
||||||
|
}
|
||||||
|
perror("execl error");
|
||||||
|
(void)fputs("failure calling session\n", stderr);
|
||||||
|
} else {
|
||||||
|
__pid_t child_pid = (__pid_t)pid;
|
||||||
|
waitpid(child_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;
|
||||||
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
// NOLINTEND(readability-function-cognitive-complexity)
|
||||||
|
47
src/chvt.c
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
#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;
|
||||||
|
// NOLINTNEXTLINE(readability-identifier-length)
|
||||||
|
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) {
|
||||||
|
// NOLINTNEXTLINE(clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling)
|
||||||
|
(void)fprintf(stderr, "activating vt %d\n", n);
|
||||||
|
// NOLINTNEXTLINE(readability-identifier-length)
|
||||||
|
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) {
|
||||||
|
// NOLINTNEXTLINE(clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling)
|
||||||
|
(void)fprintf(stderr, "Couldn't activate vt %d\n", n);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
(void)fputs("Couldn't get a file descriptor referring to the console.\n",
|
||||||
|
stderr);
|
||||||
|
return -1;
|
||||||
|
}
|
341
src/config.c
@ -1,138 +1,241 @@
|
|||||||
#include "util.h"
|
#include <linux/fs.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <config.h>
|
#include "config.h"
|
||||||
|
#include "desktop.h"
|
||||||
|
#include "log.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
bool line_parser(FILE *fd, ssize_t *blksize,
|
#define UPPER_HALF_BYTE 4
|
||||||
u_char (*cb)(char *key, char *value)) {
|
int parse_hex(char* _at, char x1, char x2) {
|
||||||
size_t opt_size = 4096;
|
// make linter happy
|
||||||
if (blksize != NULL)
|
u_char* at = (u_char*)_at;
|
||||||
opt_size = *blksize;
|
|
||||||
|
|
||||||
while (true) {
|
*at = 0;
|
||||||
size_t alloc_size = opt_size;
|
|
||||||
char *buf = malloc(alloc_size);
|
if ('0' <= x1 && x1 <= '9') {
|
||||||
if (buf == NULL)
|
*at += (x1 - '0') << UPPER_HALF_BYTE;
|
||||||
return false;
|
} else if ('A' <= x1 && x1 <= 'F') {
|
||||||
ssize_t read_size = getline(&buf, &alloc_size, fd);
|
*at += (x1 - 'A' + 10) << UPPER_HALF_BYTE;
|
||||||
if (read_size == -1) {
|
} else if ('a' <= x1 && x1 <= 'f') {
|
||||||
free(buf);
|
*at += (x1 - 'a' + 10) << UPPER_HALF_BYTE;
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ('0' <= x2 && x2 <= '9') {
|
||||||
|
*at += (x2 - '0');
|
||||||
|
} else if ('A' <= x2 && x2 <= 'F') {
|
||||||
|
*at += (x2 - 'A' + 10);
|
||||||
|
} else if ('a' <= x2 && x2 <= 'f') {
|
||||||
|
*at += (x2 - 'a' + 10);
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct parser_error {
|
||||||
|
const char* NULLABLE msg;
|
||||||
|
size_t col;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define FAIL(str) \
|
||||||
|
return (struct parser_error) { \
|
||||||
|
str, p - raw \
|
||||||
|
}
|
||||||
|
#define NOFAIL return (struct parser_error){NULL, 0}
|
||||||
|
struct parser_error parse_str_inplace(char* raw) {
|
||||||
|
// reader pointer
|
||||||
|
char* p = raw; // NOLINT(readability-identifier-length)
|
||||||
|
if (*p != '"') FAIL("Strign not quoted");
|
||||||
|
p++;
|
||||||
|
|
||||||
|
// writer iterator, by nature will always be under the reader
|
||||||
|
size_t i = 0; // NOLINT(readability-identifier-length)
|
||||||
|
while (*p != '\0') {
|
||||||
|
if (*p == '"') {
|
||||||
|
if (p[1] == '\0') {
|
||||||
|
raw[i] = '\0';
|
||||||
|
NOFAIL;
|
||||||
|
}
|
||||||
|
FAIL("String finished but there's content after");
|
||||||
|
}
|
||||||
|
if (*p == '\\') {
|
||||||
|
p++;
|
||||||
|
if (*p == '\0') break;
|
||||||
|
switch (*p) {
|
||||||
|
case '\\':
|
||||||
|
raw[i++] = '\\';
|
||||||
|
break;
|
||||||
|
case 't':
|
||||||
|
raw[i++] = '\t';
|
||||||
|
break;
|
||||||
|
case 'n':
|
||||||
|
raw[i++] = '\n';
|
||||||
|
break;
|
||||||
|
case '\"':
|
||||||
|
raw[i++] = '\"';
|
||||||
|
break;
|
||||||
|
case '\'':
|
||||||
|
raw[i++] = '\'';
|
||||||
|
break;
|
||||||
|
case 'x':
|
||||||
|
if (p[1] == '\0' || p[2] == '\0') goto unfinished;
|
||||||
|
if (parse_hex(&raw[i++], p[1], p[2]) != 0)
|
||||||
|
FAIL("Invalid hex escape sequence");
|
||||||
|
p += 2;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
FAIL("Invalid escape variant");
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
raw[i++] = *p;
|
||||||
|
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
|
||||||
|
unfinished:
|
||||||
|
FAIL("Unfinished string");
|
||||||
|
}
|
||||||
|
#undef FAIL
|
||||||
|
#undef NOFAIL
|
||||||
|
|
||||||
|
#define FAIL(str) return (struct parser_error){str, 0}
|
||||||
|
#define NOFAIL return (struct parser_error){NULL, 0}
|
||||||
|
union typ_ptr {
|
||||||
|
char** string;
|
||||||
|
bool* boolean;
|
||||||
|
enum keys* key;
|
||||||
|
struct Vector* vec;
|
||||||
|
uintptr_t ptr;
|
||||||
|
};
|
||||||
|
struct parser_error parse_key(enum introspection_type typ, union typ_ptr at,
|
||||||
|
char* key, size_t offset) {
|
||||||
|
char* aux_str = NULL;
|
||||||
|
struct parser_error aux_err;
|
||||||
|
|
||||||
|
switch (typ) {
|
||||||
|
case STRING:
|
||||||
|
aux_str = strdup(key);
|
||||||
|
if (!aux_str) FAIL("allocation failure");
|
||||||
|
aux_err = parse_str_inplace(aux_str);
|
||||||
|
if (aux_err.msg) {
|
||||||
|
free(aux_str);
|
||||||
|
return aux_err;
|
||||||
|
}
|
||||||
|
// FIXME: it be broken, prob the ptr arithmetic or smth, we mem leak
|
||||||
|
// instead 😎 If the ptr is not the default it means it was prev
|
||||||
|
// allocated, we should free if (*(char**)((uintptr_t)(&default_config) +
|
||||||
|
// offset) != *at.string) {
|
||||||
|
// free(*at.string);
|
||||||
|
// }
|
||||||
|
*at.string = aux_str;
|
||||||
|
break;
|
||||||
|
case BOOL:
|
||||||
|
if (strcmp(key, "true") == 0)
|
||||||
|
*at.boolean = true;
|
||||||
|
else if (strcmp(key, "false") == 0)
|
||||||
|
*at.boolean = false;
|
||||||
|
else {
|
||||||
|
FAIL("Invalid key value, wasn't 'true' nor 'false'");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case KEY:
|
||||||
|
// NOLINTNEXTLINE(performance-no-int-to-ptr)
|
||||||
|
if (find_keyname(at.key, key) != 0) {
|
||||||
|
FAIL("Keyboard KEY name not found");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case STRING_ARRAY:
|
||||||
|
aux_str = strdup(key);
|
||||||
|
if (!aux_str) FAIL("allocation failure");
|
||||||
|
aux_err = parse_str_inplace(aux_str);
|
||||||
|
if (aux_err.msg) {
|
||||||
|
free(aux_str);
|
||||||
|
return aux_err;
|
||||||
|
}
|
||||||
|
vec_push(at.vec, aux_str);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
uint read;
|
|
||||||
char *key = malloc(read_size);
|
|
||||||
if (key == NULL) {
|
|
||||||
free(buf);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if ((read = sscanf(buf, "%[^ ] = %[^\n]\n", key, buf)) != 0) {
|
|
||||||
u_char ret = cb(key, buf);
|
|
||||||
if (ret & 0b0100)
|
|
||||||
free(key);
|
|
||||||
if (ret & 0b0010)
|
|
||||||
free(buf);
|
|
||||||
if (ret & 0b1000)
|
|
||||||
return false;
|
|
||||||
if (ret & 0b0001)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
NOFAIL;
|
||||||
}
|
}
|
||||||
|
#undef FAIL
|
||||||
|
#undef NOFAIL
|
||||||
|
|
||||||
struct config *__config;
|
// NOLINTBEGIN(readability-identifier-length,readability-function-cognitive-complexity)
|
||||||
u_char config_line_handler(char *k, char *v) {
|
struct status config_line_handler(void* _config, char* table, char* k,
|
||||||
if(strcmp(k, "colors.bg") == 0)
|
char* v) {
|
||||||
__config->theme.colors.bg = v;
|
struct config* config = (struct config*)_config;
|
||||||
else if(strcmp(k, "colors.fg") == 0)
|
struct status ret = {.finish = false};
|
||||||
__config->theme.colors.fg = v;
|
|
||||||
else if(strcmp(k, "colors.err") == 0)
|
const struct introspection_table* this_intros_table = NULL;
|
||||||
__config->theme.colors.err = v;
|
for (size_t i = 0; i < LEN(CONFIG_INSTROSPECTION); i++) {
|
||||||
else if(strcmp(k, "colors.s_wl") == 0)
|
if (table == NULL) {
|
||||||
__config->theme.colors.s_wl = v;
|
if (table != CONFIG_INSTROSPECTION[i].tname) continue;
|
||||||
else if(strcmp(k, "colors.s_xorg") == 0)
|
} else if (strcmp(CONFIG_INSTROSPECTION[i].tname, table) != 0)
|
||||||
__config->theme.colors.s_xorg = v;
|
continue;
|
||||||
else if(strcmp(k, "colors.s_shell") == 0)
|
this_intros_table = &CONFIG_INSTROSPECTION[i];
|
||||||
__config->theme.colors.s_shell = v;
|
break;
|
||||||
else if(strcmp(k, "colors.f_other") == 0)
|
}
|
||||||
__config->theme.colors.f_other = v;
|
if (this_intros_table == NULL) {
|
||||||
else if(strcmp(k, "colors.e_hostname") == 0)
|
log_printf("[E] table '%s' is not part of the config\n", table);
|
||||||
__config->theme.colors.e_hostname = v;
|
return ret;
|
||||||
else if(strcmp(k, "colors.e_date") == 0)
|
}
|
||||||
__config->theme.colors.e_date = v;
|
|
||||||
else if(strcmp(k, "colors.e_box") == 0)
|
const struct introspection_item* this_intros_key = NULL;
|
||||||
__config->theme.colors.e_box = v;
|
for (size_t i = 0; i < this_intros_table->len; i++) {
|
||||||
else if(strcmp(k, "colors.e_header") == 0)
|
if (strcmp(this_intros_table->intros[i].name, k) != 0) continue;
|
||||||
__config->theme.colors.e_header = v;
|
this_intros_key = &this_intros_table->intros[i];
|
||||||
else if(strcmp(k, "colors.e_user") == 0)
|
break;
|
||||||
__config->theme.colors.e_user = v;
|
}
|
||||||
else if(strcmp(k, "colors.e_passwd") == 0)
|
if (this_intros_key == NULL) {
|
||||||
__config->theme.colors.e_passwd = v;
|
log_printf("[E] key '%s' is not part of the table '%s' in config\n", k,
|
||||||
else if(strcmp(k, "colors.e_badpasswd") == 0)
|
table);
|
||||||
__config->theme.colors.e_badpasswd = v;
|
return ret;
|
||||||
else if(strcmp(k, "colors.e_key") == 0)
|
}
|
||||||
__config->theme.colors.e_key = v;
|
|
||||||
else if(strcmp(k, "chars.hb") == 0)
|
size_t offset = this_intros_table->offset + this_intros_key->offset;
|
||||||
__config->theme.chars.hb = v;
|
union typ_ptr k_addr = {.ptr = (uintptr_t)config + offset};
|
||||||
else if(strcmp(k, "chars.vb") == 0)
|
|
||||||
__config->theme.chars.vb = v;
|
struct parser_error err = parse_key(this_intros_key->typ, k_addr, v, offset);
|
||||||
else if(strcmp(k, "chars.ctl") == 0)
|
if (err.msg != NULL) {
|
||||||
__config->theme.chars.ctl = v;
|
log_printf("[E] cfg parser, failed to parse [%s.%s] (%s): %s\n", table, k,
|
||||||
else if(strcmp(k, "chars.ctr") == 0)
|
INTROS_TYS_NAMES[this_intros_key->typ], err.msg);
|
||||||
__config->theme.chars.ctr = v;
|
log_printf("%s\n%*c^\n", v, err.col);
|
||||||
else if(strcmp(k, "chars.cbl") == 0)
|
return ret;
|
||||||
__config->theme.chars.cbl = v;
|
}
|
||||||
else if(strcmp(k, "chars.cbr") == 0)
|
|
||||||
__config->theme.chars.cbr = v;
|
if (this_intros_key->typ == STRING)
|
||||||
else if(strcmp(k, "functions.poweroff") == 0)
|
log_printf("[I] cfg parsed [%s.%s] (%s)\n", table, k, *k_addr.string);
|
||||||
__config->functions.poweroff = find_keyname(v);
|
|
||||||
else if(strcmp(k, "functions.reboot") == 0)
|
|
||||||
__config->functions.reboot = find_keyname(v);
|
|
||||||
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
|
else
|
||||||
return 0b1111;
|
log_printf("[I] cfg parsed [%s.%s]\n", table, k);
|
||||||
|
|
||||||
return 0b100;
|
return ret;
|
||||||
}
|
}
|
||||||
|
// NOLINTEND(readability-identifier-length,readability-function-cognitive-complexity)
|
||||||
|
|
||||||
struct config *parse_config(char *path) {
|
int parse_config(struct config* NNULLABLE config, char* NNULLABLE path) {
|
||||||
struct stat sb;
|
FILE* fd = fopen(path, "r");
|
||||||
FILE *fd = fopen(path, "r");
|
if (fd == NULL) {
|
||||||
if (fd == NULL || (stat(path, &sb) == -1)) {
|
|
||||||
perror("fopen");
|
perror("fopen");
|
||||||
return NULL;
|
(void)fputs(
|
||||||
|
"Please place a config file at /etc/lidm.ini or set the LIDM_CONF "
|
||||||
|
"env variable",
|
||||||
|
stderr);
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
__config = malloc(sizeof(struct config));
|
bool ret = read_desktop(fd, config, config_line_handler);
|
||||||
if (__config == NULL)
|
(void)fclose(fd);
|
||||||
return NULL;
|
|
||||||
bool ret = line_parser(fd, &sb.st_blksize, config_line_handler);
|
|
||||||
if (!ret) {
|
|
||||||
free(__config);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return __config;
|
if (!ret) return -1;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
85
src/desktop.c
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
// NOLINTBEGIN(clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,readability-function-cognitive-complexity)
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "desktop.h"
|
||||||
|
|
||||||
|
char* trim_str(char* str) {
|
||||||
|
while (*str == ' ' || *str == '\t')
|
||||||
|
str++;
|
||||||
|
|
||||||
|
size_t i = strlen(str); // NOLINT(readability-identifier-length)
|
||||||
|
while (i > 0) {
|
||||||
|
if (str[i - 1] != ' ' && str[i - 1] != '\t' && str[i - 1] != '\n') break;
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
str[i] = '\0';
|
||||||
|
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
int read_desktop(FILE* fd, void* ctx,
|
||||||
|
struct status (*cb)(void* ctx, char* table, char* key,
|
||||||
|
char* value)) {
|
||||||
|
char* table_name = NULL;
|
||||||
|
|
||||||
|
bool ret = -1;
|
||||||
|
char* buf = NULL;
|
||||||
|
size_t alloc_size = 0;
|
||||||
|
size_t read_size;
|
||||||
|
while ((read_size = getline(&buf, &alloc_size, fd)) > 0) {
|
||||||
|
ret = 0;
|
||||||
|
|
||||||
|
char* buf_start = trim_str(buf);
|
||||||
|
size_t indent_size = buf_start - buf;
|
||||||
|
|
||||||
|
if (read_size - indent_size < 1) continue;
|
||||||
|
if (*buf_start == '#') continue;
|
||||||
|
|
||||||
|
if (*buf_start == '[' && buf_start[strlen(buf_start) - 1] == ']') {
|
||||||
|
if (table_name != NULL) free(table_name);
|
||||||
|
buf_start[strlen(buf_start) - 1] = '\0';
|
||||||
|
table_name = strdup(buf_start + 1);
|
||||||
|
if (table_name == NULL) {
|
||||||
|
ret = -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Find '='
|
||||||
|
size_t eq_idx = 0;
|
||||||
|
while (buf_start[eq_idx] != '\0') {
|
||||||
|
if (buf_start[eq_idx] == '=') break;
|
||||||
|
eq_idx++;
|
||||||
|
}
|
||||||
|
// impossible with a min len of 1 (empty line)
|
||||||
|
if (eq_idx == 0) continue;
|
||||||
|
// Check its not end
|
||||||
|
if (buf_start[eq_idx] != '=') {
|
||||||
|
ret = -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Key & Value
|
||||||
|
char* key = buf_start;
|
||||||
|
buf_start[eq_idx] = '\0'; // the equal
|
||||||
|
key = trim_str(key);
|
||||||
|
char* value = &buf_start[eq_idx + 1];
|
||||||
|
buf_start[read_size - 1] = '\0'; // the newline
|
||||||
|
value = trim_str(value);
|
||||||
|
|
||||||
|
// Callback
|
||||||
|
struct status cb_ret = cb(ctx, table_name, key, value);
|
||||||
|
if (cb_ret.finish) {
|
||||||
|
ret = cb_ret.ret;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (table_name != NULL) free(table_name);
|
||||||
|
if (buf != NULL) free(buf);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
// NOLINTEND(clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,readability-function-cognitive-complexity)
|
100
src/efield.c
@ -1,72 +1,84 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <efield.h>
|
#include "efield.h"
|
||||||
#include <ui.h>
|
#include "ui.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
struct editable_field field_new(char* content) {
|
// NOLINTBEGIN(clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling)
|
||||||
struct editable_field __efield;
|
|
||||||
if(content != NULL) {
|
struct editable_field efield_new(char* content) {
|
||||||
__efield.length = __efield.pos = strlen(content);
|
struct editable_field efield;
|
||||||
memcpy(__efield.content, content, __efield.length);
|
if (content != NULL) {
|
||||||
|
efield.pos = strlen(content);
|
||||||
|
memcpy(efield.content, content, strlen(content) + 1);
|
||||||
} else {
|
} else {
|
||||||
field_trim(&__efield, 0);
|
efield_trim(&efield, 0);
|
||||||
}
|
}
|
||||||
__efield.content[__efield.length] = '\0';
|
|
||||||
return __efield;
|
return efield;
|
||||||
}
|
}
|
||||||
|
|
||||||
void field_trim(struct editable_field *field, u_char pos) {
|
void efield_trim(struct editable_field* self, u_char pos) {
|
||||||
field->length = field->pos = pos;
|
self->pos = pos;
|
||||||
field->content[field->length] = '\0';
|
self->content[pos + 1] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
void field_update(struct editable_field *field, char *update) {
|
#define BACKSPACE_CODE 127
|
||||||
|
void efield_update(struct editable_field* self, char* update) {
|
||||||
u_char insert_len = strlen(update);
|
u_char insert_len = strlen(update);
|
||||||
if (insert_len == 0)
|
if (insert_len == 0) return;
|
||||||
return;
|
|
||||||
|
if (self->pos > strlen(self->content))
|
||||||
|
self->pos = strlen(self->content); // WTF tho
|
||||||
|
|
||||||
if (field->pos > field->length)
|
|
||||||
field->pos = field->length; // WTF
|
|
||||||
if (insert_len == 1) {
|
if (insert_len == 1) {
|
||||||
// backspace
|
// backspace
|
||||||
if (*update == 127) {
|
if (*update == BACKSPACE_CODE) {
|
||||||
if (field->pos == 0) return;
|
if (self->pos == 0) return;
|
||||||
if (field->pos < field->length) {
|
char* curr = &self->content[self->pos];
|
||||||
memcpy(&field->content[field->pos - 1], &field->content[field->pos],
|
char* prev = (char*)utf8back(curr);
|
||||||
field->length - field->pos);
|
memmove(prev, curr, strlen(self->content) - self->pos + 1);
|
||||||
}
|
|
||||||
(field->pos)--;
|
self->pos -= curr - prev;
|
||||||
(field->length)--;
|
|
||||||
field->content[field->length] = '\0';
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// TODO: Del
|
||||||
}
|
}
|
||||||
|
|
||||||
// append
|
// append
|
||||||
if (field->length + field->pos >= 255) {
|
if (strlen(update) + self->pos + 1 >= 255) {
|
||||||
print_err("field too long");
|
print_err("field too long");
|
||||||
}
|
}
|
||||||
if (field->pos < field->length) {
|
|
||||||
// move with immediate buffer
|
|
||||||
memmove(&field->content[field->pos + insert_len], &field->content[field->pos],
|
|
||||||
field->length - field->pos);
|
|
||||||
}
|
|
||||||
memcpy(&field->content[field->pos], update, insert_len);
|
|
||||||
|
|
||||||
field->pos += insert_len;
|
// move the after pos, including nullbyte
|
||||||
field->length += insert_len;
|
memmove(&self->content[self->pos + insert_len], &self->content[self->pos],
|
||||||
field->content[field->length] = '\0';
|
strlen(self->content) - self->pos + 1);
|
||||||
|
memcpy(&self->content[self->pos], update, insert_len);
|
||||||
|
|
||||||
|
self->pos += insert_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns bool depending if it was able to "use" the seek
|
// returns bool depending if it was able to "use" the seek
|
||||||
bool field_seek(struct editable_field *field, char seek) {
|
bool efield_seek(struct editable_field* self, char seek) {
|
||||||
if(field->length == 0) return false;
|
if (*self->content == '\0') return false;
|
||||||
|
if (seek == 0) return false;
|
||||||
|
|
||||||
if(seek < 0 && -seek > field->pos) field->pos = 0;
|
u_char count = seek < 0 ? -seek : seek;
|
||||||
else if(seek > 0 && 255 - field->pos < seek) field->pos = 255;
|
char* ptr = &self->content[self->pos];
|
||||||
else field->pos += seek;
|
char* start = ptr;
|
||||||
|
|
||||||
if(field->pos > field->length) field->pos = field->length;
|
while (count-- > 0) {
|
||||||
|
if (seek < 0) {
|
||||||
|
if (ptr == self->content) break;
|
||||||
|
ptr = (char*)utf8back(ptr);
|
||||||
|
} else {
|
||||||
|
if (*ptr == '\0') break;
|
||||||
|
ptr = (char*)utf8seek(ptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
self->pos = (u_char)(ptr - self->content);
|
||||||
|
return ptr != start;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOLINTEND(clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling)
|
||||||
|
52
src/launch_state.c
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
// Small file for saving last selection
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "launch_state.h"
|
||||||
|
|
||||||
|
#define STATE_DIR "/var/lib/lidm"
|
||||||
|
#define STATE_FILE "/var/lib/lidm/state"
|
||||||
|
|
||||||
|
#define RWXR_X___ 0750
|
||||||
|
|
||||||
|
int read_launch_state(struct LaunchState* NNULLABLE state) {
|
||||||
|
FILE* state_fd = fopen(STATE_FILE, "r");
|
||||||
|
if (state_fd == NULL) return -1;
|
||||||
|
|
||||||
|
*state = (struct LaunchState){
|
||||||
|
.username = NULL,
|
||||||
|
.session_opt = NULL,
|
||||||
|
};
|
||||||
|
|
||||||
|
size_t num = 0;
|
||||||
|
if (getline(&state->username, &num, state_fd) < 0) goto fail;
|
||||||
|
state->username[strcspn(state->username, "\n")] = 0;
|
||||||
|
|
||||||
|
num = 0;
|
||||||
|
if (getline(&state->session_opt, &num, state_fd) < 0) {
|
||||||
|
free(state->session_opt);
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
state->session_opt[strcspn(state->session_opt, "\n")] = 0;
|
||||||
|
|
||||||
|
(void)fclose(state_fd);
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
fail:
|
||||||
|
(void)fclose(state_fd);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool write_launch_state(struct LaunchState state) {
|
||||||
|
FILE* state_fd = fopen(STATE_FILE, "w");
|
||||||
|
if (state_fd == NULL) {
|
||||||
|
if (mkdir(STATE_DIR, RWXR_X___) == -1) return false;
|
||||||
|
state_fd = fopen(STATE_FILE, "w");
|
||||||
|
if (state_fd == NULL) return false;
|
||||||
|
}
|
||||||
|
(void)fprintf(state_fd, "%s\n%s\n", state.username, state.session_opt);
|
||||||
|
(void)fclose(state_fd);
|
||||||
|
return true;
|
||||||
|
}
|
38
src/log.c
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
#include <errno.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "log.h"
|
||||||
|
|
||||||
|
static FILE* logger_out = NULL;
|
||||||
|
|
||||||
|
void log_init(FILE* fd) {
|
||||||
|
if (logger_out) (void)fclose(logger_out);
|
||||||
|
logger_out = fd;
|
||||||
|
}
|
||||||
|
|
||||||
|
void log_puts(const char* msg) {
|
||||||
|
if (!logger_out) return;
|
||||||
|
(void)fputs(msg, logger_out);
|
||||||
|
}
|
||||||
|
|
||||||
|
void log_printf(const char* fmt, ...) {
|
||||||
|
if (!logger_out) return;
|
||||||
|
|
||||||
|
va_list args;
|
||||||
|
va_start(args, fmt);
|
||||||
|
|
||||||
|
(void)vfprintf(logger_out, fmt, args);
|
||||||
|
|
||||||
|
va_end(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
// NOLINTNEXTLINE(readability-identifier-length)
|
||||||
|
void log_perror(const char* s) {
|
||||||
|
if (!logger_out) return;
|
||||||
|
|
||||||
|
if (s)
|
||||||
|
(void)fprintf(logger_out, "%s: %s", s, strerror(errno));
|
||||||
|
else
|
||||||
|
(void)fprintf(logger_out, "%s", strerror(errno));
|
||||||
|
}
|
49
src/main.c
@ -1,26 +1,47 @@
|
|||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <config.h>
|
#include "chvt.h"
|
||||||
#include <sessions.h>
|
#include "config.h"
|
||||||
#include <ui.h>
|
#include "log.h"
|
||||||
#include <users.h>
|
#include "sessions.h"
|
||||||
|
#include "ui.h"
|
||||||
|
#include "users.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
struct config* config = parse_config("/etc/lidm.ini");
|
// Logger
|
||||||
if(config == NULL) {
|
char* log_output = getenv("LIDM_LOG");
|
||||||
fprintf(stderr, "error parsing config\n");
|
if (log_output) {
|
||||||
|
FILE* log_fd = fopen(log_output, "w");
|
||||||
|
if (!log_fd) {
|
||||||
|
perror("fopen");
|
||||||
|
(void)fputs("failed to open logfile in write mode", stderr);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
log_init(log_fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Chvt
|
||||||
|
if (argc == 2) chvt_str(argv[1]);
|
||||||
|
|
||||||
|
struct config config = DEFAULT_CONFIG;
|
||||||
|
char* conf_override = getenv("LIDM_CONF");
|
||||||
|
char* conf_path = conf_override ? conf_override : "/etc/lidm.ini";
|
||||||
|
if (parse_config(&config, conf_path) != 0) {
|
||||||
|
(void)fputs("error parsing config\n", stderr);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
setup(*config);
|
setup(&config);
|
||||||
|
|
||||||
struct users_list *users = get_human_users();
|
struct Vector users = get_human_users();
|
||||||
struct sessions_list *sessions = get_avaliable_sessions();
|
struct Vector sessions = get_avaliable_sessions();
|
||||||
|
|
||||||
int ret = load(users, sessions);
|
int ret = load(&users, &sessions);
|
||||||
if (ret == 0)
|
if (ret == 0) execl(argv[0], argv[0], NULL);
|
||||||
execl(argv[0], argv[0], NULL);
|
|
||||||
}
|
}
|
||||||
|
77
src/ofield.c
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
#include "efield.h"
|
||||||
|
#include "ofield.h"
|
||||||
|
#include "ui.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
|
struct opts_field ofield_new(size_t opts) {
|
||||||
|
if (opts == 0) {
|
||||||
|
return (struct opts_field){
|
||||||
|
.opts = 0,
|
||||||
|
.current_opt = 0,
|
||||||
|
.efield = efield_new(""),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return (struct opts_field){
|
||||||
|
.opts = opts,
|
||||||
|
.current_opt = 1,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
void ofield_toedit(struct opts_field* self, char* init) {
|
||||||
|
self->current_opt = 0;
|
||||||
|
self->efield = efield_new(init);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ofield_kbd_type(struct opts_field* self, char* typed,
|
||||||
|
char* empty_default) {
|
||||||
|
if (self->current_opt != 0) ofield_toedit(self, empty_default);
|
||||||
|
efield_update(&self->efield, typed);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ofield_opts_seek(struct opts_field* self, char seek) {
|
||||||
|
// no options or (a single option but its selected instead of on edit)
|
||||||
|
if (self->opts == 0 || (self->opts == 1 && self->current_opt != 0))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
self->current_opt =
|
||||||
|
1 + ((self->current_opt - 1 + seek + self->opts) % self->opts);
|
||||||
|
ui_update_ofield(self);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ofield_seek(struct opts_field* self, char seek) {
|
||||||
|
if (self->current_opt == 0) {
|
||||||
|
if (efield_seek(&self->efield, seek)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (self->opts == 0) return false;
|
||||||
|
ofield_opts_seek(self, seek);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
u_char ofield_display_cursor_col(struct opts_field* self, u_char maxlen) {
|
||||||
|
if (self->current_opt == 0) {
|
||||||
|
u_char display_len = utf8len(self->efield.content);
|
||||||
|
u_char pos = utf8len_until(self->efield.content,
|
||||||
|
&self->efield.content[self->efield.pos]);
|
||||||
|
|
||||||
|
if (display_len > maxlen) {
|
||||||
|
if (pos < maxlen / 2) {
|
||||||
|
return pos;
|
||||||
|
}
|
||||||
|
if (display_len - pos < maxlen / 2) {
|
||||||
|
return maxlen - (display_len - pos);
|
||||||
|
}
|
||||||
|
return maxlen / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
return pos;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
184
src/sessions.c
@ -7,133 +7,125 @@
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <sessions.h>
|
#include "desktop.h"
|
||||||
#include <util.h>
|
#include "log.h"
|
||||||
|
#include "sessions.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
struct source_dir {
|
struct source_dir {
|
||||||
enum session_type type;
|
enum session_type type;
|
||||||
char *dir;
|
char* dir;
|
||||||
};
|
};
|
||||||
static const struct source_dir sources[] = {
|
static const struct source_dir SOURCES[] = {
|
||||||
{XORG, "/usr/share/xsessions"},
|
{XORG, "/usr/share/xsessions"},
|
||||||
{WAYLAND, "/usr/share/wayland-sessions"},
|
{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,
|
static struct Vector* cb_sessions = NULL;
|
||||||
const char *exec, const char *tryexec) {
|
|
||||||
struct session __session;
|
|
||||||
__session.type = type;
|
|
||||||
strcln(&__session.name, name);
|
|
||||||
strcln(&__session.exec, exec);
|
|
||||||
strcln(&__session.tryexec, tryexec);
|
|
||||||
|
|
||||||
return __session;
|
struct ctx_typ {
|
||||||
|
char* NULLABLE name;
|
||||||
|
char* NULLABLE exec;
|
||||||
|
char* NULLABLE tryexec;
|
||||||
|
};
|
||||||
|
struct status cb(void* _ctx, char* NULLABLE table, char* key, char* value) {
|
||||||
|
struct ctx_typ* ctx = (struct ctx_typ*)_ctx;
|
||||||
|
struct status ret;
|
||||||
|
ret.finish = false;
|
||||||
|
|
||||||
|
if (table == NULL) return ret;
|
||||||
|
if (strcmp(table, "Desktop Entry") != 0) return ret;
|
||||||
|
|
||||||
|
char** NULLABLE copy_at = NULL;
|
||||||
|
if (strcmp(key, "Name") == 0) {
|
||||||
|
if (ctx->name == NULL) copy_at = &ctx->name;
|
||||||
|
} else if (strcmp(key, "Exec") == 0) {
|
||||||
|
if (ctx->exec == NULL) copy_at = &ctx->exec;
|
||||||
|
} else if (strcmp(key, "TryExec") == 0) {
|
||||||
|
if (ctx->tryexec == NULL) copy_at = &ctx->tryexec;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (copy_at != NULL) {
|
||||||
|
*copy_at = strdup(value);
|
||||||
|
if (*copy_at == NULL) {
|
||||||
|
log_perror("strdup");
|
||||||
|
log_puts("[E] failed to allocate memory");
|
||||||
|
ret.finish = true;
|
||||||
|
ret.ret = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ctx->name != NULL && ctx->exec != NULL && ctx->tryexec != NULL) {
|
||||||
|
ret.finish = true;
|
||||||
|
ret.ret = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const u_int8_t bs = 16;
|
// also, always return 0 or we will break parsing and we don't want a bad
|
||||||
static const u_int8_t unit_size = sizeof(struct session);
|
// desktop file to break all possible sessions
|
||||||
|
|
||||||
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 enum session_type session_type;
|
static enum session_type session_type;
|
||||||
static int fn(const char *fpath, const struct stat *sb, int typeflag) {
|
// NOLINTNEXTLINE(readability-function-cognitive-complexity)
|
||||||
// practically impossible to reach this
|
static int fn(const char* fpath, const struct stat* sb, int typeflag) {
|
||||||
// but will prevent break
|
// guessing symlink behavior
|
||||||
if (used_size == 0xffff)
|
// - FTW_PHYS if set doesn't follow symlinks, so ftw() has no flags and it
|
||||||
return 0;
|
// follows symlinks, we should never get to handle that
|
||||||
|
if (typeflag != FTW_F) return 0;
|
||||||
|
log_printf("[I] found file %s\n", fpath);
|
||||||
|
|
||||||
if (!S_ISREG(sb->st_mode))
|
struct ctx_typ ctx = {
|
||||||
return 0;
|
.name = NULL,
|
||||||
|
.exec = NULL,
|
||||||
|
.tryexec = NULL,
|
||||||
|
};
|
||||||
|
|
||||||
FILE *fd = fopen(fpath, "r");
|
FILE* fd = fopen(fpath, "r");
|
||||||
if (fd == NULL) {
|
if (fd == NULL) {
|
||||||
fprintf(stderr, "error opening file (r) %s", fpath);
|
log_perror("fopen");
|
||||||
|
log_printf("[E] error opening file '%s' for read\n", fpath);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
u_char found = 0;
|
int ret = read_desktop(fd, &ctx, &cb);
|
||||||
size_t alloc_size = sb->st_blksize;
|
if (ret < 0) { // any error
|
||||||
|
log_printf("[E] format error parsing %s", fpath);
|
||||||
char *name_buf = NULL;
|
return 0;
|
||||||
char *exec_buf = NULL;
|
|
||||||
char *tryexec_buf = NULL;
|
|
||||||
while (true) {
|
|
||||||
char *buf = malloc(sb->st_blksize);
|
|
||||||
ssize_t read_size = getline(&buf, &alloc_size, fd);
|
|
||||||
if (read_size == -1) {
|
|
||||||
free(buf);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint read;
|
|
||||||
char *key = malloc(read_size);
|
|
||||||
if ((read = sscanf(buf, "%[^=]=%[^\n]\n", key, buf)) != 0) {
|
|
||||||
if (strcmp(key, "Name") == 0) {
|
|
||||||
found &= 0b001;
|
|
||||||
name_buf = realloc(buf, read);
|
|
||||||
} else if (strcmp(key, "Exec") == 0) {
|
|
||||||
found &= 0b010;
|
|
||||||
exec_buf = realloc(buf, read);
|
|
||||||
} else if (strcmp(key, "TryExec") == 0) {
|
|
||||||
found &= 0b100;
|
|
||||||
tryexec_buf = realloc(buf, read);
|
|
||||||
} else
|
|
||||||
free(buf);
|
|
||||||
} else
|
|
||||||
free(buf);
|
|
||||||
free(key);
|
|
||||||
|
|
||||||
if (found == 0b111)
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(fd);
|
(void)fclose(fd);
|
||||||
|
|
||||||
// just add this to the list
|
// just add this to the list
|
||||||
if (name_buf != NULL && exec_buf != NULL) {
|
if (ctx.name != NULL && ctx.exec != NULL) {
|
||||||
if (used_size >= alloc_size) {
|
struct session* this_session = malloc(sizeof(struct session));
|
||||||
alloc_size += bs;
|
if (this_session == NULL) return 0;
|
||||||
sessions = realloc(sessions, alloc_size * unit_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*printf("n %s\ne %s\nte %s\n", name_buf, exec_buf, tryexec_buf);*/
|
*this_session = (struct session){
|
||||||
sessions[used_size] = __new_session(session_type, name_buf, exec_buf,
|
.name = ctx.name,
|
||||||
tryexec_buf == NULL ? "" : tryexec_buf);
|
.exec = ctx.exec,
|
||||||
|
.tryexec = ctx.tryexec,
|
||||||
|
.type = session_type,
|
||||||
|
};
|
||||||
|
|
||||||
used_size++;
|
vec_push(cb_sessions, this_session);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (name_buf != NULL)
|
|
||||||
free(name_buf);
|
|
||||||
if (exec_buf != NULL)
|
|
||||||
free(exec_buf);
|
|
||||||
if (tryexec_buf != NULL)
|
|
||||||
free(tryexec_buf);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct sessions_list __list;
|
|
||||||
// This code is designed to be run purely single threaded
|
// This code is designed to be run purely single threaded
|
||||||
struct sessions_list *get_avaliable_sessions() {
|
#define LIKELY_BOUND_SESSIONS 8
|
||||||
if (sessions != NULL)
|
struct Vector get_avaliable_sessions() {
|
||||||
return __sessions_list;
|
struct Vector sessions = VEC_NEW;
|
||||||
else
|
vec_reserve(&sessions, LIKELY_BOUND_SESSIONS);
|
||||||
sessions = malloc(alloc_size * unit_size);
|
|
||||||
|
|
||||||
for (uint i = 0; i < sources_size; i++) {
|
cb_sessions = &sessions;
|
||||||
session_type = sources[i].type;
|
for (size_t i = 0; i < (sizeof(SOURCES) / sizeof(SOURCES[0])); i++) {
|
||||||
ftw(sources[i].dir, &fn, 1);
|
log_printf("[I] parsing 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);
|
return sessions;
|
||||||
|
|
||||||
__list.length = used_size;
|
|
||||||
__list.sessions = sessions;
|
|
||||||
return __sessions_list = &__list;
|
|
||||||
}
|
}
|
||||||
|
689
src/ui.c
@ -2,68 +2,71 @@
|
|||||||
// really sorry
|
// really sorry
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <pwd.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <stddef.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
|
#include <sys/reboot.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <auth.h>
|
#include "auth.h"
|
||||||
#include <efield.h>
|
#include "efield.h"
|
||||||
#include <keys.h>
|
#include "keys.h"
|
||||||
#include <sessions.h>
|
#include "launch_state.h"
|
||||||
#include <ui.h>
|
#include "log.h"
|
||||||
#include <util.h>
|
#include "ofield.h"
|
||||||
|
#include "sessions.h"
|
||||||
|
#include "ui.h"
|
||||||
|
#include "ui_state.h"
|
||||||
|
#include "users.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
|
const u_char INPUTS_N = 3;
|
||||||
|
|
||||||
static void print_box();
|
static void print_box();
|
||||||
static void print_footer();
|
static void print_footer();
|
||||||
static void restore_all();
|
static void restore_all();
|
||||||
static void signal_handler(int);
|
static void signal_handler(int code);
|
||||||
|
|
||||||
const uint boxw = 50;
|
|
||||||
const uint boxh = 12;
|
|
||||||
|
|
||||||
struct uint_point {
|
struct uint_point {
|
||||||
uint x;
|
uint x;
|
||||||
uint y;
|
uint y;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void print_session(struct uint_point, struct session, bool);
|
static void print_session(struct uint_point origin, struct session session,
|
||||||
static void print_user(struct uint_point, struct user, bool);
|
bool multiple);
|
||||||
static void print_passwd(struct uint_point, uint, bool);
|
static void print_user(struct uint_point origin, struct user user,
|
||||||
|
bool multiple);
|
||||||
enum input { SESSION, USER, PASSWD };
|
static void print_passwd(struct uint_point origin, uint length, bool err);
|
||||||
static u_char inputs_n = 3;
|
|
||||||
|
|
||||||
// ansi resource: https://gist.github.com/fnky/458719343aabd01cfb17a3a4f7296797
|
// ansi resource: https://gist.github.com/fnky/458719343aabd01cfb17a3a4f7296797
|
||||||
static struct termios orig_term;
|
static struct termios orig_term;
|
||||||
static struct termios term;
|
static struct termios term;
|
||||||
static struct winsize window;
|
static struct winsize window;
|
||||||
|
|
||||||
static struct theme theme;
|
#define INNER_BOX_OUT_MARGIN 2
|
||||||
static struct functions functions;
|
struct config* g_config = NULL;
|
||||||
static struct strings strings;
|
void setup(struct config* config) {
|
||||||
static struct behavior behavior;
|
g_config = config;
|
||||||
void setup(struct config __config) {
|
|
||||||
ioctl(STDOUT_FILENO, TIOCGWINSZ, &window);
|
ioctl(STDOUT_FILENO, TIOCGWINSZ, &window);
|
||||||
|
|
||||||
|
// at least
|
||||||
// 2 padding top and bottom for footer and vertical compensation
|
// 2 padding top and bottom for footer and vertical compensation
|
||||||
// 2 padding left & right to not overflow footer width
|
// 2 padding left & right to not overflow footer width
|
||||||
if (window.ws_row < boxh + 4 || window.ws_col < boxw + 4) {
|
if (window.ws_row < BOX_HEIGHT + INNER_BOX_OUT_MARGIN * 2 ||
|
||||||
fprintf(stderr, "\x1b[1;31mScreen too small\x1b[0m\n");
|
window.ws_col < BOX_WIDTH + INNER_BOX_OUT_MARGIN * 2) {
|
||||||
|
(void)fprintf(stderr, "\x1b[1;31mScreen too small\x1b[0m\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
theme = __config.theme;
|
|
||||||
functions = __config.functions;
|
|
||||||
strings = __config.strings;
|
|
||||||
behavior = __config.behavior;
|
|
||||||
|
|
||||||
tcgetattr(STDOUT_FILENO, &orig_term);
|
tcgetattr(STDOUT_FILENO, &orig_term);
|
||||||
term = orig_term; // save term
|
term = orig_term; // save term
|
||||||
// "stty" attrs
|
// "stty" attrs
|
||||||
@ -72,295 +75,185 @@ void setup(struct config __config) {
|
|||||||
|
|
||||||
// save cursor pos, save screen, set color and reset screen
|
// save cursor pos, save screen, set color and reset screen
|
||||||
// (applying color to all screen)
|
// (applying color to all screen)
|
||||||
printf("\x1b[s\x1b[?47h\x1b[%s;%sm\x1b[2J", theme.colors.bg, theme.colors.fg);
|
printf("\x1b[s\x1b[?47h\x1b[%s;%sm\x1b[2J", g_config->colors.bg,
|
||||||
|
g_config->colors.fg);
|
||||||
|
|
||||||
print_footer();
|
print_footer();
|
||||||
atexit(restore_all);
|
(void)atexit(restore_all);
|
||||||
signal(SIGINT, signal_handler);
|
(void)signal(SIGINT, signal_handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct uint_point box_start() {
|
static struct uint_point box_start() {
|
||||||
struct uint_point __start;
|
return (struct uint_point){
|
||||||
__start.x = (window.ws_col - boxw) / 2 + 1;
|
.x = ((window.ws_col - BOX_WIDTH) / 2) + 1, // looks better
|
||||||
__start.y = (window.ws_row - boxh) / 2 + 1;
|
.y = ((window.ws_row - BOX_HEIGHT) / 2), // leave more space under
|
||||||
return __start;
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *fmt_time() {
|
#define STRFTIME_PREALLOC 64
|
||||||
time_t t = time(NULL);
|
#define TM_YEAR_EPOCH 1900
|
||||||
struct tm tm = *localtime(&t);
|
static char* fmt_time(const char* fmt) {
|
||||||
|
time_t tme = time(NULL);
|
||||||
|
struct tm tm = *localtime(&tme);
|
||||||
|
|
||||||
size_t bsize =
|
size_t alloc_size = STRFTIME_PREALLOC;
|
||||||
snprintf(NULL, 0, "%d-%02d-%02d %02d:%02d:%02d", tm.tm_year + 1900,
|
char* buf = malloc(alloc_size);
|
||||||
tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec) +
|
if (!buf) return NULL;
|
||||||
1;
|
while (true) {
|
||||||
char *buf = malloc(bsize);
|
if (strftime(buf, alloc_size, fmt, &tm) != 0) return buf;
|
||||||
snprintf(buf, bsize, "%d-%02d-%02d %02d:%02d:%02d", tm.tm_year + 1900,
|
|
||||||
tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
|
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: handle buffers longer than the buffer (cut str to the end, change
|
alloc_size *= 2;
|
||||||
// cursor pos...) should just overlap for now
|
char* nbuf = realloc(buf, alloc_size);
|
||||||
|
if (!nbuf) {
|
||||||
// ugh, this represent a field which might have options
|
free(buf);
|
||||||
// opts is the ammount of other options possible (0 will behave as a passwd)
|
return NULL;
|
||||||
// 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 {
|
|
||||||
uint opts;
|
|
||||||
uint current_opt; // 0 is edit mode btw
|
|
||||||
struct editable_field efield;
|
|
||||||
};
|
|
||||||
void print_ofield(struct opt_field *focused_input);
|
|
||||||
|
|
||||||
static struct opt_field ofield_new(uint opts) {
|
|
||||||
struct opt_field __field;
|
|
||||||
__field.opts = opts;
|
|
||||||
__field.current_opt = 1;
|
|
||||||
if (opts == 0) {
|
|
||||||
__field.current_opt = 0;
|
|
||||||
__field.efield = field_new("");
|
|
||||||
}
|
|
||||||
return __field;
|
|
||||||
}
|
|
||||||
static void ofield_toedit(struct opt_field *ofield, char *init) {
|
|
||||||
ofield->current_opt = 0;
|
|
||||||
ofield->efield = field_new(init);
|
|
||||||
}
|
|
||||||
static void ofield_type(struct opt_field *ofield, char *new, char *startstr) {
|
|
||||||
if (ofield->current_opt != 0)
|
|
||||||
ofield_toedit(ofield, startstr);
|
|
||||||
field_update(&ofield->efield, new);
|
|
||||||
}
|
|
||||||
// true if it changed anything, single opt fields return false
|
|
||||||
static bool ofield_opt_seek(struct opt_field *ofield, char seek) {
|
|
||||||
// TODO: think this
|
|
||||||
if (ofield->opts == 0 || (ofield->opts == 1 && ofield->current_opt != 0))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
ofield->current_opt =
|
|
||||||
1 + ((ofield->current_opt - 1 + seek + ofield->opts) % ofield->opts);
|
|
||||||
|
|
||||||
print_ofield(ofield);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
// true in case it was able to "use" the seek (a empty only editable field
|
|
||||||
// wouldn't)
|
|
||||||
static bool ofield_seek(struct opt_field *ofield, char seek) {
|
|
||||||
if (ofield->current_opt == 0) {
|
|
||||||
if (field_seek(&ofield->efield, seek)) {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
buf = nbuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ofield->opts == 0)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
ofield_opt_seek(ofield, seek);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static u_char ofield_max_displ_pos(struct opt_field *ofield) {
|
void ui_update_cursor_focus() {
|
||||||
// TODO: set max cursor pos too
|
|
||||||
// keep in mind that also have to keep in mind scrolling and ughhh, mentally
|
|
||||||
// blocked, but this is complex
|
|
||||||
if (ofield->current_opt == 0)
|
|
||||||
return ofield->efield.pos;
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
enum input focused_input = PASSWD;
|
|
||||||
struct opt_field of_session;
|
|
||||||
struct opt_field of_user;
|
|
||||||
struct opt_field of_passwd;
|
|
||||||
|
|
||||||
struct users_list *gusers;
|
|
||||||
struct sessions_list *gsessions;
|
|
||||||
|
|
||||||
// not *that* OF tho
|
|
||||||
struct opt_field *get_of(enum input from) {
|
|
||||||
if (from == SESSION)
|
|
||||||
return &of_session;
|
|
||||||
if (from == USER)
|
|
||||||
return &of_user;
|
|
||||||
if (from == PASSWD)
|
|
||||||
return &of_passwd;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ffield_cursor_focus() {
|
|
||||||
struct uint_point bstart = box_start();
|
struct uint_point bstart = box_start();
|
||||||
u_char line = bstart.y;
|
u_char line = bstart.y;
|
||||||
u_char row = bstart.x + 15;
|
u_char col = bstart.x + VALUES_COL;
|
||||||
|
|
||||||
|
struct opts_field* ofield = get_opts_ffield();
|
||||||
|
u_char maxlen = VALUE_MAXLEN;
|
||||||
|
if (ofield->opts > 1) {
|
||||||
|
maxlen -= utf8len(g_config->strings.opts_pre) +
|
||||||
|
utf8len(g_config->strings.opts_post);
|
||||||
|
}
|
||||||
|
col += ofield_display_cursor_col(ofield, maxlen);
|
||||||
|
if (ofield->opts > 1) col += utf8len(g_config->strings.opts_pre);
|
||||||
|
|
||||||
// rows in here quite bodged
|
// rows in here quite bodged
|
||||||
if (focused_input == SESSION) {
|
if (focused_input == SESSION) {
|
||||||
line += 5;
|
line += SESSION_ROW;
|
||||||
row += (of_session.opts > 1) * 2;
|
|
||||||
} else if (focused_input == USER) {
|
} else if (focused_input == USER) {
|
||||||
line += 7;
|
line += USER_ROW;
|
||||||
row += (of_user.opts > 1) * 2;
|
|
||||||
} else if (focused_input == PASSWD)
|
} else if (focused_input == PASSWD)
|
||||||
line += 9;
|
line += PASSWD_ROW;
|
||||||
|
|
||||||
struct opt_field *ofield = get_of(focused_input);
|
(void)printf("\x1b[%d;%dH", line, col);
|
||||||
row += ofield->current_opt == 0 ? ofield_max_displ_pos(ofield) : 0;
|
(void)fflush(stdout);
|
||||||
|
|
||||||
printf("\x1b[%d;%dH", line, row);
|
|
||||||
fflush(stdout);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct user get_current_user() {
|
void ui_update_field(enum input focused_input) {
|
||||||
if (of_user.current_opt != 0)
|
|
||||||
return gusers->users[of_user.current_opt - 1];
|
|
||||||
else {
|
|
||||||
struct user custom_user;
|
|
||||||
custom_user.shell = "/usr/bin/bash";
|
|
||||||
custom_user.username = custom_user.display_name = of_user.efield.content;
|
|
||||||
return custom_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
|
|
||||||
if (behavior.include_defshell &&
|
|
||||||
of_session.current_opt == gsessions->length + 1) {
|
|
||||||
struct session shell_session;
|
|
||||||
shell_session.type = SHELL;
|
|
||||||
shell_session.exec = shell_session.name = get_current_user().shell;
|
|
||||||
return shell_session;
|
|
||||||
} else
|
|
||||||
return gsessions->sessions[of_session.current_opt - 1];
|
|
||||||
} else {
|
|
||||||
struct session custom_session;
|
|
||||||
custom_session.type = SHELL;
|
|
||||||
custom_session.name = custom_session.exec = of_session.efield.content;
|
|
||||||
return custom_session;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void print_field(enum input focused_input) {
|
|
||||||
struct uint_point origin = box_start();
|
struct uint_point origin = box_start();
|
||||||
|
|
||||||
if (focused_input == PASSWD) {
|
if (focused_input == PASSWD) {
|
||||||
print_passwd(origin, of_passwd.efield.length, false);
|
print_passwd(origin, utf8len(of_passwd.efield.content), false);
|
||||||
} else if (focused_input == SESSION) {
|
} else if (focused_input == SESSION) {
|
||||||
print_session(origin, get_current_session(), of_session.opts > 1);
|
print_session(origin, st_session(g_config->behavior.include_defshell),
|
||||||
|
of_session.opts > 1);
|
||||||
} else if (focused_input == USER) {
|
} else if (focused_input == USER) {
|
||||||
print_user(origin, get_current_user(), of_user.opts > 1);
|
print_user(origin, st_user(), of_user.opts > 1);
|
||||||
print_field(SESSION);
|
ui_update_field(SESSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
ffield_cursor_focus();
|
ui_update_cursor_focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_ffield() { print_field(focused_input); }
|
void ui_update_ffield() {
|
||||||
void print_ofield(struct opt_field *ofield) {
|
ui_update_field(focused_input);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ui_update_ofield(struct opts_field* NNULLABLE self) {
|
||||||
enum input input;
|
enum input input;
|
||||||
if (ofield == &of_session)
|
if (self == &of_session)
|
||||||
input = SESSION;
|
input = SESSION;
|
||||||
else if (ofield == &of_user)
|
else if (self == &of_user)
|
||||||
input = USER;
|
input = USER;
|
||||||
else if (ofield == &of_passwd)
|
else if (self == &of_passwd)
|
||||||
input = PASSWD;
|
input = PASSWD;
|
||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
|
|
||||||
print_field(input);
|
ui_update_field(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
// true = forward, false = backward
|
static char* unknown_str = "unknown";
|
||||||
void ffield_move(bool direction) {
|
// NOLINTNEXTLINE(readability-function-cognitive-complexity)
|
||||||
if (direction)
|
int load(struct Vector* users, struct Vector* sessions) {
|
||||||
focused_input = (focused_input + 1 + inputs_n) % inputs_n;
|
|
||||||
else
|
|
||||||
focused_input = (focused_input - 1 + inputs_n) % inputs_n;
|
|
||||||
|
|
||||||
ffield_cursor_focus();
|
|
||||||
}
|
|
||||||
|
|
||||||
// tf I'm doing
|
|
||||||
void ffield_change_opt(bool direction) {
|
|
||||||
struct opt_field *ffield = get_of(focused_input);
|
|
||||||
if (focused_input == PASSWD)
|
|
||||||
ffield = &of_session;
|
|
||||||
if (!ofield_opt_seek(ffield, direction ? 1 : -1)) {
|
|
||||||
if (focused_input == PASSWD || focused_input == SESSION)
|
|
||||||
ofield_opt_seek(&of_user, direction ? 1 : -1);
|
|
||||||
else
|
|
||||||
ofield_opt_seek(&of_session, direction ? 1 : -1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void ffield_change_pos(bool direction) {
|
|
||||||
struct opt_field *ffield = get_of(focused_input);
|
|
||||||
if (!ofield_seek(ffield, direction ? 1 : -1))
|
|
||||||
if (!ofield_opt_seek(&of_session, direction ? 1 : -1))
|
|
||||||
ofield_opt_seek(&of_user, direction ? 1 : -1);
|
|
||||||
|
|
||||||
ffield_cursor_focus();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ffield_type(char *text) {
|
|
||||||
struct opt_field *field = get_of(focused_input);
|
|
||||||
char *start = "";
|
|
||||||
if (focused_input == USER && of_user.current_opt != 0)
|
|
||||||
start = get_current_user().username;
|
|
||||||
if (focused_input == SESSION && of_session.current_opt != 0 &&
|
|
||||||
get_current_session().type == SHELL)
|
|
||||||
start = get_current_session().exec;
|
|
||||||
|
|
||||||
ofield_type(field, text, start);
|
|
||||||
print_ffield();
|
|
||||||
}
|
|
||||||
|
|
||||||
int load(struct users_list *users, struct sessions_list *sessions) {
|
|
||||||
/// SETUP
|
/// SETUP
|
||||||
gusers = users;
|
gusers = users;
|
||||||
gsessions = sessions;
|
gsessions = sessions;
|
||||||
|
|
||||||
// hostnames larger won't render properly
|
// hostnames larger won't render properly
|
||||||
char *hostname = malloc(16);
|
const u_char HOSTNAME_SIZE = VALUES_COL - VALUES_SEPR - BOX_HMARGIN;
|
||||||
if (gethostname(hostname, 16) != 0) {
|
char hostname_buf[HOSTNAME_SIZE];
|
||||||
free(hostname);
|
char* hostname = hostname_buf;
|
||||||
hostname = "unknown";
|
if (gethostname(hostname_buf, HOSTNAME_SIZE) != 0) {
|
||||||
|
hostname = unknown_str;
|
||||||
} else {
|
} else {
|
||||||
hostname = realloc(hostname, strlen(hostname) + 1);
|
// Ig "successful completion" doesn't contemplate truncation case, so need
|
||||||
|
// to append the unspecified nullbyte
|
||||||
|
|
||||||
|
// char* hidx =
|
||||||
|
// (char*)utf8back(&hostname[VALUES_COL - VALUES_SEPR - BOX_HMARGIN -
|
||||||
|
// 1]);
|
||||||
|
// *hidx = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
of_session = ofield_new(sessions->length + behavior.include_defshell);
|
of_session =
|
||||||
|
ofield_new(sessions->length + g_config->behavior.include_defshell);
|
||||||
of_user = ofield_new(users->length);
|
of_user = ofield_new(users->length);
|
||||||
of_passwd = ofield_new(0);
|
of_passwd = ofield_new(0);
|
||||||
|
|
||||||
|
of_user.current_opt = users->length > 0;
|
||||||
|
of_session.current_opt = sessions->length > 0;
|
||||||
|
struct LaunchState initial_state;
|
||||||
|
if (read_launch_state(&initial_state) == 0) {
|
||||||
|
for (size_t i = 0; i < users->length; i++) {
|
||||||
|
struct user* user_i = (struct user*)vec_get(users, i);
|
||||||
|
if (strcmp(user_i->username, initial_state.username) == 0) {
|
||||||
|
of_user.current_opt = i + 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (size_t i = 0; i < sessions->length; i++) {
|
||||||
|
struct session* session_i = (struct session*)vec_get(sessions, i);
|
||||||
|
if (strcmp(session_i->name, initial_state.session_opt) == 0) {
|
||||||
|
of_session.current_opt = i + 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (g_config->behavior.include_defshell) {
|
||||||
|
if (strcmp(st_user().shell, initial_state.session_opt) == 0)
|
||||||
|
of_session.current_opt = sessions->length + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
free(initial_state.username);
|
||||||
|
free(initial_state.session_opt);
|
||||||
|
}
|
||||||
|
|
||||||
/// PRINTING
|
/// PRINTING
|
||||||
const struct uint_point boxstart = box_start();
|
const struct uint_point BOXSTART = box_start();
|
||||||
|
|
||||||
// printf box
|
// printf box
|
||||||
print_box();
|
print_box();
|
||||||
|
|
||||||
// put hostname
|
// put hostname
|
||||||
printf("\x1b[%d;%dH\x1b[%sm%s\x1b[%sm", boxstart.y + 2,
|
printf("\x1b[%d;%dH\x1b[%sm%s\x1b[%sm", BOXSTART.y + HEAD_ROW,
|
||||||
boxstart.x + 12 - (uint)strlen(hostname), theme.colors.e_hostname,
|
BOXSTART.x + VALUES_COL - VALUES_SEPR - (uint)utf8len(hostname),
|
||||||
hostname, theme.colors.fg);
|
g_config->colors.e_hostname, hostname, g_config->colors.fg);
|
||||||
|
|
||||||
// put date
|
// put date
|
||||||
char *fmtd_time = fmt_time();
|
char* fmtd_time = fmt_time(g_config->behavior.timefmt);
|
||||||
printf("\x1b[%d;%dH\x1b[%sm%s\x1b[%sm", boxstart.y + 2,
|
printf("\x1b[%d;%dH\x1b[%sm%s\x1b[%sm", BOXSTART.y + HEAD_ROW,
|
||||||
boxstart.x + boxw - 3 - (uint)strlen(fmtd_time), theme.colors.e_date,
|
BOXSTART.x + BOX_WIDTH - 1 - BOX_HMARGIN - (uint)utf8len(fmtd_time),
|
||||||
fmtd_time, theme.colors.fg);
|
g_config->colors.e_date, fmtd_time, g_config->colors.fg);
|
||||||
|
free(fmtd_time);
|
||||||
|
|
||||||
print_field(SESSION);
|
ui_update_field(SESSION);
|
||||||
print_field(USER);
|
ui_update_field(USER);
|
||||||
print_field(PASSWD);
|
ui_update_field(PASSWD);
|
||||||
ffield_cursor_focus();
|
ui_update_cursor_focus();
|
||||||
|
|
||||||
/// INTERACTIVE
|
/// INTERACTIVE
|
||||||
u_char len;
|
u_char len;
|
||||||
char seq[256];
|
char seq[0xff];
|
||||||
uint esc = 0;
|
uint esc = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
read_press(&len, seq);
|
read_press(&len, seq);
|
||||||
@ -369,215 +262,243 @@ int load(struct users_list *users, struct sessions_list *sessions) {
|
|||||||
if (ansi_code != -1) {
|
if (ansi_code != -1) {
|
||||||
if (ansi_code == ESC) {
|
if (ansi_code == ESC) {
|
||||||
esc = 2;
|
esc = 2;
|
||||||
} else if (ansi_code == functions.refresh) {
|
} else if (ansi_code == g_config->functions.refresh) {
|
||||||
restore_all();
|
restore_all();
|
||||||
return 0;
|
return 0;
|
||||||
} else if (ansi_code == functions.reboot) {
|
} else if (ansi_code == g_config->functions.reboot) {
|
||||||
restore_all();
|
restore_all();
|
||||||
system("reboot");
|
reboot(RB_AUTOBOOT);
|
||||||
exit(0);
|
exit(0);
|
||||||
} else if (ansi_code == functions.poweroff) {
|
} else if (ansi_code == g_config->functions.poweroff) {
|
||||||
restore_all();
|
restore_all();
|
||||||
system("poweroff");
|
reboot(RB_POWER_OFF);
|
||||||
exit(0);
|
exit(0);
|
||||||
} else if (ansi_code == A_UP || ansi_code == A_DOWN) {
|
} else if (ansi_code == A_UP || ansi_code == A_DOWN) {
|
||||||
ffield_move(ansi_code == A_DOWN);
|
st_ch_focus(ansi_code == A_DOWN ? 1 : -1);
|
||||||
} else if (ansi_code == A_RIGHT || ansi_code == A_LEFT) {
|
} else if (ansi_code == A_RIGHT || ansi_code == A_LEFT) {
|
||||||
if (esc)
|
if (esc)
|
||||||
ffield_change_opt(ansi_code == A_RIGHT);
|
st_ch_of_opts(ansi_code == A_RIGHT ? 1 : -1);
|
||||||
else
|
else
|
||||||
ffield_change_pos(ansi_code == A_RIGHT);
|
st_ch_ef_col(ansi_code == A_RIGHT ? 1 : -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (len == 1 && *seq == '\n') {
|
if (len == 1 && *seq == '\n') {
|
||||||
if (!launch(get_current_user().username, of_passwd.efield.content,
|
bool successful_write = write_launch_state((struct LaunchState){
|
||||||
get_current_session(), &restore_all)) {
|
.username = st_user().username,
|
||||||
print_passwd(box_start(), of_passwd.efield.length, true);
|
.session_opt = st_session(g_config->behavior.include_defshell).name,
|
||||||
ffield_cursor_focus();
|
});
|
||||||
continue;
|
if (!successful_write) log_puts("[E] failed to write launch state");
|
||||||
|
|
||||||
|
if (!launch(st_user().username, of_passwd.efield.content,
|
||||||
|
st_session(g_config->behavior.include_defshell),
|
||||||
|
&restore_all, g_config)) {
|
||||||
|
print_passwd(box_start(), utf8len(of_passwd.efield.content), true);
|
||||||
|
ui_update_cursor_focus();
|
||||||
}
|
}
|
||||||
}
|
} else
|
||||||
ffield_type(seq);
|
st_kbd_type(seq, g_config->behavior.include_defshell);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (esc != 0)
|
if (esc != 0) esc--;
|
||||||
esc--;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *line_cleaner = NULL;
|
void clean_line(struct uint_point origin, uint line) {
|
||||||
static void clean_line(struct uint_point origin, uint line) {
|
// - outline + nullbyte
|
||||||
if (line_cleaner == NULL) {
|
static char line_cleaner[BOX_WIDTH - 2 + 1] = {
|
||||||
line_cleaner = malloc((boxw - 2) * sizeof(char));
|
[0 ... BOX_WIDTH - 2 - 1] = ' ', [BOX_WIDTH - 2] = '\0'};
|
||||||
memset(line_cleaner, 32, boxw - 2);
|
printf("\x1b[%d;%dH%s", origin.y + line, origin.x + 1, line_cleaner);
|
||||||
}
|
|
||||||
printf("\x1b[%d;%dH", origin.y + line, origin.x + 1);
|
|
||||||
fflush(stdout);
|
|
||||||
write(STDOUT_FILENO, line_cleaner, boxw - 2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: session_len > 32
|
u_char get_render_pos_offset(struct opts_field* self, u_char maxlen) {
|
||||||
static void print_session(struct uint_point origin, struct session session,
|
if (self->current_opt != 0) return 0;
|
||||||
bool multiple) {
|
|
||||||
clean_line(origin, 5);
|
u_char pos = utf8len_until(self->efield.content,
|
||||||
const char *session_type;
|
&self->efield.content[self->efield.pos]);
|
||||||
|
return pos - ofield_display_cursor_col(self, maxlen);
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_session(struct uint_point origin, struct session session,
|
||||||
|
bool multiple) {
|
||||||
|
clean_line(origin, SESSION_ROW);
|
||||||
|
|
||||||
|
const char* NNULLABLE session_type;
|
||||||
if (session.type == XORG) {
|
if (session.type == XORG) {
|
||||||
session_type = strings.s_xorg;
|
session_type = g_config->strings.s_xorg;
|
||||||
} else if (session.type == WAYLAND) {
|
} else if (session.type == WAYLAND) {
|
||||||
session_type = strings.s_wayland;
|
session_type = g_config->strings.s_wayland;
|
||||||
} else if (session.type == SHELL) {
|
} else if (session.type == SHELL) {
|
||||||
session_type = strings.s_shell;
|
session_type = g_config->strings.s_shell;
|
||||||
|
} else {
|
||||||
|
__builtin_unreachable();
|
||||||
}
|
}
|
||||||
printf("\r\x1b[%luC\x1b[%sm%s\x1b[%sm", origin.x + 11 - strlen(session_type),
|
|
||||||
theme.colors.e_header, session_type, theme.colors.fg);
|
|
||||||
|
|
||||||
char *session_color;
|
// already in the box, - 1 bcs no need to step over margin, same reasoning in
|
||||||
|
// other places
|
||||||
|
printf(
|
||||||
|
"\r\x1b[%luC\x1b[%sm%s\x1b[%sm",
|
||||||
|
(ulong)(origin.x + VALUES_COL - VALUES_SEPR - utf8len(session_type) - 1),
|
||||||
|
g_config->colors.e_header, session_type, g_config->colors.fg);
|
||||||
|
|
||||||
|
char* session_color;
|
||||||
if (session.type == XORG) {
|
if (session.type == XORG) {
|
||||||
session_color = theme.colors.s_xorg;
|
session_color = g_config->colors.s_xorg;
|
||||||
} else if (session.type == WAYLAND) {
|
} else if (session.type == WAYLAND) {
|
||||||
session_color = theme.colors.s_wl;
|
session_color = g_config->colors.s_wayland;
|
||||||
} else if (session.type == SHELL) {
|
} else {
|
||||||
session_color = theme.colors.s_shell;
|
session_color = g_config->colors.s_shell;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char* toprint = session.name;
|
||||||
if (multiple) {
|
if (multiple) {
|
||||||
printf("\r\x1b[%dC< \x1b[%sm%s\x1b[%sm >", origin.x + 14, session_color,
|
u_char maxlen = VALUE_MAXLEN - utf8len(g_config->strings.opts_pre) -
|
||||||
session.name, theme.colors.fg);
|
utf8len(g_config->strings.opts_post);
|
||||||
|
toprint += get_render_pos_offset(&of_session, maxlen);
|
||||||
|
size_t printlen = utf8seekn(toprint, maxlen) - toprint;
|
||||||
|
|
||||||
|
printf("\r\x1b[%dC%s\x1b[%sm%.*s\x1b[%sm%s", origin.x + VALUES_COL - 1,
|
||||||
|
g_config->strings.opts_pre, session_color, (int)printlen, toprint,
|
||||||
|
g_config->colors.fg, g_config->strings.opts_post);
|
||||||
} else {
|
} else {
|
||||||
printf("\r\x1b[%dC\x1b[%sm%s\x1b[%sm", origin.x + 14, session_color,
|
toprint += get_render_pos_offset(&of_session, VALUE_MAXLEN);
|
||||||
session.name, theme.colors.fg);
|
size_t printlen = utf8seekn(toprint, VALUE_MAXLEN) - toprint;
|
||||||
|
printf("\r\x1b[%dC\x1b[%sm%.*s\x1b[%sm", origin.x + VALUES_COL - 1,
|
||||||
|
session_color, (int)printlen, toprint, g_config->colors.fg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: user_len > 32
|
void print_user(struct uint_point origin, struct user user, bool multiple) {
|
||||||
static void print_user(struct uint_point origin, struct user user,
|
clean_line(origin, USER_ROW);
|
||||||
bool multiple) {
|
|
||||||
clean_line(origin, 7);
|
|
||||||
printf("\r\x1b[%luC\x1b[%sm%s\x1b[%sm",
|
printf("\r\x1b[%luC\x1b[%sm%s\x1b[%sm",
|
||||||
origin.x + 11 - strlen(strings.e_user), theme.colors.e_header,
|
(ulong)(origin.x + VALUES_COL - VALUES_SEPR -
|
||||||
strings.e_user, theme.colors.fg);
|
utf8len(g_config->strings.e_user) - 1),
|
||||||
|
g_config->colors.e_header, g_config->strings.e_user,
|
||||||
|
g_config->colors.fg);
|
||||||
|
|
||||||
char *user_color = theme.colors.e_user;
|
char* user_color = g_config->colors.e_user;
|
||||||
|
|
||||||
|
char* toprint = user.display_name;
|
||||||
if (multiple) {
|
if (multiple) {
|
||||||
printf("\r\x1b[%dC< \x1b[%sm%s\x1b[%sm >", origin.x + 14, user_color,
|
u_char maxlen = VALUE_MAXLEN - utf8len(g_config->strings.opts_pre) -
|
||||||
user.display_name, theme.colors.fg);
|
utf8len(g_config->strings.opts_post);
|
||||||
|
toprint += get_render_pos_offset(&of_session, maxlen);
|
||||||
|
size_t printlen = utf8seekn(toprint, maxlen) - toprint;
|
||||||
|
|
||||||
|
printf("\r\x1b[%dC< \x1b[%sm%.*s\x1b[%sm >", origin.x + VALUES_COL - 1,
|
||||||
|
user_color, (int)printlen, toprint, g_config->colors.fg);
|
||||||
} else {
|
} else {
|
||||||
printf("\r\x1b[%dC\x1b[%sm%s\x1b[%sm", origin.x + 14, user_color,
|
toprint += get_render_pos_offset(&of_user, VALUE_MAXLEN);
|
||||||
user.display_name, theme.colors.fg);
|
size_t printlen = utf8seekn(toprint, VALUE_MAXLEN) - toprint;
|
||||||
|
printf("\r\x1b[%dC\x1b[%sm%.*s\x1b[%sm", origin.x + VALUES_COL - 1,
|
||||||
|
user_color, (int)printlen, toprint, g_config->colors.fg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *passwd_prompt[32];
|
void print_passwd(struct uint_point origin, uint length, bool err) {
|
||||||
// TODO: passwd_len > 32
|
char passwd_prompt[VALUE_MAXLEN + 1];
|
||||||
static void print_passwd(struct uint_point origin, uint length, bool err) {
|
clean_line(origin, PASSWD_ROW);
|
||||||
clean_line(origin, 9);
|
|
||||||
printf("\r\x1b[%luC\x1b[%sm%s\x1b[%sm",
|
printf("\r\x1b[%luC\x1b[%sm%s\x1b[%sm",
|
||||||
origin.x + 11 - strlen(strings.e_passwd), theme.colors.e_header,
|
(ulong)(origin.x + VALUES_COL - VALUES_SEPR -
|
||||||
strings.e_passwd, theme.colors.fg);
|
utf8len(g_config->strings.e_passwd) - 1),
|
||||||
|
g_config->colors.e_header, g_config->strings.e_passwd,
|
||||||
|
g_config->colors.fg);
|
||||||
|
|
||||||
char *pass_color;
|
char* pass_color;
|
||||||
if (err)
|
if (err)
|
||||||
pass_color = theme.colors.e_badpasswd;
|
pass_color = g_config->colors.e_badpasswd;
|
||||||
else
|
else
|
||||||
pass_color = theme.colors.e_passwd;
|
pass_color = g_config->colors.e_passwd;
|
||||||
|
|
||||||
memset(passwd_prompt, 32, 32);
|
ulong actual_len = length > VALUE_MAXLEN ? VALUE_MAXLEN : length;
|
||||||
memset(passwd_prompt, '*', length);
|
memset(passwd_prompt, ' ', VALUE_MAXLEN);
|
||||||
|
memset(passwd_prompt, '*', actual_len);
|
||||||
|
passwd_prompt[VALUE_MAXLEN] = '\0';
|
||||||
|
|
||||||
printf("\r\x1b[%dC\x1b[%sm\x1b[4m", origin.x + 14, pass_color);
|
printf("\r\x1b[%dC\x1b[%sm", origin.x + VALUES_COL - 1, pass_color);
|
||||||
fflush(stdout);
|
printf("%s", passwd_prompt);
|
||||||
write(STDOUT_FILENO, passwd_prompt, 32);
|
|
||||||
printf("\x1b[%sm", theme.colors.fg);
|
printf("\x1b[%sm", g_config->colors.fg);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ik this code is... *quirky*
|
static void print_empty_row(uint wid, uint n, char* edge1, char* edge2) {
|
||||||
// w just accounts for filler
|
for (size_t i = 0; i < n; i++) {
|
||||||
// if filler == NULL, it will just move cursor
|
printf("%s\x1b[%dC%s\x1b[%dD\x1b[1B", edge1, wid, edge2, wid + 2);
|
||||||
static void print_row(uint w, uint n, char *edge1, char *edge2, char **filler) {
|
}
|
||||||
char *row;
|
}
|
||||||
size_t row_size;
|
|
||||||
|
|
||||||
uint size;
|
static void print_row(uint wid, uint n, char* edge1, char* edge2,
|
||||||
if (filler == NULL) {
|
char* filler) {
|
||||||
row_size = snprintf(NULL, 0, "%s\x1b[%dC%s\x1b[%dD\x1b[1B", edge1, w, edge2,
|
for (size_t i = 0; i < n; i++) {
|
||||||
w + 2) +
|
printf("%s", edge1);
|
||||||
1;
|
for (size_t i = 0; i < wid; i++) {
|
||||||
row = malloc(row_size);
|
printf("%s", filler);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
snprintf(&row[nbytes1 + fillersize], nbytes2, "%s\x1b[%dD\x1b[1B", edge2,
|
printf("%s\x1b[%dD\x1b[1B", edge2, wid + 2);
|
||||||
w + 2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint i = 0; i < n; i++) {
|
|
||||||
write(STDOUT_FILENO, row, row_size);
|
|
||||||
}
|
|
||||||
free(row);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void print_box() {
|
static void print_box() {
|
||||||
// TODO: check min sizes
|
const struct uint_point BSTART = box_start();
|
||||||
const struct uint_point bstart = box_start();
|
|
||||||
|
|
||||||
printf("\x1b[%d;%dH\x1b[%sm", bstart.y, bstart.x, theme.colors.e_box);
|
printf("\x1b[%d;%dH\x1b[%sm", BSTART.y, BSTART.x, g_config->colors.e_box);
|
||||||
fflush(stdout);
|
print_row(BOX_WIDTH - 2, 1, g_config->chars.ctl, g_config->chars.ctr,
|
||||||
print_row(boxw - 2, 1, theme.chars.ctl, theme.chars.ctr, &theme.chars.hb);
|
g_config->chars.hb);
|
||||||
print_row(boxw - 2, boxh - 2, theme.chars.vb, theme.chars.vb, NULL);
|
print_empty_row(BOX_WIDTH - 2, BOX_HEIGHT - 2, g_config->chars.vb,
|
||||||
print_row(boxw - 2, 1, theme.chars.cbl, theme.chars.cbr, &theme.chars.hb);
|
g_config->chars.vb);
|
||||||
printf("\x1b[%sm", theme.colors.fg);
|
print_row(BOX_WIDTH - 2, 1, g_config->chars.cbl, g_config->chars.cbr,
|
||||||
fflush(stdout);
|
g_config->chars.hb);
|
||||||
|
printf("\x1b[%sm", g_config->colors.fg);
|
||||||
|
(void)fflush(stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void print_footer() {
|
static void print_footer() {
|
||||||
size_t bsize = snprintf(NULL, 0, "%s %s %s %s %s %s", strings.f_poweroff,
|
size_t bsize = utf8len(g_config->strings.f_poweroff) +
|
||||||
key_names[functions.poweroff], strings.f_reboot,
|
utf8len(KEY_NAMES[g_config->functions.poweroff]) +
|
||||||
key_names[functions.reboot], strings.f_refresh,
|
utf8len(g_config->strings.f_reboot) +
|
||||||
key_names[functions.refresh]);
|
utf8len(KEY_NAMES[g_config->functions.reboot]) +
|
||||||
|
utf8len(g_config->strings.f_refresh) +
|
||||||
|
utf8len(KEY_NAMES[g_config->functions.refresh]);
|
||||||
|
|
||||||
|
bsize += 2 * 2 + // 2 wide separators between 3 items
|
||||||
|
3 * 1; // 3 thin separators inside every item
|
||||||
|
|
||||||
uint row = window.ws_row - 1;
|
uint row = window.ws_row - 1;
|
||||||
uint col = window.ws_col - 2 - bsize;
|
uint col = window.ws_col - 2 - bsize;
|
||||||
printf("\x1b[%3$d;%4$dH%8$s \x1b[%1$sm%5$s\x1b[%2$sm %9$s "
|
printf(
|
||||||
"\x1b[%1$sm%6$s\x1b[%2$sm %10$s \x1b[%1$sm%7$s\x1b[%2$sm",
|
"\x1b[%3$d;%4$dH%8$s \x1b[%1$sm%5$s\x1b[%2$sm %9$s "
|
||||||
theme.colors.e_key, theme.colors.fg, row, col,
|
"\x1b[%1$sm%6$s\x1b[%2$sm %10$s \x1b[%1$sm%7$s\x1b[%2$sm",
|
||||||
key_names[functions.poweroff], key_names[functions.reboot],
|
g_config->colors.e_key, g_config->colors.fg, row, col,
|
||||||
key_names[functions.refresh], strings.f_poweroff, strings.f_reboot,
|
KEY_NAMES[g_config->functions.poweroff],
|
||||||
strings.f_refresh);
|
KEY_NAMES[g_config->functions.reboot],
|
||||||
fflush(stdout);
|
KEY_NAMES[g_config->functions.refresh], g_config->strings.f_poweroff,
|
||||||
|
g_config->strings.f_reboot, g_config->strings.f_refresh);
|
||||||
|
(void)fflush(stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_err(const char *msg) {
|
void print_err(const char* msg) {
|
||||||
struct uint_point origin = box_start();
|
struct uint_point origin = box_start();
|
||||||
fprintf(stderr, "\x1b[%d;%dH%s(%d): %s", origin.y - 1, origin.x, msg, errno,
|
(void)fprintf(stderr, "\x1b[%d;%dH%s(%d): %s", origin.y - 1, origin.x, msg,
|
||||||
strerror(errno));
|
errno, strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_errno(const char *descr) {
|
void print_errno(const char* descr) {
|
||||||
struct uint_point origin = box_start();
|
struct uint_point origin = box_start();
|
||||||
if (descr == NULL)
|
if (descr == NULL)
|
||||||
fprintf(stderr, "\x1b[%d;%dH\x1b[%smunknown error(%d): %s", origin.y - 1,
|
(void)fprintf(stderr, "\x1b[%d;%dH\x1b[%smunknown error(%d): %s",
|
||||||
origin.x, theme.colors.err, errno, strerror(errno));
|
origin.y - 1, origin.x, g_config->colors.err, errno,
|
||||||
|
strerror(errno));
|
||||||
else {
|
else {
|
||||||
fprintf(stderr, "\x1b[%d;%dH\x1b[%sm%s(%d): %s", origin.y - 1, origin.x,
|
(void)fprintf(stderr, "\x1b[%d;%dH\x1b[%sm%s(%d): %s", origin.y - 1,
|
||||||
descr, theme.colors.err, errno, strerror(errno));
|
origin.x, g_config->colors.err, descr, errno,
|
||||||
|
strerror(errno));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void restore_all() {
|
void restore_all() {
|
||||||
// restore cursor pos, restore screen and show cursor
|
// restore cursor pos, restore screen and show cursor
|
||||||
printf("\x1b[u\x1b[?47l\x1b[?25h");
|
(void)printf("\x1b[u\x1b[?47l\x1b[?25h");
|
||||||
fflush(stdout);
|
(void)fflush(stdout);
|
||||||
tcsetattr(STDOUT_FILENO, TCSANOW, &orig_term);
|
tcsetattr(STDOUT_FILENO, TCSANOW, &orig_term);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
93
src/ui_state.c
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
#include "ui_state.h"
|
||||||
|
#include "ofield.h"
|
||||||
|
#include "sessions.h"
|
||||||
|
#include "ui.h"
|
||||||
|
#include "users.h"
|
||||||
|
|
||||||
|
enum input focused_input = PASSWD;
|
||||||
|
|
||||||
|
struct Vector* gusers;
|
||||||
|
struct Vector* gsessions;
|
||||||
|
|
||||||
|
struct opts_field of_session;
|
||||||
|
struct opts_field of_user;
|
||||||
|
struct opts_field of_passwd;
|
||||||
|
|
||||||
|
struct opts_field* NNULLABLE get_opts_field(enum input from) {
|
||||||
|
if (from == SESSION) return &of_session;
|
||||||
|
if (from == USER) return &of_user;
|
||||||
|
if (from == PASSWD) return &of_passwd;
|
||||||
|
__builtin_unreachable();
|
||||||
|
}
|
||||||
|
|
||||||
|
struct opts_field* NNULLABLE get_opts_ffield() {
|
||||||
|
return get_opts_field(focused_input);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct user st_user() {
|
||||||
|
if (of_user.current_opt != 0)
|
||||||
|
return *(struct user*)vec_get(gusers, of_user.current_opt - 1);
|
||||||
|
|
||||||
|
struct user custom_user;
|
||||||
|
custom_user.shell = "/usr/bin/bash";
|
||||||
|
custom_user.username = custom_user.display_name = of_user.efield.content;
|
||||||
|
return custom_user;
|
||||||
|
}
|
||||||
|
struct session st_session(bool include_defshell) {
|
||||||
|
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
|
||||||
|
if (include_defshell && of_session.current_opt == gsessions->length + 1) {
|
||||||
|
struct session shell_session;
|
||||||
|
shell_session.type = SHELL;
|
||||||
|
shell_session.exec = shell_session.name = st_user().shell;
|
||||||
|
return shell_session;
|
||||||
|
}
|
||||||
|
|
||||||
|
return *(struct session*)vec_get(gsessions, of_session.current_opt - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct session custom_session;
|
||||||
|
custom_session.type = SHELL;
|
||||||
|
custom_session.name = custom_session.exec = of_session.efield.content;
|
||||||
|
return custom_session;
|
||||||
|
}
|
||||||
|
|
||||||
|
void st_ch_focus(char direction) {
|
||||||
|
focused_input = (focused_input + direction) % INPUTS_N;
|
||||||
|
ui_update_cursor_focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
void st_ch_of_opts(char direction) {
|
||||||
|
struct opts_field* ffield = get_opts_ffield();
|
||||||
|
if (focused_input == PASSWD) ffield = &of_session;
|
||||||
|
if (!ofield_opts_seek(ffield, direction)) {
|
||||||
|
if (focused_input == PASSWD || focused_input == SESSION)
|
||||||
|
ofield_opts_seek(&of_user, direction);
|
||||||
|
else
|
||||||
|
ofield_opts_seek(&of_session, direction);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void st_ch_ef_col(char direction) {
|
||||||
|
struct opts_field* ffield = get_opts_ffield();
|
||||||
|
if (!ofield_seek(ffield, direction))
|
||||||
|
if (!ofield_opts_seek(&of_session, direction))
|
||||||
|
ofield_opts_seek(&of_user, direction);
|
||||||
|
|
||||||
|
ui_update_cursor_focus();
|
||||||
|
ui_update_ffield();
|
||||||
|
}
|
||||||
|
|
||||||
|
void st_kbd_type(char* text, bool cfg_include_defshell) {
|
||||||
|
struct opts_field* field = get_opts_ffield();
|
||||||
|
char* start = "";
|
||||||
|
if (focused_input == USER && of_user.current_opt != 0)
|
||||||
|
start = st_user().username;
|
||||||
|
if (focused_input == SESSION && of_session.current_opt != 0 &&
|
||||||
|
st_session(cfg_include_defshell).type == SHELL)
|
||||||
|
start = st_session(cfg_include_defshell).exec;
|
||||||
|
|
||||||
|
ofield_kbd_type(field, text, start);
|
||||||
|
ui_update_ffield();
|
||||||
|
}
|
106
src/users.c
@ -1,62 +1,66 @@
|
|||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <users.h>
|
#include "log.h"
|
||||||
#include <util.h>
|
#include "macros.h"
|
||||||
|
#include "users.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
static struct user __new_user(struct passwd *p) {
|
// NOLINTNEXTLINE(readability-identifier-length)
|
||||||
struct user __user;
|
int build_user(struct user* NNULLABLE user, struct passwd* p) {
|
||||||
strcln(&__user.shell, p->pw_shell);
|
char* shell = strdup(p->pw_shell);
|
||||||
strcln(&__user.username, p->pw_name);
|
char* username = strdup(p->pw_name);
|
||||||
if (p->pw_gecos[0] == '\0')
|
char* displayname;
|
||||||
__user.display_name = __user.username;
|
if (strlen(p->pw_gecos) == 0)
|
||||||
else
|
displayname = username;
|
||||||
strcln(&__user.display_name, p->pw_gecos);
|
else {
|
||||||
|
displayname = strdup(p->pw_gecos);
|
||||||
return __user;
|
}
|
||||||
}
|
if (!shell || !username || !displayname) {
|
||||||
|
free(shell);
|
||||||
static const u_int8_t bs = 16;
|
free(username);
|
||||||
static const u_int8_t unit_size = sizeof(struct user);
|
if (displayname != username) free(displayname);
|
||||||
|
// actually tidy struggles with the line i have avobe
|
||||||
static u_int16_t alloc_size = bs;
|
// NOLINTNEXTLINE(clang-analyzer-unix.Malloc)
|
||||||
static u_int16_t used_size = 0;
|
return -1;
|
||||||
|
|
||||||
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 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))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (used_size >= alloc_size) {
|
|
||||||
alloc_size += bs;
|
|
||||||
users = realloc(users, alloc_size * unit_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
users[used_size] = __new_user(pwd);
|
|
||||||
used_size++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
users = realloc(users, used_size * unit_size);
|
*user = (struct user){
|
||||||
|
.shell = shell,
|
||||||
|
.username = username,
|
||||||
|
.display_name = displayname,
|
||||||
|
};
|
||||||
|
|
||||||
__list.length = used_size;
|
return 0;
|
||||||
__list.users = users;
|
}
|
||||||
return __users_list = &__list;
|
|
||||||
|
// This code is designed to be run purely single threaded
|
||||||
|
#define LIKELY_BOUND_USERS 4
|
||||||
|
struct Vector get_human_users() {
|
||||||
|
struct Vector users = VEC_NEW;
|
||||||
|
vec_reserve(&users, LIKELY_BOUND_USERS);
|
||||||
|
|
||||||
|
struct passwd* NULLABLE pwd;
|
||||||
|
while ((pwd = getpwent()) != NULL) {
|
||||||
|
log_printf("[I] handling user %s\n", pwd->pw_name);
|
||||||
|
// `- 1` bcs sizeof counts the nullbyte
|
||||||
|
if (pwd->pw_dir &&
|
||||||
|
strncmp(pwd->pw_dir, "/home/", sizeof("/home/") - 1) != 0)
|
||||||
|
continue;
|
||||||
|
log_printf("[I] found %s\n", pwd->pw_name);
|
||||||
|
|
||||||
|
struct user* user_i = malloc(sizeof(struct user));
|
||||||
|
if (user_i == NULL) continue; // malloc error
|
||||||
|
|
||||||
|
if (build_user(user_i, pwd) != 0) {
|
||||||
|
log_printf("[E] failed to allocate allocate memory for %s\n",
|
||||||
|
pwd->pw_name);
|
||||||
|
}
|
||||||
|
vec_push(&users, user_i);
|
||||||
|
}
|
||||||
|
|
||||||
|
return users;
|
||||||
}
|
}
|
||||||
|
156
src/util.c
@ -1,33 +1,30 @@
|
|||||||
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <keys.h>
|
#include "keys.h"
|
||||||
#include <ui.h>
|
#include "ui.h"
|
||||||
#include <util.h>
|
#include "util.h"
|
||||||
|
|
||||||
static int selret_magic();
|
static int selret_magic();
|
||||||
|
|
||||||
void strcln(char **dest, const char *source) {
|
int find_keyname(enum keys* at, const char* name) {
|
||||||
*dest = malloc(strlen(source) + sizeof(char));
|
for (size_t i = 0; i < LEN(KEY_MAPPINGS); i++) {
|
||||||
strcpy(*dest, source);
|
if (strcmp(KEY_NAMES[i], name) == 0) {
|
||||||
}
|
*at = (enum keys)i;
|
||||||
|
return 0;
|
||||||
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)
|
|
||||||
return (enum keys)i;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
perror("key not found");
|
return -1;
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
enum keys find_ansi(char *seq) {
|
enum keys find_ansi(const char* seq) {
|
||||||
for (size_t i = 0; i < sizeof(key_mappings) / sizeof(key_mappings[0]); i++) {
|
for (size_t i = 0; i < LEN(KEY_MAPPINGS); i++) {
|
||||||
struct key_mapping mapping = key_mappings[i];
|
struct key_mapping mapping = KEY_MAPPINGS[i];
|
||||||
for (size_t j = 0; mapping.sequences[j] != NULL; j++) {
|
for (size_t j = 0; mapping.sequences[j] != NULL; j++) {
|
||||||
if (strcmp(mapping.sequences[j], seq) == 0) {
|
if (strcmp(mapping.sequences[j], seq) == 0) {
|
||||||
return (enum keys)i;
|
return (enum keys)i;
|
||||||
@ -37,8 +34,7 @@ enum keys find_ansi(char *seq) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://stackoverflow.com/a/48040042
|
void read_press(u_char* length, char* out) {
|
||||||
void read_press(u_char *length, char *out) {
|
|
||||||
*length = 0;
|
*length = 0;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
@ -57,6 +53,7 @@ void read_press(u_char *length, char *out) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://stackoverflow.com/a/48040042
|
||||||
static int selret_magic() {
|
static int selret_magic() {
|
||||||
fd_set set;
|
fd_set set;
|
||||||
struct timeval timeout;
|
struct timeval timeout;
|
||||||
@ -66,3 +63,124 @@ static int selret_magic() {
|
|||||||
timeout.tv_usec = 0;
|
timeout.tv_usec = 0;
|
||||||
return select(1, &set, NULL, NULL, &timeout);
|
return select(1, &set, NULL, NULL, &timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UTF-8 shii
|
||||||
|
#define UTF8_CONT_MSK 0b11000000
|
||||||
|
#define UTF8_CONT_VAL 0b10000000
|
||||||
|
bool utf8_iscont(char byte) {
|
||||||
|
return (byte & UTF8_CONT_MSK) == UTF8_CONT_VAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t utf8len(const char* str) {
|
||||||
|
size_t len = 0;
|
||||||
|
while (*str != '\0') {
|
||||||
|
if (!utf8_iscont(*(str++))) len++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t utf8len_until(const char* str, const char* until) {
|
||||||
|
size_t len = 0;
|
||||||
|
while (str < until) {
|
||||||
|
if (!utf8_iscont(*(str++))) len++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* utf8back(const char* str) {
|
||||||
|
while (utf8_iscont(*(--str))) {
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
const char* utf8seek(const char* str) {
|
||||||
|
while (utf8_iscont(*(++str))) {
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* utf8seekn(const char* str, size_t n) {
|
||||||
|
while (n > 0 && *str != '\0') {
|
||||||
|
str = utf8seek(str);
|
||||||
|
n--;
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Vector shii
|
||||||
|
const struct Vector VEC_NEW = {
|
||||||
|
.length = 0,
|
||||||
|
.capacity = 0,
|
||||||
|
.pages = NULL,
|
||||||
|
};
|
||||||
|
|
||||||
|
int vec_resize(struct Vector* self, size_t size) {
|
||||||
|
void** new_location =
|
||||||
|
(void**)realloc((void*)self->pages, size * sizeof(void*));
|
||||||
|
if (new_location != NULL) {
|
||||||
|
if (self->length > size) self->length = size;
|
||||||
|
self->capacity = size;
|
||||||
|
self->pages = new_location;
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int vec_reserve(struct Vector* self, size_t size) {
|
||||||
|
uint32_t new_capacity = self->capacity;
|
||||||
|
while (self->length + size > new_capacity) {
|
||||||
|
new_capacity = new_capacity + (new_capacity >> 1) +
|
||||||
|
1; // cap * 1.5 + 1; 0 1 2 4 7 11...
|
||||||
|
}
|
||||||
|
return vec_resize(self, new_capacity);
|
||||||
|
}
|
||||||
|
|
||||||
|
int vec_reserve_exact(struct Vector* self, size_t size) {
|
||||||
|
uint32_t needed_capacity = self->length + size;
|
||||||
|
if (self->capacity < needed_capacity) {
|
||||||
|
return vec_resize(self, needed_capacity);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int vec_push(struct Vector* self, void* item) {
|
||||||
|
int res_ret = vec_reserve(self, 1);
|
||||||
|
if (res_ret != 0) return res_ret;
|
||||||
|
|
||||||
|
self->pages[self->length++] = item;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void vec_free(struct Vector* self) {
|
||||||
|
while (self->length > 0)
|
||||||
|
free(self->pages[--self->length]);
|
||||||
|
|
||||||
|
vec_clear(self);
|
||||||
|
}
|
||||||
|
|
||||||
|
void vec_clear(struct Vector* self) {
|
||||||
|
free((void*)self->pages);
|
||||||
|
vec_reset(self);
|
||||||
|
}
|
||||||
|
|
||||||
|
void vec_reset(struct Vector* self) {
|
||||||
|
*self = (struct Vector){
|
||||||
|
.length = 0,
|
||||||
|
.capacity = 0,
|
||||||
|
.pages = NULL,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
void* vec_pop(struct Vector* self) {
|
||||||
|
if (self->length == 0) return NULL;
|
||||||
|
|
||||||
|
return self->pages[--self->length];
|
||||||
|
}
|
||||||
|
|
||||||
|
void* vec_get(struct Vector* self, size_t index) {
|
||||||
|
if (index >= self->length) return NULL;
|
||||||
|
|
||||||
|
return self->pages[index];
|
||||||
|
}
|
||||||
|
45
themes/README.md
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
# Themes
|
||||||
|
|
||||||
|
## cherry.ini
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## default.ini
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## kanagawa-dragon.ini
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## kanagawa-wave.ini
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## minimal.ini
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
> [!WARNING]
|
||||||
|
> This theme **heavily** relies on terminal rendering. It's just to show
|
||||||
|
> customizability, a TTY won't render this properly
|
||||||
|
|
||||||
|
## nature.ini
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## nord.ini
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## old-blue.ini
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## nothing.ini
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## tasteless.ini
|
||||||
|
|
||||||
|

|
47
themes/cherry.ini
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
[colors]
|
||||||
|
bg = "48;2;77;33;55"
|
||||||
|
fg = "22;3;24;38;2;245;245;245"
|
||||||
|
# err = "1;31"
|
||||||
|
# s_wayland = "38;2;255;174;66"
|
||||||
|
# s_xorg = "38;2;37;175;255"
|
||||||
|
s_shell = "32"
|
||||||
|
e_hostname = "1;23;38;5;197"
|
||||||
|
e_date = "31"
|
||||||
|
e_box = "31"
|
||||||
|
e_header = "1;4;38;5;204"
|
||||||
|
e_user = "38;5;51"
|
||||||
|
e_passwd = "4;2;38;5;203"
|
||||||
|
e_badpasswd = "4;31"
|
||||||
|
e_key = "1;23;38;5;197"
|
||||||
|
|
||||||
|
[chars]
|
||||||
|
# hb = "─"
|
||||||
|
# vb = "│"
|
||||||
|
# ctl = "┌"
|
||||||
|
# ctr = "┐"
|
||||||
|
# cbl = "└"
|
||||||
|
# cbr = "┘"
|
||||||
|
|
||||||
|
[functions]
|
||||||
|
# poweroff = F1
|
||||||
|
# reboot = F2
|
||||||
|
# refresh = F5
|
||||||
|
|
||||||
|
[strings]
|
||||||
|
# f_poweroff = "poweroff"
|
||||||
|
# f_reboot = "reboot"
|
||||||
|
# f_refresh = "refresh"
|
||||||
|
# e_user = "user"
|
||||||
|
# e_passwd = "password"
|
||||||
|
# s_wayland = "wayland"
|
||||||
|
# s_xorg = "xorg"
|
||||||
|
# s_shell = "shell"
|
||||||
|
# opts_pre = "< "
|
||||||
|
# opts_post = " >"
|
||||||
|
|
||||||
|
[behavior]
|
||||||
|
# include_defshell = true
|
||||||
|
# timefmt = "%X %x"
|
||||||
|
source = "/etc/lidm.env"
|
||||||
|
source = "/etc/locale.conf"
|
||||||
|
user_source = ".lidm.env"
|
47
themes/default.ini
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
[colors]
|
||||||
|
# bg = "48;2;38;28;28"
|
||||||
|
# fg = "22;24;38;2;245;245;245"
|
||||||
|
# err = "1;31"
|
||||||
|
# s_wayland = "38;2;255;174;66"
|
||||||
|
# s_xorg = "38;2;37;175;255"
|
||||||
|
# s_shell = "38;2;34;140;34"
|
||||||
|
# e_hostname = "38;2;255;64;64"
|
||||||
|
# e_date = "38;2;144;144;144"
|
||||||
|
# e_box = "38;2;122;122;122"
|
||||||
|
# e_header = "4;38;2;0;255;0"
|
||||||
|
# e_user = "36"
|
||||||
|
# e_passwd = "4;38;2;245;245;205"
|
||||||
|
# e_badpasswd = "3;4;31"
|
||||||
|
# e_key = "38;2;255;174;66"
|
||||||
|
|
||||||
|
[chars]
|
||||||
|
# hb = "─"
|
||||||
|
# vb = "│"
|
||||||
|
# ctl = "┌"
|
||||||
|
# ctr = "┐"
|
||||||
|
# cbl = "└"
|
||||||
|
# cbr = "┘"
|
||||||
|
|
||||||
|
[functions]
|
||||||
|
# poweroff = F1
|
||||||
|
# reboot = F2
|
||||||
|
# refresh = F5
|
||||||
|
|
||||||
|
[strings]
|
||||||
|
# f_poweroff = "poweroff"
|
||||||
|
# f_reboot = "reboot"
|
||||||
|
# f_refresh = "refresh"
|
||||||
|
# e_user = "user"
|
||||||
|
# e_passwd = "password"
|
||||||
|
# s_wayland = "wayland"
|
||||||
|
# s_xorg = "xorg"
|
||||||
|
# s_shell = "shell"
|
||||||
|
# opts_pre = "< "
|
||||||
|
# opts_post = " >"
|
||||||
|
|
||||||
|
[behavior]
|
||||||
|
# include_defshell = true
|
||||||
|
# timefmt = "%X %x"
|
||||||
|
source = "/etc/lidm.env"
|
||||||
|
source = "/etc/locale.conf"
|
||||||
|
user_source = ".lidm.env"
|
47
themes/kanagawa-dragon.ini
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
[colors]
|
||||||
|
bg = "48;2;24;22;22"
|
||||||
|
fg = "22;24;38;2;185;185;185"
|
||||||
|
# err = "1;31"
|
||||||
|
# s_wayland = "38;2;255;174;66"
|
||||||
|
# s_xorg = "38;2;37;175;255"
|
||||||
|
# s_shell = "38;2;34;140;34"
|
||||||
|
e_hostname = "38;2;208;189;156"
|
||||||
|
e_date = "38;2;144;144;144"
|
||||||
|
# e_box = "38;2;122;122;122"
|
||||||
|
e_header = "4;38;2;126;146;178"
|
||||||
|
e_user = "38;2;148;89;84"
|
||||||
|
# e_passwd = "4;38;2;245;245;205"
|
||||||
|
# e_badpasswd = "3;4;31"
|
||||||
|
# e_key = "38;2;255;174;66"
|
||||||
|
|
||||||
|
[chars]
|
||||||
|
# hb = "─"
|
||||||
|
# vb = "│"
|
||||||
|
# ctl = "┌"
|
||||||
|
# ctr = "┐"
|
||||||
|
# cbl = "└"
|
||||||
|
# cbr = "┘"
|
||||||
|
|
||||||
|
[functions]
|
||||||
|
# poweroff = F1
|
||||||
|
# reboot = F2
|
||||||
|
# refresh = F5
|
||||||
|
|
||||||
|
[strings]
|
||||||
|
# f_poweroff = "poweroff"
|
||||||
|
# f_reboot = "reboot"
|
||||||
|
# f_refresh = "refresh"
|
||||||
|
# e_user = "user"
|
||||||
|
# e_passwd = "password"
|
||||||
|
# s_wayland = "wayland"
|
||||||
|
# s_xorg = "xorg"
|
||||||
|
# s_shell = "shell"
|
||||||
|
# opts_pre = "< "
|
||||||
|
# opts_post = " >"
|
||||||
|
|
||||||
|
[behavior]
|
||||||
|
# include_defshell = true
|
||||||
|
timefmt = "%Y-%m-%d %H:%M:%S"
|
||||||
|
source = "/etc/lidm.env"
|
||||||
|
source = "/etc/locale.conf"
|
||||||
|
user_source = ".lidm.env"
|
47
themes/kanagawa-wave.ini
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
[colors]
|
||||||
|
bg = "48;2;28;28;36"
|
||||||
|
fg = "22;24;38;2;168;168;168"
|
||||||
|
# err = "1;31"
|
||||||
|
# s_wayland = "38;2;255;174;66"
|
||||||
|
# s_xorg = "38;2;37;175;255"
|
||||||
|
# s_shell = "38;2;34;140;34"
|
||||||
|
e_hostname = "38;2;196;165;112"
|
||||||
|
e_date = "38;2;144;144;144"
|
||||||
|
# e_box = "38;2;122;122;122"
|
||||||
|
e_header = "4;38;2;114;133;162"
|
||||||
|
e_user = "38;2;211;137;88"
|
||||||
|
# e_passwd = "4;38;2;245;245;205"
|
||||||
|
# e_badpasswd = "3;4;31"
|
||||||
|
# e_key = "38;2;255;174;66"
|
||||||
|
|
||||||
|
[chars]
|
||||||
|
# hb = "─"
|
||||||
|
# vb = "│"
|
||||||
|
# ctl = "┌"
|
||||||
|
# ctr = "┐"
|
||||||
|
# cbl = "└"
|
||||||
|
# cbr = "┘"
|
||||||
|
|
||||||
|
[functions]
|
||||||
|
# poweroff = F1
|
||||||
|
# reboot = F2
|
||||||
|
# refresh = F5
|
||||||
|
|
||||||
|
[strings]
|
||||||
|
# f_poweroff = "poweroff"
|
||||||
|
# f_reboot = "reboot"
|
||||||
|
# f_refresh = "refresh"
|
||||||
|
# e_user = "user"
|
||||||
|
# e_passwd = "password"
|
||||||
|
# s_wayland = "wayland"
|
||||||
|
# s_xorg = "xorg"
|
||||||
|
# s_shell = "shell"
|
||||||
|
# opts_pre = "< "
|
||||||
|
# opts_post = " >"
|
||||||
|
|
||||||
|
[behavior]
|
||||||
|
# include_defshell = true
|
||||||
|
timefmt = "%Y-%m-%d %H:%M:%S"
|
||||||
|
source = "/etc/lidm.env"
|
||||||
|
source = "/etc/locale.conf"
|
||||||
|
user_source = ".lidm.env"
|
48
themes/minimal.ini
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
[colors]
|
||||||
|
# bg = "48;2;38;28;28"
|
||||||
|
# fg = "22;24;38;2;245;245;245"
|
||||||
|
# err = "1;31"
|
||||||
|
# s_wayland = "38;2;255;174;66"
|
||||||
|
# s_xorg = "38;2;37;175;255"
|
||||||
|
# s_shell = "38;2;34;140;34"
|
||||||
|
# e_hostname = "38;2;255;64;64"
|
||||||
|
# e_date = "38;2;144;144;144"
|
||||||
|
# e_box = "38;2;122;122;122"
|
||||||
|
e_header = "38;2;0;255;0"
|
||||||
|
# e_user = "36"
|
||||||
|
# e_passwd = "4;38;2;245;245;205"
|
||||||
|
# e_badpasswd = "3;4;31"
|
||||||
|
# e_key = "38;2;255;174;66"
|
||||||
|
|
||||||
|
[chars]
|
||||||
|
hb = " "
|
||||||
|
vb = " "
|
||||||
|
ctl = " "
|
||||||
|
ctr = " "
|
||||||
|
cbl = " "
|
||||||
|
cbr = " "
|
||||||
|
|
||||||
|
[functions]
|
||||||
|
# poweroff = F1
|
||||||
|
# reboot = F2
|
||||||
|
# refresh = F5
|
||||||
|
|
||||||
|
# EXCLUSIVE TO NERD FONTS
|
||||||
|
[strings]
|
||||||
|
f_poweroff = "\xef\x80\x91 "
|
||||||
|
f_reboot = "\xee\xab\x92 "
|
||||||
|
f_refresh = "\xf3\xb0\x91\x93 "
|
||||||
|
e_user = "\xee\xb4\xb5"
|
||||||
|
e_passwd = "\xef\x80\xa3"
|
||||||
|
s_wayland = "W"
|
||||||
|
s_xorg = "X"
|
||||||
|
s_shell = "$"
|
||||||
|
# opts_pre = "< "
|
||||||
|
# opts_post = " >"
|
||||||
|
|
||||||
|
[behavior]
|
||||||
|
# include_defshell = true
|
||||||
|
timefmt = "\xef\x80\x97 %X \xef\x84\xb3 %x"
|
||||||
|
source = "/etc/lidm.env"
|
||||||
|
source = "/etc/locale.conf"
|
||||||
|
user_source = ".lidm.env"
|
47
themes/nature.ini
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
[colors]
|
||||||
|
bg = "48;2;15;22;15"
|
||||||
|
fg = "22;23;24;38;2;245;245;245"
|
||||||
|
# err = "1;31"
|
||||||
|
# s_wayland = "38;2;255;174;66"
|
||||||
|
# s_xorg = "38;2;37;175;255"
|
||||||
|
s_shell = "32"
|
||||||
|
e_hostname = "38;5;28"
|
||||||
|
e_date = "32"
|
||||||
|
e_box = "32"
|
||||||
|
e_header = "1;4;32"
|
||||||
|
e_user = "38;5;51"
|
||||||
|
e_passwd = "4;2;38;5;83"
|
||||||
|
e_badpasswd = "3;4;31"
|
||||||
|
e_key = "32"
|
||||||
|
|
||||||
|
[chars]
|
||||||
|
# hb = "─"
|
||||||
|
# vb = "│"
|
||||||
|
# ctl = "┌"
|
||||||
|
# ctr = "┐"
|
||||||
|
# cbl = "└"
|
||||||
|
# cbr = "┘"
|
||||||
|
|
||||||
|
[functions]
|
||||||
|
# poweroff = F1
|
||||||
|
# reboot = F2
|
||||||
|
# refresh = F5
|
||||||
|
|
||||||
|
[strings]
|
||||||
|
# f_poweroff = "poweroff"
|
||||||
|
# f_reboot = "reboot"
|
||||||
|
# f_refresh = "refresh"
|
||||||
|
# e_user = "user"
|
||||||
|
# e_passwd = "password"
|
||||||
|
# s_wayland = "wayland"
|
||||||
|
# s_xorg = "xorg"
|
||||||
|
# s_shell = "shell"
|
||||||
|
# opts_pre = "< "
|
||||||
|
# opts_post = " >"
|
||||||
|
|
||||||
|
[behavior]
|
||||||
|
# include_defshell = true
|
||||||
|
timefmt = "%Y-%m-%d %H:%M:%S"
|
||||||
|
source = "/etc/lidm.env"
|
||||||
|
source = "/etc/locale.conf"
|
||||||
|
user_source = ".lidm.env"
|
47
themes/nord.ini
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
[colors]
|
||||||
|
bg = "48;2;19;19;22"
|
||||||
|
fg = "22;24;38;2;245;245;245"
|
||||||
|
# err = "1;31"
|
||||||
|
# s_wayland = "38;2;255;174;66"
|
||||||
|
# s_xorg = "38;2;37;175;255"
|
||||||
|
s_shell = "32"
|
||||||
|
e_hostname = "34"
|
||||||
|
e_date = "38;2;66;66;88"
|
||||||
|
# e_box = "38;2;122;122;122"
|
||||||
|
e_header = "1;4;36"
|
||||||
|
e_user = "38;5;51"
|
||||||
|
e_passwd = "4;2;38;5;80"
|
||||||
|
# e_badpasswd = "3;4;31"
|
||||||
|
e_key = "34"
|
||||||
|
|
||||||
|
[chars]
|
||||||
|
# hb = "─"
|
||||||
|
# vb = "│"
|
||||||
|
# ctl = "┌"
|
||||||
|
# ctr = "┐"
|
||||||
|
# cbl = "└"
|
||||||
|
# cbr = "┘"
|
||||||
|
|
||||||
|
[functions]
|
||||||
|
# poweroff = F1
|
||||||
|
# reboot = F2
|
||||||
|
# refresh = F5
|
||||||
|
|
||||||
|
[strings]
|
||||||
|
# f_poweroff = "poweroff"
|
||||||
|
# f_reboot = "reboot"
|
||||||
|
# f_refresh = "refresh"
|
||||||
|
# e_user = "user"
|
||||||
|
# e_passwd = "password"
|
||||||
|
# s_wayland = "wayland"
|
||||||
|
# s_xorg = "xorg"
|
||||||
|
# s_shell = "shell"
|
||||||
|
# opts_pre = "< "
|
||||||
|
# opts_post = " >"
|
||||||
|
|
||||||
|
[behavior]
|
||||||
|
# include_defshell = true
|
||||||
|
timefmt = "%Y-%m-%d %H:%M:%S"
|
||||||
|
source = "/etc/lidm.env"
|
||||||
|
source = "/etc/locale.conf"
|
||||||
|
user_source = ".lidm.env"
|
49
themes/nothing.ini
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
[colors]
|
||||||
|
# the '-' makes '\x1b[-m' which usually does nothing
|
||||||
|
bg = "-"
|
||||||
|
# you can even break out of the '\x1b...m' context like do, I wouldn't though
|
||||||
|
fg = "24;39m\x1b[?25l\x1b[-"
|
||||||
|
err = "-"
|
||||||
|
s_wayland = "-"
|
||||||
|
s_xorg = "-"
|
||||||
|
s_shell = "-"
|
||||||
|
e_hostname = "-"
|
||||||
|
e_date = "30"
|
||||||
|
e_box = "-"
|
||||||
|
e_header = "30"
|
||||||
|
e_user = "-"
|
||||||
|
e_passwd = "24;30"
|
||||||
|
e_badpasswd = "-"
|
||||||
|
e_key = "-"
|
||||||
|
|
||||||
|
[chars]
|
||||||
|
hb = " "
|
||||||
|
vb = " "
|
||||||
|
ctl = " "
|
||||||
|
ctr = " "
|
||||||
|
cbl = " "
|
||||||
|
cbr = " "
|
||||||
|
|
||||||
|
[functions]
|
||||||
|
# poweroff = F1
|
||||||
|
# reboot = F2
|
||||||
|
# refresh = F5
|
||||||
|
|
||||||
|
[strings]
|
||||||
|
# f_poweroff = "poweroff"
|
||||||
|
# f_reboot = "reboot"
|
||||||
|
# f_refresh = "refresh"
|
||||||
|
e_user = ""
|
||||||
|
e_passwd = ""
|
||||||
|
s_wayland = ""
|
||||||
|
s_xorg = ""
|
||||||
|
s_shell = ""
|
||||||
|
# opts_pre = "< "
|
||||||
|
# opts_post = " >"
|
||||||
|
|
||||||
|
[behavior]
|
||||||
|
# include_defshell = true
|
||||||
|
timefmt = " "
|
||||||
|
source = "/etc/lidm.env"
|
||||||
|
source = "/etc/locale.conf"
|
||||||
|
user_source = ".lidm.env"
|
47
themes/old-blue.ini
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
[colors]
|
||||||
|
bg = "48;2;0;0;255"
|
||||||
|
fg = "22;24;39;48;2;0;0;255"
|
||||||
|
# err = "1;31"
|
||||||
|
# s_wayland = "38;2;255;174;66"
|
||||||
|
# s_xorg = "38;2;37;175;255"
|
||||||
|
# s_shell = "38;2;34;140;34"
|
||||||
|
# e_hostname = "38;2;255;64;64"
|
||||||
|
e_date = "38;2;144;144;144"
|
||||||
|
e_box = "34"
|
||||||
|
e_header = "4;38;2;0;255;0"
|
||||||
|
e_user = "36"
|
||||||
|
e_passwd = "4;38;2;245;245;205"
|
||||||
|
# e_badpasswd = "3;4;31"
|
||||||
|
e_key = "1;31;48;2;255;174;66"
|
||||||
|
|
||||||
|
[chars]
|
||||||
|
hb = "█"
|
||||||
|
vb = "█"
|
||||||
|
ctl = "█"
|
||||||
|
ctr = "█"
|
||||||
|
cbl = "█"
|
||||||
|
cbr = "█"
|
||||||
|
|
||||||
|
[functions]
|
||||||
|
# poweroff = F1
|
||||||
|
# reboot = F2
|
||||||
|
# refresh = F5
|
||||||
|
|
||||||
|
[strings]
|
||||||
|
f_poweroff = "powewoff"
|
||||||
|
f_reboot = "rewoot"
|
||||||
|
f_refresh = "rewresh"
|
||||||
|
e_user = "wuser"
|
||||||
|
e_passwd = "passwd"
|
||||||
|
s_wayland = "waywand"
|
||||||
|
s_xorg = "xworg"
|
||||||
|
s_shell = "swell"
|
||||||
|
# opts_pre = "< "
|
||||||
|
# opts_post = " >"
|
||||||
|
|
||||||
|
[behavior]
|
||||||
|
# include_defshell = true
|
||||||
|
timefmt = "%Y-%m-%d %H:%M:%S"
|
||||||
|
source = "/etc/lidm.env"
|
||||||
|
source = "/etc/locale.conf"
|
||||||
|
user_source = ".lidm.env"
|
BIN
themes/screenshots/cherry.png
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
themes/screenshots/default.png
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
themes/screenshots/kanagawa-dragon.png
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
themes/screenshots/kanagawa-wave.png
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
themes/screenshots/minimal.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
themes/screenshots/nature.png
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
themes/screenshots/nord.png
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
themes/screenshots/nothing.png
Normal file
After Width: | Height: | Size: 9.9 KiB |
BIN
themes/screenshots/old-blue.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
themes/screenshots/tasteless.png
Normal file
After Width: | Height: | Size: 13 KiB |