mirror of
https://github.com/javalsai/lidm.git
synced 2026-02-27 20:10:44 +01:00
Compare commits
227 Commits
v0.1.0
...
actions/up
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f14eff273e | ||
|
15b8089e37
|
|||
|
|
dd6760127c | ||
|
|
8e9a222908 | ||
|
502d749df6
|
|||
| 0b2d0bdf03 | |||
| c009c6c31c | |||
| 6de3996cf0 | |||
|
|
dba9a719d5 | ||
|
|
bdad1fa3f8 | ||
|
|
a84d83ab29 | ||
| aa2feb3462 | |||
| 978aaad199 | |||
| 9cf5297205 | |||
| 7e7a297e2e | |||
|
|
d65bd7a8ee | ||
|
|
728611aa19 | ||
|
|
4eca2b056f | ||
|
|
a7a1f42f0a | ||
|
|
feeba5c41b | ||
|
ddc38ef27f
|
|||
|
|
b3c8d3cbea | ||
| 5761838112 | |||
|
363deeab28
|
|||
|
|
98b898fc08 | ||
|
|
6b4b64d3fc | ||
|
7e1ec83c7f
|
|||
| 8f0213db74 | |||
| 4a1b868b8e | |||
|
|
589f33ffec | ||
|
|
8fc6bff60f | ||
| 6c99675be7 | |||
|
663b882f34
|
|||
|
|
cd5a3ede52 | ||
|
|
3f264a66b9 | ||
|
ecf254bf7f
|
|||
|
57fedc9fd5
|
|||
|
3d993c6260
|
|||
| ba3c15b0f4 | |||
| 54953a18e8 | |||
|
a22c6b4597
|
|||
|
ab7666f561
|
|||
|
f0ef834eaa
|
|||
|
d85ebc0e78
|
|||
|
4611ad87a8
|
|||
|
3625aa9426
|
|||
|
fcc8be77ee
|
|||
|
2f2a2c2696
|
|||
|
9af69c2417
|
|||
|
16901b14c8
|
|||
| 2574ef4ac0 | |||
|
689c962cc9
|
|||
|
be6e039a9b
|
|||
|
6cac2f91ed
|
|||
|
ee244be195
|
|||
|
b580b6917b
|
|||
|
22c75a37e1
|
|||
|
3ad16d3a3c
|
|||
|
df6a565874
|
|||
| 310b0a87dc | |||
|
6384a94f61
|
|||
|
56e8897565
|
|||
|
f67e30991a
|
|||
|
|
e8a9e57af9 | ||
|
31c3ad6d42
|
|||
|
a00a73756c
|
|||
|
|
51c12eefdc | ||
| f678056c5b | |||
|
3a7bd6f9f5
|
|||
| 5207e1e94b | |||
|
|
69d48d32d6 | ||
|
7f75b8edce
|
|||
|
75fc3c139b
|
|||
| ec41c6f70e | |||
|
65bbb7d1b4
|
|||
| 9fe938b96a | |||
|
5f7e412408
|
|||
|
335459e127
|
|||
|
c05218d30a
|
|||
|
3d6efa448b
|
|||
|
f3ae85bb94
|
|||
|
521a7c295e
|
|||
|
d1b993c32a
|
|||
|
7cd976f916
|
|||
|
240bdbede6
|
|||
|
e4b11f9a30
|
|||
|
736e816509
|
|||
|
3fb74ece44
|
|||
|
19a1355b06
|
|||
|
9c022c5813
|
|||
|
a316afecb2
|
|||
|
5a6471dd00
|
|||
|
9084dfdcda
|
|||
|
5b5adf76b7
|
|||
|
ba836e5cd4
|
|||
| 981aa4efc7 | |||
|
9f905622a2
|
|||
|
|
3ec1eec56f | ||
|
|
9245d38ecf | ||
|
|
afd23657c0 | ||
| 92d3351292 | |||
|
|
f5445248d3 | ||
|
|
68ed11fb2d | ||
| bae810eb99 | |||
|
|
4c955053e8 | ||
| 3bfc2f52f3 | |||
|
59acddf652
|
|||
|
6c6769b2b3
|
|||
|
99e27dd0c0
|
|||
|
|
b653fdcc57 | ||
|
|
d7b5f4f090 | ||
| 4b6d113bdb | |||
|
|
4fa400eb06 | ||
| 11e9257c4a | |||
| 7d7cf10600 | |||
|
64e088884d
|
|||
|
bceb13b844
|
|||
|
|
d5a708ec4a | ||
|
|
f0e962ad50 | ||
|
|
16d1325f96 | ||
|
|
8b8784a210 | ||
|
|
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
|
@@ -1,2 +1,11 @@
|
||||
BasedOnStyle: LLVM
|
||||
BasedOnStyle: Chromium
|
||||
IndentWidth: 2
|
||||
SpacesBeforeTrailingComments: 1
|
||||
AllowShortIfStatementsOnASingleLine: WithoutElse
|
||||
|
||||
AlignAfterOpenBracket: Align
|
||||
BinPackParameters: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: true
|
||||
|
||||
IndentPPDirectives: BeforeHash
|
||||
IndentGotoLabels: true
|
||||
|
||||
49
.clang-tidy
Normal file
49
.clang-tidy
Normal file
@@ -0,0 +1,49 @@
|
||||
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-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-naming.EnumCase
|
||||
value: "CamelCase"
|
||||
- key: readability-identifier-naming.FunctionCase
|
||||
value: "lower_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"
|
||||
@@ -1,2 +1,2 @@
|
||||
[codespell]
|
||||
skip = ./assets/pkg/aur/*/src
|
||||
skip = ./assets/pkg/aur/*/src,./assets/pkg/aur/*/*/objects,./assets/pkg/aur/*/*.tar.*
|
||||
|
||||
2
.gitattributes
vendored
Normal file
2
.gitattributes
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
*.gif filter=lfs diff=lfs merge=lfs -text
|
||||
*.png filter=lfs diff=lfs merge=lfs -text
|
||||
162
.github/workflows/build.yml
vendored
Normal file
162
.github/workflows/build.yml
vendored
Normal file
@@ -0,0 +1,162 @@
|
||||
name: Build
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
|
||||
jobs:
|
||||
build-linux-amd64:
|
||||
name: amd64
|
||||
runs-on: ubuntu-24.04
|
||||
permissions: write-all
|
||||
steps:
|
||||
- uses: awalsh128/cache-apt-pkgs-action@latest
|
||||
with:
|
||||
packages: "git libpam0g-dev"
|
||||
version: 1.0
|
||||
- uses: actions/checkout@v4
|
||||
- id: build
|
||||
run: ARCH=amd64 assets/github_scripts/build.sh
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: build-amd64
|
||||
path: lidm-amd64
|
||||
retention-days: 1
|
||||
|
||||
build-linux-i386:
|
||||
name: i386
|
||||
runs-on: ubuntu-24.04
|
||||
permissions: write-all
|
||||
|
||||
steps:
|
||||
- uses: awalsh128/cache-apt-pkgs-action@latest
|
||||
with:
|
||||
packages: "git libpam0g-dev gcc-multilib"
|
||||
version: 1.0
|
||||
- uses: actions/checkout@v4
|
||||
- run: |
|
||||
sudo dpkg --add-architecture i386
|
||||
sudo apt-get update -y
|
||||
sudo apt-get install -y libpam0g-dev:i386
|
||||
|
||||
- id: build
|
||||
run: ARCH=i386 assets/github_scripts/build.sh CFLAGS="-O3 -Wall -m32"
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: build-i386
|
||||
path: lidm-i386
|
||||
retention-days: 1
|
||||
|
||||
build-linux-aarch64:
|
||||
name: aarch64
|
||||
runs-on: ubuntu-24.04
|
||||
permissions: write-all
|
||||
steps:
|
||||
- uses: awalsh128/cache-apt-pkgs-action@latest
|
||||
with:
|
||||
packages: "git"
|
||||
version: 1.0
|
||||
- uses: actions/checkout@v4
|
||||
- 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: ARCH=aarch64 GITHUB_STEP_SUMMARY=gss.out GITHUB_OUTPUT=go.out assets/github_scripts/build.sh
|
||||
- if: always()
|
||||
run: set +e; cat gss.out >>"$GITHUB_STEP_SUMMARY"; cat go.out >>"$GITHUB_OUTPUT"
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: build-aarch64
|
||||
path: lidm-aarch64
|
||||
retention-days: 1
|
||||
|
||||
build-linux-armv7:
|
||||
name: armv7
|
||||
runs-on: ubuntu-24.04
|
||||
permissions: write-all
|
||||
steps:
|
||||
- uses: awalsh128/cache-apt-pkgs-action@latest
|
||||
with:
|
||||
packages: "git"
|
||||
version: 1.0
|
||||
- uses: actions/checkout@v4
|
||||
- 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: ARCH=armv7 GITHUB_STEP_SUMMARY=gss.out GITHUB_OUTPUT=go.out assets/github_scripts/build.sh
|
||||
- if: always()
|
||||
run: set +e; cat gss.out >>"$GITHUB_STEP_SUMMARY"; cat go.out >>"$GITHUB_OUTPUT"
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: build-armv7
|
||||
path: lidm-armv7
|
||||
retention-days: 1
|
||||
|
||||
build-linux-riscv64:
|
||||
name: riscv64
|
||||
runs-on: ubuntu-24.04
|
||||
permissions: write-all
|
||||
steps:
|
||||
- uses: awalsh128/cache-apt-pkgs-action@latest
|
||||
with:
|
||||
packages: "git"
|
||||
version: 1.0
|
||||
- uses: actions/checkout@v4
|
||||
- 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: ARCH=riscv64 GITHUB_STEP_SUMMARY=gss.out GITHUB_OUTPUT=go.out assets/github_scripts/build.sh
|
||||
- if: always()
|
||||
run: set +e; cat gss.out >>"$GITHUB_STEP_SUMMARY"; cat go.out >>"$GITHUB_OUTPUT"
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: build-riscv64
|
||||
path: lidm-riscv64
|
||||
retention-days: 1
|
||||
|
||||
# This build job is only symbolic, the behavior of the packaged Void Linux version may differ.
|
||||
build-linux-amd64-musl:
|
||||
name: amd64-musl
|
||||
runs-on: ubuntu-24.04
|
||||
permissions: write-all
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Run in Musl Container
|
||||
uses: addnab/docker-run-action@v3
|
||||
with:
|
||||
image: ghcr.io/void-linux/void-musl-full
|
||||
options: -v ${{ github.workspace }}:/workspace
|
||||
run: |
|
||||
cd /workspace
|
||||
|
||||
xbps-install -Syu xbps && xbps-install -yu
|
||||
xbps-install -y git pam-devel make gcc bash git
|
||||
|
||||
ARCH=amd64-musl GITHUB_STEP_SUMMARY=gss.out GITHUB_OUTPUT=go.out assets/github_scripts/build.sh
|
||||
- if: always()
|
||||
run: set +e; cat gss.out >>"$GITHUB_STEP_SUMMARY"; cat go.out >>"$GITHUB_OUTPUT"
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: build-amd64-musl
|
||||
path: lidm-amd64-musl
|
||||
retention-days: 1
|
||||
259
.github/workflows/check-and-build.yml
vendored
259
.github/workflows/check-and-build.yml
vendored
@@ -1,259 +0,0 @@
|
||||
name: Check and Build
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
set-statuses:
|
||||
required: false
|
||||
default: true
|
||||
type: boolean
|
||||
|
||||
jobs:
|
||||
spellcheck:
|
||||
name: Check Grammar
|
||||
runs-on: ubuntu-24.04
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: awalsh128/cache-apt-pkgs-action@latest
|
||||
with:
|
||||
packages: "codespell"
|
||||
version: 1.0
|
||||
- run: codespell
|
||||
|
||||
shellcheck:
|
||||
name: Shell Check
|
||||
runs-on: ubuntu-24.04
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: awalsh128/cache-apt-pkgs-action@latest
|
||||
with:
|
||||
packages: "shellcheck"
|
||||
version: 1.0
|
||||
- run: find . -type f -name '*.sh' -not -path './assets/pkg/aur/*/src/*' | xargs shellcheck
|
||||
|
||||
clangcheck:
|
||||
name: Chang Check
|
||||
runs-on: ubuntu-24.04
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: awalsh128/cache-apt-pkgs-action@latest
|
||||
with:
|
||||
packages: "clang-format clang-tidy"
|
||||
version: 1.0
|
||||
- run: clang-format -ni src/*.c include/*.h
|
||||
# TODO: include when the errors/warnings are bearable
|
||||
#- run: clang-tidy src/*.c include/*.h
|
||||
|
||||
build-linux-amd64:
|
||||
name: Build for amd64
|
||||
runs-on: ubuntu-24.04
|
||||
permissions: write-all
|
||||
needs: [spellcheck, shellcheck, clangcheck]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: awalsh128/cache-apt-pkgs-action@latest
|
||||
with:
|
||||
packages: "libpam0g-dev"
|
||||
version: 1.0
|
||||
- id: build
|
||||
run: |
|
||||
make -j$(nproc) 2> /tmp/stderr
|
||||
cat /tmp/stderr >&2
|
||||
|
||||
HSIZE="$(stat --printf="%s" lidm | numfmt --to=iec-i)B"
|
||||
WARNS="$(cat /tmp/stderr | grep '^[^ ]*\.[ch]:' | wc -l)"
|
||||
mv lidm lidm-amd64
|
||||
|
||||
echo "DESCR='$HSIZE, $WARNS warnings'" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- uses: myrotvorets/set-commit-status-action@master
|
||||
if: inputs.set-statuses
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
status: ${{ job.status }}
|
||||
description: ${{ steps.build.outputs.DESCR }}
|
||||
context: Build for amd64
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: build-amd64
|
||||
path: lidm-amd64
|
||||
retention-days: 1
|
||||
|
||||
build-linux-i386:
|
||||
name: Build for i386
|
||||
runs-on: ubuntu-24.04
|
||||
permissions: write-all
|
||||
needs: [spellcheck, shellcheck, clangcheck]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: awalsh128/cache-apt-pkgs-action@latest
|
||||
with:
|
||||
packages: "libpam0g-dev gcc-multilib"
|
||||
version: 1.0
|
||||
- run: |
|
||||
sudo dpkg --add-architecture i386
|
||||
sudo apt-get update -y
|
||||
sudo apt-get install -y libpam0g-dev:i386
|
||||
|
||||
- id: build
|
||||
run: |
|
||||
make -j$(nproc) CFLAGS="-O3 -Wall -m32" 2> /tmp/stderr
|
||||
cat /tmp/stderr >&2
|
||||
|
||||
HSIZE="$(stat --printf="%s" lidm | numfmt --to=iec-i)B"
|
||||
WARNS="$(cat /tmp/stderr | grep '^[^ ]*\.[ch]:' | wc -l)"
|
||||
mv lidm lidm-i386
|
||||
|
||||
echo "DESCR='$HSIZE, $WARNS warnings'" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- uses: myrotvorets/set-commit-status-action@master
|
||||
if: inputs.set-statuses
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
status: ${{ job.status }}
|
||||
description: ${{ steps.build.outputs.DESCR }}
|
||||
context: Build for i386
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: build-i386
|
||||
path: lidm-i386
|
||||
retention-days: 1
|
||||
|
||||
build-linux-aarch64:
|
||||
name: Build for aarch64
|
||||
runs-on: ubuntu-24.04
|
||||
permissions: write-all
|
||||
needs: [spellcheck, shellcheck, clangcheck]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: uraimo/run-on-arch-action@v2
|
||||
with:
|
||||
arch: 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
|
||||
|
||||
cat /tmp/stderr >&2
|
||||
mv lidm lidm-aarch64
|
||||
|
||||
- if: inputs.set-statuses
|
||||
id: status
|
||||
run: |
|
||||
HSIZE="$(stat --printf="%s" lidm-aarch64 | numfmt --to=iec-i)B"
|
||||
WARNS="$(cat /tmp/stderr | grep '^[^ ]*\.[ch]:' | wc -l)"
|
||||
|
||||
echo "DESCR='$HSIZE, $WARNS warnings'" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- uses: myrotvorets/set-commit-status-action@master
|
||||
if: inputs.set-statuses
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
status: ${{ job.status }}
|
||||
description: ${{ steps.status.outputs.DESCR }}
|
||||
context: Build for aarch64
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: build-aarch64
|
||||
path: lidm-aarch64
|
||||
retention-days: 1
|
||||
|
||||
build-linux-armv7:
|
||||
name: Build for armv7
|
||||
runs-on: ubuntu-24.04
|
||||
permissions: write-all
|
||||
needs: [spellcheck, shellcheck, clangcheck]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: uraimo/run-on-arch-action@v2
|
||||
with:
|
||||
arch: 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
|
||||
|
||||
cat /tmp/stderr >&2
|
||||
mv lidm lidm-armv7
|
||||
|
||||
- if: inputs.set-statuses
|
||||
id: status
|
||||
run: |
|
||||
HSIZE="$(stat --printf="%s" lidm-armv7 | numfmt --to=iec-i)B"
|
||||
WARNS="$(cat /tmp/stderr | grep '^[^ ]*\.[ch]:' | wc -l)"
|
||||
|
||||
echo "DESCR='$HSIZE, $WARNS warnings'" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- uses: myrotvorets/set-commit-status-action@master
|
||||
if: inputs.set-statuses
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
status: ${{ job.status }}
|
||||
description: ${{ steps.status.outputs.DESCR }}
|
||||
context: Build for armv7
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: build-armv7
|
||||
path: lidm-armv7
|
||||
retention-days: 1
|
||||
|
||||
build-linux-riscv64:
|
||||
name: Build for riscv64
|
||||
runs-on: ubuntu-24.04
|
||||
permissions: write-all
|
||||
needs: [spellcheck, shellcheck, clangcheck]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: uraimo/run-on-arch-action@v2
|
||||
with:
|
||||
arch: 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
|
||||
|
||||
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
|
||||
51
.github/workflows/check.yml
vendored
Normal file
51
.github/workflows/check.yml
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
name: Check
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
|
||||
jobs:
|
||||
spellcheck:
|
||||
name: 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: Shellcheck
|
||||
runs-on: ubuntu-24.04
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: awalsh128/cache-apt-pkgs-action@latest
|
||||
with:
|
||||
packages: "shellcheck"
|
||||
version: 1.0
|
||||
- run: git ls-files "*.sh" "*/PKGBUILD" | xargs shellcheck --shell=bash
|
||||
|
||||
clangcheck:
|
||||
name: Clang
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ubuntu:25.04
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- run: apt -y update && apt install -y clang-format clang-tidy make gcc git bear libpam0g-dev
|
||||
|
||||
- run: bear -- make
|
||||
- run: clang-format -version && clang-format -dump-config
|
||||
- run: |
|
||||
set -euo pipefail
|
||||
clang-format -ni src/*.c include/*.h -Werror 2>&1 | \
|
||||
sed -E 's/^([^ ]+\.[ch]):([0-9]+):([0-9]+): ([a-z]+): (.*)$/::\4 file=\1,line=\2,col=\3::\5/'
|
||||
- run: clang-tidy -version && clang-tidy -dump-config
|
||||
- run: |
|
||||
set -euo pipefail
|
||||
clang-tidy -p . src/*.c include/*.h -warnings-as-errors=\* 2>&1 1>/dev/null |
|
||||
sed -E 's/^([^ ]+\.[ch]):([0-9]+):([0-9]+): ([a-z]+): (.*)$/::\4 file=\1,line=\2,col=\3::\5/'
|
||||
99
.github/workflows/make-release.yml
vendored
99
.github/workflows/make-release.yml
vendored
@@ -1,26 +1,55 @@
|
||||
name: Check and Build Release
|
||||
name: Make 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 }}
|
||||
release-checks:
|
||||
name: Release Checks
|
||||
runs-on: ubuntu-24.04
|
||||
permissions: write-all
|
||||
needs: build
|
||||
outputs:
|
||||
VERSION: ${{ steps.check-ver-changed.outputs.VERSION }}
|
||||
steps:
|
||||
- uses: awalsh128/cache-apt-pkgs-action@latest
|
||||
with:
|
||||
packages: "git"
|
||||
version: 1.0
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-tags: true
|
||||
|
||||
- name: Check Version Changed
|
||||
id: check-ver-changed
|
||||
run: |
|
||||
GIT_TAG=$(git describe --no-long --abbrev=0 --tags --always)
|
||||
MAKE_TAG=$(make print-version)
|
||||
|
||||
if [[ "$GIT_TAG" == "v$MAKE_TAG" ]]; then
|
||||
echo "ERR: Git tag matches makefile, did you bump Makefile up?" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "VERSION=$MAKE_TAG" >> "$GITHUB_OUTPUT"
|
||||
|
||||
|
||||
check:
|
||||
name: Check
|
||||
needs: release-checks
|
||||
uses: ./.github/workflows/check.yml
|
||||
permissions: write-all
|
||||
|
||||
build:
|
||||
name: Build
|
||||
needs: release-checks
|
||||
uses: ./.github/workflows/build.yml
|
||||
permissions: write-all
|
||||
|
||||
release:
|
||||
name: Make Release v${{ needs.release-checks.outputs.VERSION }}
|
||||
runs-on: ubuntu-24.04
|
||||
permissions: write-all
|
||||
needs: [ release-checks, check, build ]
|
||||
steps:
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
@@ -30,10 +59,42 @@ jobs:
|
||||
|
||||
- uses: ncipollo/release-action@v1
|
||||
with:
|
||||
tag: v${{ inputs.version }}
|
||||
tag: v${{ needs.release-checks.outputs.VERSION }}
|
||||
commit: ${{ github.sha }}
|
||||
artifacts: builds/lidm-*
|
||||
artifactsErrorsFailBuild: true
|
||||
artifactErrorsFailBuild: true
|
||||
body: Release notes not generated yet.
|
||||
|
||||
# TODO: get checksums and commit new AUR pkgbuilds
|
||||
nix-update:
|
||||
name: Update NixOS module
|
||||
runs-on: ubuntu-24.04
|
||||
permissions: write-all
|
||||
needs: [ release-checks, release ]
|
||||
steps:
|
||||
- uses: cachix/install-nix-action@v31
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-tags: true
|
||||
|
||||
- run: |
|
||||
tmpdir=$(mktemp -d)
|
||||
git archive v${{ needs.release-checks.outputs.VERSION }} | tar -xC "$tmpdir"
|
||||
sha256sum=$(nix hash path "$tmpdir")
|
||||
|
||||
sed -i -E 's/(.*version\s*=\s*")[0-9.]*(".*)/\1'${{ needs.release-checks.outputs.VERSION }}'\2/' assets/pkg/nix/module.nix
|
||||
sed -i -E 's|(.*sha256\s*=\s*")[^"]*(".*)|\1'"$sha256sum"'\2|' assets/pkg/nix/module.nix
|
||||
# would be cool to be able to check the new module.nix builds
|
||||
|
||||
- run: |
|
||||
BRANCH=actions/update-nix-${{ needs.release-checks.outputs.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 NixOS module to v${{ needs.release-checks.outputs.VERSION }}"
|
||||
git push -u origin $BRANCH
|
||||
gh pr create --head $BRANCH \
|
||||
--title "[Nix update]: Bump to ${{ needs.release-checks.outputs.VERSION }}" \
|
||||
--body "*This PR was created automatically*"
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
|
||||
35
.github/workflows/push.yml
vendored
35
.github/workflows/push.yml
vendored
@@ -1,10 +1,35 @@
|
||||
name: Push Checks
|
||||
name: _
|
||||
|
||||
on:
|
||||
push
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
check-and-build:
|
||||
name: Check and Build
|
||||
uses: ./.github/workflows/check-and-build.yml
|
||||
check:
|
||||
name: Check
|
||||
uses: ./.github/workflows/check.yml
|
||||
permissions: write-all
|
||||
check_paths:
|
||||
name: Paths Filter
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
code_changed: ${{ steps.filter.outputs.code }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- id: filter
|
||||
uses: dorny/paths-filter@v3
|
||||
with:
|
||||
filters: |
|
||||
code:
|
||||
- Makefile
|
||||
- 'src/**'
|
||||
- 'include/**'
|
||||
build:
|
||||
name: Build
|
||||
needs: check_paths
|
||||
if: github.event_name != 'push' || needs.check_paths.outputs.code_changed == 'true'
|
||||
uses: ./.github/workflows/build.yml
|
||||
permissions: write-all
|
||||
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -3,6 +3,8 @@ dist/
|
||||
/compile_commands.json
|
||||
|
||||
.cache/
|
||||
# just in case, i dont wanna rebase ever again
|
||||
valgrind-out.txt
|
||||
|
||||
# nix build result
|
||||
result
|
||||
|
||||
23
CHANGELOG.md
Normal file
23
CHANGELOG.md
Normal file
@@ -0,0 +1,23 @@
|
||||
<!-- Unspecified dates shall be in CET/CEST -->
|
||||
|
||||
<!-- Add only very relevant changes, bottom to top -->
|
||||
<!-- By "very relevant" I mean big features or something manual packagers should know, like leftover files -->
|
||||
<!-- Once a release would be opened, group the last bunch of dangling changes, add release version as header and its date -->
|
||||
|
||||
# 2.0.2
|
||||
|
||||
- fix off-by-one error with launch state save
|
||||
|
||||
# 2.0.1
|
||||
|
||||
- source and header files can be nested in `src/` and `include/`
|
||||
- lidm now calls bash for logging in and sourcing profile files, other shells can be configured
|
||||
- a good PATH default is fetched from `confstr`
|
||||
- debug logs are now unbuffered
|
||||
|
||||
# 2.0.0
|
||||
|
||||
- Most stuff (most of `/etc` being a notable exception) now installs to `/usr/local` by default, check [`docs/PACKAGERS.md`](./docs/PACKAGERS.md).
|
||||
- Added a changelog.
|
||||
- Finally add proper (experimental) xorg support.
|
||||
- Systemd service install path changed to `/usr/local/lib/systemd`, there could be a leftover file at `/etc/systemd/system/lidm.service`.
|
||||
69
INSTALL.md
69
INSTALL.md
@@ -1,69 +0,0 @@
|
||||
# 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
|
||||
102
Makefile
102
Makefile
@@ -1,75 +1,71 @@
|
||||
CDIR=src
|
||||
LDIR=lib
|
||||
IDIR=include
|
||||
ODIR=dist
|
||||
VERSION := 2.0.2
|
||||
.DEFAULT_GOAL := lidm
|
||||
|
||||
PREFIX=/usr
|
||||
CDIR = src
|
||||
LDIR = lib
|
||||
IDIR = include
|
||||
ODIR = dist
|
||||
|
||||
CC?=gcc
|
||||
CFLAGS?=-O3 -Wall
|
||||
_CFLAGS=-I$(DIR)
|
||||
ALLFLAGS=$(CFLAGS) -I$(IDIR)
|
||||
PREFIX = /usr/local
|
||||
|
||||
LIBS=-lm -lpam -lpam_misc
|
||||
INFO_GIT_REV ?= $(shell git describe --long --tags --always || echo '?')
|
||||
INFO_GIT_REV := $(INFO_GIT_REV)
|
||||
INFO_BUILD_TS ?= $(shell date +%s)
|
||||
INFO_BUILD_TS := $(INFO_BUILD_TS)
|
||||
|
||||
_DEPS = util.h ui.h config.h auth.h efield.h keys.h users.h sessions.h chvt.h
|
||||
DEPS = $(patsubst %,$(IDIR)/%,$(_DEPS))
|
||||
CFLAGS ?= -O3 -Wall -Wextra -fdata-sections -ffunction-sections
|
||||
# C PreProcessor flags, not C Plus Plus
|
||||
CPPFLAGS ?=
|
||||
_DFLAGS?= \
|
||||
-DLIDM_VERSION=\"$(VERSION)\" \
|
||||
-DLIDM_GIT_REV=\"$(INFO_GIT_REV)\" \
|
||||
-DLIDM_BUILD_TS=$(INFO_BUILD_TS)
|
||||
ALLFLAGS = $(_DFLAGS) $(CFLAGS) $(CPPFLAGS) -I$(IDIR)
|
||||
LDFLAGS ?= -Wl,--gc-sections
|
||||
|
||||
_OBJ = main.o util.o ui.o config.o auth.o efield.o users.o sessions.o chvt.o
|
||||
OBJ = $(patsubst %,$(ODIR)/%,$(_OBJ))
|
||||
LIBS = -lpam
|
||||
|
||||
# includes all headers in `$(IDIR)` and compiles everything in `$(CDIR)`
|
||||
DEPS = $(wildcard $(IDIR)/*.h $(IDIR)/**/*.h)
|
||||
_SOURCES = $(wildcard $(CDIR)/*.c) $(wildcard $(CDIR)/**/*.c)
|
||||
OBJ = $(patsubst $(CDIR)/%.c,$(ODIR)/%.o,$(_SOURCES))
|
||||
|
||||
$(ODIR)/%.o: $(CDIR)/%.c $(DEPS)
|
||||
@mkdir -p $(ODIR)
|
||||
@mkdir -p $(dir $@)
|
||||
$(CC) -c -o $@ $< $(ALLFLAGS)
|
||||
|
||||
lidm: $(OBJ)
|
||||
$(CC) -o $@ $^ $(ALLFLAGS) $(LIBS)
|
||||
$(CC) -o $@ $^ $(ALLFLAGS) $(LIBS) $(LDFLAGS)
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -f $(ODIR)/*.o lidm
|
||||
rm -rf $(ODIR) lidm
|
||||
|
||||
# Copy lidm to ${DESTDIR}${PREFIX}/bin (/usr/bin)
|
||||
install: lidm
|
||||
mkdir -p ${DESTDIR}${PREFIX}/bin ${DESTDIR}${PREFIX}/share/man/man{1,5}
|
||||
install -Dm755 ./lidm ${DESTDIR}${PREFIX}/bin/
|
||||
install -Dm644 ./themes/default.ini ${DESTDIR}/etc/lidm.ini
|
||||
[ -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/
|
||||
gzip -f ${DESTDIR}${PREFIX}/share/man/man{1/lidm.1,5/lidm-config.5}
|
||||
|
||||
uninstall:
|
||||
uninstall: uninstall-service
|
||||
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
|
||||
rm -rf ${DESTDIR}${PREFIX}/share/man/man{1/lidm.1,5/lidm-config.5}.gz
|
||||
|
||||
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
|
||||
include services.mk
|
||||
|
||||
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
|
||||
prettier -c "**/*.md"
|
||||
git ls-files "*.sh" "*/PKGBUILD" | xargs shellcheck --shell=bash
|
||||
clang-format -i $$(git ls-files "*.c" "*.h")
|
||||
git ls-files -z "*.c" "*.h" | \
|
||||
parallel -j$$(nproc) -q0 --no-notice --will-cite --tty clang-tidy -warnings-as-errors=\* --quiet |& \
|
||||
grep -v "warnings generated." || true
|
||||
|
||||
print-version:
|
||||
@echo $(VERSION)
|
||||
|
||||
.PHONY: clean \
|
||||
install uninstall \
|
||||
pre-commit \
|
||||
print-version
|
||||
|
||||
147
README.md
147
README.md
@@ -4,45 +4,41 @@
|
||||
|
||||
# LiDM
|
||||
|
||||
LiDM is a really light UI portion a unix [login manager](https://en.wikipedia.org/wiki/Login_manager) made in C, highly customizable and held together by hopes and prayers 🙏.
|
||||
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 🙏.
|
||||
|
||||
LiDM is like any [X Display Manager](https://en.wikipedia.org/wiki/X_display_manager) you have seen such as SDDM or GDM but without using X org graphics, instead being a purely [text based interface](https://en.wikipedia.org/wiki/Text-based_user_interface).
|
||||
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.
|
||||
|
||||

|
||||
|
||||
> *shown as in a featured terminal emulator, actual linux console doesn't support as much color and decorations*
|
||||
<blockquote><details>
|
||||
<summary><i>
|
||||
shown as in a featured terminal emulator, actual linux console doesn't support as much color and decorations
|
||||
</i></summary>
|
||||
|
||||
> *however, all colors and strings are fully customizable*
|
||||
If you want to add fancy color and font support to your TTYs you can try wrapping lidm in [`kmscon`](https://wiki.archlinux.org/title/KMSCON). (edit appropriate service files). e.g:
|
||||
|
||||
```sh
|
||||
kmscon -l --vt /dev/tty7 --font-name "Cascadia Code" -- /usr/bin/lidm
|
||||
```
|
||||
|
||||
Kmscon is NOT officially supported so you are on your own when trying this, [according to the arch wiki](https://wiki.archlinux.org/title/KMSCON#Window_managers_cannot_be_started_from_KMS_console) it's not possible to start window managers if you do this.
|
||||
|
||||
But [according to farouk](https://github.com/javalsai/lidm/issues/91#issuecomment-3708503568) you can make it work if you tell kmscon to work in `no-drm` mode. There's still input grabbing issues which cause <kbd><kbd>Ctrl</kbd> + <kbd>C</kbd></kbd> to kill lidm, they are likely fixable though.
|
||||
|
||||
</details></blockquote>
|
||||
|
||||
> _however, all colors and strings are fully customizable_
|
||||
|
||||
## Features
|
||||
|
||||
* Builds **FAST**.
|
||||
* `a32e4a5`:
|
||||
* `2.830s`: laptop, -O3, -j2, `AMD E-450 APU with Radeon(tm) HD Graphics`
|
||||
* `0.172s`: desktop, -O3, -j12, `AMD Ryzen 5 5600G with Radeon Graphics`
|
||||
* `663427e`:
|
||||
* `0.085s`: desktop, -O0, `AMD Ryzen 5 5600G with Radeon Graphics`
|
||||
* `0.009s`: desktop, -O0, CC=tcc, `AMD Ryzen 5 5600G with Radeon Graphics`
|
||||
* Works everywhere you can get gcc to compile.
|
||||
* Fast and possibly efficient.
|
||||
* Fully customizable, from strings, including action keys, to colors (I hope you know ansi escape codes)
|
||||
* Automatically detects xorg and wayland sessions, plus allowing to launch the default user shell (if enabled in config)
|
||||
* Starts with many init systems (systemd, dinit, runit, openrc and s6).
|
||||
- Simple as C, meant to depend only on standard libc and basic unix system headers.
|
||||
- Fully customizable: ALL strings, colors (with its ANSI keys) and most behavior.
|
||||
- Experimental Xorg support[\*](https://github.com/javalsai/lidm/pull/80?#issuecomment-3764073217) and wayland sessions, while supporting the default user shell (if enabled in config)
|
||||
- Init agnostinc (systemd, dinit, runit, openrc and s6).
|
||||
- Supports [fido yubikeys](./docs/yubikey.md) (via pam_u2f).
|
||||
|
||||
## WIP
|
||||
# Table of Contents
|
||||
|
||||
* Desktop's file `TryExec` key.
|
||||
* Save last selection.
|
||||
* Show/hide passwd switch.
|
||||
* Long sessions, strings, usernames, passwords... they will just overflow or fuck your terminal, I know it and I don't know if I'll fix it.
|
||||
* UTF characters or any multi-byte character, not yet supported properly, everything treats characters as a single byte, some chars might work or not depending on the context, but it's not designed to.
|
||||
|
||||
# Index
|
||||
|
||||
- [LiDM](#lidm)
|
||||
- [Features](#features)
|
||||
- [WIP](#wip)
|
||||
- [Index](#index)
|
||||
- [Ideology](#ideology)
|
||||
- [Usage](#usage)
|
||||
- [Arguments](#arguments)
|
||||
@@ -50,8 +46,10 @@ LiDM is like any [X Display Manager](https://en.wikipedia.org/wiki/X_display_man
|
||||
- [Requirements](#requirements)
|
||||
- [Installation](#installation)
|
||||
- [Configuring](#configuring)
|
||||
- [PAM](#pam)
|
||||
- [Contributing](#contributing)
|
||||
- [Backstory](#backstory)
|
||||
- [License](#license)
|
||||
- [Inspiration](#inspiration)
|
||||
- [Contributors](#contributors)
|
||||
|
||||
# Ideology
|
||||
@@ -60,66 +58,97 @@ We all know that the most important thing in a project is the ideology of the au
|
||||
|
||||
[  ](https://stopchatcontrol.eu)
|
||||
|
||||
> *there's also a [change.org post](https://www.change.org/p/stoppt-die-chatkontrolle-grundrechte-gelten-auch-im-netz).*
|
||||
> _there's also a [change.org post](https://www.change.org/p/stoppt-die-chatkontrolle-grundrechte-gelten-auch-im-netz)._
|
||||
|
||||
# Usage
|
||||
|
||||
### Arguments
|
||||
|
||||
If a single argument is provided (don't even do `--` or standard parsing...), it passes that argument to `chvt` on startup, used (at least) by most service files.
|
||||
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
|
||||
|
||||
On top of pure intuition:
|
||||
Base (mostly intuitive):
|
||||
|
||||
* 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.
|
||||
- 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
|
||||
|
||||
* A computer with unix based system.
|
||||
* That system should have the resources necessary for this program to make sense (Sessions, users...).
|
||||
* A compiler (optional, you can compile by hand, but I doubt you want to see the code).
|
||||
* Make (Also optional, but does things automatically, make sure `gcc` and `mkdir -p` work as expected).
|
||||
* PAM, used for user authentication, just what `login` or `su` use internally. Don't worry, it's surely pre-installed.
|
||||
- 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
|
||||
|
||||
Check the [installation guide](./INSTALL.md) to use your preferred installation source.
|
||||
Check the [installation guide](./docs/INSTALL.md) to use your preferred installation source.
|
||||
|
||||
<details>
|
||||
|
||||
<summary>Packagers read here!!</summary>
|
||||
|
||||
If you are a package maintainer or are willing to become one, please read [the packagers guide](./docs/PACKAGERS.md).
|
||||
|
||||
</details>
|
||||
|
||||
# Configuring
|
||||
|
||||
Copy any `.ini` file from [`themes/`](./themes/) (`default.ini` will always be updated) to `/etc/lidm.ini` and/or configure it to your liking. Also, don't place empty lines (for now). You can also set `LIDM_CONF` environment variable to specify a config path.
|
||||
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.
|
||||
|
||||
Configured colors are just gonna be put inside `\x1b[...m`, ofc you can add an 'm' to break this and this can f\*ck up really bad or even make some nice UI effect possible, you should also be able to embed the `\x1b` byte in the config as I won't parse escape codes, I think that the parser is just gonna grab anything in the config file from the space after the `=` (yes, I'ma enforce that space, get good taste if you don't like it) until the newline, you can put any abomination in there. But please, keep in mind this might break easily.
|
||||
The format attempts to mimic the TOML format. Escape sequences like `\x1b` are allowed as well as comments and empty lines.
|
||||
|
||||
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).
|
||||
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.
|
||||
|
||||
# PAM
|
||||
|
||||
If your distribution does not use the standard PAM service name `login` (`/etc/pam.d/login`) for its PAM services or if you want to use another PAM file, simply set the `LIDM_PAM_SERVICE` env variable to your PAM service name.
|
||||
|
||||
When the env variable is empty it defaults to the `login` PAM service or whatever fallback your distribution packager has defined during compilation.
|
||||
|
||||
# Contributing
|
||||
|
||||
If you want to contribute check the [CONTRIBUTING.md](docs/CONTRIBUTING.md)
|
||||
If you want to contribute check the [contribution guide](docs/CONTRIBUTING.md).
|
||||
|
||||
# Backstory
|
||||
# License
|
||||
|
||||
Summer travelling to visit family with an old laptop that barely supports x86\_64, and ly recently added some avx2 instructions I think (invalid op codes), manually building (any previous commit too) didn't work because of something in the `build.zig` file, so out of boredom I decided to craft up my own simple display manager on the only language this thing can handle... **C** (I hate this and reserve the right for the rust rewrite, actually solid).
|
||||
This project is licensed under the GNU General Public License v3.0 **only**.
|
||||
|
||||
I spedrun it in roughly 3 days and I'm bad af in C, so this is spaghetti code on **another** level. I think it doesn't do almost anything unsafe, I mean, I didn't check allocations and it's capable of reallocating memory until your username uses all memory, crashing the system due to a off-by-one error, but pretty consistent otherwise (probably).
|
||||
# Inspiration
|
||||
|
||||
The name is just ly but changing "y" with "i", that had a reason but forgot it, (maybe the i in *simple*), so I remembered this sh\*tty laptop with a lid, this thing is also a display manager (dm, ly command is also `ly-dm`), so just did lidm due to all that.
|
||||
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
|
||||
|
||||
[](https://github.com/javalsai/lidm/graphs/contributors)
|
||||
[](https://github.com/javalsai/lidm/graphs/contributors)
|
||||
|
||||
* KillerTofus, [made the AUR package](https://github.com/javalsai/lidm/pull/2)! Saved me from reading the Arch Wiki 💀.
|
||||
* DeaDvey, the most awesomest of all, did some pretty HARDCORE gramer checking. (and trolling, he wrote that, 33 commits of just readme changes ffs)
|
||||
* grialion, made a simple C implementation of `chvt` instead of insecurely relying on `kbd utils`'s command.
|
||||
* cerealexperiments\_, found a missing newline (had the guts to read the source code, crazy ik)
|
||||
* ChatGPT, in times of slow laptops where pages take ages to load, a single tab connected to a bunch of burning cloud GPUs feeding corporate hype is all you need to get quick answers for your questions, as long as you know how to filter AI crap ofc.
|
||||
* [My lack of gf](https://www.instagram.com/reel/C8sa3Gltmtq), can't imagine this project being possible if somebody actually cared about me daily.
|
||||
[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)
|
||||
|
||||
With their big or small contributions, every commit has helped in its own way and encouraged me to keep putting my soul into this.
|
||||
|
||||
---
|
||||
|
||||
🌟 Finally, consider starring this repo [or...](https://www.reddit.com/r/github/comments/1l2mchg/is_this_allowed) 🔪
|
||||
|
||||

|
||||
|
||||
48
assets/github_scripts/build.sh
Executable file
48
assets/github_scripts/build.sh
Executable file
@@ -0,0 +1,48 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
if [ -z "$ARCH" ]; then
|
||||
echo "\$ARCH not present" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ERR=0
|
||||
# shellcheck disable=SC2034
|
||||
make -j"$(nproc)" "$@" 2> /tmp/stderr || ERR=$?
|
||||
|
||||
BSIZE=$(stat --printf="%s" lidm)
|
||||
HSIZE=$(numfmt --to=iec-i<<<"$BSIZE")B
|
||||
WARNS=$(
|
||||
sed -nE \
|
||||
's/^([^ ]+\.[ch]):([0-9]+):([0-9]+): ([a-z]+): (.*)$/::\4 file=\1,line=\2,col=\3::\5/p' \
|
||||
/tmp/stderr
|
||||
)
|
||||
WARNS_NUM=$({ [[ "$WARNS" == "" ]] && echo 0; } || wc -l <<<"$WARNS")
|
||||
|
||||
echo "$WARNS"
|
||||
|
||||
{
|
||||
echo "# Build for $ARCH"
|
||||
echo ""
|
||||
if [ -s "/tmp/stderr" ]; then
|
||||
echo "<details><summary><code>stderr</code></summary>"
|
||||
echo ""
|
||||
echo "\`\`\`"
|
||||
cat "/tmp/stderr"
|
||||
echo "\`\`\`"
|
||||
echo ""
|
||||
echo "</details>"
|
||||
else
|
||||
echo "*no \`stderr\` to show*"
|
||||
fi
|
||||
echo ""
|
||||
echo "## Stats"
|
||||
echo "* **Filesize:** $HSIZE ($BSIZE B)"
|
||||
echo "* **Warnings & Errors:** $WARNS_NUM"
|
||||
} >> "$GITHUB_STEP_SUMMARY"
|
||||
|
||||
if [ "$ERR" -ne 0 ]; then exit "$ERR"; fi
|
||||
|
||||
mv lidm lidm-"$ARCH"
|
||||
|
||||
echo "DESCR='$HSIZE, $WARNS_NUM warnings'" >> "$GITHUB_OUTPUT"
|
||||
@@ -10,70 +10,105 @@ lidm-config \- Configuration file syntax for lidm
|
||||
\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.
|
||||
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 config parser is very primitive still, so the file only consists of \fBkey/value\fP pairs separated by \fB' = '\fP (yes, the surrounding spaces are necessary). It will also not warn if the config is invalid.
|
||||
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.
|
||||
|
||||
You can't escape characters with \fB'\\'\fP, but the program reads until the end of line, so you can put any raw bytes there.
|
||||
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
|
||||
Similar keys are grouped together to keep this as short as possible.
|
||||
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 keys under this section are always wrapped inside ansi sequences (\fB\\x1b[...m\fP).
|
||||
.SS colors
|
||||
All these values are of type \fBSTRING\fP.
|
||||
.TP
|
||||
\fBcolors.bd, colors.fg, colors.err\fP
|
||||
\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
|
||||
\fBcolors.s_wayland, colors.s_xorg, colors.s_shell\fP
|
||||
\fBs_wayland, s_xorg, s_shell\fP
|
||||
Coloring for sessions of such types (Wayland, X.org, Shells)
|
||||
.TP
|
||||
.TP
|
||||
\fBcolors.e_hostname, colors.e_date, colors.e_box\fP
|
||||
\fBe_hostname, e_date, e_box\fP
|
||||
Coloring for the hostname, date and box elements.
|
||||
.TP
|
||||
\fBcolors.e_header\fP
|
||||
\fB.e_header\fP
|
||||
Coloring for heading elements (left column)
|
||||
.TP
|
||||
\fBcolors.e_user, colors.e_passwd, colors.e_badpasswd\fP
|
||||
\fBe_user, e_passwd, e_badpasswd\fP
|
||||
Coloring for the user element, password and bad padssword.
|
||||
.TP
|
||||
\fBcolors.e_key\fP
|
||||
\fBe_key\fP
|
||||
Coloring for key elements (eg: F1, F2, CTRL...)
|
||||
|
||||
.SS
|
||||
Single characters used for some elements (can be longer than a character, but it will likely break UI)
|
||||
.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
|
||||
\fBchars.hb, chars.vb\fP
|
||||
\fBhb, vb\fP
|
||||
Character for the horizontal bar (hb) and vertical bar (vb).
|
||||
.TP
|
||||
\fBchars.ctl, chars.ctr, chars.cbl, chars.cbr\fP
|
||||
\fBctl, ctr, cbl, cbr\fP
|
||||
Characters for the corners of the box (ctl = corner top left, cbr = corner bottom right)
|
||||
|
||||
.SS Functions
|
||||
.SS functions
|
||||
All these are of type \fBKEY\fP.
|
||||
.TP
|
||||
\fBfunctions.poweroff, functions.reboot, functions.refresh\fP
|
||||
\fBpoweroff, reboot, fido, refresh\fP
|
||||
Function key to use for such action.
|
||||
|
||||
.SS String
|
||||
Strings to use for some elements.
|
||||
.SS strings
|
||||
Display strings to use for some elements.
|
||||
.TP
|
||||
\fBstrings.f_poweroff, strings.f_reboot, strings.f_refresh\fP
|
||||
Text displayed to name such functions.
|
||||
\fBf_poweroff, f_reboot, f_fido, f_refresh\fP
|
||||
Text displayed to name such functions at the bottom of the screen.
|
||||
.TP
|
||||
\fBstrings.e_user, strings.e_passwd\fP
|
||||
\fBe_user, e_passwd\fP
|
||||
Text to display for these element headers.
|
||||
.TP
|
||||
\fBstrings.s_wayland, strings.s_xorg, strings.s_shell\fP
|
||||
\fBs_wayland, s_xorg, s_shell\fP
|
||||
Text to display as the header for such sessions.
|
||||
|
||||
.SS Behavior
|
||||
.TP
|
||||
\fBbehavior.include_defshell\fP
|
||||
"true"/"false" (invalid input defaults to false), if true, includes the user default shell as a session to launch
|
||||
\fBopts_pre, opts_post\fP
|
||||
To be used for items with multiple options on the left and right sides \fB"< "\fP and \fB" >"\fP.
|
||||
.TP
|
||||
\fBellipsis\fP
|
||||
Ellipsis to be used in multiple parts such as overflowing hostnames.
|
||||
|
||||
.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.
|
||||
.TP
|
||||
\fBrefresh_rate\fP
|
||||
Rate (in milliseconds) at which the UI should refresh, affects clock and resize behavior.
|
||||
.TP
|
||||
\fBbypass_shell_login\fP
|
||||
Type \fBBOOL\fP, lidm logins through a login shell (e.g. `bash`) in login mode (e.g. `arg0` being `-bash`) to load `/etc/profile/, `/etc/profile.d/` and more. If this option is enabled that's bypassed entirely.
|
||||
|
||||
|
||||
.SH "SEE ALSO"
|
||||
.BR lidm (1)
|
||||
.BR strftime (3)
|
||||
|
||||
@@ -23,6 +23,9 @@ TTY to switch to, does not mean that it will run in it.
|
||||
.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
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 148 KiB After Width: | Height: | Size: 131 B |
4
assets/pkg/aur/.gitignore
vendored
4
assets/pkg/aur/.gitignore
vendored
@@ -1,4 +0,0 @@
|
||||
*/*
|
||||
!*/.gitignore
|
||||
!*/PKGBUILD
|
||||
!*/.SRCINFO
|
||||
@@ -1,12 +0,0 @@
|
||||
# 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).
|
||||
@@ -1,21 +0,0 @@
|
||||
pkgbase = lidm-bin
|
||||
pkgdesc = A fully colorful customizable TUI display manager made in C. (release binary)
|
||||
pkgver = 0.0.2
|
||||
pkgrel = 1
|
||||
url = https://github.com/javalsai/lidm
|
||||
arch = x86_64
|
||||
license = GPL
|
||||
makedepends = gzip
|
||||
depends = pam
|
||||
provides = lidm
|
||||
conflicts = lidm
|
||||
source = lidm::https://github.com/javalsai/lidm/releases/download/0.0.2/lidm-x86_64
|
||||
source = default-theme.ini::https://raw.githubusercontent.com/javalsai/lidm/0.0.2/themes/default.ini
|
||||
source = lidm.1::https://raw.githubusercontent.com/javalsai/lidm/0.0.2/assets/man/lidm.1
|
||||
source = lidm-config.5::https://raw.githubusercontent.com/javalsai/lidm/0.0.2/assets/man/lidm-config.5
|
||||
sha256sums = b5d1dbdaa6b78da57be69ce5e2cc3366717a045de3cb316e66c1c3f36b796ee0
|
||||
sha256sums = 27db9b0cd2da80c0c60dcb13dfad0f9d65e7dddbb7b344b859803b9ac3943cd7
|
||||
sha256sums = SKIP
|
||||
sha256sums = SKIP
|
||||
|
||||
pkgname = lidm-bin
|
||||
3
assets/pkg/aur/lidm-bin/.gitignore
vendored
3
assets/pkg/aur/lidm-bin/.gitignore
vendored
@@ -1,3 +0,0 @@
|
||||
*
|
||||
!PKGBUILD
|
||||
!.SRCINFO
|
||||
@@ -1,32 +0,0 @@
|
||||
# Maintainer: javalsai <javalsai@proton.me>
|
||||
pkgname=lidm-bin
|
||||
pkgver=0.0.2
|
||||
pkgrel=1
|
||||
depends=('pam')
|
||||
makedepends=('gzip')
|
||||
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/$pkgver/lidm-$arch"
|
||||
"default-theme.ini::https://raw.githubusercontent.com/javalsai/lidm/$pkgver/themes/default.ini"
|
||||
"lidm.1::https://raw.githubusercontent.com/javalsai/lidm/$pkgver/assets/man/lidm.1"
|
||||
"lidm-config.5::https://raw.githubusercontent.com/javalsai/lidm/$pkgver/assets/man/lidm-config.5"
|
||||
)
|
||||
sha256sums=(
|
||||
'b5d1dbdaa6b78da57be69ce5e2cc3366717a045de3cb316e66c1c3f36b796ee0'
|
||||
'27db9b0cd2da80c0c60dcb13dfad0f9d65e7dddbb7b344b859803b9ac3943cd7'
|
||||
'SKIP'
|
||||
'SKIP'
|
||||
)
|
||||
|
||||
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/"
|
||||
install -Dm644 lidm-config.5 "${pkgdir}/usr/share/man/man5/"
|
||||
gzip -f "${pkgdir}"/share/man/man{1/lidm.1,5/lidm-config.5}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
pkgbase = lidm-git
|
||||
pkgdesc = A fully colorful customizable TUI display manager made in C. (last git commit)
|
||||
pkgver = 0.0.2.r37.gf1f9d6b
|
||||
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
3
assets/pkg/aur/lidm-git/.gitignore
vendored
@@ -1,3 +0,0 @@
|
||||
*
|
||||
!PKGBUILD
|
||||
!.SRCINFO
|
||||
@@ -1,30 +0,0 @@
|
||||
# Maintainer: javalsai <javalsai@proton.me>
|
||||
pkgname=lidm-git
|
||||
pkgver=0.0.2.r37.gf1f9d6b
|
||||
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}"
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
pkgbase = lidm
|
||||
pkgdesc = A fully colorful customizable TUI display manager made in C. (build latest tag)
|
||||
pkgver = 0.0.2
|
||||
pkgrel = 1
|
||||
url = https://github.com/javalsai/lidm
|
||||
arch = any
|
||||
license = GPL
|
||||
makedepends = git
|
||||
makedepends = make
|
||||
makedepends = gcc
|
||||
makedepends = gzip
|
||||
depends = pam
|
||||
source = tarball.tar.gz::https://github.com/javalsai/lidm/archive/refs/tags/0.0.2.tar.gz
|
||||
sha256sums = adf2d196969f6a2df8ceeb3564e1d51cc377f0deaeca31fee0bace58a3d2df2d
|
||||
|
||||
pkgname = lidm
|
||||
3
assets/pkg/aur/lidm/.gitignore
vendored
3
assets/pkg/aur/lidm/.gitignore
vendored
@@ -1,3 +0,0 @@
|
||||
*
|
||||
!PKGBUILD
|
||||
!.SRCINFO
|
||||
@@ -1,24 +0,0 @@
|
||||
# Maintainer: javalsai <javalsai@proton.me>
|
||||
pkgname=lidm
|
||||
pkgver=0.0.2
|
||||
pkgrel=1
|
||||
depends=('pam')
|
||||
makedepends=('git' 'make' 'gcc' 'gzip')
|
||||
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/$pkgver.tar.gz")
|
||||
sha256sums=('adf2d196969f6a2df8ceeb3564e1d51cc377f0deaeca31fee0bace58a3d2df2d')
|
||||
|
||||
build() {
|
||||
tar -xzf "tarball.tar.gz"
|
||||
cd "lidm-$pkgver"
|
||||
|
||||
make CFLAGS="-O3"
|
||||
}
|
||||
|
||||
package() {
|
||||
cd "lidm-$pkgver"
|
||||
make install DESTDIR="${pkgdir}"
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
#!/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
|
||||
@@ -1,15 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
MYSELF=$(realpath "$0")
|
||||
MYDIR=$(dirname "$MYSELF")
|
||||
|
||||
for pkg in "$MYDIR"/*/; do
|
||||
cd "$pkg"
|
||||
printf "\x1b[1mEntering '%s'\x1b[0m\n" "$pkg"
|
||||
|
||||
rm -rf ./*.{gz,zst} src pkg
|
||||
makepkg -f .
|
||||
|
||||
echo
|
||||
done
|
||||
23
assets/pkg/nix/get-cfg-file.nix
Normal file
23
assets/pkg/nix/get-cfg-file.nix
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
cfg,
|
||||
src,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
let
|
||||
maker = import ./make-cfg.nix {
|
||||
inherit lib;
|
||||
keys-h-file = builtins.readFile "${src}/include/keys.h";
|
||||
};
|
||||
in
|
||||
{
|
||||
inherit maker;
|
||||
file = builtins.toFile "lidm.conf" (
|
||||
if builtins.isString cfg then
|
||||
builtins.readFile "${src}/themes/${cfg}.ini"
|
||||
else if builtins.isAttrs cfg then
|
||||
maker.make cfg
|
||||
else
|
||||
builtins.throw "invalid cfg type, expected str or attrs"
|
||||
);
|
||||
}
|
||||
50
assets/pkg/nix/lidm.nix
Normal file
50
assets/pkg/nix/lidm.nix
Normal file
@@ -0,0 +1,50 @@
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
let
|
||||
get-cfg =
|
||||
if config.cfg != null then
|
||||
import ./get-cfg-file.nix {
|
||||
inherit lib;
|
||||
inherit (config) cfg src;
|
||||
}
|
||||
else
|
||||
null;
|
||||
cfg-file = get-cfg.file;
|
||||
maker = get-cfg.maker;
|
||||
in
|
||||
pkgs.stdenv.mkDerivation rec {
|
||||
pname = "lidm";
|
||||
version = config.version;
|
||||
src = config.src;
|
||||
|
||||
nativeBuildInputs = with pkgs; [
|
||||
gcc
|
||||
gnumake
|
||||
linux-pam
|
||||
];
|
||||
|
||||
makeFlags =
|
||||
[
|
||||
"DESTDIR=$(out)"
|
||||
"PREFIX="
|
||||
]
|
||||
++ lib.optional (
|
||||
config.xsessions != null
|
||||
) "CPPFLAGS+=-DSESSIONS_XSESSIONS=\\\"${config.xsessions}\\\""
|
||||
++ lib.optional (
|
||||
config.wayland-sessions != null
|
||||
) "CPPFLAGS+=-DSESSIONS_WAYLAND=\\\"${config.wayland-sessions}\\\""
|
||||
++ lib.optional (cfg-file != null) "CPPFLAGS+=-DLIDM_CONF_PATH=\\\"${cfg-file}\\\"";
|
||||
|
||||
fixupPhase = ''
|
||||
rm -rf $out/etc
|
||||
'';
|
||||
|
||||
passthru = {
|
||||
keysEnum = maker.keys-enum;
|
||||
};
|
||||
}
|
||||
73
assets/pkg/nix/make-cfg.nix
Normal file
73
assets/pkg/nix/make-cfg.nix
Normal file
@@ -0,0 +1,73 @@
|
||||
{ lib, keys-h-file }:
|
||||
|
||||
let
|
||||
double-match-to-nameval = dmatch: {
|
||||
name = builtins.elemAt dmatch 0;
|
||||
value = builtins.elemAt dmatch 1;
|
||||
};
|
||||
|
||||
keys-enum =
|
||||
let
|
||||
key-names = builtins.replaceStrings [ "\n" " " ] [ "" "" ] (
|
||||
builtins.elemAt (builtins.match ".*KEY_NAMES\\[][[:blank:]]*=[[:blank:]]*\\{([^}]*)}.*" keys-h-file) 0
|
||||
);
|
||||
|
||||
keys-2d-list = builtins.map (builtins.match "\\[(.*)]=\"(.*)\"") (
|
||||
builtins.filter (s: builtins.isString s && s != "") (builtins.split "," key-names)
|
||||
);
|
||||
|
||||
in
|
||||
builtins.listToAttrs (
|
||||
builtins.map (
|
||||
k:
|
||||
k
|
||||
// {
|
||||
value = {
|
||||
__enum_key = k.value;
|
||||
};
|
||||
}
|
||||
) (builtins.map double-match-to-nameval keys-2d-list)
|
||||
);
|
||||
in
|
||||
{
|
||||
inherit keys-enum;
|
||||
make =
|
||||
let
|
||||
name-val-to-attrs = (name: value: { inherit name value; });
|
||||
map-attrs = attrset: fn: lib.map fn (lib.attrsets.mapAttrsToList name-val-to-attrs attrset);
|
||||
|
||||
try-foldl' =
|
||||
op: nul: list:
|
||||
if (builtins.length list) == 0 then "" else builtins.foldl' op nul list;
|
||||
concat-with = sepr: list: try-foldl' (x: y: if x == null then y else x + sepr + y) null list;
|
||||
|
||||
ser-bool = bool: if bool then "true" else "false";
|
||||
ser-str = str: "\"${builtins.replaceStrings [ "\n" "\"" ] [ "\\n" "\\\"" ] str}\"";
|
||||
ser-kvs =
|
||||
{ name, value }:
|
||||
if builtins.isList value then
|
||||
concat-with "\n" (builtins.map (value: ser-kvs { inherit name value; }) value)
|
||||
else
|
||||
"${name} = ${
|
||||
if builtins.isString value then
|
||||
ser-str value
|
||||
else if builtins.isInt value then
|
||||
builtins.toString value
|
||||
else if builtins.isBool value then
|
||||
ser-bool value
|
||||
else if builtins.isAttrs value then
|
||||
value.__enum_key
|
||||
else
|
||||
builtins.throw "type not supported"
|
||||
}";
|
||||
|
||||
ser-table =
|
||||
table':
|
||||
let
|
||||
tname = table'.name;
|
||||
table = table'.value;
|
||||
in
|
||||
"[${tname}]\n" + (concat-with "\n" (map-attrs table ser-kvs));
|
||||
in
|
||||
cfg: concat-with "\n\n" (map-attrs cfg ser-table);
|
||||
}
|
||||
73
assets/pkg/nix/module.nix
Normal file
73
assets/pkg/nix/module.nix
Normal file
@@ -0,0 +1,73 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
cfg = config.services.lidm;
|
||||
|
||||
dmcfg = config.services.displayManager;
|
||||
desktops = dmcfg.sessionData.desktops;
|
||||
|
||||
version = "2.0.2";
|
||||
lidmPkg = pkgs.callPackage ./lidm.nix {
|
||||
inherit pkgs;
|
||||
config = {
|
||||
inherit version lib;
|
||||
cfg = cfg.config;
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "javalsai";
|
||||
repo = "lidm";
|
||||
rev = "v${version}";
|
||||
sha256 = "sha256-P0thtKNVae1oBuJq400fjZMMgd69iY4YDNed5RfQH4I=";
|
||||
};
|
||||
|
||||
xsessions = "${desktops}/share/xsessions";
|
||||
wayland-sessions = "${desktops}/share/wayland-sessions";
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
options = {
|
||||
lidm.keysEnum = lib.mkOption {
|
||||
type = with lib.types; attrs;
|
||||
default = lidm.passthru.keysEnum;
|
||||
readOnly = true;
|
||||
description = "Keys enum constants";
|
||||
};
|
||||
services.lidm.config = lib.mkOption {
|
||||
type =
|
||||
with lib.types;
|
||||
oneOf [
|
||||
str
|
||||
attrs
|
||||
];
|
||||
default = { };
|
||||
description = "Config options for lidm | Either attr tree or name of bundled themes";
|
||||
};
|
||||
};
|
||||
config = {
|
||||
services.displayManager.defaultSession = "lidm";
|
||||
|
||||
systemd.services.lidm = {
|
||||
description = "TUI display manager";
|
||||
aliases = [ "display-manager.service" ];
|
||||
after = [
|
||||
"systemd-user-sessions.service"
|
||||
"plymouth-quit-wait.service"
|
||||
];
|
||||
serviceConfig = {
|
||||
Type = "idle";
|
||||
ExecStart = "${lidmPkg}/bin/lidm 7";
|
||||
StandardInput = "tty";
|
||||
StandardOutput = "tty";
|
||||
StandardError = "tty";
|
||||
TTYPath = "/dev/tty7";
|
||||
TTYReset = "yes";
|
||||
TTYVHangup = "yes";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -2,38 +2,44 @@
|
||||
|
||||
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're using lidm from a packaged source, this should be included with the package. Only read this for manual installations, if you are packaging or if your package exceptionally doesn't include them.
|
||||
|
||||
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.
|
||||
There's make scripts to automatically copy the service files to the proper locations, you just have to run `make install-service-$INIT` (or `make install-service-$INIT-etc`). `make install-service` will attempt to detect the init system in use and install for it.
|
||||
|
||||
The manual steps for installation are:
|
||||
|
||||
## Systemd
|
||||
|
||||
* Copy `systemd.service` to `/etc/systemd/system/lidm.service`
|
||||
* To enable it you can run `systemctl enable lidm`
|
||||
- Copy `systemd.service` to `/usr/local/lib/systemd/system/lidm.service` (if the directory doesn't exist, create it first) or `/usr/lib/systemd/system/lidm.service` (if you wish to install along your system files).
|
||||
- To enable it you can run `systemctl enable lidm`
|
||||
|
||||
## Dinit
|
||||
|
||||
* Copy `dinit` to `/etc/dinit.d/lidm`
|
||||
* To enable it, run `dinitctl enable lidm`
|
||||
- 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`
|
||||
Your runit service path can be either `/etc/runit/sv` or `/etc/sv`.
|
||||
|
||||
- Copy `runit/` to `runit-path/lidm/`
|
||||
- Add the service with `ln -s runit-path/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`
|
||||
- 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)
|
||||
Your S6 service path can be either `/etc/s6/sv` or `/etc/sv`.
|
||||
|
||||
> \[!WARNING]
|
||||
- Copy `s6/` to `s6-path/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.
|
||||
|
||||
@@ -5,12 +5,13 @@ After=systemd-user-sessions.service plymouth-quit-wait.service
|
||||
[Service]
|
||||
Type=idle
|
||||
ExecStart=/usr/bin/lidm 7
|
||||
StandardError=journal
|
||||
StandardInput=tty
|
||||
StandardOutput=tty
|
||||
StandardError=tty
|
||||
TTYPath=/dev/tty7
|
||||
TTYReset=yes
|
||||
TTYVHangup=yes
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
Alias=display-manager.service
|
||||
|
||||
3
debug/README.md
Normal file
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
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
|
||||
9
debug/lidm-debug
Normal file
9
debug/lidm-debug
Normal file
@@ -0,0 +1,9 @@
|
||||
type = process
|
||||
command = /bin/sh -c "LIDM_LOG=/tmp/lidm.debug /sbin/agetty tty8 linux-c -n -l /usr/local/bin/lidm -o 8"
|
||||
restart = true
|
||||
depends-on = login.target
|
||||
termsignal = HUP
|
||||
smooth-recovery = true
|
||||
inittab-id = 8
|
||||
inittab-line = tty8
|
||||
log-type = buffer
|
||||
@@ -2,29 +2,35 @@
|
||||
|
||||
Contributions are welcome! Here's how you can help:
|
||||
|
||||
- [Contributing code](#code)
|
||||
- [Reporting issues](#issues)
|
||||
- [Contributing](#contributing)
|
||||
- [Code](#code)
|
||||
- [Issues](#issues)
|
||||
- [Other](#other)
|
||||
|
||||
## Code
|
||||
|
||||
For small fixes or incremental improvements simply fork the repo and follow the process below. For larger changes submit an [RFC:](RFC.md)
|
||||
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!
|
||||
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 "*.cpp" "*.h")`
|
||||
- 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 above along a few extra stuff (shellcheck, spellcheck, prettier, etc).
|
||||
|
||||
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)
|
||||
- Header line: explain the commit in one line (use the imperative) ("feat" for features, "fix", "style", "chore", "docs", etc)
|
||||
- Be descriptive.
|
||||
- Have a first line with less than *80 characters* and have a second line that is *empty* if you want to add a description.
|
||||
- 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 briefly what you've done (or if it's a work-in-progress - what you need to do)
|
||||
- Add a short description explaining what you've done (or if it's a work-in-progress - what you need to do)
|
||||
|
||||
## Issues
|
||||
|
||||
@@ -33,7 +39,10 @@ For small fixes or incremental improvements simply fork the repo and follow the
|
||||
- Screenshots.
|
||||
- Ways to reproduce the issue.
|
||||
- Your lidm version.
|
||||
- Your platform (e.g. arch linux or Ubuntu 15.04 x64)
|
||||
- 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.
|
||||
|
||||
175
docs/INSTALL.md
Normal file
175
docs/INSTALL.md
Normal file
@@ -0,0 +1,175 @@
|
||||
# Table of Contents
|
||||
|
||||
- [Packages](#packages)
|
||||
- [Void Linux](#void-linux)
|
||||
- [Fedora](#fedora)
|
||||
- [AUR](#aur)
|
||||
- [Nix Flake](#nix-flake)
|
||||
- [Nix Module](#nix-module)
|
||||
- [Installing from Source](#installing-from-source)
|
||||
|
||||
# Packages
|
||||
|
||||
Lidm relies on its community to package lidm for distributions and make the installation easier for everyone. Please raise any issues on the packages themselves and not the source repository.
|
||||
|
||||
If you packaged lidm for any distribution not listed here or keep your own version of an inactive package, feel free to contact me to be added here. (could be a GitHub discussion or an email if you don't use GitHub)
|
||||
|
||||
These packages just install lidm, once installed you have to enable it. It depends on your init system, but if you're using systemd (most likely), first find your currently active display manager (if any, examples are `sddm`, `gdm`, `ly`) and disable it:
|
||||
|
||||
```sh
|
||||
systemctl disable <display manager name here>
|
||||
```
|
||||
|
||||
And then enable lidm:
|
||||
|
||||
```sh
|
||||
systemctl enable lidm
|
||||
```
|
||||
|
||||
Lidm now should show on the next boot!
|
||||
|
||||
If you are on a TTY and don't wish to reboot, you should be able to use `--now` with both commands. It's likely to kill your current desktop environment if it was launched from it.
|
||||
|
||||
## Void Linux
|
||||
|
||||
Lidm can be installed from the official Void Linux packages:
|
||||
|
||||
```sh
|
||||
xbps-install lidm
|
||||
```
|
||||
|
||||
To enable the service that starts on boot:
|
||||
|
||||
```sh
|
||||
ln -s /etc/sv/lidm /var/service/
|
||||
```
|
||||
|
||||
It is recommended to disable any other display managers that are still enabled:
|
||||
|
||||
```sh
|
||||
touch /etc/sv/lightdm/down # replace lightdm with your previous display manager (e.g., sddm, gdm)
|
||||
```
|
||||
|
||||
## Fedora
|
||||
|
||||
Thanks to @KernelFreeze there's a COPR repo available at <https://copr.fedorainfracloud.org/coprs/celestelove/lidm/> to install lidm. (<https://github.com/javalsai/lidm/discussions/92>)
|
||||
|
||||
## AUR
|
||||
|
||||
There are several [AUR packages](https://aur.archlinux.org/packages?K=lidm&SeB=n) for most things. You only need to install one of the following:
|
||||
|
||||
- `lidm`
|
||||
- `lidm-bin`
|
||||
- `lidm-git`
|
||||
|
||||
Each of those depend on `lidm-service` which is provided by `lidm-systemd` and `lidm-dinit` (you'll have to pick one). I maintain both but I'm open to anyone that actually uses systemd to take the first one.
|
||||
|
||||
There's packagers needed for openrc, s6 and runit. If you know how to make AUR packages, feel free to take any of those if you use each init system.
|
||||
|
||||
## 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
|
||||
```
|
||||
|
||||
## Nix Module
|
||||
|
||||
<details>
|
||||
<summary>Sidenote</summary>
|
||||
|
||||
The nix module lacks on several aspects, if you know much about nix and know
|
||||
how to improve this package, feel free to open an issue or a PR to help. The
|
||||
nix package maintainer position is open too.
|
||||
|
||||
</details>
|
||||
|
||||
Lidm includes a nix module in `assets/pkg/nix/module.nix` that you can add
|
||||
(along the included nix files) and import in your `configuration.nix`.
|
||||
|
||||
Once imported you'll need to add:
|
||||
|
||||
```nix
|
||||
services.displayManager.enable = true;
|
||||
systemd.services.lidm.enable = true;
|
||||
```
|
||||
|
||||
Optionally, you can configure it setting `services.lidm.config`. You can either
|
||||
pass:
|
||||
|
||||
- A string to copy the config from a theme in `themes/` with said name
|
||||
(**name**, e.g `"cherry"`).
|
||||
- An attribute tree with the same names as the config file, e.g:
|
||||
|
||||
```nix
|
||||
with config.lidm.keysEnum; {
|
||||
strings = {
|
||||
f_poweroff = "custom_poweroff";
|
||||
};
|
||||
|
||||
behavior = {
|
||||
include_defshell = true;
|
||||
source = [
|
||||
"path1"
|
||||
"path2"
|
||||
];
|
||||
};
|
||||
|
||||
functions = { poweroff = F1; };
|
||||
|
||||
# etc...
|
||||
};
|
||||
```
|
||||
|
||||
> _it's not necessary to cover all keys and anything can be put there, even if it's not valid config_
|
||||
|
||||
# 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 are 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
|
||||
```
|
||||
|
||||
This will install mostly into `/usr/local` by default, this path is mostly unused nowadays (systemd can load services from it but man usually doesn't find manual pages in there) and could feel like lidm didn't install at all. You can add `PREFIX=/usr` to install along the rest of your system packages if you wish.
|
||||
|
||||
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 (/etc/sv)
|
||||
make install-service-runit-etc # runit (/etc/runit/sv)
|
||||
make install-service-openrc # openrc
|
||||
make install-service-s6 # s6 (/etc/sv)
|
||||
make install-service-s6-etc # s6 (/etc/s6/sv)
|
||||
|
||||
# For runit and s6, some distros (e.g. Artix) like to put it in /etc/<init>/sv
|
||||
# to better isolate their packages while other distros (e.g. Void) just put it
|
||||
# in /etc/sv
|
||||
```
|
||||
78
docs/PACKAGERS.md
Normal file
78
docs/PACKAGERS.md
Normal file
@@ -0,0 +1,78 @@
|
||||
This is a guide listing all possible options packagers have to tweak behavior of lidm and the extra stuff to package.
|
||||
|
||||
# Components
|
||||
|
||||
If you want to package lidm for a distribution you have to package the binary and:
|
||||
|
||||
- Man pages ([`../assets/man/`](../assets/man/))
|
||||
- Service files ([`../assets/services/`](../assets/services/))
|
||||
- PAM (see [#preprocessor-defines](#preprocessor-defines))
|
||||
- And optionally you can include some default themes in `/usr` ([`../themes/`](../themes/))
|
||||
|
||||
# Preprocessor Defines
|
||||
|
||||
Most of the behavior that can be tweaked using preprocessor `#define`s, to include some simply add `CPPFLAGS+='-D{{name}}={{value}}'` to your `make` command. e.g:
|
||||
|
||||
```sh
|
||||
make \
|
||||
CPPFLAGS+='-DSESSIONS_XSESSIONS=\"/var/empty\"' \
|
||||
CPPFLAGS+='-DSESSIONS_WAYLAND=\"/var/empty\"'
|
||||
```
|
||||
|
||||
The list of possible `#define`s is:
|
||||
|
||||
| Name | Default | Description | Env Override? |
|
||||
| -------------------------- | ------------------------------------- | -------------------------------------------------------------------------- | ------------------------ |
|
||||
| `PAM_SERVICE_FALLBACK` | `"login"` | Name of the default PAM module to use. Defaults to the distro's `"login"`. | Yes (`LIDM_PAM_SERVICE`) |
|
||||
| `SESSIONS_XSESSIONS` | `"/usr/share/xsessions"` | | No |
|
||||
| `SESSIONS_XSESSIONS_LOCAL` | `"/usr/local/share/xsessions"` | | No |
|
||||
| `SESSIONS_WAYLAND` | `"/usr/share/wayland-sessions"` | | No |
|
||||
| `SESSIONS_WAYLAND_LOCAL` | `"/usr/local/share/wayland-sessions"` | | No |
|
||||
| `LIDM_CONF_PATH` | `"/etc/lidm.ini"` | Path of the default configuration. | Yes (`LIDM_CONF`) |
|
||||
| `LOGIN_SHELL` | `"bash"` | Login shell name. | No |
|
||||
|
||||
# Other Build Settings
|
||||
|
||||
## Compiler
|
||||
|
||||
Lidm attempts to support being built by `gcc` and `clang` with preference over the first. However, if you wish to take advantage of LLVM's optimizations over GNU's you can change the compiler with `make CC=clang` or try any other compiler.
|
||||
|
||||
## Compiler Flags
|
||||
|
||||
Compiler flags should be passed with `CFLAGS`, its `-O3 -Wall` by default so adding anything will overwrite this.
|
||||
|
||||
## Build Metadata
|
||||
|
||||
`lidm -v` outputs some information about the build version, this can be weaked with `INFO_GIT_REV` and `INFO_BUILD_TS`, by default they are:
|
||||
|
||||
```make
|
||||
INFO_GIT_REV?=$$(git describe --long --tags --always || echo '?')
|
||||
INFO_BUILD_TS?=$$(date +%s)
|
||||
```
|
||||
|
||||
But this can be changed by just passing those env variables, for example, in the case git is not applicable in the build environment of the package.
|
||||
|
||||
## Target Directory
|
||||
|
||||
`DESTDIR` can be used to for installation recipes to install on alternative root directories. Along with `PREFIX` (defaults to `/usr/local`, packaging this you'll probably want to make it `/usr`) for systems which don't use the common `/usr` structure. e.g. `make install DESTDIR=$out PREFIX=`
|
||||
|
||||
`/etc` is sometimes in that `PREFIX` and sometimes not, be careful.
|
||||
|
||||
```txt
|
||||
$ fd -t f . --base-directory $out
|
||||
bin/lidm
|
||||
etc/lidm.ini
|
||||
share/man/man1/lidm.1
|
||||
share/man/man5/lidm-config.5
|
||||
```
|
||||
|
||||
# Build Recipes for Packaging
|
||||
|
||||
To ease most of the installation process there's several `make` recipes to install man pages and service files, I encpurage you to check their source yourself, but:
|
||||
|
||||
- `make` / `make lidm`: Builds the app binary.
|
||||
- `make install`: Attempts to install the binary, place a default config file in `/etc/lidm.ini` and install the man pages.
|
||||
- `make install-service-(systemd|dinit|runit|openrc|s6)(|-etc)`: Just check the source, service files for different init systems and `-etc` variants for alternative paths. You might need `FORCE=1` in the environment if you are packaging for other init system or scripting.
|
||||
- `make print-version`: Outputs the current version in the `Makefile` for scripts that might want to extract that info.
|
||||
|
||||
You can choose to use these packages or create your own service files / etc. There's are merely suggestions on what to use.
|
||||
89
docs/structure.md
Normal file
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.
|
||||
30
docs/yubikey.md
Normal file
30
docs/yubikey.md
Normal file
@@ -0,0 +1,30 @@
|
||||
# Yubikeys
|
||||
|
||||
Quick reference explaining how yubikeys work for now.
|
||||
|
||||
# Enable
|
||||
|
||||
Yubikeys are disabled by default, to enable them activate a keybinding for it (`[functions] fido`) in the config file.
|
||||
|
||||
Note that pressing this configured keybinding has no difference from trying to log in with an empty password, there's virtually no difference.
|
||||
|
||||
`pam_u2f` must be configured with a registered key (`pamu2fcfg`).
|
||||
|
||||
# Extra
|
||||
|
||||
All my yubikey knowledge comes from the [pr that implemented this](https://github.com/javalsai/lidm/pull/89), please refer to it for extra details. Contributions to this documentation are welcome (explaining more in detail, potential issues... really anything that improves this).
|
||||
|
||||
Allegedly this pam module configuration should work:
|
||||
|
||||
```pam
|
||||
#%PAM-1.0
|
||||
|
||||
auth sufficient pam_u2f.so cue
|
||||
auth requisite pam_nologin.so
|
||||
auth include system-local-login
|
||||
account include system-local-login
|
||||
session include system-local-login
|
||||
password include system-local-login
|
||||
```
|
||||
|
||||
Also, I recommend giving the [arch wiki](https://wiki.archlinux.org/title/YubiKey) a read anyways.
|
||||
12
flake.lock
generated
12
flake.lock
generated
@@ -5,11 +5,11 @@
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1710146030,
|
||||
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
|
||||
"lastModified": 1731533236,
|
||||
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
|
||||
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -20,11 +20,11 @@
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1724224976,
|
||||
"narHash": "sha256-Z/ELQhrSd7bMzTO8r7NZgi9g5emh+aRKoCdaAv5fiO0=",
|
||||
"lastModified": 1751637120,
|
||||
"narHash": "sha256-xVNy/XopSfIG9c46nRmPaKfH1Gn/56vQ8++xWA8itO4=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "c374d94f1536013ca8e92341b540eba4c22f9c62",
|
||||
"rev": "5c724ed1388e53cc231ed98330a60eb2f7be4be3",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
||||
50
flake.nix
50
flake.nix
@@ -1,46 +1,46 @@
|
||||
{
|
||||
description = "A ✨fully✨ colorful customizable TUI display manager made in C for simplicity.";
|
||||
|
||||
inputs = {
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
|
||||
};
|
||||
|
||||
outputs =
|
||||
{ flake-utils, nixpkgs, ... }:
|
||||
{
|
||||
flake-utils,
|
||||
nixpkgs,
|
||||
self,
|
||||
}:
|
||||
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;
|
||||
version = builtins.elemAt (builtins.match "VERSION[[:blank:]]*=[[:space:]]*([^\n]*)\n.*" (builtins.readFile ./Makefile)) 0;
|
||||
|
||||
lidm = pkgs.callPackage assets/pkg/nix/lidm.nix {
|
||||
inherit pkgs;
|
||||
lib = pkgs.lib;
|
||||
config = {
|
||||
inherit version;
|
||||
src = ./.;
|
||||
|
||||
nativeBuildInputs = with pkgs; [
|
||||
gcc
|
||||
gnumake
|
||||
linux-pam
|
||||
];
|
||||
|
||||
makeFlags = [
|
||||
"DESTDIR=$(out)"
|
||||
"PREFIX="
|
||||
];
|
||||
|
||||
fixupPhase = ''
|
||||
rm -rf $out/etc
|
||||
'';
|
||||
}
|
||||
);
|
||||
xsessions = null;
|
||||
wayland-sessions = null;
|
||||
cfg = null;
|
||||
# cfg = "cherry";
|
||||
};
|
||||
};
|
||||
in
|
||||
rec {
|
||||
defaultApp = flake-utils.lib.mkApp { drv = defaultPackage; };
|
||||
defaultPackage = lidm;
|
||||
devShell = pkgs.mkShell { buildInputs = lidm.nativeBuildInputs ++ [ pkgs.clang-tools ]; };
|
||||
formatter = nixpkgs.legacyPackages.${system}.nixfmt-tree;
|
||||
}
|
||||
);
|
||||
)
|
||||
// {
|
||||
nixosModules.lidm = assets/pkg/nix/module.nix;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
#ifndef _AUTHH_
|
||||
#define _AUTHH_
|
||||
#ifndef AUTHH_
|
||||
#define AUTHH_
|
||||
|
||||
#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* NNULLABLE user, char* NNULLABLE passwd,
|
||||
struct session session, void (*NULLABLE cb)(void),
|
||||
struct config* NNULLABLE config);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef _CHVTH_
|
||||
#define _CHVTH_
|
||||
#ifndef CHVTH_
|
||||
#define CHVTH_
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <linux/kd.h>
|
||||
@@ -20,6 +20,6 @@ int chvt(int n);
|
||||
* @param str virtual terminal number (string)
|
||||
* @return int non-negative value on success
|
||||
*/
|
||||
int chvt_str(char *str);
|
||||
int chvt_str(char* str);
|
||||
|
||||
#endif
|
||||
|
||||
211
include/config.h
211
include/config.h
@@ -1,81 +1,170 @@
|
||||
#ifndef _CONFIGH_
|
||||
#define _CONFIGH_
|
||||
#ifndef CONFIGH_
|
||||
#define CONFIGH_
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include <keys.h>
|
||||
#include <sessions.h>
|
||||
#include <users.h>
|
||||
#include "keys.h"
|
||||
#include "macros.h"
|
||||
#include "util/vec.h"
|
||||
|
||||
enum IntrospectionType {
|
||||
STRING,
|
||||
BOOL,
|
||||
NUMBER,
|
||||
KEY,
|
||||
STRING_ARRAY,
|
||||
};
|
||||
static const char* NNULLABLE const INTROS_TYS_NAMES[] = {
|
||||
[STRING] = "STRING",
|
||||
[BOOL] = "BOOL",
|
||||
[NUMBER] = "NUMBER",
|
||||
[KEY] = "KEY",
|
||||
[STRING_ARRAY] = "STRING_ARRAY",
|
||||
};
|
||||
|
||||
struct introspection_item {
|
||||
char* NNULLABLE name;
|
||||
size_t offset;
|
||||
enum IntrospectionType 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
|
||||
// if not prepared accordingly, it might break
|
||||
struct theme_colors {
|
||||
char *bg;
|
||||
char *fg;
|
||||
char *err;
|
||||
char *s_wayland;
|
||||
char *s_xorg;
|
||||
char *s_shell;
|
||||
char *e_hostname;
|
||||
char *e_date;
|
||||
char *e_box;
|
||||
char *e_header;
|
||||
char *e_user;
|
||||
char *e_passwd;
|
||||
char *e_badpasswd;
|
||||
char *e_key;
|
||||
};
|
||||
#define TABLE_COLORS(F, name) \
|
||||
F(char* NNULLABLE, bg, STRING, "48;2;38;28;28", name) \
|
||||
F(char* NNULLABLE, fg, STRING, "22;24;38;2;245;245;245", name) \
|
||||
F(char* NNULLABLE, err, STRING, "1;31", name) \
|
||||
F(char* NNULLABLE, s_wayland, STRING, "38;2;255;174;66", name) \
|
||||
F(char* NNULLABLE, s_xorg, STRING, "38;2;37;175;255", name) \
|
||||
F(char* NNULLABLE, s_shell, STRING, "38;2;34;140;34", name) \
|
||||
F(char* NNULLABLE, e_hostname, STRING, "38;2;255;64;64", name) \
|
||||
F(char* NNULLABLE, e_date, STRING, "38;2;144;144;144", name) \
|
||||
F(char* NNULLABLE, e_box, STRING, "38;2;122;122;122", name) \
|
||||
F(char* NNULLABLE, e_header, STRING, "4;38;2;0;255;0", name) \
|
||||
F(char* NNULLABLE, e_user, STRING, "36", name) \
|
||||
F(char* NNULLABLE, e_passwd, STRING, "4;38;2;245;245;205", name) \
|
||||
F(char* NNULLABLE, e_badpasswd, STRING, "3;4;31", name) \
|
||||
F(char* NNULLABLE, e_key, STRING, "38;2;255;174;66", name)
|
||||
|
||||
BUILD(colors, COLORS, TABLE_COLORS);
|
||||
|
||||
// even if they're multiple bytes long
|
||||
// they should only take up 1 char size on display
|
||||
struct theme_chars {
|
||||
char *hb;
|
||||
char *vb;
|
||||
#define TABLE_CHARS(F, name) \
|
||||
F(char* NNULLABLE, hb, STRING, "─", name) \
|
||||
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;
|
||||
char *ctr;
|
||||
char *cbl;
|
||||
char *cbr;
|
||||
};
|
||||
BUILD(chars, CHARS, TABLE_CHARS);
|
||||
|
||||
struct theme {
|
||||
struct theme_colors colors;
|
||||
struct theme_chars chars;
|
||||
};
|
||||
#define TABLE_FUNCTIONS(F, name) \
|
||||
F(enum Keys, poweroff, KEY, F1, name) \
|
||||
F(enum Keys, reboot, KEY, F2, name) \
|
||||
F(enum Keys, fido, KEY, NONE, name) \
|
||||
F(enum Keys, refresh, KEY, F5, name)
|
||||
|
||||
struct functions {
|
||||
enum keys poweroff;
|
||||
enum keys reboot;
|
||||
enum keys refresh;
|
||||
};
|
||||
BUILD(functions, FUNCTIONS, TABLE_FUNCTIONS);
|
||||
|
||||
struct strings {
|
||||
char *f_poweroff;
|
||||
char *f_reboot;
|
||||
char *f_refresh;
|
||||
char *e_user;
|
||||
char *e_passwd;
|
||||
char *s_wayland;
|
||||
char *s_xorg;
|
||||
char *s_shell;
|
||||
};
|
||||
#define TABLE_STRINGS(F, name) \
|
||||
F(char* NNULLABLE, f_poweroff, STRING, "poweroff", name) \
|
||||
F(char* NNULLABLE, f_reboot, STRING, "reboot", name) \
|
||||
F(char* NNULLABLE, f_fido, STRING, "fido", name) \
|
||||
F(char* NNULLABLE, f_refresh, STRING, "refresh", name) \
|
||||
F(char* NNULLABLE, e_user, STRING, "user", name) \
|
||||
F(char* NNULLABLE, e_passwd, STRING, "password", name) \
|
||||
F(char* NNULLABLE, s_wayland, STRING, "wayland", name) \
|
||||
F(char* NNULLABLE, s_xorg, STRING, "xorg", name) \
|
||||
F(char* NNULLABLE, s_shell, STRING, "shell", name) \
|
||||
F(char* NNULLABLE, opts_pre, STRING, "< ", name) \
|
||||
F(char* NNULLABLE, opts_post, STRING, " >", name) \
|
||||
F(char* NNULLABLE, ellipsis, STRING, "…", name)
|
||||
|
||||
struct behavior {
|
||||
bool include_defshell;
|
||||
};
|
||||
BUILD(strings, STRINGS, TABLE_STRINGS);
|
||||
|
||||
#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) \
|
||||
F(long long, refresh_rate, NUMBER, 100, name) \
|
||||
F(bool, bypass_shell_login, BOOL, false, name)
|
||||
|
||||
BUILD(behavior, BEHAVIOR, TABLE_BEHAVIOR);
|
||||
|
||||
//// CONFIG
|
||||
struct config {
|
||||
struct theme theme;
|
||||
struct functions functions;
|
||||
struct strings strings;
|
||||
struct behavior behavior;
|
||||
struct table_colors colors;
|
||||
struct table_chars chars;
|
||||
struct table_functions functions;
|
||||
struct table_strings strings;
|
||||
struct table_behavior behavior;
|
||||
};
|
||||
|
||||
bool line_parser(
|
||||
FILE *fd, ssize_t *blksize,
|
||||
u_char (*cb)(char *key,
|
||||
char *value)); // might use this for parsing .desktop files too
|
||||
struct config *parse_config(char *path);
|
||||
static const struct config DEFAULT_CONFIG = {
|
||||
.colors = DEFAULT_TABLE_COLORS,
|
||||
.chars = DEFAULT_TABLE_CHARS,
|
||||
.functions = DEFAULT_TABLE_FUNCTIONS,
|
||||
.strings = DEFAULT_TABLE_STRINGS,
|
||||
.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,
|
||||
LEN(INTROS_TABLE_COLORS)},
|
||||
{"chars", offsetof(struct config, chars), INTROS_TABLE_CHARS,
|
||||
LEN(INTROS_TABLE_CHARS)},
|
||||
{"functions", offsetof(struct config, functions), INTROS_TABLE_FUNCTIONS,
|
||||
LEN(INTROS_TABLE_FUNCTIONS)},
|
||||
{"strings", offsetof(struct config, strings), INTROS_TABLE_STRINGS,
|
||||
LEN(INTROS_TABLE_STRINGS)},
|
||||
{"behavior", offsetof(struct config, behavior), INTROS_TABLE_BEHAVIOR,
|
||||
LEN(INTROS_TABLE_BEHAVIOR)},
|
||||
};
|
||||
|
||||
//// FUNCTIONS
|
||||
int parse_config(struct config* NNULLABLE config, char* NNULLABLE path);
|
||||
|
||||
#endif
|
||||
|
||||
20
include/desktop.h
Normal file
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
|
||||
14
include/desktop_exec.h
Normal file
14
include/desktop_exec.h
Normal file
@@ -0,0 +1,14 @@
|
||||
// TODO: rewrite properly
|
||||
// NOLINTBEGIN(clang-diagnostic-nullability-completeness)
|
||||
|
||||
#ifndef DESKTOP_EXEC_H_
|
||||
#define DESKTOP_EXEC_H_
|
||||
|
||||
#include "macros.h"
|
||||
|
||||
char* NULLABLE desktop_as_cmdline(char** args);
|
||||
int parse_exec_string(const char* exec_s, int* arg_count, char*** args);
|
||||
void free_parsed_args(int arg_count, char** args);
|
||||
|
||||
#endif
|
||||
// NOLINTEND(clang-diagnostic-nullability-completeness)
|
||||
@@ -1,18 +1,19 @@
|
||||
#ifndef _EFIELDH_
|
||||
#define _EFIELDH_
|
||||
#ifndef EFIELDH_
|
||||
#define EFIELDH_
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
// holds also the max string buffer in itself, not dynamic
|
||||
struct editable_field {
|
||||
u_char length;
|
||||
u_char pos;
|
||||
uint8_t pos;
|
||||
char content[255];
|
||||
};
|
||||
|
||||
struct editable_field field_new(char *);
|
||||
void field_trim(struct editable_field *, u_char);
|
||||
void field_update(struct editable_field *, char *);
|
||||
bool field_seek(struct editable_field *, char);
|
||||
struct editable_field efield_new(char* content);
|
||||
void efield_trim(struct editable_field* self, uint8_t pos);
|
||||
void efield_update(struct editable_field* self, char* update);
|
||||
bool efield_seek(struct editable_field* self, char seek);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
#ifndef _KEYSH_
|
||||
#define _KEYSH_
|
||||
#ifndef KEYSH_
|
||||
#define KEYSH_
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
enum keys {
|
||||
enum Keys {
|
||||
ESC,
|
||||
F1,
|
||||
F2,
|
||||
@@ -32,9 +35,11 @@ enum keys {
|
||||
END,
|
||||
PAGE_UP,
|
||||
PAGE_DOWN,
|
||||
NONE,
|
||||
};
|
||||
|
||||
static const char *const key_names[] = {
|
||||
static const char* const KEY_NAMES[] = {
|
||||
[NONE] = "NONE",
|
||||
[ESC] = "ESC",
|
||||
[F1] = "F1",
|
||||
[F2] = "F2",
|
||||
@@ -66,11 +71,11 @@ static const char *const key_names[] = {
|
||||
};
|
||||
|
||||
struct key_mapping {
|
||||
enum keys key;
|
||||
const char *sequences[3];
|
||||
enum Keys key;
|
||||
const char* sequences[3];
|
||||
};
|
||||
|
||||
static const struct key_mapping key_mappings[] = {
|
||||
static const struct key_mapping KEY_MAPPINGS[] = {
|
||||
{ESC, {"\x1b", NULL}},
|
||||
{F1, {"\x1bOP", "\x1b[[A", NULL}},
|
||||
{F2, {"\x1bOQ", "\x1b[[B", NULL}},
|
||||
@@ -101,4 +106,15 @@ static const struct key_mapping key_mappings[] = {
|
||||
{PAGE_DOWN, {"\x1b[6~", NULL}},
|
||||
};
|
||||
|
||||
struct option_keys {
|
||||
bool is_some;
|
||||
enum Keys key;
|
||||
};
|
||||
|
||||
int find_keyname(enum Keys* at, const char* name);
|
||||
struct option_keys find_ansi(const char* seq);
|
||||
void read_press(uint8_t* length, char* out);
|
||||
// non blocking, waits up to tv or interrupt, returns true if actually read
|
||||
bool read_press_nb(uint8_t* length, char* out, struct timeval* tv);
|
||||
|
||||
#endif
|
||||
|
||||
17
include/launch_state.h
Normal file
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
|
||||
14
include/log.h
Normal file
14
include/log.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef LOGH_
|
||||
#define LOGH_
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "macros.h"
|
||||
|
||||
void log_init(FILE* NNULLABLE fd);
|
||||
void log_puts(const char* NNULLABLE msg);
|
||||
void log_printf(const char* NNULLABLE fmt, ...);
|
||||
// NOLINTNEXTLINE(readability-identifier-length)
|
||||
void log_perror(const char* NNULLABLE s);
|
||||
|
||||
#endif
|
||||
41
include/macros.h
Normal file
41
include/macros.h
Normal file
@@ -0,0 +1,41 @@
|
||||
#ifndef MACROSH_
|
||||
#define MACROSH_
|
||||
|
||||
// More like constants but I'm not making yet another header file just for this
|
||||
#ifndef LIDM_CONF_PATH
|
||||
#define LIDM_CONF_PATH "/etc/lidm.ini"
|
||||
#endif
|
||||
|
||||
// Do we just replace the compiler with clang??
|
||||
#ifdef __clang__
|
||||
#define NULLABLE _Nullable
|
||||
#else
|
||||
#define NULLABLE
|
||||
#endif
|
||||
|
||||
#ifdef __clang__
|
||||
#define NNULLABLE _Nonnull
|
||||
#else
|
||||
#define NNULLABLE
|
||||
#endif
|
||||
|
||||
#ifdef __clang__
|
||||
#define UNULLABLE _Null_unspecified
|
||||
#else
|
||||
#define UNULLABLE
|
||||
#endif
|
||||
|
||||
#ifdef __clang__
|
||||
#define COMPILER_VERSION __VERSION__
|
||||
#elif defined(__GNUC__)
|
||||
#define xstr(s) str(s)
|
||||
#define str(s) #s
|
||||
|
||||
#define COMPILER_VERSION \
|
||||
"GCC " xstr(__GNUC__) "." xstr(__GNUC_MINOR__) "." xstr(__GNUC_PATCHLEVEL__)
|
||||
#endif
|
||||
|
||||
#define LEN(X) (sizeof(X) / sizeof((X)[0]))
|
||||
#define UNUSED(x) ((void)(x))
|
||||
|
||||
#endif
|
||||
23
include/ofield.h
Normal file
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);
|
||||
|
||||
uint8_t ofield_display_cursor_col(struct opts_field* self, uint8_t maxlen);
|
||||
|
||||
#endif
|
||||
33
include/pam.h
Normal file
33
include/pam.h
Normal file
@@ -0,0 +1,33 @@
|
||||
#ifndef PAM_H
|
||||
#define PAM_H
|
||||
|
||||
#include <pwd.h>
|
||||
#include <security/_pam_types.h>
|
||||
#include <security/pam_appl.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "macros.h"
|
||||
#include "sessions.h"
|
||||
|
||||
#define PAMH_ERR_NOERR 0
|
||||
#define PAMH_ERR_ALLOC 1
|
||||
#define PAMH_ERR_ERRNO 2
|
||||
#define PAMH_ERR_NOERRNO 3
|
||||
|
||||
struct pamh_getenv_status {
|
||||
char error_flag;
|
||||
union {
|
||||
char* NULLABLE* NNULLABLE envlist;
|
||||
const char* NNULLABLE errfn;
|
||||
};
|
||||
};
|
||||
|
||||
// Doesn't include `source`s
|
||||
struct pamh_getenv_status pamh_get_complete_env(pam_handle_t* NNULLABLE handle,
|
||||
struct passwd* NNULLABLE pw,
|
||||
enum SessionType session_typ);
|
||||
|
||||
void free_envlist(char* NULLABLE* NNULLABLE envlist);
|
||||
pam_handle_t* NULLABLE get_pamh(char* NNULLABLE user, char* NNULLABLE passwd);
|
||||
|
||||
#endif /* PAM_H */
|
||||
@@ -1,26 +1,65 @@
|
||||
#ifndef _SESSIONSH_
|
||||
#define _SESSIONSH_
|
||||
#ifndef SESSIONSH_
|
||||
#define SESSIONSH_
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
enum session_type {
|
||||
#include "macros.h"
|
||||
#include "util/vec.h"
|
||||
|
||||
enum SessionType {
|
||||
XORG,
|
||||
WAYLAND,
|
||||
SHELL,
|
||||
};
|
||||
|
||||
enum ExecType {
|
||||
EXEC_SHELL,
|
||||
EXEC_DESKTOP,
|
||||
};
|
||||
|
||||
struct desktop_exec {
|
||||
char* NULLABLE* NNULLABLE args;
|
||||
int arg_count;
|
||||
};
|
||||
|
||||
struct session_exec {
|
||||
enum ExecType typ;
|
||||
union {
|
||||
char* NNULLABLE shell;
|
||||
struct desktop_exec desktop;
|
||||
};
|
||||
};
|
||||
|
||||
static inline struct session_exec session_exec_shell(char* NNULLABLE shell) {
|
||||
return (struct session_exec){
|
||||
.typ = EXEC_SHELL,
|
||||
.shell = shell,
|
||||
};
|
||||
}
|
||||
|
||||
static inline struct session_exec session_exec_desktop(
|
||||
int arg_count, char* NULLABLE* NNULLABLE args) {
|
||||
return (struct session_exec){
|
||||
.typ = EXEC_DESKTOP,
|
||||
.desktop =
|
||||
{
|
||||
.args = args,
|
||||
.arg_count = arg_count,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
struct session {
|
||||
char *name;
|
||||
char *exec;
|
||||
char *tryexec;
|
||||
enum session_type type;
|
||||
char* NNULLABLE name;
|
||||
struct session_exec exec;
|
||||
enum SessionType type;
|
||||
};
|
||||
|
||||
struct sessions_list {
|
||||
u_int16_t length;
|
||||
struct session *sessions;
|
||||
};
|
||||
|
||||
struct sessions_list *get_avaliable_sessions();
|
||||
struct Vector get_avaliable_sessions();
|
||||
int session_exec_exec(struct session_exec* NNULLABLE exec,
|
||||
char* NULLABLE* NNULLABLE envp);
|
||||
int session_exec_login_through_shell(struct session_exec* NNULLABLE exec,
|
||||
char* NULLABLE* NNULLABLE envp);
|
||||
|
||||
#endif
|
||||
|
||||
8
include/signal_handler.h
Normal file
8
include/signal_handler.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#ifndef SIGNALHANDLERH_
|
||||
#define SIGNALHANDLERH_
|
||||
|
||||
// handle SIGTERM by sending SIGTERM to all children, resulting
|
||||
// in a graceful graphical shutdown
|
||||
void setup_sigterm();
|
||||
|
||||
#endif /* SIGNALHANDLERH_ */
|
||||
60
include/ui.h
60
include/ui.h
@@ -1,11 +1,57 @@
|
||||
#ifndef _UIH_
|
||||
#define _UIH_
|
||||
#ifndef UIH_
|
||||
#define UIH_
|
||||
|
||||
#include <config.h>
|
||||
#include "config.h"
|
||||
#include "ofield.h"
|
||||
#include "util/vec.h"
|
||||
|
||||
void setup(struct config);
|
||||
int load(struct users_list *, struct sessions_list *);
|
||||
void print_err(const char *);
|
||||
void print_errno(const char *);
|
||||
// [box_start]
|
||||
// ↓
|
||||
// 0 [┌]───────────────────────────────────────────────┐
|
||||
// 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 uint8_t 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 print_pam_msg(const char* msg, int msg_style);
|
||||
void clear_pam_msg(void);
|
||||
|
||||
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
|
||||
|
||||
29
include/ui_state.h
Normal file
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_
|
||||
#define _USERSH_
|
||||
#ifndef USERSH_
|
||||
#define USERSH_
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "util/vec.h"
|
||||
|
||||
struct user {
|
||||
char *shell;
|
||||
char *username;
|
||||
char *display_name;
|
||||
char* shell;
|
||||
char* username;
|
||||
char* display_name;
|
||||
};
|
||||
|
||||
struct users_list {
|
||||
u_int16_t length;
|
||||
struct user *users;
|
||||
};
|
||||
|
||||
struct users_list *get_human_users();
|
||||
struct Vector get_human_users();
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
#ifndef _UTILH_
|
||||
#define _UTILH_
|
||||
|
||||
#include <keys.h>
|
||||
#include <stdbool.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
enum keys find_keyname(char *);
|
||||
enum keys find_ansi(char *);
|
||||
void read_press(u_char *, char *);
|
||||
void strcln(char **dest, const char *source);
|
||||
|
||||
#endif
|
||||
10
include/util/path.h
Normal file
10
include/util/path.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#ifndef UTIL_PATH_H
|
||||
#define UTIL_PATH_H
|
||||
|
||||
#include "macros.h"
|
||||
|
||||
char* NULLABLE search_path(const char* NNULLABLE for_binary);
|
||||
int execvpe(const char* NNULLABLE file, char* NULLABLE const argv[NNULLABLE],
|
||||
char* NULLABLE const envp[NNULLABLE]);
|
||||
|
||||
#endif /* UTIL_PATH_H */
|
||||
15
include/util/utf8.h
Normal file
15
include/util/utf8.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef UTIL_UTF8_H
|
||||
#define UTIL_UTF8_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
bool utf8_iscont(char byte);
|
||||
size_t utf8len(const char* str);
|
||||
size_t utf8len_until(const char* str, const char* until);
|
||||
size_t utf8trunc(char* str, size_t n);
|
||||
const char* utf8back(const char* str);
|
||||
const char* utf8seek(const char* str);
|
||||
const char* utf8seekn(const char* str, size_t n);
|
||||
|
||||
#endif /* UTIL_UTF8_H */
|
||||
26
include/util/vec.h
Normal file
26
include/util/vec.h
Normal file
@@ -0,0 +1,26 @@
|
||||
#ifndef UTIL_VEC_H
|
||||
#define UTIL_VEC_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
struct Vector {
|
||||
uint32_t length;
|
||||
uint32_t capacity;
|
||||
void** pages;
|
||||
};
|
||||
|
||||
struct Vector vec_from_raw(void** raw);
|
||||
void** vec_as_raw(struct Vector self);
|
||||
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 /* UTIL_VEC_H */
|
||||
91
services.mk
Normal file
91
services.mk
Normal file
@@ -0,0 +1,91 @@
|
||||
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 \
|
||||
if [ -d /etc/sv ]; then \
|
||||
make install-service-runit; \
|
||||
elif [ -d /etc/runit/sv ]; then \
|
||||
make install-service-runit-etc; \
|
||||
else \
|
||||
printf '\033[31m%s\033[0m\n' "Unknown init system structure, skipping service install..." >&2; \
|
||||
fi \
|
||||
elif command -v rc-update &> /dev/null; then \
|
||||
make install-service-openrc; \
|
||||
elif command -v s6-service &> /dev/null; then \
|
||||
if [ -d /etc/sv ]; then \
|
||||
make install-service-s6; \
|
||||
elif [ -d /etc/r6nit/sv ]; then \
|
||||
make install-service-s6-etc; \
|
||||
else \
|
||||
printf '\033[31m%s\033[0m\n' "Unknown init system structure, skipping service install..." >&2; \
|
||||
fi \
|
||||
else \
|
||||
printf '\033[1;31m%s\033[0m\n' "Unknown init system, skipping service install..." >&2; \
|
||||
fi
|
||||
|
||||
install-service-systemd:
|
||||
@sed -e 's|ExecStart=/usr/bin/lidm|ExecStart=${DESTDIR}${PREFIX}/bin/lidm|' ./assets/services/systemd.service > ./dist/lidm.service
|
||||
install -Dm644 ./dist/lidm.service ${DESTDIR}${PREFIX}/lib/systemd/system/lidm.service
|
||||
@printf '\033[1m%s\033[0m\n\n' " don't forget to run 'systemctl enable lidm'"
|
||||
install-service-dinit:
|
||||
install -m644 ./assets/services/dinit ${DESTDIR}/etc/dinit.d/lidm
|
||||
@printf '\033[1m%s\033[0m\n\n' " don't forget to run 'dinitctl enable lidm'"
|
||||
install-service-runit:
|
||||
@if [ ! -e /etc/sv ] && [ -d /etc/runit/sv ] && [ -z "$$FORCE" ]; then \
|
||||
printf '\033[31m%s\033[0m\n' "/etc/sv doesn't exist but /etc/runit/sv does" >&2; \
|
||||
printf '\033[31m%s\033[0m\n' "you probably meant to 'make install-service-runit-etc'" >&2; \
|
||||
exit 1; \
|
||||
fi
|
||||
mkdir -p ${DESTDIR}/etc/sv/lidm
|
||||
cp -r --update=all ./assets/services/runit/* ${DESTDIR}/etc/sv/lidm/
|
||||
@printf '\033[1m%s\033[0m\n\n' " don't forget to run 'ln -s ${DESTDIR}/etc/sv/lidm /var/service' or your distro equivalent"
|
||||
install-service-runit-etc:
|
||||
@if [ ! -e /etc/runit/sv ] && [ -d /etc/sv ] && [ -z "$$FORCE" ]; then \
|
||||
printf '\033[31m%s\033[0m\n' "/etc/runit/sv doesn't exist but /etc/sv does" >&2; \
|
||||
printf '\033[31m%s\033[0m\n' "you probably meant to 'make install-service-runit'" >&2; \
|
||||
exit 1; \
|
||||
fi
|
||||
mkdir -p ${DESTDIR}/etc/runit/sv/lidm
|
||||
cp -r --update=all ./assets/services/runit/* ${DESTDIR}/etc/runit/sv/lidm/
|
||||
@printf '\033[1m%s\033[0m\n\n' " don't forget to run 'ln -s ${DESTDIR}/etc/runit/sv/lidm /run/runit/service' or your distro equivalent"
|
||||
install-service-openrc:
|
||||
install -m755 ./assets/services/openrc ${DESTDIR}/etc/init.d/lidm
|
||||
@printf '\033[1m%s\033[0m\n\n' " don't forget to run 'rc-update add lidm'"
|
||||
install-service-s6:
|
||||
@if [ ! -e /etc/sv ] && [ -d /etc/s6/sv ] && [ -z "$$FORCE" ]; then \
|
||||
printf '\033[31m%s\033[0m\n' "/etc/sv doesn't exist but /etc/s6/sv does" >&2; \
|
||||
printf '\033[31m%s\033[0m\n' "you probably meant to 'make install-service-s6-etc'" >&2; \
|
||||
exit 1; \
|
||||
fi
|
||||
mkdir -p ${DESTDIR}/etc/sv/lidm
|
||||
cp -r --update=all ./assets/services/s6/* ${DESTDIR}/etc/sv/lidm/
|
||||
@printf '\033[1m%s\033[0m\n\n' " don't forget to run 's6-service add default lidm' and 's6-db-reload'"
|
||||
install-service-s6-etc:
|
||||
@if [ ! -e /etc/s6/sv ] && [ -d /etc/sv ] && [ -z "$$FORCE" ]; then \
|
||||
printf '\033[31m%s\033[0m\n' "/etc/s6/sv doesn't exist but /etc/sv does" >&2; \
|
||||
printf '\033[31m%s\033[0m\n' "you probably meant to 'make install-service-s6'" >&2; \
|
||||
exit 1; \
|
||||
fi
|
||||
mkdir -p ${DESTDIR}/etc/s6/sv/lidm
|
||||
cp -r --update=all ./assets/services/s6/* ${DESTDIR}/etc/s6/sv/lidm/
|
||||
@printf '\033[1m%s\033[0m\n\n' " don't forget to run 's6-service add default lidm' and 's6-db-reload'"
|
||||
|
||||
uninstall-service:
|
||||
rm -rf \
|
||||
${DESTDIR}${PREFIX}/lib/systemd/system/lidm.service \
|
||||
${DESTDIR}/etc/dinit.d/lidm \
|
||||
${DESTDIR}/etc/sv/lidm \
|
||||
${DESTDIR}/etc/runit/sv/lidm \
|
||||
${DESTDIR}/etc/init.d/lidm \
|
||||
${DESTDIR}/etc/s6/sv/lidm
|
||||
|
||||
.PHONY: install-service uninstall-service \
|
||||
install-service-s6 \
|
||||
install-service-s6-etc \
|
||||
install-service-dinit \
|
||||
install-service-runit \
|
||||
install-service-runit-etc \
|
||||
install-service-openrc \
|
||||
install-service-systemd
|
||||
468
src/auth.c
468
src/auth.c
@@ -1,194 +1,366 @@
|
||||
// TODO: handle `fork() == -1`
|
||||
|
||||
#include <errno.h>
|
||||
#include <grp.h>
|
||||
#include <pwd.h>
|
||||
#include <security/pam_misc.h>
|
||||
#include <signal.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
#include <auth.h>
|
||||
#include <sessions.h>
|
||||
#include <ui.h>
|
||||
#include <unistd.h>
|
||||
#include <util.h>
|
||||
|
||||
int pam_conversation(int num_msg, const struct pam_message **msg,
|
||||
struct pam_response **resp, void *appdata_ptr) {
|
||||
struct pam_response *reply =
|
||||
(struct pam_response *)malloc(sizeof(struct pam_response) * num_msg);
|
||||
for (int i = 0; i < num_msg; i++) {
|
||||
reply[i].resp = NULL;
|
||||
reply[i].resp_retcode = 0;
|
||||
if (msg[i]->msg_style == PAM_PROMPT_ECHO_OFF ||
|
||||
msg[i]->msg_style == PAM_PROMPT_ECHO_ON) {
|
||||
char *input = (char *)appdata_ptr;
|
||||
reply[i].resp = strdup(input);
|
||||
}
|
||||
}
|
||||
*resp = reply;
|
||||
return PAM_SUCCESS;
|
||||
}
|
||||
#include "auth.h"
|
||||
#include "config.h"
|
||||
#include "log.h"
|
||||
#include "macros.h"
|
||||
#include "pam.h"
|
||||
#include "sessions.h"
|
||||
#include "ui.h"
|
||||
#include "util/path.h"
|
||||
#include "util/vec.h"
|
||||
|
||||
#define CHECK_PAM_RET(call) \
|
||||
ret = (call); \
|
||||
if (ret != PAM_SUCCESS) { \
|
||||
pam_end(pamh, ret); \
|
||||
return NULL; \
|
||||
#define XORG_MESSAGE_LENGTH 16
|
||||
|
||||
static void try_source_file(struct Vector* NNULLABLE vec_envlist,
|
||||
char* NNULLABLE filepath) {
|
||||
log_printf("sourcing %s\n", filepath);
|
||||
FILE* file2source = fopen(filepath, "r");
|
||||
if (file2source == NULL) {
|
||||
log_printf("error sourcing %s\n", filepath);
|
||||
return;
|
||||
}
|
||||
|
||||
void clear_screen() { printf("\x1b[H\x1b[J"); }
|
||||
char* line = NULL;
|
||||
size_t len = 0;
|
||||
ssize_t read;
|
||||
|
||||
pam_handle_t *get_pamh(char *user, char *passwd) {
|
||||
pam_handle_t *pamh = NULL;
|
||||
struct pam_conv pamc = {pam_conversation, (void *)passwd};
|
||||
int ret;
|
||||
while ((read = getline(&line, &len, file2source)) != -1) {
|
||||
if (read == 0 || (read > 0 && *line == '#')) continue;
|
||||
if (line[read - 1] == '\n') line[read - 1] = '\0';
|
||||
|
||||
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))
|
||||
for (ssize_t i = 1; i < read; i++) {
|
||||
if (line[i] == '=') {
|
||||
vec_push(vec_envlist, (void*)line);
|
||||
line = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return pamh;
|
||||
}
|
||||
#undef CHECK_PAM_RET
|
||||
|
||||
void *shmalloc(size_t size) {
|
||||
return mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS,
|
||||
-1, 0);
|
||||
if (line) free(line);
|
||||
(void)fclose(file2source);
|
||||
}
|
||||
|
||||
void moarEnv(char *user, struct session session, struct passwd *pw) {
|
||||
if (chdir(pw->pw_dir) == -1)
|
||||
print_errno("can't chdir to user home");
|
||||
static void source_paths(struct Vector* NNULLABLE vec_envlist,
|
||||
struct Vector* NNULLABLE abs_source,
|
||||
const char* NULLABLE user_home,
|
||||
struct Vector* NNULLABLE user_source) {
|
||||
for (size_t i = 0; i < abs_source->length; i++) {
|
||||
char* path = vec_get(abs_source, i);
|
||||
try_source_file(vec_envlist, path);
|
||||
}
|
||||
|
||||
setenv("HOME", pw->pw_dir, true);
|
||||
setenv("USER", pw->pw_name, true);
|
||||
setenv("SHELL", pw->pw_shell, true);
|
||||
// TERM
|
||||
setenv("LOGNAME", pw->pw_name, true);
|
||||
// MAIL?
|
||||
|
||||
// PATH?
|
||||
|
||||
char *xdg_session_type;
|
||||
if (session.type == SHELL)
|
||||
xdg_session_type = "tty";
|
||||
if (session.type == XORG)
|
||||
xdg_session_type = "x11";
|
||||
if (session.type == WAYLAND)
|
||||
xdg_session_type = "wayland";
|
||||
setenv("XDG_SESSION_TYPE", xdg_session_type, true);
|
||||
|
||||
/*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);*/
|
||||
if (user_home)
|
||||
for (size_t i = 0; i < user_source->length; i++) {
|
||||
char* path = NULL;
|
||||
asprintf(&path, "%s/%s", user_home, (char*)vec_get(user_source, i));
|
||||
if (!path) {
|
||||
log_puts("alloc failure on user source\n");
|
||||
continue;
|
||||
}
|
||||
try_source_file(vec_envlist, path);
|
||||
free(path);
|
||||
}
|
||||
else {
|
||||
log_puts("user has no home\n");
|
||||
}
|
||||
}
|
||||
|
||||
bool launch(char *user, char *passwd, struct session session,
|
||||
void (*cb)(void)) {
|
||||
struct passwd *pw = getpwnam(user);
|
||||
struct child_msg {
|
||||
char* msg;
|
||||
int _errno;
|
||||
bool err;
|
||||
};
|
||||
|
||||
/// block until X returns the display number or an error occurs
|
||||
static bool x_get_display(const int xorg_pipefd[2], int* display) {
|
||||
char buffer[XORG_MESSAGE_LENGTH];
|
||||
bool status;
|
||||
|
||||
close(xorg_pipefd[1]);
|
||||
ssize_t bytes_read = read(xorg_pipefd[0], buffer, sizeof(buffer) - 1);
|
||||
buffer[bytes_read] = '\0';
|
||||
|
||||
if (bytes_read > 0) {
|
||||
char* endptr;
|
||||
int val = (int)strtol(buffer, &endptr, 10);
|
||||
if (endptr == buffer) {
|
||||
(void)fputs("failed to parse Xorg display response\n", stderr);
|
||||
status = false;
|
||||
} else {
|
||||
*display = val;
|
||||
status = true;
|
||||
}
|
||||
} else if (bytes_read == 0) {
|
||||
(void)fputs("Xorg pipe closed\n", stderr);
|
||||
status = false;
|
||||
} else {
|
||||
perror("read");
|
||||
status = false;
|
||||
}
|
||||
|
||||
close(xorg_pipefd[0]);
|
||||
return status;
|
||||
}
|
||||
|
||||
/// small helper to push dyn arr
|
||||
static void push_dyn_arr(void*** arr, void* item) {
|
||||
struct Vector vec = vec_from_raw(*arr);
|
||||
vec_push(&vec, item);
|
||||
*arr = vec_as_raw(vec);
|
||||
}
|
||||
|
||||
// TODO: properly pass this down
|
||||
extern int vt;
|
||||
|
||||
static void start_xorg_server(struct passwd* pw, char** NNULLABLE envlist,
|
||||
int xorg_pipefd[2]) {
|
||||
close(xorg_pipefd[0]);
|
||||
if (!pw->pw_dir) _exit(EXIT_FAILURE);
|
||||
// !!!!!!!!!! ATTENTION: this fails silently, of course add failure msgs but
|
||||
// for now I can't so be careful
|
||||
if (vt == -1) _exit(EXIT_FAILURE);
|
||||
|
||||
// pass the pipe so Xorg can write the DISPLAY value in there
|
||||
char* fd_str;
|
||||
asprintf(&fd_str, "%d", xorg_pipefd[1]);
|
||||
if (!fd_str) _exit(EXIT_FAILURE);
|
||||
|
||||
char* vt_path;
|
||||
asprintf(&vt_path, "vt%d", vt);
|
||||
if (!vt_path) {
|
||||
free(fd_str);
|
||||
_exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
char* xorg_path = search_path("Xorg");
|
||||
if (!xorg_path) {
|
||||
(void)fputs("couldn't find Xorg binary in PATH, sure it's installed?\n",
|
||||
stderr);
|
||||
_exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
int exit = execle(xorg_path, xorg_path, "-displayfd", fd_str, vt_path, NULL,
|
||||
envlist);
|
||||
perror("exec");
|
||||
|
||||
free(vt_path);
|
||||
free(fd_str);
|
||||
free(xorg_path);
|
||||
_exit(exit);
|
||||
}
|
||||
|
||||
// TODO: add error msgs
|
||||
/// returns on completion
|
||||
static void launch_with_xorg_server(struct config* config,
|
||||
struct session_exec* NNULLABLE exec,
|
||||
struct passwd* pw,
|
||||
char** NNULLABLE envlist) {
|
||||
int xorg_pipefd[2];
|
||||
if (pipe(xorg_pipefd) == -1) _exit(EXIT_FAILURE);
|
||||
|
||||
(void)fflush(NULL);
|
||||
pid_t xorg_pid = fork();
|
||||
if (xorg_pid == 0) {
|
||||
start_xorg_server(pw, envlist, xorg_pipefd);
|
||||
}
|
||||
|
||||
int display = 0;
|
||||
if (!x_get_display(xorg_pipefd, &display)) {
|
||||
(void)fputs("failed to get X display, aborting\n", stderr);
|
||||
int status;
|
||||
waitpid(xorg_pid, &status, 0);
|
||||
_exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
char* display_env;
|
||||
asprintf(&display_env, "DISPLAY=:%d", display);
|
||||
if (!display_env) {
|
||||
(void)fputs("failure allocating memory for DISPLAY string\n", stderr);
|
||||
_exit(EXIT_FAILURE);
|
||||
}
|
||||
// convert back for convenient push-ing
|
||||
push_dyn_arr((void***)&envlist, display_env);
|
||||
if (!envlist) {
|
||||
(void)fputs("failure allocating memory for DISPLAY env\n", stderr);
|
||||
_exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
(void)fflush(NULL);
|
||||
pid_t xorg_session_pid = fork();
|
||||
if (xorg_session_pid == 0) {
|
||||
if (config->behavior.bypass_shell_login)
|
||||
session_exec_exec(exec, envlist);
|
||||
else
|
||||
session_exec_login_through_shell(exec, envlist);
|
||||
|
||||
perror("session exec error");
|
||||
(void)fputs("failure calling session\n", stderr);
|
||||
_exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
// looks weird, waiting on -1 should wait on any child and then just check if
|
||||
// its xorg server or the session and kill the other waiting on it
|
||||
pid_t pid;
|
||||
int status; // not even read for now
|
||||
while ((pid = waitpid(-1, &status, 0)) > 0) {
|
||||
if (pid == xorg_pid || pid == xorg_session_pid) {
|
||||
pid_t pid_to_kill = pid ^ xorg_pid ^ xorg_session_pid;
|
||||
if (pid == xorg_pid) printf("Xorg server died\n");
|
||||
if (pid == xorg_session_pid) printf("Xorg session died\n");
|
||||
|
||||
kill(pid_to_kill, SIGTERM);
|
||||
waitpid(pid_to_kill, &status, 0);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#define SEND_MSG(MSG) \
|
||||
{ \
|
||||
write(pipefd[1], &(MSG), sizeof(struct child_msg)); \
|
||||
close(pipefd[1]); \
|
||||
}
|
||||
#define SEND_ERR(MSG) \
|
||||
{ \
|
||||
write(pipefd[1], \
|
||||
&(struct child_msg){.msg = (MSG), ._errno = errno, .err = true}, \
|
||||
sizeof(struct child_msg)); \
|
||||
close(pipefd[1]); \
|
||||
_exit(EXIT_FAILURE); \
|
||||
}
|
||||
#define DUMMY_READ() \
|
||||
{ \
|
||||
char _dummy; \
|
||||
read(pipefd[0], &_dummy, sizeof(_dummy)); \
|
||||
}
|
||||
inline static void forked(struct config* config, int pipefd[2],
|
||||
struct passwd* pw, char* NNULLABLE user,
|
||||
struct session* NNULLABLE session,
|
||||
char** NNULLABLE envlist) {
|
||||
if (chdir(pw->pw_dir) == -1) SEND_ERR("chdir");
|
||||
if (setgid(pw->pw_gid) == -1) SEND_ERR("setgid");
|
||||
if (initgroups(user, pw->pw_gid) == -1) SEND_ERR("initgroups");
|
||||
if (setuid(pw->pw_uid) == -1) SEND_ERR("setuid");
|
||||
|
||||
SEND_MSG((struct child_msg){.err = false});
|
||||
DUMMY_READ();
|
||||
close(pipefd[0]);
|
||||
|
||||
if (!getenv("PATH")) {
|
||||
size_t path_size = confstr(_CS_PATH, NULL, 0);
|
||||
char* path_env = malloc(path_size);
|
||||
confstr(_CS_PATH, path_env, path_size);
|
||||
setenv("PATH", path_env, 1);
|
||||
free(path_env);
|
||||
}
|
||||
|
||||
log_printf(" [I] using shell login?: %s",
|
||||
config->behavior.bypass_shell_login ? "true" : "false");
|
||||
if (session->type == XORG) {
|
||||
launch_with_xorg_server(config, &session->exec, pw, envlist);
|
||||
_exit(EXIT_SUCCESS);
|
||||
} else {
|
||||
if (config->behavior.bypass_shell_login)
|
||||
session_exec_exec(&session->exec, envlist);
|
||||
else
|
||||
session_exec_login_through_shell(&session->exec, envlist);
|
||||
perror("session exec error");
|
||||
_exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
#undef SEND_MSG
|
||||
#undef SEND_ERR
|
||||
#undef DUMMY_READ
|
||||
|
||||
// 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) {
|
||||
print_err("could not get user info");
|
||||
return false;
|
||||
}
|
||||
|
||||
pam_handle_t *pamh = get_pamh(user, passwd);
|
||||
pam_handle_t* pamh = get_pamh(user, passwd);
|
||||
if (pamh == NULL) {
|
||||
print_err("error on pam authentication");
|
||||
print_pam_msg("authentication failed", PAM_ERROR_MSG);
|
||||
return false;
|
||||
}
|
||||
clear_pam_msg();
|
||||
|
||||
struct pamh_getenv_status env_ret =
|
||||
pamh_get_complete_env(pamh, pw, session.type);
|
||||
if (env_ret.error_flag != PAMH_ERR_NOERR) {
|
||||
if (env_ret.error_flag == PAMH_ERR_ALLOC) {
|
||||
print_err("allocator error");
|
||||
} else if (env_ret.error_flag == PAMH_ERR_ERRNO) {
|
||||
print_errno(env_ret.errfn);
|
||||
} else if (env_ret.error_flag == PAMH_ERR_NOERRNO) {
|
||||
print_err(env_ret.errfn);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool *reach_session = shmalloc(sizeof(bool));
|
||||
if (reach_session == NULL) {
|
||||
perror("error allocating shared memory");
|
||||
struct Vector envlist_vec = vec_from_raw((void**)env_ret.envlist);
|
||||
|
||||
source_paths(&envlist_vec, &config->behavior.source, pw->pw_dir,
|
||||
&config->behavior.user_source);
|
||||
char** envlist = (char**)vec_as_raw(envlist_vec);
|
||||
if (!envlist) {
|
||||
print_err("vec alloc error");
|
||||
return false;
|
||||
}
|
||||
*reach_session = false;
|
||||
|
||||
int pipefd[2];
|
||||
pipe(pipefd);
|
||||
|
||||
uint pid = fork();
|
||||
if (pid == 0) { // child
|
||||
char *TERM = NULL;
|
||||
char *_GETTERM = getenv("TERM");
|
||||
if (_GETTERM != NULL)
|
||||
strcln(&TERM, _GETTERM);
|
||||
if (clearenv() != 0) {
|
||||
print_errno("clearenv");
|
||||
_exit(EXIT_FAILURE);
|
||||
if (pid == 0)
|
||||
forked(config, pipefd, pw, user, &session, envlist);
|
||||
else {
|
||||
struct child_msg msg;
|
||||
read(pipefd[0], &msg, sizeof(struct child_msg));
|
||||
close(pipefd[0]);
|
||||
if (msg.err) {
|
||||
errno = msg._errno;
|
||||
print_errno(msg.msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
char **envlist = pam_getenvlist(pamh);
|
||||
if (envlist == NULL) {
|
||||
print_errno("pam_getenvlist");
|
||||
_exit(EXIT_FAILURE);
|
||||
}
|
||||
for (uint i = 0; envlist[i] != NULL; i++) {
|
||||
putenv(envlist[i]);
|
||||
}
|
||||
// FIXME: path hotfix
|
||||
putenv("PATH=/bin:/usr/bin");
|
||||
if (TERM != NULL) {
|
||||
setenv("TERM", TERM, true);
|
||||
free(TERM);
|
||||
}
|
||||
if (cb) cb();
|
||||
printf("\x1b[0m\x1b[H\x1b[J");
|
||||
(void)fflush(stdout);
|
||||
close(pipefd[1]);
|
||||
|
||||
free(envlist);
|
||||
moarEnv(user, session, pw);
|
||||
|
||||
// TODO: chown stdin to user
|
||||
// does it inherit stdin from parent and
|
||||
// does parent need to reclaim it after
|
||||
// this dies?
|
||||
|
||||
if (setgid(pw->pw_gid) == -1) {
|
||||
print_errno("setgid");
|
||||
_exit(EXIT_FAILURE);
|
||||
}
|
||||
if (initgroups(user, pw->pw_gid) == -1) {
|
||||
print_errno("initgroups");
|
||||
_exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (setuid(pw->pw_uid) == -1) {
|
||||
perror("setuid");
|
||||
_exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (cb != NULL)
|
||||
cb();
|
||||
|
||||
*reach_session = true;
|
||||
|
||||
// TODO: these will be different due to TryExec
|
||||
// and, Exec/TryExec might contain spaces as args
|
||||
if (session.type == SHELL) {
|
||||
clear_screen();
|
||||
execlp(session.exec, session.exec, NULL);
|
||||
} else if (session.type == XORG || session.type == WAYLAND) {
|
||||
clear_screen();
|
||||
execlp(session.exec, session.exec, NULL);
|
||||
}
|
||||
perror("execl error");
|
||||
fprintf(stderr, "failure calling session\n");
|
||||
} else {
|
||||
waitpid(pid, NULL, 0);
|
||||
int exit_code;
|
||||
waitpid((pid_t)pid, &exit_code, 0);
|
||||
|
||||
pam_setcred(pamh, PAM_DELETE_CRED);
|
||||
pam_close_session(pamh, 0);
|
||||
pam_end(pamh, PAM_SUCCESS);
|
||||
|
||||
if (*reach_session == false) {
|
||||
return false;
|
||||
} else
|
||||
if (exit_code != 0) return false;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
// NOLINTEND(readability-function-cognitive-complexity)
|
||||
|
||||
25
src/chvt.c
25
src/chvt.c
@@ -3,34 +3,38 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <chvt.h>
|
||||
#include "chvt.h"
|
||||
#include "macros.h"
|
||||
|
||||
static char *vterms[] = {"/dev/tty", "/dev/tty0", "/dev/vc/0", "/dev/systty",
|
||||
static char* vterms[] = {"/dev/tty", "/dev/tty0", "/dev/vc/0", "/dev/systty",
|
||||
"/dev/console"};
|
||||
|
||||
int chvt_str(char *str) {
|
||||
char *err;
|
||||
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;
|
||||
if (i > INT_MAX || i < INT_MIN || *err) return -1;
|
||||
|
||||
return chvt((int)i);
|
||||
}
|
||||
|
||||
int vt = -1;
|
||||
int chvt(int n) {
|
||||
fprintf(stderr, "activating vt %d\n", n);
|
||||
(void)fprintf(stderr, "activating vt %d\n", n);
|
||||
vt = n;
|
||||
// NOLINTNEXTLINE(readability-identifier-length)
|
||||
char c = 0;
|
||||
for (int i = 0; i < sizeof(vterms) / sizeof(vterms[0]); i++) {
|
||||
for (size_t i = 0; i < LEN(vterms); i++) {
|
||||
int fd = open(vterms[i], O_RDWR);
|
||||
if (fd >= 0 && isatty(fd) && ioctl(fd, KDGKBTYPE, &c) == 0 && c < 3) {
|
||||
if (ioctl(fd, VT_ACTIVATE, n) < 0 || ioctl(fd, VT_WAITACTIVE, n) < 0) {
|
||||
fprintf(stderr, "Couldn't activate vt %d\n", n);
|
||||
(void)fprintf(stderr, "Couldn't activate vt %d\n", n);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -38,6 +42,7 @@ int chvt(int n) {
|
||||
close(fd);
|
||||
}
|
||||
|
||||
fprintf(stderr, "Couldn't get a file descriptor referring to the console.\n");
|
||||
(void)fputs("Couldn't get a file descriptor referring to the console.\n",
|
||||
stderr);
|
||||
return -1;
|
||||
}
|
||||
|
||||
354
src/config.c
354
src/config.c
@@ -1,136 +1,256 @@
|
||||
#include "util.h"
|
||||
#include <errno.h>
|
||||
#include <linux/fs.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <config.h>
|
||||
#include "config.h"
|
||||
#include "desktop.h"
|
||||
#include "keys.h"
|
||||
#include "log.h"
|
||||
#include "macros.h"
|
||||
#include "util/vec.h"
|
||||
|
||||
bool line_parser(FILE *fd, ssize_t *blksize,
|
||||
u_char (*cb)(char *key, char *value)) {
|
||||
size_t opt_size = 4096;
|
||||
if (blksize != NULL)
|
||||
opt_size = *blksize;
|
||||
#define UPPER_HALF_BYTE 4
|
||||
int parse_hex(char* _at, char x1, char x2) {
|
||||
// make linter happy
|
||||
uint8_t* at = (uint8_t*)_at;
|
||||
|
||||
while (true) {
|
||||
size_t alloc_size = opt_size;
|
||||
char *buf = malloc(alloc_size);
|
||||
if (buf == NULL)
|
||||
return false;
|
||||
ssize_t read_size = getline(&buf, &alloc_size, fd);
|
||||
if (read_size == -1) {
|
||||
free(buf);
|
||||
break;
|
||||
*at = 0;
|
||||
|
||||
if ('0' <= x1 && x1 <= '9') {
|
||||
*at += (x1 - '0') << UPPER_HALF_BYTE;
|
||||
} else if ('A' <= x1 && x1 <= 'F') {
|
||||
*at += (x1 - 'A' + 10) << UPPER_HALF_BYTE;
|
||||
} else if ('a' <= x1 && x1 <= 'f') {
|
||||
*at += (x1 - 'a' + 10) << UPPER_HALF_BYTE;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
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 true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct config *__config;
|
||||
u_char config_line_handler(char *k, char *v) {
|
||||
if (strcmp(k, "colors.bg") == 0)
|
||||
__config->theme.colors.bg = v;
|
||||
else if (strcmp(k, "colors.fg") == 0)
|
||||
__config->theme.colors.fg = v;
|
||||
else if (strcmp(k, "colors.err") == 0)
|
||||
__config->theme.colors.err = v;
|
||||
else if (strcmp(k, "colors.s_wayland") == 0)
|
||||
__config->theme.colors.s_wayland = v;
|
||||
else if (strcmp(k, "colors.s_xorg") == 0)
|
||||
__config->theme.colors.s_xorg = v;
|
||||
else if (strcmp(k, "colors.s_shell") == 0)
|
||||
__config->theme.colors.s_shell = v;
|
||||
else if (strcmp(k, "colors.e_hostname") == 0)
|
||||
__config->theme.colors.e_hostname = v;
|
||||
else if (strcmp(k, "colors.e_date") == 0)
|
||||
__config->theme.colors.e_date = v;
|
||||
else if (strcmp(k, "colors.e_box") == 0)
|
||||
__config->theme.colors.e_box = v;
|
||||
else if (strcmp(k, "colors.e_header") == 0)
|
||||
__config->theme.colors.e_header = v;
|
||||
else if (strcmp(k, "colors.e_user") == 0)
|
||||
__config->theme.colors.e_user = v;
|
||||
else if (strcmp(k, "colors.e_passwd") == 0)
|
||||
__config->theme.colors.e_passwd = v;
|
||||
else if (strcmp(k, "colors.e_badpasswd") == 0)
|
||||
__config->theme.colors.e_badpasswd = v;
|
||||
else if (strcmp(k, "colors.e_key") == 0)
|
||||
__config->theme.colors.e_key = v;
|
||||
else if (strcmp(k, "chars.hb") == 0)
|
||||
__config->theme.chars.hb = v;
|
||||
else if (strcmp(k, "chars.vb") == 0)
|
||||
__config->theme.chars.vb = v;
|
||||
else if (strcmp(k, "chars.ctl") == 0)
|
||||
__config->theme.chars.ctl = v;
|
||||
else if (strcmp(k, "chars.ctr") == 0)
|
||||
__config->theme.chars.ctr = v;
|
||||
else if (strcmp(k, "chars.cbl") == 0)
|
||||
__config->theme.chars.cbl = v;
|
||||
else if (strcmp(k, "chars.cbr") == 0)
|
||||
__config->theme.chars.cbr = v;
|
||||
else if (strcmp(k, "functions.poweroff") == 0)
|
||||
__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_wayland") == 0)
|
||||
__config->strings.s_wayland = v;
|
||||
else if (strcmp(k, "strings.s_xorg") == 0)
|
||||
__config->strings.s_xorg = v;
|
||||
else if (strcmp(k, "strings.s_shell") == 0)
|
||||
__config->strings.s_shell = v;
|
||||
else if (strcmp(k, "behavior.include_defshell") == 0)
|
||||
__config->behavior.include_defshell = strcmp(v, "true") == 0;
|
||||
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;
|
||||
long long* number;
|
||||
bool* boolean;
|
||||
enum Keys* key;
|
||||
struct Vector* vec;
|
||||
uintptr_t ptr;
|
||||
};
|
||||
struct parser_error parse_key(enum IntrospectionType typ, union typ_ptr at,
|
||||
char* key) {
|
||||
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 NUMBER:
|
||||
errno = 0;
|
||||
*at.number = strtol(key, NULL, 10);
|
||||
if (errno) {
|
||||
FAIL("strtol failed");
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
NOFAIL;
|
||||
}
|
||||
#undef FAIL
|
||||
#undef NOFAIL
|
||||
|
||||
// NOLINTBEGIN(readability-identifier-length,readability-function-cognitive-complexity)
|
||||
struct status config_line_handler(void* _config, char* table, char* k,
|
||||
char* v) {
|
||||
struct config* config = (struct config*)_config;
|
||||
struct status ret = {.finish = false};
|
||||
|
||||
const struct introspection_table* this_intros_table = NULL;
|
||||
for (size_t i = 0; i < LEN(CONFIG_INSTROSPECTION); i++) {
|
||||
if (table == NULL) {
|
||||
if (table != CONFIG_INSTROSPECTION[i].tname) continue;
|
||||
} else if (strcmp(CONFIG_INSTROSPECTION[i].tname, table) != 0)
|
||||
continue;
|
||||
this_intros_table = &CONFIG_INSTROSPECTION[i];
|
||||
break;
|
||||
}
|
||||
if (this_intros_table == NULL) {
|
||||
log_printf("[E] table '%s' is not part of the config\n", table);
|
||||
return ret;
|
||||
}
|
||||
|
||||
const struct introspection_item* this_intros_key = NULL;
|
||||
for (size_t i = 0; i < this_intros_table->len; i++) {
|
||||
if (strcmp(this_intros_table->intros[i].name, k) != 0) continue;
|
||||
this_intros_key = &this_intros_table->intros[i];
|
||||
break;
|
||||
}
|
||||
if (this_intros_key == NULL) {
|
||||
log_printf("[E] key '%s' is not part of the table '%s' in config\n", k,
|
||||
table);
|
||||
return ret;
|
||||
}
|
||||
|
||||
size_t offset = this_intros_table->offset + this_intros_key->offset;
|
||||
union typ_ptr k_addr = {.ptr = (uintptr_t)config + offset};
|
||||
|
||||
log_printf("[I] parsing [%s.%s] as %s\n", table, k,
|
||||
INTROS_TYS_NAMES[this_intros_key->typ]);
|
||||
struct parser_error err = parse_key(this_intros_key->typ, k_addr, v);
|
||||
if (err.msg != NULL) {
|
||||
log_printf("[E] cfg parser, failed to parse [%s.%s] (%s): %s\n", table, k,
|
||||
INTROS_TYS_NAMES[this_intros_key->typ], err.msg);
|
||||
log_printf("%s\n%*c^\n", v, err.col);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (this_intros_key->typ == NUMBER)
|
||||
log_printf("[I] cfg parsed [%s.%s] (%lld)\n", table, k, *k_addr.number);
|
||||
else if (this_intros_key->typ == STRING)
|
||||
log_printf("[I] cfg parsed [%s.%s] (%s)\n", table, k, *k_addr.string);
|
||||
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) {
|
||||
struct stat sb;
|
||||
FILE *fd = fopen(path, "r");
|
||||
if (fd == NULL || (stat(path, &sb) == -1)) {
|
||||
perror("fopen");
|
||||
return NULL;
|
||||
int parse_config(struct config* NNULLABLE config, char* NNULLABLE path) {
|
||||
FILE* fd = fopen(path, "r");
|
||||
if (fd == NULL) {
|
||||
log_perror("fopen");
|
||||
log_printf(" [I] No config, place one at " LIDM_CONF_PATH
|
||||
" or set the LIDM_CONF env variable\n");
|
||||
return 0; // Its fine now anyways
|
||||
}
|
||||
|
||||
__config = malloc(sizeof(struct config));
|
||||
if (__config == NULL)
|
||||
return NULL;
|
||||
bool ret = line_parser(fd, (ssize_t *)&sb.st_blksize, config_line_handler);
|
||||
if (!ret) {
|
||||
free(__config);
|
||||
return NULL;
|
||||
}
|
||||
bool ret = read_desktop(fd, config, config_line_handler);
|
||||
(void)fclose(fd);
|
||||
|
||||
return __config;
|
||||
if (!ret) return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
84
src/desktop.c
Normal file
84
src/desktop.c
Normal file
@@ -0,0 +1,84 @@
|
||||
#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;
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(readability-function-cognitive-complexity)
|
||||
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];
|
||||
if (buf_start[read_size - 1] == '\n') buf_start[read_size - 1] = '\0';
|
||||
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;
|
||||
}
|
||||
220
src/desktop_exec.c
Normal file
220
src/desktop_exec.c
Normal file
@@ -0,0 +1,220 @@
|
||||
// TODO: rewrite properly
|
||||
// NOLINTBEGIN(clang-diagnostic-nullability-completeness)
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "desktop_exec.h"
|
||||
#include "macros.h"
|
||||
#include "util/path.h"
|
||||
|
||||
// constants for exec string parsing
|
||||
#define MAX_ARGS 100
|
||||
// ARG_LENGTH is the initial length of a parsed argument
|
||||
#define ARG_LENGTH 64
|
||||
|
||||
char* NULLABLE desktop_as_cmdline(char** args) {
|
||||
if (args[0] == NULL) return NULL;
|
||||
size_t fmtd_len = 0;
|
||||
|
||||
char** ptr = args;
|
||||
while (*ptr) {
|
||||
fmtd_len += strlen(*ptr) + 1;
|
||||
ptr++;
|
||||
}
|
||||
fmtd_len -= 1;
|
||||
|
||||
char* fmt_cmdline = malloc(fmtd_len + 1);
|
||||
if (!fmt_cmdline) return NULL;
|
||||
|
||||
size_t fmting_len = 0;
|
||||
ptr = args;
|
||||
while (*ptr) {
|
||||
char* nbyte = stpcpy(&fmt_cmdline[fmting_len], *ptr);
|
||||
*nbyte = ' ';
|
||||
|
||||
fmting_len += nbyte - &fmt_cmdline[fmting_len] + 1;
|
||||
ptr++;
|
||||
}
|
||||
fmt_cmdline[fmting_len - 1] = '\0';
|
||||
|
||||
return fmt_cmdline;
|
||||
}
|
||||
|
||||
// parse Exec=/bin/prog arg1 arg2\ with\ spaces
|
||||
void free_parsed_args(int arg_count, char** args) {
|
||||
if (!args) return;
|
||||
for (int i = 0; i < arg_count; i++) {
|
||||
free(args[i]);
|
||||
}
|
||||
free((void*)args);
|
||||
}
|
||||
|
||||
/* small closure-like struct to pass state to helper functions */
|
||||
struct ctx {
|
||||
char** pcur;
|
||||
size_t* pcur_len;
|
||||
size_t* pcur_cap;
|
||||
char*** pargv;
|
||||
int* pargc;
|
||||
};
|
||||
/* append_char(state, ch) -> 0 on error, 1 on success */
|
||||
int append_char(struct ctx* st, char ch) {
|
||||
char** pcur = st->pcur;
|
||||
size_t* plen = st->pcur_len;
|
||||
size_t* pcap = st->pcur_cap;
|
||||
if (*plen + 1 >= *pcap) {
|
||||
size_t newcap = *pcap ? (*pcap) * 2 : ARG_LENGTH;
|
||||
char* cur = (char*)realloc(*pcur, newcap);
|
||||
if (!cur) return 0;
|
||||
*pcur = cur;
|
||||
*pcap = newcap;
|
||||
}
|
||||
(*pcur)[(*plen)++] = ch;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* push_arg(state) -> 0 on error, 1 on success */
|
||||
int push_arg(struct ctx* st) {
|
||||
char** pcur = st->pcur;
|
||||
size_t* plen = st->pcur_len;
|
||||
size_t* pcap = st->pcur_cap;
|
||||
char*** pargv = st->pargv;
|
||||
int* pargc = st->pargc;
|
||||
|
||||
if (*pargc > MAX_ARGS) {
|
||||
return 1;
|
||||
}
|
||||
if (!*pcur) {
|
||||
char* empty = strdup("");
|
||||
if (!empty) return 0;
|
||||
char** na = (char**)realloc((void*)*pargv, sizeof(char*) * ((*pargc) + 1));
|
||||
if (!na) {
|
||||
free(empty);
|
||||
return 0;
|
||||
}
|
||||
*pargv = na;
|
||||
(*pargv)[(*pargc)++] = empty;
|
||||
return 1;
|
||||
}
|
||||
if (!append_char(st, '\0')) return 0;
|
||||
char* final = (char*)realloc(*pcur, *plen);
|
||||
if (!final) final = *pcur;
|
||||
*pcur = NULL;
|
||||
*plen = 0;
|
||||
*pcap = 0;
|
||||
char** na = (char**)realloc((void*)*pargv, sizeof(char*) * ((*pargc) + 1));
|
||||
if (!na) {
|
||||
free(final);
|
||||
return 0;
|
||||
}
|
||||
*pargv = na;
|
||||
(*pargv)[(*pargc)++] = final;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Return codes:
|
||||
0 = success
|
||||
1 = bad args
|
||||
2 = memory
|
||||
3 = syntax
|
||||
Important: call free_parsed_args afterwards to free the passed ***args
|
||||
*/
|
||||
|
||||
// NOLINTBEGIN(readability-function-cognitive-complexity)
|
||||
int parse_exec_string(const char* exec_s, int* arg_count, char*** args) {
|
||||
if (!exec_s || !args || !arg_count) return 1;
|
||||
*args = NULL;
|
||||
*arg_count = 0;
|
||||
|
||||
size_t len = strlen(exec_s);
|
||||
size_t idx = 0;
|
||||
char* cur = NULL;
|
||||
size_t cur_len = 0;
|
||||
size_t cur_cap = 0;
|
||||
char** argv = NULL;
|
||||
int argc = 0;
|
||||
int in_quote = 0;
|
||||
|
||||
struct ctx ctx;
|
||||
ctx.pcur = &cur;
|
||||
ctx.pcur_len = &cur_len;
|
||||
ctx.pcur_cap = &cur_cap;
|
||||
ctx.pargv = &argv;
|
||||
ctx.pargc = &argc;
|
||||
|
||||
while (idx < len) {
|
||||
char cur_c = exec_s[idx];
|
||||
if (!in_quote && (cur_c == ' ' || cur_c == '\t' || cur_c == '\n')) {
|
||||
if (cur_cap) {
|
||||
if (!push_arg(&ctx)) goto nomem;
|
||||
}
|
||||
idx++;
|
||||
continue;
|
||||
}
|
||||
if (!in_quote && cur_c == '"') {
|
||||
in_quote = 1;
|
||||
idx++;
|
||||
continue;
|
||||
}
|
||||
if (in_quote && cur_c == '"') {
|
||||
in_quote = 0;
|
||||
idx++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (cur_c == '\\') {
|
||||
if (idx + 1 >= len) goto syntax_err;
|
||||
if (!append_char(&ctx, exec_s[idx + 1])) goto nomem;
|
||||
idx += 2;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (cur_c == '%') {
|
||||
if (idx + 1 >= len) goto syntax_err;
|
||||
if (exec_s[idx + 1] == '%') {
|
||||
if (!append_char(&ctx, '%')) goto nomem;
|
||||
idx += 2;
|
||||
continue;
|
||||
}
|
||||
/* drop any %X */
|
||||
idx += 2;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!append_char(&ctx, cur_c)) goto nomem;
|
||||
idx++;
|
||||
}
|
||||
|
||||
if (in_quote) goto syntax_err;
|
||||
if (cur_cap) {
|
||||
if (!push_arg(&ctx)) goto nomem;
|
||||
}
|
||||
char** na = (char**)realloc((void*)argv, sizeof(char*) * (argc + 1));
|
||||
if (!na) goto nomem;
|
||||
argv = na;
|
||||
argv[argc] = NULL;
|
||||
|
||||
*args = argv;
|
||||
*arg_count = argc;
|
||||
return 0;
|
||||
|
||||
nomem:
|
||||
if (cur) free(cur);
|
||||
free_parsed_args(argc, argv);
|
||||
*args = NULL;
|
||||
*arg_count = 0;
|
||||
return 2;
|
||||
|
||||
syntax_err:
|
||||
if (cur) free(cur);
|
||||
free_parsed_args(argc, argv);
|
||||
*args = NULL;
|
||||
*arg_count = 0;
|
||||
return 3;
|
||||
}
|
||||
// NOLINTEND(readability-function-cognitive-complexity)
|
||||
// NOLINTEND(clang-diagnostic-nullability-completeness)
|
||||
102
src/efield.c
102
src/efield.c
@@ -1,78 +1,80 @@
|
||||
#include <string.h>
|
||||
|
||||
#include <efield.h>
|
||||
#include <ui.h>
|
||||
#include "efield.h"
|
||||
#include "ui.h"
|
||||
#include "util/utf8.h"
|
||||
|
||||
struct editable_field field_new(char *content) {
|
||||
struct editable_field __efield;
|
||||
struct editable_field efield_new(char* content) {
|
||||
struct editable_field efield;
|
||||
if (content != NULL) {
|
||||
__efield.length = __efield.pos = strlen(content);
|
||||
memcpy(__efield.content, content, __efield.length);
|
||||
efield.pos = strlen(content);
|
||||
memcpy(efield.content, content, strlen(content) + 1);
|
||||
} 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) {
|
||||
field->length = field->pos = pos;
|
||||
field->content[field->length] = '\0';
|
||||
void efield_trim(struct editable_field* self, uint8_t pos) {
|
||||
self->pos = pos;
|
||||
self->content[pos + 1] = '\0';
|
||||
}
|
||||
|
||||
void field_update(struct editable_field *field, char *update) {
|
||||
u_char insert_len = strlen(update);
|
||||
if (insert_len == 0)
|
||||
return;
|
||||
#define BACKSPACE_CODE 127
|
||||
void efield_update(struct editable_field* self, char* update) {
|
||||
uint8_t insert_len = strlen(update);
|
||||
if (insert_len == 0) 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) {
|
||||
// backspace
|
||||
if (*update == 127) {
|
||||
if (field->pos == 0)
|
||||
return;
|
||||
if (field->pos < field->length) {
|
||||
memmove(&field->content[field->pos - 1], &field->content[field->pos],
|
||||
field->length - field->pos);
|
||||
}
|
||||
(field->pos)--;
|
||||
(field->length)--;
|
||||
field->content[field->length] = '\0';
|
||||
if (*update == BACKSPACE_CODE) {
|
||||
if (self->pos == 0) return;
|
||||
char* curr = &self->content[self->pos];
|
||||
char* prev = (char*)utf8back(curr);
|
||||
memmove(prev, curr, strlen(self->content) - self->pos + 1);
|
||||
|
||||
self->pos -= curr - prev;
|
||||
return;
|
||||
}
|
||||
// TODO: Del
|
||||
}
|
||||
|
||||
// append
|
||||
if (field->length + field->pos >= 255) {
|
||||
if (strlen(update) + self->pos + 1 >= 255) {
|
||||
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;
|
||||
field->length += insert_len;
|
||||
field->content[field->length] = '\0';
|
||||
// move the after pos, including nullbyte
|
||||
memmove(&self->content[self->pos + insert_len], &self->content[self->pos],
|
||||
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
|
||||
bool field_seek(struct editable_field *field, char seek) {
|
||||
if (field->length == 0)
|
||||
return false;
|
||||
bool efield_seek(struct editable_field* self, char seek) {
|
||||
if (*self->content == '\0') return false;
|
||||
if (seek == 0) return false;
|
||||
|
||||
if (seek < 0 && -seek > field->pos)
|
||||
field->pos = 0;
|
||||
else if (seek > 0 && 255 - field->pos < seek)
|
||||
field->pos = 255;
|
||||
else
|
||||
field->pos += seek;
|
||||
uint8_t count = seek < 0 ? -seek : seek;
|
||||
char* ptr = &self->content[self->pos];
|
||||
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 = (uint8_t)(ptr - self->content);
|
||||
return ptr != start;
|
||||
}
|
||||
|
||||
77
src/keys.c
Normal file
77
src/keys.c
Normal file
@@ -0,0 +1,77 @@
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "keys.h"
|
||||
#include "macros.h"
|
||||
#include "ui.h"
|
||||
|
||||
static int selret_magic();
|
||||
|
||||
int find_keyname(enum Keys* at, const char* name) {
|
||||
for (size_t i = 0; i < LEN(KEY_MAPPINGS); i++) {
|
||||
if (strcmp(KEY_NAMES[i], name) == 0) {
|
||||
*at = (enum Keys)i;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
struct option_keys find_ansi(const char* seq) {
|
||||
for (size_t i = 0; i < LEN(KEY_MAPPINGS); i++) {
|
||||
struct key_mapping mapping = KEY_MAPPINGS[i];
|
||||
for (size_t j = 0; mapping.sequences[j] != NULL; j++) {
|
||||
if (strcmp(mapping.sequences[j], seq) == 0) {
|
||||
return (struct option_keys){
|
||||
.is_some = true,
|
||||
.key = (enum Keys)i,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
return (struct option_keys){.is_some = false};
|
||||
}
|
||||
|
||||
void read_press(uint8_t* length, char* out) {
|
||||
*length = 0;
|
||||
|
||||
while (true) {
|
||||
if (read(STDIN_FILENO, &out[(*length)++], 1) != 1) {
|
||||
print_errno("read error");
|
||||
sleep(3);
|
||||
exit(1);
|
||||
}
|
||||
int selret = selret_magic();
|
||||
if (selret == -1) {
|
||||
print_errno("selret error");
|
||||
} else if (selret != 1) {
|
||||
out[*length] = '\0';
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool read_press_nb(uint8_t* length, char* out, struct timeval* tv) {
|
||||
fd_set fds;
|
||||
FD_ZERO(&fds);
|
||||
FD_SET(STDIN_FILENO, &fds);
|
||||
errno = 0;
|
||||
int ret = select(STDIN_FILENO + 1, &fds, NULL, NULL, tv);
|
||||
if (errno || ret <= 0) return false;
|
||||
|
||||
read_press(length, out);
|
||||
return true;
|
||||
}
|
||||
|
||||
// https://stackoverflow.com/a/48040042
|
||||
static int selret_magic() {
|
||||
fd_set set;
|
||||
struct timeval timeout;
|
||||
FD_ZERO(&set);
|
||||
FD_SET(STDIN_FILENO, &set);
|
||||
timeout.tv_sec = 0;
|
||||
timeout.tv_usec = 0;
|
||||
return select(1, &set, NULL, NULL, &timeout);
|
||||
}
|
||||
54
src/launch_state.c
Normal file
54
src/launch_state.c
Normal file
@@ -0,0 +1,54 @@
|
||||
// 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;
|
||||
ssize_t chars = getline(&state->username, &num, state_fd);
|
||||
if (chars <= 0) goto fail;
|
||||
if (state->username[chars - 1] == '\n') state->username[chars - 1] = 0;
|
||||
|
||||
num = 0;
|
||||
chars = getline(&state->session_opt, &num, state_fd);
|
||||
if (chars <= 0) {
|
||||
free(state->session_opt);
|
||||
goto fail;
|
||||
}
|
||||
if (state->session_opt[chars - 1] == '\n') state->session_opt[chars - 1] = 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;
|
||||
}
|
||||
39
src/log.c
Normal file
39
src/log.c
Normal file
@@ -0,0 +1,39 @@
|
||||
#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);
|
||||
(void)setvbuf(fd, NULL, _IONBF, 0);
|
||||
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\n", s, strerror(errno));
|
||||
else
|
||||
(void)fprintf(logger_out, "%s\n", strerror(errno));
|
||||
}
|
||||
98
src/main.c
98
src/main.c
@@ -1,32 +1,94 @@
|
||||
#include <pwd.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/types.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <chvt.h>
|
||||
#include <config.h>
|
||||
#include <sessions.h>
|
||||
#include <ui.h>
|
||||
#include <users.h>
|
||||
#include "chvt.h"
|
||||
#include "config.h"
|
||||
#include "log.h"
|
||||
#include "macros.h"
|
||||
#include "sessions.h"
|
||||
#include "signal_handler.h"
|
||||
#include "ui.h"
|
||||
#include "users.h"
|
||||
#include "util/vec.h"
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
if (argc == 2)
|
||||
#define DATESTR_MAXBUFSIZE 0x20
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
// Logger
|
||||
char* log_output = getenv("LIDM_LOG");
|
||||
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);
|
||||
log_puts("Starting log:");
|
||||
}
|
||||
|
||||
if (argc == 2) {
|
||||
if (strcmp(argv[1], "-v") == 0 || strcmp(argv[1], "--version") == 0) {
|
||||
// NOLINTBEGIN(clang-analyzer-deadcode.DeadStores)
|
||||
char* version = "?";
|
||||
char* revision = "?";
|
||||
char* builddate = "?";
|
||||
char* compilever = "?";
|
||||
// NOLINTEND(clang-analyzer-deadcode.DeadStores)
|
||||
#ifdef LIDM_VERSION
|
||||
version = LIDM_VERSION;
|
||||
#endif
|
||||
#ifdef LIDM_GIT_REV
|
||||
revision = LIDM_GIT_REV;
|
||||
#endif
|
||||
#ifdef LIDM_BUILD_TS
|
||||
time_t ts = LIDM_BUILD_TS;
|
||||
char date_buf[DATESTR_MAXBUFSIZE];
|
||||
builddate = date_buf;
|
||||
if (strftime(date_buf, 0xff, "%Y-%m-%dT%H:%M:%SZ", localtime(&ts)) > 0)
|
||||
builddate = date_buf;
|
||||
#endif
|
||||
#ifdef COMPILER_VERSION
|
||||
compilever = COMPILER_VERSION;
|
||||
#endif
|
||||
printf("lidm version %s (git %s, build date %s, compiler %s)\n", version,
|
||||
revision, builddate, compilever);
|
||||
return 0;
|
||||
}
|
||||
if (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0) {
|
||||
printf(
|
||||
"Usage: lidm [vt number]\n"
|
||||
"Options:\n"
|
||||
" -h, --help Display help menu\n"
|
||||
" -v, --version Display version information\n");
|
||||
return 0;
|
||||
}
|
||||
// Chvt
|
||||
chvt_str(argv[1]);
|
||||
}
|
||||
|
||||
char *conf_override = getenv("LIDM_CONF");
|
||||
struct config *config =
|
||||
parse_config(conf_override == NULL ? "/etc/lidm.ini" : conf_override);
|
||||
if (config == NULL) {
|
||||
fprintf(stderr, "error parsing config\n");
|
||||
// Copy
|
||||
struct config config = DEFAULT_CONFIG;
|
||||
char* conf_override = getenv("LIDM_CONF");
|
||||
char* conf_path = conf_override ? conf_override : LIDM_CONF_PATH;
|
||||
if (parse_config(&config, conf_path) != 0) {
|
||||
(void)fputs("error parsing config\n", stderr);
|
||||
return 1;
|
||||
}
|
||||
setup(*config);
|
||||
setup(&config);
|
||||
|
||||
struct users_list *users = get_human_users();
|
||||
struct sessions_list *sessions = get_avaliable_sessions();
|
||||
struct Vector users = get_human_users();
|
||||
struct Vector sessions = get_avaliable_sessions();
|
||||
|
||||
int ret = load(users, sessions);
|
||||
if (ret == 0)
|
||||
execl(argv[0], argv[0], NULL);
|
||||
setup_sigterm();
|
||||
|
||||
int ret = load(&users, &sessions);
|
||||
if (ret == 0) execl(argv[0], argv[0], NULL);
|
||||
}
|
||||
|
||||
76
src/ofield.c
Normal file
76
src/ofield.c
Normal file
@@ -0,0 +1,76 @@
|
||||
#include <stddef.h>
|
||||
|
||||
#include "efield.h"
|
||||
#include "ofield.h"
|
||||
#include "ui.h"
|
||||
#include "util/utf8.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;
|
||||
}
|
||||
|
||||
uint8_t ofield_display_cursor_col(struct opts_field* self, uint8_t maxlen) {
|
||||
if (self->current_opt == 0) {
|
||||
uint8_t display_len = utf8len(self->efield.content);
|
||||
uint8_t 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;
|
||||
}
|
||||
197
src/pam.c
Normal file
197
src/pam.c
Normal file
@@ -0,0 +1,197 @@
|
||||
#include <pwd.h>
|
||||
#include <security/_pam_types.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "log.h"
|
||||
#include "macros.h"
|
||||
#include "pam.h"
|
||||
#include "sessions.h"
|
||||
#include "ui.h"
|
||||
|
||||
struct envpair {
|
||||
const char* NNULLABLE name;
|
||||
char* NULLABLE value;
|
||||
};
|
||||
|
||||
char* NULLABLE make_env_kv(const char* NNULLABLE key, char* NNULLABLE value) {
|
||||
char* buf = NULL;
|
||||
asprintf(&buf, "%s=%s", key, value);
|
||||
return buf;
|
||||
}
|
||||
|
||||
void free_envlist(char** NNULLABLE envlist) {
|
||||
for (char** ptr = envlist; *ptr; ptr++)
|
||||
free(*ptr);
|
||||
free((void*)envlist);
|
||||
}
|
||||
|
||||
// NULL when allocation failure
|
||||
// in any case, envlist would be freed after this function
|
||||
char** NULLABLE merge_envlist(char** NNULLABLE envlist, struct envpair extra[],
|
||||
size_t extra_len) {
|
||||
size_t envlist_len = 0;
|
||||
while (envlist[envlist_len])
|
||||
envlist_len++;
|
||||
|
||||
size_t nonnullelems = 0;
|
||||
for (size_t i = 0; i < extra_len; i++) {
|
||||
if (extra[i].value) nonnullelems++;
|
||||
}
|
||||
|
||||
size_t new_envlist_len = envlist_len + nonnullelems + 1;
|
||||
char** new_envlist =
|
||||
(char**)realloc((void*)envlist, sizeof(char*) * new_envlist_len);
|
||||
if (!new_envlist) {
|
||||
free_envlist(envlist);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(readability-identifier-length)
|
||||
size_t k = 0;
|
||||
for (size_t i = 0; i < extra_len; i++) {
|
||||
if (!extra[i].value) continue;
|
||||
char* env_kv = make_env_kv(extra[i].name, extra[i].value);
|
||||
if (!env_kv) goto free_new_envlist_extra;
|
||||
new_envlist[envlist_len + k++] = env_kv;
|
||||
}
|
||||
|
||||
new_envlist[envlist_len + nonnullelems] = NULL;
|
||||
return new_envlist;
|
||||
|
||||
free_new_envlist_extra:
|
||||
for (size_t j = 0; j < envlist_len + k; j++) {
|
||||
free(new_envlist[envlist_len + j]);
|
||||
}
|
||||
free((void*)new_envlist);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char* NULLABLE xdg_ssession_type_str(enum SessionType typ) {
|
||||
char* xdg_session_type = NULL;
|
||||
if (typ == SHELL) xdg_session_type = "tty";
|
||||
if (typ == XORG) xdg_session_type = "x11";
|
||||
if (typ == WAYLAND) xdg_session_type = "wayland";
|
||||
return xdg_session_type;
|
||||
}
|
||||
|
||||
#define FAIL_ALLOC() \
|
||||
{ \
|
||||
return (struct pamh_getenv_status){.error_flag = PAMH_ERR_ALLOC}; \
|
||||
}
|
||||
#define FAIL(ERR, ERRFN) \
|
||||
{ \
|
||||
return (struct pamh_getenv_status){.error_flag = (ERR), .errfn = (ERRFN)}; \
|
||||
}
|
||||
|
||||
struct pamh_getenv_status pamh_get_complete_env(pam_handle_t* handle,
|
||||
struct passwd* NNULLABLE pw,
|
||||
enum SessionType session_typ) {
|
||||
char** raw_envlist = pam_getenvlist(handle);
|
||||
if (!raw_envlist) FAIL(PAMH_ERR_ERRNO, "pam_getenvlist");
|
||||
|
||||
char** ptr = raw_envlist;
|
||||
while (*ptr)
|
||||
log_printf("[I] got pam env %s\n", *(ptr++));
|
||||
|
||||
struct envpair extra_env[] = {
|
||||
{"TERM", getenv("TERM")},
|
||||
{"PATH", getenv("PATH")},
|
||||
{"HOME", pw->pw_dir},
|
||||
{"USER", pw->pw_name},
|
||||
{"SHELL", pw->pw_shell},
|
||||
{"LOGNAME", pw->pw_name},
|
||||
{"XDG_SESSION_TYPE", xdg_ssession_type_str(session_typ)}};
|
||||
|
||||
char** envlist = merge_envlist(raw_envlist, extra_env, LEN(extra_env));
|
||||
if (!envlist) FAIL_ALLOC();
|
||||
return (struct pamh_getenv_status){
|
||||
.error_flag = PAMH_ERR_NOERR,
|
||||
.envlist = envlist,
|
||||
};
|
||||
}
|
||||
|
||||
#undef FAIL
|
||||
#undef FAIL_ALLOC
|
||||
|
||||
///////////////
|
||||
|
||||
struct pam_conv_data {
|
||||
char* password;
|
||||
void (*display_pam_msg)(const char* msg, int msg_style);
|
||||
};
|
||||
|
||||
int pam_conversation(int num_msg, const struct pam_message** msg,
|
||||
struct pam_response** resp, void* appdata_ptr) {
|
||||
struct pam_response* reply = malloc(sizeof(struct pam_response) * num_msg);
|
||||
if (!reply) {
|
||||
return PAM_BUF_ERR;
|
||||
}
|
||||
|
||||
struct pam_conv_data* conv_data = (struct pam_conv_data*)appdata_ptr;
|
||||
|
||||
for (int i = 0; i < num_msg; i++) {
|
||||
reply[i].resp = NULL;
|
||||
reply[i].resp_retcode = 0;
|
||||
|
||||
switch (msg[i]->msg_style) {
|
||||
case PAM_PROMPT_ECHO_OFF:
|
||||
case PAM_PROMPT_ECHO_ON:
|
||||
reply[i].resp = strdup(conv_data->password);
|
||||
if (!reply[i].resp) {
|
||||
for (int j = 0; j < i; j++)
|
||||
free(reply[j].resp);
|
||||
free(reply);
|
||||
return PAM_BUF_ERR;
|
||||
}
|
||||
break;
|
||||
|
||||
case PAM_TEXT_INFO:
|
||||
case PAM_ERROR_MSG:
|
||||
if (conv_data->display_pam_msg && msg[i]->msg) {
|
||||
conv_data->display_pam_msg(msg[i]->msg, msg[i]->msg_style);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
*resp = reply;
|
||||
return PAM_SUCCESS;
|
||||
}
|
||||
|
||||
#ifndef PAM_SERVICE_FALLBACK
|
||||
#define PAM_SERVICE_FALLBACK "login"
|
||||
#endif
|
||||
|
||||
#define CHECK_PAM_RET(call) \
|
||||
ret = (call); \
|
||||
if (ret != PAM_SUCCESS) { \
|
||||
pam_end(pamh, ret); \
|
||||
return NULL; \
|
||||
}
|
||||
pam_handle_t* get_pamh(char* user, char* passwd) {
|
||||
pam_handle_t* pamh = NULL;
|
||||
struct pam_conv_data conv_data = {.password = passwd,
|
||||
.display_pam_msg = print_pam_msg};
|
||||
struct pam_conv pamc = {pam_conversation, (void*)&conv_data};
|
||||
int ret;
|
||||
|
||||
char* pam_service_override = getenv("LIDM_PAM_SERVICE");
|
||||
char* pam_service_name =
|
||||
pam_service_override ? pam_service_override : PAM_SERVICE_FALLBACK;
|
||||
|
||||
CHECK_PAM_RET(pam_start(pam_service_name, user, &pamc, &pamh))
|
||||
CHECK_PAM_RET(pam_authenticate(pamh, 0))
|
||||
CHECK_PAM_RET(pam_acct_mgmt(pamh, 0))
|
||||
CHECK_PAM_RET(pam_setcred(pamh, PAM_ESTABLISH_CRED))
|
||||
CHECK_PAM_RET(pam_open_session(pamh, 0))
|
||||
CHECK_PAM_RET(pam_setcred(pamh, PAM_REINITIALIZE_CRED))
|
||||
|
||||
return pamh;
|
||||
}
|
||||
#undef CHECK_PAM_RET
|
||||
289
src/sessions.c
289
src/sessions.c
@@ -1,3 +1,4 @@
|
||||
#include <errno.h>
|
||||
#include <ftw.h>
|
||||
#include <limits.h>
|
||||
#include <stdbool.h>
|
||||
@@ -6,142 +7,214 @@
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <sessions.h>
|
||||
#include <util.h>
|
||||
#include "config.h"
|
||||
#include "desktop.h"
|
||||
#include "desktop_exec.h"
|
||||
#include "log.h"
|
||||
#include "macros.h"
|
||||
#include "sessions.h"
|
||||
#include "util/path.h"
|
||||
#include "util/vec.h"
|
||||
|
||||
struct source_dir {
|
||||
enum session_type type;
|
||||
char *dir;
|
||||
enum SessionType type;
|
||||
char* dir;
|
||||
};
|
||||
static const struct source_dir sources[] = {
|
||||
{XORG, "/usr/share/xsessions"},
|
||||
{WAYLAND, "/usr/share/wayland-sessions"},
|
||||
|
||||
#ifndef SESSIONS_XSESSIONS
|
||||
#define SESSIONS_XSESSIONS "/usr/share/xsessions"
|
||||
#endif
|
||||
#ifndef SESSIONS_XSESSIONS_LOCAL
|
||||
#define SESSIONS_XSESSIONS_LOCAL "/usr/local/share/xsessions"
|
||||
#endif
|
||||
#ifndef SESSIONS_WAYLAND
|
||||
#define SESSIONS_WAYLAND "/usr/share/wayland-sessions"
|
||||
#endif
|
||||
#ifndef SESSIONS_WAYLAND_LOCAL
|
||||
#define SESSIONS_WAYLAND_LOCAL "/usr/local/share/wayland-sessions"
|
||||
#endif
|
||||
static const struct source_dir SOURCES[] = {{XORG, SESSIONS_XSESSIONS},
|
||||
{XORG, SESSIONS_XSESSIONS_LOCAL},
|
||||
{WAYLAND, SESSIONS_WAYLAND},
|
||||
{WAYLAND, SESSIONS_WAYLAND_LOCAL}};
|
||||
|
||||
static struct Vector* cb_sessions = NULL;
|
||||
|
||||
struct ctx_typ {
|
||||
char* NULLABLE name;
|
||||
char* NULLABLE exec;
|
||||
char* NULLABLE tryexec;
|
||||
};
|
||||
static const size_t sources_size = sizeof(sources) / sizeof(sources[0]);
|
||||
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;
|
||||
|
||||
static struct session __new_session(enum session_type type, char *name,
|
||||
const char *exec, const char *tryexec) {
|
||||
struct session __session;
|
||||
__session.type = type;
|
||||
strcln(&__session.name, name);
|
||||
strcln(&__session.exec, exec);
|
||||
strcln(&__session.tryexec, tryexec);
|
||||
if (table == NULL) return ret;
|
||||
if (strcmp(table, "Desktop Entry") != 0) return ret;
|
||||
|
||||
return __session;
|
||||
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;
|
||||
static const u_int8_t unit_size = sizeof(struct session);
|
||||
// also, always return 0 or we will break parsing and we don't want a bad
|
||||
// desktop file to break all possible sessions
|
||||
static enum SessionType session_type;
|
||||
// NOLINTNEXTLINE(readability-function-cognitive-complexity)
|
||||
static int fn(const char* fpath, const struct stat* sb, int typeflag) {
|
||||
UNUSED(sb);
|
||||
|
||||
static u_int16_t alloc_size = bs;
|
||||
static u_int16_t used_size = 0;
|
||||
// guessing symlink behavior
|
||||
// - FTW_PHYS if set doesn't follow symlinks, so ftw() has no flags and it
|
||||
// follows symlinks, we should never get to handle that
|
||||
if (typeflag != FTW_F) return 0;
|
||||
log_printf("[I] found file %s\n", fpath);
|
||||
|
||||
static struct session *sessions = NULL;
|
||||
static struct sessions_list *__sessions_list = NULL;
|
||||
struct ctx_typ ctx = {
|
||||
.name = NULL,
|
||||
.exec = NULL,
|
||||
.tryexec = NULL,
|
||||
};
|
||||
|
||||
// NOTE: commented printf's here would be nice to have debug logs if I ever
|
||||
// implement it
|
||||
static enum session_type session_type;
|
||||
static int fn(const char *fpath, const struct stat *sb, int typeflag) {
|
||||
// practically impossible to reach this
|
||||
// but will prevent break
|
||||
if (used_size == 0xffff)
|
||||
return 0;
|
||||
|
||||
if (sb == NULL || !S_ISREG(sb->st_mode))
|
||||
return 0;
|
||||
|
||||
/*printf("gonna open %s\n", fpath);*/
|
||||
FILE *fd = fopen(fpath, "r");
|
||||
FILE* fd = fopen(fpath, "r");
|
||||
if (fd == NULL) {
|
||||
perror("fopen");
|
||||
fprintf(stderr, "error opening file (r) %s\n", fpath);
|
||||
log_perror("fopen");
|
||||
log_printf("[E] error opening file '%s' for read\n", fpath);
|
||||
return 0;
|
||||
}
|
||||
|
||||
u_char found = 0;
|
||||
size_t alloc_size = sb->st_blksize;
|
||||
int ret = read_desktop(fd, &ctx, &cb);
|
||||
// any error
|
||||
if (ret < 0) goto err_close;
|
||||
|
||||
char *name_buf = NULL;
|
||||
char *exec_buf = NULL;
|
||||
char *tryexec_buf = NULL;
|
||||
while (true) {
|
||||
/*printf(".");*/
|
||||
char *buf = malloc(sb->st_blksize);
|
||||
ssize_t read_size = getline(&buf, &alloc_size, fd);
|
||||
if (read_size == -1) {
|
||||
free(buf);
|
||||
break;
|
||||
}
|
||||
(void)fclose(fd);
|
||||
|
||||
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;
|
||||
}
|
||||
/*printf("\nend parsing...\n");*/
|
||||
|
||||
fclose(fd);
|
||||
// TODO: filter based on tryexec
|
||||
// https://specifications.freedesktop.org/desktop-entry-spec/latest/recognized-keys.html
|
||||
free(ctx.tryexec);
|
||||
|
||||
// just add this to the list
|
||||
if (name_buf != NULL && exec_buf != NULL) {
|
||||
/*printf("gonna add to session list\n");*/
|
||||
if (used_size >= alloc_size) {
|
||||
alloc_size += bs;
|
||||
sessions = realloc(sessions, alloc_size * unit_size);
|
||||
if (ctx.name != NULL && ctx.exec != NULL) {
|
||||
struct session* this_session = malloc(sizeof(struct session));
|
||||
if (this_session == NULL) return 0;
|
||||
|
||||
int arg_count;
|
||||
char** args;
|
||||
int parse_status = parse_exec_string(ctx.exec, &arg_count, &args);
|
||||
if (parse_status != 0 || arg_count == 0 || !args[0]) {
|
||||
log_printf("[E] parsing exec string '%s': %d\n", ctx.exec, parse_status);
|
||||
free(this_session);
|
||||
goto err_parsing;
|
||||
}
|
||||
free(ctx.exec);
|
||||
|
||||
*this_session = (struct session){
|
||||
.name = ctx.name,
|
||||
.exec = session_exec_desktop(arg_count, args),
|
||||
.type = session_type,
|
||||
};
|
||||
|
||||
vec_push(cb_sessions, this_session);
|
||||
}
|
||||
|
||||
/*printf("n %s\ne %s\nte %s\n", name_buf, exec_buf, tryexec_buf);*/
|
||||
sessions[used_size] = __new_session(session_type, name_buf, exec_buf,
|
||||
tryexec_buf == NULL ? "" : tryexec_buf);
|
||||
|
||||
used_size++;
|
||||
}
|
||||
|
||||
if (name_buf != NULL)
|
||||
free(name_buf);
|
||||
if (exec_buf != NULL)
|
||||
free(exec_buf);
|
||||
if (tryexec_buf != NULL)
|
||||
free(tryexec_buf);
|
||||
return 0;
|
||||
|
||||
err_close:
|
||||
(void)fclose(fd);
|
||||
err_parsing:
|
||||
log_printf("[E] format error parsing %s", fpath);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct sessions_list __list;
|
||||
// This code is designed to be run purely single threaded
|
||||
struct sessions_list *get_avaliable_sessions() {
|
||||
if (sessions != NULL)
|
||||
return __sessions_list;
|
||||
else
|
||||
sessions = malloc(alloc_size * unit_size);
|
||||
#define LIKELY_BOUND_SESSIONS 8
|
||||
struct Vector get_avaliable_sessions() {
|
||||
struct Vector sessions = VEC_NEW;
|
||||
vec_reserve(&sessions, LIKELY_BOUND_SESSIONS);
|
||||
|
||||
for (uint i = 0; i < sources_size; i++) {
|
||||
session_type = sources[i].type;
|
||||
/*printf("recurring into %s\n", sources[i].dir);*/
|
||||
ftw(sources[i].dir, &fn, 1);
|
||||
cb_sessions = &sessions;
|
||||
for (size_t i = 0; i < LEN(SOURCES); i++) {
|
||||
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);
|
||||
|
||||
__list.length = used_size;
|
||||
__list.sessions = sessions;
|
||||
return __sessions_list = &__list;
|
||||
return sessions;
|
||||
}
|
||||
|
||||
int session_exec_exec(struct session_exec* NNULLABLE exec,
|
||||
char* NULLABLE* NNULLABLE envp) {
|
||||
switch (exec->typ) {
|
||||
case EXEC_SHELL: {
|
||||
char* argv[] = {exec->shell, NULL};
|
||||
return execvpe(exec->shell, argv, envp);
|
||||
}
|
||||
case EXEC_DESKTOP:
|
||||
return execvpe(exec->desktop.args[0], exec->desktop.args, envp);
|
||||
default:
|
||||
__builtin_unreachable();
|
||||
}
|
||||
}
|
||||
|
||||
/// So the reason this doesn't use the user shell is because that can really be
|
||||
/// anything, also assuming it were fish for example, it can't execute posix
|
||||
/// shell files and that leaves it out of most `/etc/profile.d/` scripts.
|
||||
///
|
||||
/// I'll just default to bash for now as it's able to source almost everything
|
||||
/// and takes most flags. Maybe will try to make this more sophisticated in the
|
||||
/// future.
|
||||
///
|
||||
/// This respects errno. Even also works as any exec family function.
|
||||
#ifndef LOGIN_SHELL
|
||||
#define LOGIN_SHELL "bash"
|
||||
#endif
|
||||
// This triggers login behavior
|
||||
#define LOGIN_SHELL_ARG0 "-" LOGIN_SHELL
|
||||
int session_exec_login_through_shell(struct session_exec* NNULLABLE exec,
|
||||
char* NULLABLE* NNULLABLE envp) {
|
||||
switch (exec->typ) {
|
||||
case EXEC_SHELL: {
|
||||
char* argv[] = {LOGIN_SHELL_ARG0, "-c", exec->shell, NULL};
|
||||
return execvpe(LOGIN_SHELL, argv, envp);
|
||||
}
|
||||
case EXEC_DESKTOP: {
|
||||
char* name = desktop_as_cmdline(exec->desktop.args);
|
||||
if (!name) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
char* argv[] = {LOGIN_SHELL_ARG0, "-c", name, NULL};
|
||||
int ret = execvpe(LOGIN_SHELL, argv, envp);
|
||||
free(name);
|
||||
return ret;
|
||||
}
|
||||
default:
|
||||
__builtin_unreachable();
|
||||
}
|
||||
}
|
||||
|
||||
29
src/signal_handler.c
Normal file
29
src/signal_handler.c
Normal file
@@ -0,0 +1,29 @@
|
||||
#include <errno.h>
|
||||
#include <stddef.h>
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "signal_handler.h"
|
||||
|
||||
static void handle_sigterm(int sig) {
|
||||
(void)sig;
|
||||
|
||||
(void)signal(SIGTERM, SIG_IGN);
|
||||
kill(-getpgrp(), SIGTERM);
|
||||
|
||||
int status;
|
||||
while (waitpid(-1, &status, 0) > 0 || errno == EINTR) {
|
||||
}
|
||||
|
||||
_exit(0);
|
||||
}
|
||||
|
||||
void setup_sigterm() {
|
||||
setpgid(0, 0);
|
||||
|
||||
struct sigaction sa;
|
||||
sa.sa_handler = handle_sigterm;
|
||||
sigemptyset(&sa.sa_mask);
|
||||
sa.sa_flags = 0;
|
||||
sigaction(SIGTERM, &sa, NULL);
|
||||
}
|
||||
95
src/ui_state.c
Normal file
95
src/ui_state.c
Normal file
@@ -0,0 +1,95 @@
|
||||
#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 =
|
||||
session_exec_shell(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.exec =
|
||||
session_exec_shell(custom_session.name = 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.shell;
|
||||
|
||||
ofield_kbd_type(field, text, start);
|
||||
ui_update_ffield();
|
||||
}
|
||||
92
src/users.c
92
src/users.c
@@ -1,62 +1,66 @@
|
||||
#include <pwd.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <users.h>
|
||||
#include <util.h>
|
||||
#include "log.h"
|
||||
#include "macros.h"
|
||||
#include "users.h"
|
||||
#include "util/vec.h"
|
||||
|
||||
static struct user __new_user(struct passwd *p) {
|
||||
struct user __user;
|
||||
strcln(&__user.shell, p->pw_shell);
|
||||
strcln(&__user.username, p->pw_name);
|
||||
if (p->pw_gecos[0] == '\0')
|
||||
__user.display_name = __user.username;
|
||||
else
|
||||
strcln(&__user.display_name, p->pw_gecos);
|
||||
// NOLINTNEXTLINE(readability-identifier-length)
|
||||
int build_user(struct user* NNULLABLE user, struct passwd* p) {
|
||||
char* shell = strdup(p->pw_shell);
|
||||
char* username = strdup(p->pw_name);
|
||||
char* displayname;
|
||||
if (strlen(p->pw_gecos) == 0)
|
||||
displayname = username;
|
||||
else {
|
||||
displayname = strdup(p->pw_gecos);
|
||||
}
|
||||
if (!shell || !username || !displayname) {
|
||||
free(shell);
|
||||
free(username);
|
||||
if (displayname != username) free(displayname);
|
||||
// actually tidy struggles with the line i have avobe
|
||||
// NOLINTNEXTLINE(clang-analyzer-unix.Malloc)
|
||||
return -1;
|
||||
}
|
||||
|
||||
return __user;
|
||||
*user = (struct user){
|
||||
.shell = shell,
|
||||
.username = username,
|
||||
.display_name = displayname,
|
||||
};
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const u_int8_t bs = 16;
|
||||
static const u_int8_t unit_size = sizeof(struct user);
|
||||
|
||||
static u_int16_t alloc_size = bs;
|
||||
static u_int16_t used_size = 0;
|
||||
|
||||
static struct user *users = NULL;
|
||||
static struct users_list *__users_list = NULL;
|
||||
|
||||
struct users_list __list;
|
||||
// This code is designed to be run purely single threaded
|
||||
struct users_list *get_human_users() {
|
||||
if (users != NULL)
|
||||
return __users_list;
|
||||
else
|
||||
users = malloc(alloc_size * unit_size);
|
||||
#define LIKELY_BOUND_USERS 4
|
||||
struct Vector get_human_users() {
|
||||
struct Vector users = VEC_NEW;
|
||||
vec_reserve(&users, LIKELY_BOUND_USERS);
|
||||
|
||||
struct passwd *pwd;
|
||||
struct passwd* NULLABLE 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))
|
||||
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);
|
||||
|
||||
if (used_size >= alloc_size) {
|
||||
alloc_size += bs;
|
||||
users = realloc(users, alloc_size * unit_size);
|
||||
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);
|
||||
}
|
||||
|
||||
users[used_size] = __new_user(pwd);
|
||||
used_size++;
|
||||
}
|
||||
|
||||
users = realloc(users, used_size * unit_size);
|
||||
|
||||
__list.length = used_size;
|
||||
__list.users = users;
|
||||
return __users_list = &__list;
|
||||
return users;
|
||||
}
|
||||
|
||||
68
src/util.c
68
src/util.c
@@ -1,68 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <keys.h>
|
||||
#include <ui.h>
|
||||
#include <util.h>
|
||||
|
||||
static int selret_magic();
|
||||
|
||||
void strcln(char **dest, const char *source) {
|
||||
*dest = malloc(strlen(source) + sizeof(char));
|
||||
strcpy(*dest, source);
|
||||
}
|
||||
|
||||
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");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
enum keys find_ansi(char *seq) {
|
||||
for (size_t i = 0; i < sizeof(key_mappings) / sizeof(key_mappings[0]); i++) {
|
||||
struct key_mapping mapping = key_mappings[i];
|
||||
for (size_t j = 0; mapping.sequences[j] != NULL; j++) {
|
||||
if (strcmp(mapping.sequences[j], seq) == 0) {
|
||||
return (enum keys)i;
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
// https://stackoverflow.com/a/48040042
|
||||
void read_press(u_char *length, char *out) {
|
||||
*length = 0;
|
||||
|
||||
while (true) {
|
||||
if (read(STDIN_FILENO, &out[(*length)++], 1) != 1) {
|
||||
print_errno("read error");
|
||||
sleep(3);
|
||||
exit(1);
|
||||
}
|
||||
int selret = selret_magic();
|
||||
if (selret == -1) {
|
||||
print_errno("selret error");
|
||||
} else if (selret != 1) {
|
||||
out[*length] = '\0';
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int selret_magic() {
|
||||
fd_set set;
|
||||
struct timeval timeout;
|
||||
FD_ZERO(&set);
|
||||
FD_SET(STDIN_FILENO, &set);
|
||||
timeout.tv_sec = 0;
|
||||
timeout.tv_usec = 0;
|
||||
return select(1, &set, NULL, NULL, &timeout);
|
||||
}
|
||||
64
src/util/path.c
Normal file
64
src/util/path.c
Normal file
@@ -0,0 +1,64 @@
|
||||
#include <errno.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "util/path.h"
|
||||
|
||||
// returns NULL on any error
|
||||
// otherwise it returns the absolute path of the program that MUST BE FREED
|
||||
//
|
||||
// Should be almost completely posix compliant, except it won't resolve empty
|
||||
// PATH entries relative to the cwd
|
||||
char* NULLABLE search_path(const char* NNULLABLE for_binary) {
|
||||
if (strchr(for_binary, '/') != NULL) {
|
||||
// skip absolute paths
|
||||
return strdup(for_binary);
|
||||
}
|
||||
char* path_env = getenv("PATH");
|
||||
if (!path_env) return NULL;
|
||||
char* path = strdup(path_env);
|
||||
if (!path) return NULL;
|
||||
|
||||
char* tok = strtok(path, ":");
|
||||
while (tok) {
|
||||
char* bin_path;
|
||||
asprintf(&bin_path, "%s/%s", tok, for_binary);
|
||||
if (!bin_path) {
|
||||
free(path);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct stat stat_buf;
|
||||
if (stat(bin_path, &stat_buf) == 0 && access(bin_path, X_OK) == 0) {
|
||||
free(path);
|
||||
return bin_path;
|
||||
}
|
||||
|
||||
free(bin_path);
|
||||
tok = strtok(NULL, ":");
|
||||
}
|
||||
|
||||
free(path);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// This is present in glibc ONLY with GNU extensions, this aims to provide a
|
||||
// musl compatible variant.
|
||||
//
|
||||
// Respects errno of exec functions family.
|
||||
int execvpe(const char* NNULLABLE file, char* NULLABLE const argv[NNULLABLE],
|
||||
char* NULLABLE const envp[NNULLABLE]) {
|
||||
char* path = search_path(file);
|
||||
if (!path) {
|
||||
errno = ENOENT;
|
||||
return -1;
|
||||
}
|
||||
int ret = execve(path, argv, envp);
|
||||
free(path);
|
||||
return ret;
|
||||
}
|
||||
62
src/util/utf8.c
Normal file
62
src/util/utf8.c
Normal file
@@ -0,0 +1,62 @@
|
||||
#include "util/utf8.h"
|
||||
|
||||
#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;
|
||||
}
|
||||
|
||||
size_t utf8trunc(char* str, size_t n) {
|
||||
size_t bytes = 0;
|
||||
while (true) {
|
||||
if (str[bytes] == '\0') break;
|
||||
if (utf8_iscont(str[bytes])) {
|
||||
bytes++;
|
||||
continue;
|
||||
}
|
||||
if (n == 0) {
|
||||
str[bytes] = '\0';
|
||||
break;
|
||||
}
|
||||
bytes++;
|
||||
n--;
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
96
src/util/vec.c
Normal file
96
src/util/vec.c
Normal file
@@ -0,0 +1,96 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "util/vec.h"
|
||||
|
||||
const struct Vector VEC_NEW = {
|
||||
.length = 0,
|
||||
.capacity = 0,
|
||||
.pages = NULL,
|
||||
};
|
||||
|
||||
struct Vector vec_from_raw(void** raw) {
|
||||
size_t len = 0;
|
||||
while (raw[len])
|
||||
len++;
|
||||
|
||||
return (struct Vector){
|
||||
.length = len,
|
||||
.capacity = len,
|
||||
.pages = raw,
|
||||
};
|
||||
}
|
||||
|
||||
void** vec_as_raw(struct Vector self) {
|
||||
if (vec_push(&self, NULL) != 0) return NULL;
|
||||
return self.pages;
|
||||
}
|
||||
|
||||
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];
|
||||
}
|
||||
@@ -1,5 +1,21 @@
|
||||
# Themes
|
||||
|
||||
## catppuccin-frappe.ini
|
||||
|
||||

|
||||
|
||||
## catppuccin-latte.ini
|
||||
|
||||

|
||||
|
||||
## catppuccin-macchiato.ini
|
||||
|
||||

|
||||
|
||||
## catppuccin-mocha.ini
|
||||
|
||||

|
||||
|
||||
## cherry.ini
|
||||
|
||||

|
||||
@@ -16,6 +32,14 @@
|
||||
|
||||

|
||||
|
||||
## 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
|
||||
|
||||

|
||||
|
||||
24
themes/catppuccin-frappe.ini
Normal file
24
themes/catppuccin-frappe.ini
Normal file
@@ -0,0 +1,24 @@
|
||||
##############################################
|
||||
# #
|
||||
# Catppuccin Theme #
|
||||
# #
|
||||
##############################################
|
||||
|
||||
# Catppuccin Frappé
|
||||
# This theme was created by: Catppuccin Org! <3
|
||||
|
||||
[colors]
|
||||
bg = "23;24;25;48;2;48;52;70"
|
||||
fg = "22;23;24;25;29;38;2;198;208;245"
|
||||
err = "1;4;23;24;25;38;2;231;130;132"
|
||||
s_wayland = "3;22;24;25;38;2;202;158;230"
|
||||
s_xorg = "3;22;24;25;38;2;202;158;230"
|
||||
s_shell = "3;22;24;25;38;2;244;184;228"
|
||||
e_hostname = "1;3;24;25;29;38;2;242;213;207"
|
||||
e_date = "3;22;24;25;29;38;2;165;173;206"
|
||||
e_box = "1;23;24;25;29;38;2;115;121;148"
|
||||
e_header = "1;3;24;25;29;38;2;239;159;118"
|
||||
e_user = "3;22;24;25;29;38;2;140;170;238"
|
||||
e_passwd = "1;23;24;25;29;38;2;166;209;137"
|
||||
e_badpasswd = "1;9;23;24;25;38;2;231;130;132"
|
||||
e_key = "22;23;24;25;38;2;129;200;190"
|
||||
24
themes/catppuccin-latte.ini
Normal file
24
themes/catppuccin-latte.ini
Normal file
@@ -0,0 +1,24 @@
|
||||
##############################################
|
||||
# #
|
||||
# Catppuccin Theme #
|
||||
# #
|
||||
##############################################
|
||||
|
||||
# Catppuccin Latte
|
||||
# This theme was created by: Catppuccin Org! <3
|
||||
|
||||
[colors]
|
||||
bg = "23;24;25;48;2;239;241;245"
|
||||
fg = "22;23;24;25;29;38;2;76;79;105"
|
||||
err = "1;4;23;24;25;38;2;210;15;57"
|
||||
s_wayland = "3;22;24;25;38;2;136;57;239"
|
||||
s_xorg = "3;22;24;25;38;2;136;57;239"
|
||||
s_shell = "3;22;24;25;38;2;234;118;203"
|
||||
e_hostname = "1;3;24;25;29;38;2;220;138;120"
|
||||
e_date = "3;22;24;25;29;38;2;108;111;133"
|
||||
e_box = "1;23;24;25;29;38;2;156;160;176"
|
||||
e_header = "1;3;24;25;29;38;2;254;100;11"
|
||||
e_user = "3;22;24;25;29;38;2;30;102;245"
|
||||
e_passwd = "1;23;24;25;29;38;2;64;160;43"
|
||||
e_badpasswd = "1;9;23;24;25;38;2;210;15;57"
|
||||
e_key = "22;23;24;25;38;2;23;146;153"
|
||||
24
themes/catppuccin-macchiato.ini
Normal file
24
themes/catppuccin-macchiato.ini
Normal file
@@ -0,0 +1,24 @@
|
||||
##############################################
|
||||
# #
|
||||
# Catppuccin Theme #
|
||||
# #
|
||||
##############################################
|
||||
|
||||
# Catppuccin Macchiato
|
||||
# This theme was created by: Catppuccin Org! <3
|
||||
|
||||
[colors]
|
||||
bg = "23;24;25;48;2;36;39;58"
|
||||
fg = "22;23;24;25;29;38;2;202;211;245"
|
||||
err = "1;4;23;24;25;38;2;237;135;150"
|
||||
s_wayland = "3;22;24;25;38;2;198;160;246"
|
||||
s_xorg = "3;22;24;25;38;2;198;160;246"
|
||||
s_shell = "3;22;24;25;38;2;245;189;230"
|
||||
e_hostname = "1;3;24;25;29;38;2;244;219;214"
|
||||
e_date = "3;22;24;25;29;38;2;165;173;203"
|
||||
e_box = "1;23;24;25;29;38;2;110;115;141"
|
||||
e_header = "1;3;24;25;29;38;2;245;169;127"
|
||||
e_user = "3;22;24;25;29;38;2;138;173;244"
|
||||
e_passwd = "1;23;24;25;29;38;2;166;218;149"
|
||||
e_badpasswd = "1;9;23;24;25;38;2;237;135;150"
|
||||
e_key = "22;23;24;25;38;2;139;213;202"
|
||||
24
themes/catppuccin-mocha.ini
Normal file
24
themes/catppuccin-mocha.ini
Normal file
@@ -0,0 +1,24 @@
|
||||
##############################################
|
||||
# #
|
||||
# Catppuccin Theme #
|
||||
# #
|
||||
##############################################
|
||||
|
||||
# Catppuccin Mocha
|
||||
# This theme was created by: Catppuccin Org! <3
|
||||
|
||||
[colors]
|
||||
bg = "23;24;25;48;2;30;30;46"
|
||||
fg = "22;23;24;25;29;38;2;205;214;244"
|
||||
err = "1;4;23;24;25;38;2;243;139;168"
|
||||
s_wayland = "3;22;24;25;38;2;203;166;247"
|
||||
s_xorg = "3;22;24;25;38;2;203;166;247"
|
||||
s_shell = "3;22;24;25;38;2;245;194;231"
|
||||
e_hostname = "1;3;24;25;29;38;2;245;224;220"
|
||||
e_date = "3;22;24;25;29;38;2;166;173;200"
|
||||
e_box = "1;23;24;25;29;38;2;108;112;134"
|
||||
e_header = "1;3;24;25;29;38;2;250;179;135"
|
||||
e_user = "3;22;24;25;29;38;2;137;180;250"
|
||||
e_passwd = "1;23;24;25;29;38;2;166;227;161"
|
||||
e_badpasswd = "1;9;23;24;25;38;2;243;139;168"
|
||||
e_key = "22;23;24;25;38;2;148;226;213"
|
||||
35
themes/catppuccin.tera
Normal file
35
themes/catppuccin.tera
Normal file
@@ -0,0 +1,35 @@
|
||||
---
|
||||
whiskers:
|
||||
version: ^2.5.1
|
||||
matrix:
|
||||
- flavor
|
||||
filename: catppuccin-{{ flavor.identifier }}.ini
|
||||
---
|
||||
{%- macro rgb(col) -%}
|
||||
2;{{ col.rgb.r }};{{ col.rgb.g }};{{ col.rgb.b }}
|
||||
{%- endmacro rgb -%}
|
||||
|
||||
##############################################
|
||||
# #
|
||||
# Catppuccin Theme #
|
||||
# #
|
||||
##############################################
|
||||
|
||||
# Catppuccin {{flavor.name}}
|
||||
# This theme was created by: Catppuccin Org! <3
|
||||
|
||||
[colors]
|
||||
bg = "23;24;25;48;{{ self::rgb(col=base) }}"
|
||||
fg = "22;23;24;25;29;38;{{ self::rgb(col=text) }}"
|
||||
err = "1;4;23;24;25;38;{{ self::rgb(col=red) }}"
|
||||
s_wayland = "3;22;24;25;38;{{ self::rgb(col=mauve) }}"
|
||||
s_xorg = "3;22;24;25;38;{{ self::rgb(col=mauve) }}"
|
||||
s_shell = "3;22;24;25;38;{{ self::rgb(col=pink) }}"
|
||||
e_hostname = "1;3;24;25;29;38;{{ self::rgb(col=rosewater) }}"
|
||||
e_date = "3;22;24;25;29;38;{{ self::rgb(col=subtext0) }}"
|
||||
e_box = "1;23;24;25;29;38;{{ self::rgb(col=overlay0) }}"
|
||||
e_header = "1;3;24;25;29;38;{{ self::rgb(col=peach) }}"
|
||||
e_user = "3;22;24;25;29;38;{{ self::rgb(col=blue) }}"
|
||||
e_passwd = "1;23;24;25;29;38;{{ self::rgb(col=green) }}"
|
||||
e_badpasswd = "1;9;23;24;25;38;{{ self::rgb(col=red) }}"
|
||||
e_key = "22;23;24;25;38;{{ self::rgb(col=teal) }}"
|
||||
@@ -1,32 +1,49 @@
|
||||
colors.bg = 48;2;77;33;55
|
||||
colors.fg = 22;3;24;38;2;245;245;245
|
||||
colors.err = 1;31
|
||||
colors.s_wayland = 38;2;255;174;66
|
||||
colors.s_xorg = 38;2;37;175;255
|
||||
colors.s_shell = 32
|
||||
colors.e_hostname = 1;23;38;5;197
|
||||
colors.e_date = 31
|
||||
colors.e_box = 31
|
||||
colors.e_header = 1;4;38;5;204
|
||||
colors.e_user = 38;5;51
|
||||
colors.e_passwd = 4;2;38;5;203
|
||||
colors.e_badpasswd = 4;31
|
||||
colors.e_key = 1;23;38;5;197
|
||||
chars.hb = ─
|
||||
chars.vb = │
|
||||
chars.ctl = ┌
|
||||
chars.ctr = ┐
|
||||
chars.cbl = └
|
||||
chars.cbr = ┘
|
||||
functions.poweroff = F1
|
||||
functions.reboot = F2
|
||||
functions.refresh = F5
|
||||
strings.f_poweroff = poweroff
|
||||
strings.f_reboot = reboot
|
||||
strings.f_refresh = refresh
|
||||
strings.e_user = user
|
||||
strings.e_passwd = password
|
||||
strings.s_wayland = wayland
|
||||
strings.s_xorg = xorg
|
||||
strings.s_shell = shell
|
||||
behavior.include_defshell = true
|
||||
[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 = " >"
|
||||
# ellipsis = "…"
|
||||
|
||||
[behavior]
|
||||
# include_defshell = true
|
||||
# timefmt = "%X %x"
|
||||
# refresh_rate = 100
|
||||
source = "/etc/lidm.env"
|
||||
source = "/etc/locale.conf"
|
||||
user_source = ".lidm.env"
|
||||
|
||||
@@ -1,32 +1,51 @@
|
||||
colors.bg = 48;2;38;28;28
|
||||
colors.fg = 22;24;38;2;245;245;245
|
||||
colors.err = 1;31
|
||||
colors.s_wayland = 38;2;255;174;66
|
||||
colors.s_xorg = 38;2;37;175;255
|
||||
colors.s_shell = 38;2;34;140;34
|
||||
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 = poweroff
|
||||
strings.f_reboot = reboot
|
||||
strings.f_refresh = refresh
|
||||
strings.e_user = user
|
||||
strings.e_passwd = password
|
||||
strings.s_wayland = wayland
|
||||
strings.s_xorg = xorg
|
||||
strings.s_shell = shell
|
||||
behavior.include_defshell = true
|
||||
[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
|
||||
# fido = NONE
|
||||
# refresh = F5
|
||||
|
||||
[strings]
|
||||
# f_poweroff = "poweroff"
|
||||
# f_reboot = "reboot"
|
||||
# f_fido = "fido"
|
||||
# f_refresh = "refresh"
|
||||
# e_user = "user"
|
||||
# e_passwd = "password"
|
||||
# s_wayland = "wayland"
|
||||
# s_xorg = "xorg"
|
||||
# s_shell = "shell"
|
||||
# opts_pre = "< "
|
||||
# opts_post = " >"
|
||||
# ellipsis = "…"
|
||||
|
||||
[behavior]
|
||||
# include_defshell = true
|
||||
# timefmt = "%X %x"
|
||||
# refresh_rate = 100
|
||||
source = "/etc/lidm.env"
|
||||
source = "/etc/locale.conf"
|
||||
user_source = ".lidm.env"
|
||||
|
||||
@@ -1,32 +1,49 @@
|
||||
colors.bg = 48;2;24;22;22
|
||||
colors.fg = 22;24;38;2;185;185;185
|
||||
colors.err = 1;31
|
||||
colors.s_wayland = 38;2;255;174;66
|
||||
colors.s_xorg = 38;2;37;175;255
|
||||
colors.s_shell = 38;2;34;140;34
|
||||
colors.e_hostname = 38;2;208;189;156
|
||||
colors.e_date = 38;2;144;144;144
|
||||
colors.e_box = 38;2;122;122;122
|
||||
colors.e_header = 4;38;2;126;146;178
|
||||
colors.e_user = 38;2;148;89;84
|
||||
colors.e_passwd = 4;38;2;245;245;205
|
||||
colors.e_badpasswd = 3;4;31
|
||||
colors.e_key = 38;2;255;174;66
|
||||
chars.hb = ─
|
||||
chars.vb = │
|
||||
chars.ctl = ┌
|
||||
chars.ctr = ┐
|
||||
chars.cbl = └
|
||||
chars.cbr = ┘
|
||||
functions.poweroff = F1
|
||||
functions.reboot = F2
|
||||
functions.refresh = F5
|
||||
strings.f_poweroff = poweroff
|
||||
strings.f_reboot = reboot
|
||||
strings.f_refresh = refresh
|
||||
strings.e_user = user
|
||||
strings.e_passwd = password
|
||||
strings.s_wayland = wayland
|
||||
strings.s_xorg = xorg
|
||||
strings.s_shell = shell
|
||||
behavior.include_defshell = true
|
||||
[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 = " >"
|
||||
# ellipsis = "…"
|
||||
|
||||
[behavior]
|
||||
# include_defshell = true
|
||||
timefmt = "%Y-%m-%d %H:%M:%S"
|
||||
# refresh_rate = 100
|
||||
source = "/etc/lidm.env"
|
||||
source = "/etc/locale.conf"
|
||||
user_source = ".lidm.env"
|
||||
|
||||
@@ -1,32 +1,49 @@
|
||||
colors.bg = 48;2;28;28;36
|
||||
colors.fg = 22;24;38;2;168;168;168
|
||||
colors.err = 1;31
|
||||
colors.s_wayland = 38;2;255;174;66
|
||||
colors.s_xorg = 38;2;37;175;255
|
||||
colors.s_shell = 38;2;34;140;34
|
||||
colors.e_hostname = 38;2;196;165;112
|
||||
colors.e_date = 38;2;144;144;144
|
||||
colors.e_box = 38;2;122;122;122
|
||||
colors.e_header = 4;38;2;114;133;162
|
||||
colors.e_user = 38;2;211;137;88
|
||||
colors.e_passwd = 4;38;2;245;245;205
|
||||
colors.e_badpasswd = 3;4;31
|
||||
colors.e_key = 38;2;255;174;66
|
||||
chars.hb = ─
|
||||
chars.vb = │
|
||||
chars.ctl = ┌
|
||||
chars.ctr = ┐
|
||||
chars.cbl = └
|
||||
chars.cbr = ┘
|
||||
functions.poweroff = F1
|
||||
functions.reboot = F2
|
||||
functions.refresh = F5
|
||||
strings.f_poweroff = poweroff
|
||||
strings.f_reboot = reboot
|
||||
strings.f_refresh = refresh
|
||||
strings.e_user = user
|
||||
strings.e_passwd = password
|
||||
strings.s_wayland = wayland
|
||||
strings.s_xorg = xorg
|
||||
strings.s_shell = shell
|
||||
behavior.include_defshell = true
|
||||
[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 = " >"
|
||||
# ellipsis = "…"
|
||||
|
||||
[behavior]
|
||||
# include_defshell = true
|
||||
timefmt = "%Y-%m-%d %H:%M:%S"
|
||||
# refresh_rate = 100
|
||||
source = "/etc/lidm.env"
|
||||
source = "/etc/locale.conf"
|
||||
user_source = ".lidm.env"
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user