mirror of
https://github.com/javalsai/lidm.git
synced 2025-08-30 18:08:00 +02:00
Compare commits
111 Commits
v1.0.0
...
93af32d386
Author | SHA1 | Date | |
---|---|---|---|
93af32d386
|
|||
6f5413903a
|
|||
d52de80107
|
|||
dad5296839
|
|||
947c92ce3f
|
|||
e529483c28
|
|||
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 |
@@ -6,3 +6,6 @@ AllowShortIfStatementsOnASingleLine: WithoutElse
|
||||
AlignAfterOpenBracket: Align
|
||||
BinPackParameters: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: true
|
||||
|
||||
IndentPPDirectives: BeforeHash
|
||||
IndentGotoLabels: true
|
||||
|
@@ -1,2 +1,2 @@
|
||||
[codespell]
|
||||
skip = ./assets/pkg/aur/*/src,./assets/pkg/aur/*/*/objects
|
||||
skip = ./assets/pkg/aur/*/src,./assets/pkg/aur/*/*/objects,./assets/pkg/aur/*/*.tar.*
|
||||
|
161
.github/workflows/build.yml
vendored
Normal file
161
.github/workflows/build.yml
vendored
Normal file
@@ -0,0 +1,161 @@
|
||||
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
|
||||
|
||||
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 -Sy
|
||||
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
|
291
.github/workflows/check-and-build.yml
vendored
291
.github/workflows/check-and-build.yml
vendored
@@ -1,291 +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: Clang Check
|
||||
runs-on: ubuntu-24.04
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: awalsh128/cache-apt-pkgs-action@latest
|
||||
with:
|
||||
packages: "clang-format clang-tidy"
|
||||
version: 1.0
|
||||
- run: clang-format -ni src/*.c include/*.h
|
||||
# TODO: include when the errors/warnings are bearable
|
||||
#- run: clang-tidy src/*.c include/*.h
|
||||
|
||||
build-linux-amd64:
|
||||
name: Build for amd64
|
||||
runs-on: ubuntu-24.04
|
||||
permissions: write-all
|
||||
needs: [spellcheck, shellcheck, clangcheck]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: myrotvorets/set-commit-status-action@master
|
||||
if: inputs.set-statuses
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
status: pending
|
||||
description: ${{ steps.build.outputs.DESCR }}
|
||||
context: Build for amd64
|
||||
- uses: awalsh128/cache-apt-pkgs-action@latest
|
||||
with:
|
||||
packages: "libpam0g-dev"
|
||||
version: 1.0
|
||||
- id: build
|
||||
run: |
|
||||
make -j$(nproc) 2> /tmp/stderr || (ERR=$?; cat /tmp/stderr >&2; exit $ERR)
|
||||
cat /tmp/stderr >&2
|
||||
|
||||
HSIZE="$(stat --printf="%s" lidm | numfmt --to=iec-i)B"
|
||||
WARNS="$(cat /tmp/stderr | grep '^[^ ]*\.[ch]:' | wc -l)"
|
||||
mv lidm lidm-amd64
|
||||
|
||||
echo "DESCR='$HSIZE, $WARNS warnings'" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- uses: myrotvorets/set-commit-status-action@master
|
||||
if: inputs.set-statuses
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
status: ${{ job.status }}
|
||||
description: ${{ steps.build.outputs.DESCR }}
|
||||
context: Build for amd64
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: build-amd64
|
||||
path: lidm-amd64
|
||||
retention-days: 1
|
||||
|
||||
build-linux-i386:
|
||||
name: Build for i386
|
||||
runs-on: ubuntu-24.04
|
||||
permissions: write-all
|
||||
needs: [spellcheck, shellcheck, clangcheck]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: myrotvorets/set-commit-status-action@master
|
||||
if: inputs.set-statuses
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
status: pending
|
||||
description: ${{ steps.build.outputs.DESCR }}
|
||||
context: Build for i386
|
||||
- uses: awalsh128/cache-apt-pkgs-action@latest
|
||||
with:
|
||||
packages: "libpam0g-dev gcc-multilib"
|
||||
version: 1.0
|
||||
- run: |
|
||||
sudo dpkg --add-architecture i386
|
||||
sudo apt-get update -y
|
||||
sudo apt-get install -y libpam0g-dev:i386
|
||||
|
||||
- id: build
|
||||
run: |
|
||||
make -j$(nproc) CFLAGS="-O3 -Wall -m32" 2> /tmp/stderr || (ERR=$?; cat /tmp/stderr >&2; exit $ERR)
|
||||
cat /tmp/stderr >&2
|
||||
|
||||
HSIZE="$(stat --printf="%s" lidm | numfmt --to=iec-i)B"
|
||||
WARNS="$(cat /tmp/stderr | grep '^[^ ]*\.[ch]:' | wc -l)"
|
||||
mv lidm lidm-i386
|
||||
|
||||
echo "DESCR='$HSIZE, $WARNS warnings'" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- uses: myrotvorets/set-commit-status-action@master
|
||||
if: inputs.set-statuses
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
status: ${{ job.status }}
|
||||
description: ${{ steps.build.outputs.DESCR }}
|
||||
context: Build for i386
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: build-i386
|
||||
path: lidm-i386
|
||||
retention-days: 1
|
||||
|
||||
build-linux-aarch64:
|
||||
name: Build for aarch64
|
||||
runs-on: ubuntu-24.04
|
||||
permissions: write-all
|
||||
needs: [spellcheck, shellcheck, clangcheck]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: myrotvorets/set-commit-status-action@master
|
||||
if: inputs.set-statuses
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
status: pending
|
||||
description: ${{ steps.status.outputs.DESCR }}
|
||||
context: Build for aarch64
|
||||
- uses: uraimo/run-on-arch-action@v2
|
||||
with:
|
||||
arch: aarch64
|
||||
distro: ubuntu22.04
|
||||
githubToken: ${{ github.token }}
|
||||
install: |
|
||||
apt-get update && \
|
||||
apt-get install -y make gcc libpam0g-dev
|
||||
run: |
|
||||
make -j$(nproc) 2> /tmp/stderr || (ERR=$?; cat /tmp/stderr >&2; exit $ERR)
|
||||
|
||||
cat /tmp/stderr >&2
|
||||
mv lidm lidm-aarch64
|
||||
|
||||
- if: inputs.set-statuses
|
||||
id: status
|
||||
run: |
|
||||
HSIZE="$(stat --printf="%s" lidm-aarch64 | numfmt --to=iec-i)B"
|
||||
WARNS="$(cat /tmp/stderr | grep '^[^ ]*\.[ch]:' | wc -l)"
|
||||
|
||||
echo "DESCR='$HSIZE, $WARNS warnings'" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- uses: myrotvorets/set-commit-status-action@master
|
||||
if: inputs.set-statuses
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
status: ${{ job.status }}
|
||||
description: ${{ steps.status.outputs.DESCR }}
|
||||
context: Build for aarch64
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: build-aarch64
|
||||
path: lidm-aarch64
|
||||
retention-days: 1
|
||||
|
||||
build-linux-armv7:
|
||||
name: Build for armv7
|
||||
runs-on: ubuntu-24.04
|
||||
permissions: write-all
|
||||
needs: [spellcheck, shellcheck, clangcheck]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: myrotvorets/set-commit-status-action@master
|
||||
if: inputs.set-statuses
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
status: pending
|
||||
description: ${{ steps.status.outputs.DESCR }}
|
||||
context: Build for armv7
|
||||
- uses: uraimo/run-on-arch-action@v2
|
||||
with:
|
||||
arch: armv7
|
||||
distro: ubuntu22.04
|
||||
githubToken: ${{ github.token }}
|
||||
install: |
|
||||
apt-get update && \
|
||||
apt-get install -y make gcc libpam0g-dev
|
||||
run: |
|
||||
make -j$(nproc) 2> /tmp/stderr || (ERR=$?; cat /tmp/stderr >&2; exit $ERR)
|
||||
|
||||
cat /tmp/stderr >&2
|
||||
mv lidm lidm-armv7
|
||||
|
||||
- if: inputs.set-statuses
|
||||
id: status
|
||||
run: |
|
||||
HSIZE="$(stat --printf="%s" lidm-armv7 | numfmt --to=iec-i)B"
|
||||
WARNS="$(cat /tmp/stderr | grep '^[^ ]*\.[ch]:' | wc -l)"
|
||||
|
||||
echo "DESCR='$HSIZE, $WARNS warnings'" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- uses: myrotvorets/set-commit-status-action@master
|
||||
if: inputs.set-statuses
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
status: ${{ job.status }}
|
||||
description: ${{ steps.status.outputs.DESCR }}
|
||||
context: Build for armv7
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: build-armv7
|
||||
path: lidm-armv7
|
||||
retention-days: 1
|
||||
|
||||
build-linux-riscv64:
|
||||
name: Build for riscv64
|
||||
runs-on: ubuntu-24.04
|
||||
permissions: write-all
|
||||
needs: [spellcheck, shellcheck, clangcheck]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: myrotvorets/set-commit-status-action@master
|
||||
if: inputs.set-statuses
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
status: pending
|
||||
description: ${{ steps.status.outputs.DESCR }}
|
||||
context: Build for riscv64
|
||||
- uses: uraimo/run-on-arch-action@v2
|
||||
with:
|
||||
arch: riscv64
|
||||
distro: ubuntu22.04
|
||||
githubToken: ${{ github.token }}
|
||||
install: |
|
||||
apt-get update && \
|
||||
apt-get install -y make gcc libpam0g-dev
|
||||
run: |
|
||||
make -j$(nproc) 2> /tmp/stderr || (ERR=$?; cat /tmp/stderr >&2; exit $ERR)
|
||||
|
||||
cat /tmp/stderr >&2
|
||||
mv lidm lidm-riscv64
|
||||
|
||||
- if: inputs.set-statuses
|
||||
id: status
|
||||
run: |
|
||||
HSIZE="$(stat --printf="%s" lidm-riscv64 | numfmt --to=iec-i)B"
|
||||
WARNS="$(cat /tmp/stderr | grep '^[^ ]*\.[ch]:' | wc -l)"
|
||||
|
||||
echo "DESCR='$HSIZE, $WARNS warnings'" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- uses: myrotvorets/set-commit-status-action@master
|
||||
if: inputs.set-statuses
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
status: ${{ job.status }}
|
||||
description: ${{ steps.status.outputs.DESCR }}
|
||||
context: Build for riscv64
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: build-riscv64
|
||||
path: lidm-riscv64
|
||||
retention-days: 1
|
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/'
|
108
.github/workflows/make-release.yml
vendored
108
.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,7 +59,7 @@ jobs:
|
||||
|
||||
- uses: ncipollo/release-action@v1
|
||||
with:
|
||||
tag: v${{ inputs.version }}
|
||||
tag: v${{ needs.release-checks.outputs.VERSION }}
|
||||
commit: ${{ github.sha }}
|
||||
artifacts: builds/lidm-*
|
||||
artifactErrorsFailBuild: true
|
||||
@@ -41,10 +70,9 @@ jobs:
|
||||
runs-on: ubuntu-24.04
|
||||
container: archlinux:latest
|
||||
permissions: write-all
|
||||
needs: release
|
||||
needs: [ release-checks, release ]
|
||||
steps:
|
||||
- run: pacman -Sy --noconfirm git github-cli base-devel pacman-contrib
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- run: |
|
||||
@@ -53,20 +81,54 @@ jobs:
|
||||
|
||||
cd "assets/pkg/aur"
|
||||
chown nobody:nobody . -R
|
||||
su - -s /bin/bash nobody -c "$PWD/update-pkgs.sh ${{ inputs.version }}"
|
||||
su - -s /bin/bash nobody -c "$PWD/update-pkgs.sh ${{ needs.release-checks.outputs.VERSION }}"
|
||||
su - -s /bin/bash nobody -c "$PWD/test-makepkg.sh" # This will also update -git pkgver
|
||||
chown $UID:$(id -g) . -R
|
||||
|
||||
- run: |
|
||||
BRANCH=actions/update-aur-${{ inputs.version }}
|
||||
BRANCH=actions/update-aur-${{ 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 AUR pkgs to v${{ inputs.version }}"
|
||||
git commit -am "Update AUR pkgs to v${{ needs.release-checks.outputs.VERSION }}"
|
||||
git push -u origin $BRANCH
|
||||
gh pr create --head $BRANCH \
|
||||
--title "[AUR update]: Bump to ${{ inputs.version }}" \
|
||||
--title "[AUR update]: Bump to ${{ needs.release-checks.outputs.VERSION }}" \
|
||||
--body "*This PR was created automatically*"
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
|
||||
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 }}
|
||||
|
30
.github/workflows/push.yml
vendored
30
.github/workflows/push.yml
vendored
@@ -1,5 +1,4 @@
|
||||
# Kinda based by https://github.com/myrotvorets/set-commit-status-action/actions/runs/12344741285/workflow
|
||||
name: Push Checks
|
||||
name: _
|
||||
|
||||
on:
|
||||
push:
|
||||
@@ -9,7 +8,28 @@ on:
|
||||
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
@@ -8,3 +8,5 @@ valgrind-out.txt
|
||||
|
||||
# nix build result
|
||||
result
|
||||
|
||||
include/version.h
|
||||
|
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
|
122
Makefile
122
Makefile
@@ -1,3 +1,6 @@
|
||||
VERSION = 1.2.3
|
||||
.DEFAULT_GOAL := lidm
|
||||
|
||||
CDIR=src
|
||||
LDIR=lib
|
||||
IDIR=include
|
||||
@@ -7,17 +10,32 @@ PREFIX=/usr
|
||||
|
||||
CC?=gcc
|
||||
CFLAGS?=-O3 -Wall
|
||||
_CFLAGS=-I$(DIR)
|
||||
ALLFLAGS=$(CFLAGS) -I$(IDIR)
|
||||
# C PreProcessor flags, not C Plus Plus
|
||||
CPPFLAGS?=
|
||||
ALLFLAGS=$(CFLAGS) $(CPPFLAGS) -I$(IDIR)
|
||||
|
||||
LIBS=-lpam
|
||||
|
||||
_DEPS = log.h util.h ui.h ui_state.h config.h desktop.h auth.h ofield.h efield.h keys.h users.h sessions.h chvt.h macros.h
|
||||
_DEPS = version.h log.h util.h ui.h ui_state.h config.h desktop.h auth.h ofield.h efield.h keys.h users.h sessions.h chvt.h macros.h launch_state.h
|
||||
DEPS = $(patsubst %,$(IDIR)/%,$(_DEPS))
|
||||
|
||||
_OBJ = main.o log.o util.o ui.o ui_state.o config.o desktop.o auth.o ofield.o efield.o users.o sessions.o chvt.o
|
||||
_OBJ = main.o log.o util.o ui.o ui_state.o config.o desktop.o auth.o ofield.o efield.o users.o sessions.o chvt.o launch_state.o
|
||||
OBJ = $(patsubst %,$(ODIR)/%,$(_OBJ))
|
||||
|
||||
INFO_GIT_REV?=$$(git describe --long --tags --always || echo '?')
|
||||
INFO_BUILD_TS?=$$(date +%s)
|
||||
|
||||
$(IDIR)/version.h: Makefile
|
||||
@tmp=$$(mktemp); \
|
||||
printf '' > $$tmp; \
|
||||
echo '#define LIDM_VERSION "'$(VERSION)'"' >> $$tmp; \
|
||||
echo '#define LIDM_GIT_REV "'$(INFO_GIT_REV)'"' >> $$tmp; \
|
||||
echo '#define LIDM_BUILD_TS '$(INFO_BUILD_TS) >> $$tmp; \
|
||||
if ! cmp -s $$tmp $@; then \
|
||||
mv $$tmp $@; \
|
||||
fi; \
|
||||
rm -f $$tmp;
|
||||
|
||||
$(ODIR)/%.o: $(CDIR)/%.c $(DEPS)
|
||||
@mkdir -p $(ODIR)
|
||||
$(CC) -c -o $@ $< $(ALLFLAGS)
|
||||
@@ -25,7 +43,6 @@ $(ODIR)/%.o: $(CDIR)/%.c $(DEPS)
|
||||
lidm: $(OBJ)
|
||||
$(CC) -o $@ $^ $(ALLFLAGS) $(LIBS)
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -f $(ODIR)/*.o lidm
|
||||
|
||||
@@ -33,14 +50,14 @@ clean:
|
||||
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/
|
||||
|
||||
uninstall:
|
||||
rm -rf ${DESTDIR}${PREFIX}/bin/lidm ${DESTDIR}/etc/lidm.ini
|
||||
rm -rf ${DESTDIR}/usr/share/man/man{1/lidm.1,5/lidm-config.5}.gz
|
||||
rm -rf /etc/systemd/system/lidm.service /etc/dinit.d/lidm /etc/runit/sv/lidm
|
||||
rm -rf ${DESTDIR}/etc/systemd/system/lidm.service ${DESTDIR}/etc/dinit.d/lidm ${DESTDIR}/etc/runit/sv/lidm
|
||||
|
||||
install-service:
|
||||
@if command -v systemctl &> /dev/null; then \
|
||||
@@ -48,33 +65,94 @@ install-service:
|
||||
elif command -v dinitctl &> /dev/null; then \
|
||||
make install-service-dinit; \
|
||||
elif command -v sv &> /dev/null; then \
|
||||
make install-service-runit; \
|
||||
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 \
|
||||
make install-service-s6; \
|
||||
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 '\x1b[1;31m%s\x1b[0m\n' "Unknown init system, skipping service install..."; \
|
||||
printf '\033[1;31m%s\033[0m\n' "Unknown init system, skipping service install..." >&2; \
|
||||
fi
|
||||
|
||||
install-service-systemd:
|
||||
install -m644 ./assets/services/systemd.service /etc/systemd/system/lidm.service
|
||||
@printf '\x1b[1m%s\x1b[0m\n\n' " don't forget to run 'systemctl enable lidm'"
|
||||
install -m644 ./assets/services/systemd.service ${DESTDIR}/etc/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 /etc/dinit.d/lidm
|
||||
@printf '\x1b[1m%s\x1b[0m\n\n' " don't forget to run 'dinitctl enable lidm'"
|
||||
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:
|
||||
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'"
|
||||
@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 /etc/init.d/lidm
|
||||
@printf '\x1b[1m%s\x1b[0m\n\n' " don't forget to run 'rc-update add lidm'"
|
||||
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:
|
||||
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'"
|
||||
@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'"
|
||||
|
||||
pre-commit:
|
||||
codespell
|
||||
find . -type f -name '*.sh' -not -path './assets/pkg/aur/*/src/*' | xargs shellcheck
|
||||
prettier -c "**/*.md"
|
||||
git ls-files "*.sh" "*/PKGBUILD" | xargs shellcheck --shell=bash
|
||||
clang-format -i $$(git ls-files "*.c" "*.h")
|
||||
clang-tidy -p . $$(git ls-files "*.c" "*.h")
|
||||
git ls-files -z "*.h" | \
|
||||
parallel -j$$(nproc) -q0 --no-notice --will-cite --tty clang-tidy --quiet |& \
|
||||
grep -v "warnings generated." || true
|
||||
|
||||
print-version:
|
||||
@echo $(VERSION)
|
||||
|
||||
.PHONY: clean \
|
||||
install uninstall \
|
||||
install-service \
|
||||
install-service-s6 \
|
||||
install-service-s6-etc \
|
||||
install-service-dinit \
|
||||
install-service-runit \
|
||||
install-service-runit-etc \
|
||||
install-service-openrc \
|
||||
install-service-systemd \
|
||||
pre-commit \
|
||||
print-version
|
||||
|
100
README.md
100
README.md
@@ -10,33 +10,41 @@ LiDM is like any [Display Manager](https://en.wikipedia.org/wiki/X_display_manag
|
||||
|
||||

|
||||
|
||||
> *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 wrap 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
|
||||
```
|
||||
|
||||
</details></blockquote>
|
||||
|
||||
> _however, all colors and strings are fully customizable_
|
||||
|
||||
## Features
|
||||
|
||||
* Simple as C, you only need a C compiler and standard unix libraries to build this.
|
||||
* 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, you only need a C compiler and standard unix libraries to build this.
|
||||
- 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).
|
||||
|
||||
# Index
|
||||
# Table of Contents
|
||||
|
||||
* [LiDM](#lidm)
|
||||
* [Features](#features)
|
||||
* [WIP](#wip)
|
||||
* [Index](#index)
|
||||
* [Ideology](#ideology)
|
||||
* [Usage](#usage)
|
||||
* [Arguments](#arguments)
|
||||
* [Program](#program)
|
||||
* [Requirements](#requirements)
|
||||
* [Installation](#installation)
|
||||
* [Configuring](#configuring)
|
||||
* [Contributing](#contributing)
|
||||
* [Inspiration](#inspiration)
|
||||
* [Contributors](#contributors)
|
||||
- [Ideology](#ideology)
|
||||
- [Usage](#usage)
|
||||
- [Arguments](#arguments)
|
||||
- [Program](#program)
|
||||
- [Requirements](#requirements)
|
||||
- [Installation](#installation)
|
||||
- [Configuring](#configuring)
|
||||
- [PAM](#pam)
|
||||
- [Contributing](#contributing)
|
||||
- [Inspiration](#inspiration)
|
||||
- [Contributors](#contributors)
|
||||
|
||||
# Ideology
|
||||
|
||||
@@ -44,7 +52,7 @@ 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
|
||||
|
||||
@@ -56,25 +64,33 @@ If a single argument is provided (don't even do `--` or standard unix parsing...
|
||||
|
||||
Base (mostly intuitive):
|
||||
|
||||
* Use arrow keys to navigate the inputs and type over any of them to override the default value.
|
||||
* Enter will just attempt to login.
|
||||
* If you are focused on an edited input, horizontal arrow keys will attempt to move across the text just as expected.
|
||||
- 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.
|
||||
- Using the horizontal arrow keys if the focused input is not in text mode or the movement would overflow the input. It will try to change in such direction the option of session or the user.
|
||||
- Pressing <kbd>ESC</kbd> and then horizontal arrows will force to change the option of the focused input even if it's in edit mode.
|
||||
- Editing an option on a user or a shell session will put you in edit mode appending after the original value.
|
||||
|
||||
# Requirements
|
||||
|
||||
* Make (Also optional, but does things automatically, make sure `gcc` and `mkdir -p` work as expected).
|
||||
* A compiler like `cc`, `gcc` or `clang`. Make sure to use the desired `CC=<compiler>` on the `make` command.
|
||||
* PAM library, used for user authentication, just what `login` or `su` use internally. Don't worry, it's surely pre-installed.
|
||||
- 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
|
||||
|
||||
@@ -90,6 +106,12 @@ Colors are gonna be put inside `\x1b[...m`, if you don't know what this is check
|
||||
> [!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 [contribution guide](docs/CONTRIBUTING.md).
|
||||
@@ -102,21 +124,21 @@ For this reason the project's philosophy is to be simple and minimal, such that
|
||||
|
||||
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**.
|
||||
- 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](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"
|
@@ -86,6 +86,9 @@ Text to display as the header for such sessions.
|
||||
.TP
|
||||
\fBopts_pre, opts_post\fP
|
||||
To be used for items with multiple options on the left and right sides \fB"< "\fP and \fB" >"\fP.
|
||||
.TP
|
||||
\fBellipsis\fP
|
||||
Ellipsis to be used in multiple parts such as overflowing hostnames.
|
||||
|
||||
.SS behavior
|
||||
Other miscellaneous behavior strings, of mixed types
|
||||
@@ -98,6 +101,9 @@ Types \fBSTRING_ARRAY\fP. Specify paths to source on login if they exist, simple
|
||||
.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.
|
||||
|
||||
|
||||
.SH "SEE ALSO"
|
||||
|
@@ -4,9 +4,9 @@ These files are just for reference, I'll manually edit and publish them, at leas
|
||||
|
||||
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)
|
||||
- [`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,20 +1,32 @@
|
||||
pkgbase = lidm-bin
|
||||
pkgdesc = A fully colorful customizable TUI display manager made in C. (release binary)
|
||||
pkgver = 0.2.2
|
||||
pkgver = 1.2.3
|
||||
pkgrel = 1
|
||||
url = https://github.com/javalsai/lidm
|
||||
arch = x86_64
|
||||
arch = i686
|
||||
arch = aarch64
|
||||
arch = armv7h
|
||||
arch = riscv64
|
||||
license = GPL
|
||||
depends = pam
|
||||
depends = libpam.so=0
|
||||
provides = lidm
|
||||
conflicts = lidm
|
||||
source = lidm::https://github.com/javalsai/lidm/releases/download/v0.2.2/lidm-amd64
|
||||
source = default-theme.ini::https://raw.githubusercontent.com/javalsai/lidm/v0.2.2/themes/default.ini
|
||||
source = lidm.1::https://raw.githubusercontent.com/javalsai/lidm/v0.2.2/assets/man/lidm.1
|
||||
source = lidm-config.5::https://raw.githubusercontent.com/javalsai/lidm/v0.2.2/assets/man/lidm-config.5
|
||||
sha256sums = be2307be9bef7b3ef294fb0e8178040e2d8ccff6b8efb7546514da8b0f69c179
|
||||
sha256sums = 68662430a6d262b35cc54d9f0e164ed935b7f7f4497a87cc94946c558bbe8a91
|
||||
sha256sums = a6807a55ff72ec5a5678583156b3efd0d367f0bcb79854094132771f0cb86bce
|
||||
sha256sums = 3adaae60f79dff1cef2b2aba7dcea04196cd49816759ad36afb9f7331ac9c3e4
|
||||
source = lidm-default-theme-1.2.3.ini::https://raw.githubusercontent.com/javalsai/lidm/v1.2.3/themes/default.ini
|
||||
source = lidm-1.2.3.1::https://raw.githubusercontent.com/javalsai/lidm/v1.2.3/assets/man/lidm.1
|
||||
source = lidm-config-1.2.3.5::https://raw.githubusercontent.com/javalsai/lidm/v1.2.3/assets/man/lidm-config.5
|
||||
sha256sums = ffaa5fe2cf5011bf53c90f81bfec8585158d35f72c0666db0bd4d3866ae041ca
|
||||
sha256sums = 7f2fb91f55088be1a9b1c93ecf5d6c1e437f369b56df2eacc9d10b00c93c39f8
|
||||
sha256sums = 0aa5755bdcc60ea80cd9ee0f89233ffaf22c6cee9db9da277274a62c6ed477d9
|
||||
source_x86_64 = lidm-1.2.3-x86_64::https://github.com/javalsai/lidm/releases/download/v1.2.3/lidm-amd64
|
||||
sha256sums_x86_64 = a533b5aee3ffe04268f8d3ff8d7eb87f09d31fbe25e1b8b1ed29c42ef465bd4b
|
||||
source_i686 = lidm-1.2.3-i686::https://github.com/javalsai/lidm/releases/download/v1.2.3/lidm-i386
|
||||
sha256sums_i686 = 75018578e68bffda9807de8a65e16eaed8a16c6cf2417a0b58c5d5bcfa603e45
|
||||
source_aarch64 = lidm-1.2.3-aarch64::https://github.com/javalsai/lidm/releases/download/v1.2.3/lidm-aarch64
|
||||
sha256sums_aarch64 = 1b81a1537a1e31ca1902cbc3b60add4ac712aa64fd4d266685f53372cc365882
|
||||
source_armv7h = lidm-1.2.3-armv7h::https://github.com/javalsai/lidm/releases/download/v1.2.3/lidm-armv7
|
||||
sha256sums_armv7h = e86f59509fe2366d6312b9bc9e8d89c14e9c049fd713a04c41dab49a848b1ada
|
||||
source_riscv64 = lidm-1.2.3-riscv64::https://github.com/javalsai/lidm/releases/download/v1.2.3/lidm-riscv64
|
||||
sha256sums_riscv64 = 3f0eb0315c523d367bac332641e5cd3c86cfd9aa4e7c14b2efc036937b97a598
|
||||
|
||||
pkgname = lidm-bin
|
||||
|
@@ -1,29 +1,39 @@
|
||||
# shellcheck disable=SC2034,SC2148,SC2128,SC2154,SC2164
|
||||
# shellcheck disable=SC2034,SC2154,SC2164
|
||||
# Maintainer: javalsai <javalsai@proton.me>
|
||||
pkgname=lidm-bin
|
||||
pkgver=0.2.2
|
||||
pkgver=1.2.3
|
||||
pkgrel=1
|
||||
depends=('pam')
|
||||
depends=('libpam.so')
|
||||
pkgdesc="A fully colorful customizable TUI display manager made in C. (release binary)"
|
||||
arch=('x86_64')
|
||||
arch=('x86_64' 'i686' 'aarch64' 'armv7h' 'riscv64')
|
||||
url="https://github.com/javalsai/lidm"
|
||||
license=('GPL')
|
||||
provides=('lidm')
|
||||
conflicts=('lidm')
|
||||
source=(
|
||||
"lidm::$url/releases/download/v$pkgver/lidm-amd64"
|
||||
"default-theme.ini::https://raw.githubusercontent.com/javalsai/lidm/v$pkgver/themes/default.ini"
|
||||
"lidm.1::https://raw.githubusercontent.com/javalsai/lidm/v$pkgver/assets/man/lidm.1"
|
||||
"lidm-config.5::https://raw.githubusercontent.com/javalsai/lidm/v$pkgver/assets/man/lidm-config.5"
|
||||
"lidm-default-theme-${pkgver}.ini::https://raw.githubusercontent.com/javalsai/lidm/v$pkgver/themes/default.ini"
|
||||
"lidm-${pkgver}.1::https://raw.githubusercontent.com/javalsai/lidm/v$pkgver/assets/man/lidm.1"
|
||||
"lidm-config-${pkgver}.5::https://raw.githubusercontent.com/javalsai/lidm/v$pkgver/assets/man/lidm-config.5"
|
||||
)
|
||||
sha256sums=('be2307be9bef7b3ef294fb0e8178040e2d8ccff6b8efb7546514da8b0f69c179'
|
||||
'68662430a6d262b35cc54d9f0e164ed935b7f7f4497a87cc94946c558bbe8a91'
|
||||
'a6807a55ff72ec5a5678583156b3efd0d367f0bcb79854094132771f0cb86bce'
|
||||
'3adaae60f79dff1cef2b2aba7dcea04196cd49816759ad36afb9f7331ac9c3e4')
|
||||
source_x86_64=("lidm-${pkgver}-x86_64::$url/releases/download/v$pkgver/lidm-amd64")
|
||||
source_i686=("lidm-${pkgver}-i686::$url/releases/download/v$pkgver/lidm-i386")
|
||||
source_aarch64=("lidm-${pkgver}-aarch64::$url/releases/download/v$pkgver/lidm-aarch64")
|
||||
source_armv7h=("lidm-${pkgver}-armv7h::$url/releases/download/v$pkgver/lidm-armv7")
|
||||
source_riscv64=("lidm-${pkgver}-riscv64::$url/releases/download/v$pkgver/lidm-riscv64")
|
||||
sha256sums=('ffaa5fe2cf5011bf53c90f81bfec8585158d35f72c0666db0bd4d3866ae041ca'
|
||||
'7f2fb91f55088be1a9b1c93ecf5d6c1e437f369b56df2eacc9d10b00c93c39f8'
|
||||
'0aa5755bdcc60ea80cd9ee0f89233ffaf22c6cee9db9da277274a62c6ed477d9')
|
||||
sha256sums_x86_64=('a533b5aee3ffe04268f8d3ff8d7eb87f09d31fbe25e1b8b1ed29c42ef465bd4b')
|
||||
sha256sums_i686=('75018578e68bffda9807de8a65e16eaed8a16c6cf2417a0b58c5d5bcfa603e45')
|
||||
sha256sums_aarch64=('1b81a1537a1e31ca1902cbc3b60add4ac712aa64fd4d266685f53372cc365882')
|
||||
sha256sums_armv7h=('e86f59509fe2366d6312b9bc9e8d89c14e9c049fd713a04c41dab49a848b1ada')
|
||||
sha256sums_riscv64=('3f0eb0315c523d367bac332641e5cd3c86cfd9aa4e7c14b2efc036937b97a598')
|
||||
|
||||
package() {
|
||||
install -Dm755 lidm "${pkgdir}/usr/bin/lidm"
|
||||
install -Dm644 default-theme.ini "${pkgdir}/etc/lidm.ini"
|
||||
install -Dm644 lidm.1 "${pkgdir}/usr/share/man/man1/lidm.1"
|
||||
install -Dm644 lidm-config.5 "${pkgdir}/usr/share/man/man5/lidm-config.5"
|
||||
cd "$srcdir"
|
||||
|
||||
install -Dm755 "lidm-${pkgver}-$CARCH" "${pkgdir}/usr/bin/lidm"
|
||||
install -Dm644 "lidm-default-theme-${pkgver}.ini" "${pkgdir}/etc/lidm.ini"
|
||||
install -Dm644 "lidm-${pkgver}.1" "${pkgdir}/usr/share/man/man1/lidm.1"
|
||||
install -Dm644 "lidm-config-${pkgver}.5" "${pkgdir}/usr/share/man/man5/lidm-config.5"
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
pkgbase = lidm-git
|
||||
pkgdesc = A fully colorful customizable TUI display manager made in C. (last git commit)
|
||||
pkgver = 0.1.0.r0.g8071694
|
||||
pkgver = 1.2.3.r3.g363deea
|
||||
pkgrel = 1
|
||||
url = https://github.com/javalsai/lidm
|
||||
arch = any
|
||||
|
@@ -1,10 +1,10 @@
|
||||
# shellcheck disable=SC2034,SC2148,SC2128,SC2154,SC2164
|
||||
# shellcheck disable=SC2034,SC2154,SC2164
|
||||
# Maintainer: javalsai <javalsai@proton.me>
|
||||
pkgname=lidm-git
|
||||
pkgver=0.2.2.r0.gb22ae6b
|
||||
pkgver=1.2.3.r3.g363deea
|
||||
pkgrel=1
|
||||
depends=('pam')
|
||||
makedepends=('git' 'make' 'gcc')
|
||||
makedepends=('git')
|
||||
pkgdesc="A fully colorful customizable TUI display manager made in C. (last git commit)"
|
||||
arch=('any')
|
||||
url="https://github.com/javalsai/lidm"
|
||||
@@ -15,17 +15,17 @@ source=("lidm::git+https://github.com/javalsai/lidm")
|
||||
sha256sums=('SKIP')
|
||||
|
||||
pkgver() {
|
||||
cd "lidm"
|
||||
cd "$srcdir/lidm"
|
||||
git describe --long --abbrev=7 --tags | \
|
||||
sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g'
|
||||
}
|
||||
|
||||
build() {
|
||||
cd "lidm"
|
||||
make CFLAGS="-O3"
|
||||
cd "$srcdir/lidm"
|
||||
make
|
||||
}
|
||||
|
||||
package() {
|
||||
cd "lidm"
|
||||
make install DESTDIR="${pkgdir}"
|
||||
cd "$srcdir/lidm"
|
||||
make DESTDIR="${pkgdir}" install
|
||||
}
|
||||
|
@@ -1,14 +1,12 @@
|
||||
pkgbase = lidm
|
||||
pkgdesc = A fully colorful customizable TUI display manager made in C. (build latest tag)
|
||||
pkgver = 0.2.2
|
||||
pkgver = 1.2.3
|
||||
pkgrel = 1
|
||||
url = https://github.com/javalsai/lidm
|
||||
arch = any
|
||||
license = GPL
|
||||
makedepends = git
|
||||
makedepends = gcc
|
||||
depends = pam
|
||||
source = tarball.tar.gz::https://github.com/javalsai/lidm/archive/refs/tags/v0.2.2.tar.gz
|
||||
sha256sums = 25523abc3ce6f2f261bff0cc52663607fe114692d6d3736f27fd843cae3f3a27
|
||||
source = lidm-1.2.3.tar.gz::https://github.com/javalsai/lidm/archive/refs/tags/v1.2.3.tar.gz
|
||||
sha256sums = 1ce414b510c5bbc3e32ea882f915b4d3958cb82eb1fbb5cf33e62f69c844bf93
|
||||
|
||||
pkgname = lidm
|
||||
|
@@ -1,25 +1,21 @@
|
||||
# shellcheck disable=SC2034,SC2148,SC2128,SC2154,SC2164
|
||||
# shellcheck disable=SC2034,SC2154,SC2164
|
||||
# Maintainer: javalsai <javalsai@proton.me>
|
||||
pkgname=lidm
|
||||
pkgver=0.2.2
|
||||
pkgver=1.2.3
|
||||
pkgrel=1
|
||||
depends=('pam')
|
||||
makedepends=('git' 'gcc')
|
||||
makedepends=()
|
||||
pkgdesc="A fully colorful customizable TUI display manager made in C. (build latest tag)"
|
||||
arch=('any')
|
||||
url="https://github.com/javalsai/lidm"
|
||||
license=('GPL')
|
||||
source=("tarball.tar.gz::https://github.com/javalsai/lidm/archive/refs/tags/v$pkgver.tar.gz")
|
||||
sha256sums=('25523abc3ce6f2f261bff0cc52663607fe114692d6d3736f27fd843cae3f3a27')
|
||||
source=("${pkgname}-${pkgver}.tar.gz::https://github.com/javalsai/lidm/archive/refs/tags/v$pkgver.tar.gz")
|
||||
sha256sums=('1ce414b510c5bbc3e32ea882f915b4d3958cb82eb1fbb5cf33e62f69c844bf93')
|
||||
|
||||
build() {
|
||||
tar -xzf "tarball.tar.gz"
|
||||
cd "lidm-$pkgver"
|
||||
|
||||
make CFLAGS="-O3"
|
||||
make -C "$srcdir/lidm-$pkgver"
|
||||
}
|
||||
|
||||
package() {
|
||||
cd "lidm-$pkgver"
|
||||
make install DESTDIR="${pkgdir}"
|
||||
make -C "$srcdir/lidm-$pkgver" DESTDIR="$pkgdir" install
|
||||
}
|
||||
|
22
assets/pkg/aur/makepkg-clean.sh
Executable file
22
assets/pkg/aur/makepkg-clean.sh
Executable file
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
MYSELF=$(realpath "$0")
|
||||
MYDIR=$(dirname "$MYSELF")
|
||||
|
||||
cd "$MYDIR"
|
||||
typeset -a pkgs=(lidm{,-git,-bin})
|
||||
|
||||
for pkg in "${pkgs[@]}"; do
|
||||
printf "\x1b[mEntering '%s'\x1b[0m\n" "$pkg"
|
||||
cd "$pkg"
|
||||
# shellcheck disable=SC1091
|
||||
source PKGBUILD
|
||||
# shellcheck disable=SC2154
|
||||
for f in "${source[@]}"; do
|
||||
echo "$f"
|
||||
awk -F:: '{print $1}' <<<"$f" | xargs rm -rf
|
||||
done
|
||||
cd ..
|
||||
echo
|
||||
done
|
@@ -4,18 +4,19 @@ set -e
|
||||
MYSELF=$(realpath "$0")
|
||||
MYDIR=$(dirname "$MYSELF")
|
||||
|
||||
for pkg in "$MYDIR"/*/; do
|
||||
printf "\x1b[1mEntering '%s'\x1b[0m\n" "$pkg"
|
||||
cd "$MYDIR"
|
||||
typeset -a pkgs=(lidm{,-git,-bin})
|
||||
|
||||
for pkg in "${pkgs[@]}"; do
|
||||
printf "\x1b[mEntering '%s'\x1b[0m\n" "$pkg"
|
||||
cd "$pkg"
|
||||
|
||||
# shellcheck disable=SC1091
|
||||
source "PKGBUILD"
|
||||
for source in "${source[@]}"; do
|
||||
awk -F'::' '{print $1}' <<<"$source" | xargs rm -rf
|
||||
done
|
||||
|
||||
rm -rf ./*.{gz,zst} src pkg
|
||||
makepkg -f .
|
||||
|
||||
makepkg -Cf
|
||||
cd ..
|
||||
echo
|
||||
done
|
||||
|
||||
if [[ -n "${PRINT_TREE:-}" ]]; then
|
||||
for pkg in "${pkgs[@]}"; do
|
||||
eza --tree "$pkg/pkg/"*
|
||||
done
|
||||
fi
|
||||
|
@@ -17,12 +17,6 @@ for pkg in "$MYDIR"/lidm{,-bin}/; do
|
||||
sed -i "s/pkgver=.*/pkgver=$1/" PKGBUILD
|
||||
sed -i "s/pkgrel=.*/pkgrel=1/" PKGBUILD
|
||||
|
||||
grep 'source = ' <.SRCINFO | awk -F'= |::' '{print $2}' | \
|
||||
while read -r srcfile; do
|
||||
printf "\x1b[31mDeleting '%s'\x1b[0m\n" "$srcfile"
|
||||
rm -f "$srcfile"
|
||||
done
|
||||
|
||||
updpkgsums
|
||||
makepkg --printsrcinfo | tee .SRCINFO
|
||||
echo
|
||||
|
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 = "1.2.3";
|
||||
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-eKgBoh+bRcl2Y7oOxW77Kjtb9Ws2Xln1SenknIsGxD4=";
|
||||
};
|
||||
|
||||
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";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
@@ -4,7 +4,7 @@ This folder contains the files necessary to set up lidm on start up for the supp
|
||||
|
||||
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:
|
||||
|
||||
@@ -13,30 +13,30 @@ 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 `/etc/systemd/system/lidm.service`
|
||||
- To enable it you can run `systemctl enable lidm`
|
||||
|
||||
## Dinit
|
||||
|
||||
* Copy `dinit` to `/etc/dinit.d/lidm`
|
||||
* To enable it, run `dinitctl enable lidm`
|
||||
- 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`
|
||||
- Copy `runit/` to `/etc/runit/sv/lidm/`
|
||||
- Add the service with `ln -s /etc/runit/sv/lidm /run/runit/service`
|
||||
- And to enable it `sv enable lidm`
|
||||
|
||||
## OpenRC
|
||||
|
||||
* Copy `openrc` to `/etc/init.d/lidm`
|
||||
* Enable the service with `rc-update add lidm`
|
||||
- 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)
|
||||
- Copy `s6/` to `/etc/s6/sv/lidm/`
|
||||
- Add the service with `s6-service add default lidm`
|
||||
- Reload the database with `s6-db-reload` (you might have to run this every time the service file changes)
|
||||
|
||||
> [!WARNING]
|
||||
> Make sure to disable any other service that might run on tty7, such us lightdm or most display managers out there.
|
||||
|
@@ -5,9 +5,9 @@ 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
|
||||
|
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
|
@@ -2,9 +2,10 @@
|
||||
|
||||
Contributions are welcome! Here's how you can help:
|
||||
|
||||
* [Contributing code](#code)
|
||||
* [Reporting issues](#issues)
|
||||
* [Other](#other)
|
||||
- [Contributing](#contributing)
|
||||
- [Code](#code)
|
||||
- [Issues](#issues)
|
||||
- [Other](#other)
|
||||
|
||||
## Code
|
||||
|
||||
@@ -12,33 +13,33 @@ For small fixes or incremental improvements simply fork the repo and follow the
|
||||
|
||||
1. [Fork](https://help.github.com/articles/fork-a-repo/) the repository and [clone](https://help.github.com/articles/cloning-a-repository/) your fork.
|
||||
|
||||
2. Start coding! (it might be helpful to read a [quide on the project structure and conventions](structure.md) before this)
|
||||
* Configure clangd LSP by generating `compile_commands.json` (e.g. `bear -- make` or `compiledb make`)
|
||||
* Implement your feature.
|
||||
* Check your code works as expected.
|
||||
* Run the code formatter: `clang-format -i $(git ls-files "*.c" "*.h")`
|
||||
* Run the code linter: `clang-tidy -p . $(git ls-files "*.c" "*.h")`. Some checks are pretty pedantic, feel free to ignore or debate some of the rules.
|
||||
* If you prefer, you can run `make pre-commit` to run several code style checks like the avobe along a few extra stuff.
|
||||
2. Start coding! (it might be helpful to read a [quide on the project structure and conventions](./structure.md) before this)
|
||||
- Configure clangd LSP by generating `compile_commands.json` (e.g. `bear -- make` or `compiledb make`)
|
||||
- Implement your feature.
|
||||
- Check your code works as expected.
|
||||
- Run the code formatter: `clang-format -i $(git ls-files "*.c" "*.h")`.
|
||||
- Run the code linter: `clang-tidy -p . $(git ls-files "*.c" "*.h")`. Some checks are pretty pedantic, feel free to ignore or debate some of the rules.
|
||||
- If you prefer, you can run `make pre-commit` to run several code style checks like the 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) ("feat" for features, "fix", "style", "chore", "docs", etc)
|
||||
* Be descriptive.
|
||||
* Don't make the title too long and add commit descriptions if you think the changes need it.
|
||||
* e.g. "feat: add support for X", "fix(config): config parser segfaulting", "docs(typo): fix a typo in README.md"
|
||||
- Commit messages should:
|
||||
- Header line: explain the commit in one line (use the imperative) ("feat" for features, "fix", "style", "chore", "docs", etc)
|
||||
- Be descriptive.
|
||||
- Don't make the title too long and add commit descriptions if you think the changes need it.
|
||||
- e.g. "feat: add support for X", "fix(config): config parser segfaulting", "docs(typo): fix a typo in README.md"
|
||||
|
||||
4. Once you are happy with your changes, submit a pull request.
|
||||
* Open the pull request.
|
||||
* Add a short description explaining what you've done (or if it's a work-in-progress - what you need to do)
|
||||
- Open the pull request.
|
||||
- Add a short description explaining what you've done (or if it's a work-in-progress - what you need to do)
|
||||
|
||||
## Issues
|
||||
|
||||
1. Do a quick search on GitHub to check if the issue has already been reported.
|
||||
2. [Open an issue](https://github.com//javalsai/lidm/issues/new) and describe the issue you are having - you could include:
|
||||
* Screenshots.
|
||||
* Ways to reproduce the issue.
|
||||
* Your lidm version.
|
||||
* Your platform (e.g. arch linux or Ubuntu 15.04 x64) and init system if you know.
|
||||
- Screenshots.
|
||||
- Ways to reproduce the issue.
|
||||
- Your lidm version.
|
||||
- Your platform (e.g. arch linux or Ubuntu 15.04 x64) and init system if you know.
|
||||
|
||||
After reporting you should aim to answer questions or clarifications as this helps pinpoint the cause of the issue.
|
||||
|
||||
|
128
docs/INSTALL.md
Normal file
128
docs/INSTALL.md
Normal file
@@ -0,0 +1,128 @@
|
||||
# Table of Contents
|
||||
|
||||
- [Installing from Source](#installing-from-source)
|
||||
- [AUR](#aur)
|
||||
- [Nix Flake](#nix-flake)
|
||||
- [Nix Module](#nix-module)
|
||||
|
||||
> [!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 (/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
|
||||
```
|
||||
|
||||
# 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
|
||||
|
||||
# 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_
|
||||
|
||||
> [!NOTE]
|
||||
> [service files](../assets/pkg/aur#services) **are** included and enabled
|
73
docs/PACKAGERS.md
Normal file
73
docs/PACKAGERS.md
Normal file
@@ -0,0 +1,73 @@
|
||||
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_WAYLAND` | `"/usr/share/wayland-sessions"` | | No |
|
||||
| `LIDM_CONF_PATH` | `"/etc/lidm.ini"` | Path of the default configuration. | Yes (`LIDM_CONF`) |
|
||||
|
||||
# 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`) for systems which don't use the common `/usr` structure. e.g. `make install DESTDIR=$out PREFIX=`
|
||||
|
||||
```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.
|
||||
- `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.
|
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;
|
||||
};
|
||||
}
|
||||
|
@@ -11,12 +11,14 @@
|
||||
enum introspection_type {
|
||||
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",
|
||||
};
|
||||
@@ -104,7 +106,8 @@ BUILD(functions, FUNCTIONS, TABLE_FUNCTIONS);
|
||||
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, opts_post, STRING, " >", name) \
|
||||
F(char* NNULLABLE, ellipsis, STRING, "…", name)
|
||||
|
||||
BUILD(strings, STRINGS, TABLE_STRINGS);
|
||||
|
||||
@@ -116,7 +119,8 @@ BUILD(strings, STRINGS, TABLE_STRINGS);
|
||||
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(char* NNULLABLE, timefmt, STRING, "%X %x", name) \
|
||||
F(long long, refresh_rate, NUMBER, 100, name)
|
||||
|
||||
BUILD(behavior, BEHAVIOR, TABLE_BEHAVIOR);
|
||||
|
||||
|
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
|
@@ -3,10 +3,12 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
void log_init(FILE* fd);
|
||||
void log_puts(const char* msg);
|
||||
void log_printf(const char* fmt, ...);
|
||||
#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* s);
|
||||
void log_perror(const char* NNULLABLE s);
|
||||
|
||||
#endif
|
||||
|
@@ -1,23 +1,38 @@
|
||||
#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??
|
||||
#if defined(__clang__)
|
||||
#define NULLABLE _Nullable
|
||||
#define NULLABLE _Nullable
|
||||
#else
|
||||
#define NULLABLE
|
||||
#define NULLABLE
|
||||
#endif
|
||||
|
||||
#if defined(__clang__)
|
||||
#define NNULLABLE _Nonnull
|
||||
#define NNULLABLE _Nonnull
|
||||
#else
|
||||
#define NNULLABLE
|
||||
#define NNULLABLE
|
||||
#endif
|
||||
|
||||
#if defined(__clang__)
|
||||
#define UNULLABLE _Null_unspecified
|
||||
#define UNULLABLE _Null_unspecified
|
||||
#else
|
||||
#define UNULLABLE
|
||||
#define UNULLABLE
|
||||
#endif
|
||||
|
||||
#if defined(__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]))
|
||||
|
@@ -5,6 +5,7 @@
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "keys.h"
|
||||
@@ -12,10 +13,13 @@
|
||||
int find_keyname(enum keys* at, const char* name);
|
||||
enum keys find_ansi(const char* seq);
|
||||
void read_press(u_char* length, char* out);
|
||||
// non blocking, waits up to tv or interrupt, returns true if actually read
|
||||
bool read_press_nb(u_char* length, char* out, struct timeval* tv);
|
||||
|
||||
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);
|
||||
|
43
src/auth.c
43
src/auth.c
@@ -35,6 +35,10 @@ int pam_conversation(int num_msg, const struct pam_message** msg,
|
||||
return PAM_SUCCESS;
|
||||
}
|
||||
|
||||
#ifndef PAM_SERVICE_FALLBACK
|
||||
#define PAM_SERVICE_FALLBACK "login"
|
||||
#endif
|
||||
|
||||
#define CHECK_PAM_RET(call) \
|
||||
ret = (call); \
|
||||
if (ret != PAM_SUCCESS) { \
|
||||
@@ -51,7 +55,11 @@ pam_handle_t* get_pamh(char* user, char* passwd) {
|
||||
struct pam_conv pamc = {pam_conversation, (void*)passwd};
|
||||
int ret;
|
||||
|
||||
CHECK_PAM_RET(pam_start("login", user, &pamc, &pamh))
|
||||
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))
|
||||
@@ -121,19 +129,26 @@ void moarEnv(char* user, struct session session, struct passwd* pw,
|
||||
sourceFileTry((char*)vec_get(&config->behavior.source, i));
|
||||
}
|
||||
/* printf("\n"); */
|
||||
if (pw->pw_dir) {
|
||||
uint home_len = strlen(pw->pw_dir);
|
||||
for (size_t i = 0; i < config->behavior.user_source.length; i++) {
|
||||
char* file2sourcepath = (char*)vec_get(&config->behavior.user_source, i);
|
||||
size_t newbuf_len = home_len + strlen(file2sourcepath) + 2;
|
||||
char* newbuf = malloc(newbuf_len); // nullbyte and slash
|
||||
if (newbuf == NULL) continue; // can't bother
|
||||
memcpy(newbuf, pw->pw_dir, newbuf_len);
|
||||
newbuf[home_len] = '/'; // assume pw_dir doesn't start with '/' :P
|
||||
memcpy(&newbuf[home_len + 1], file2sourcepath, newbuf_len - home_len);
|
||||
|
||||
sourceFileTry(newbuf);
|
||||
free(newbuf);
|
||||
if (pw->pw_dir) {
|
||||
const char* home = pw->pw_dir;
|
||||
size_t home_len = strlen(home);
|
||||
|
||||
for (size_t i = 0; i < config->behavior.user_source.length; i++) {
|
||||
const char* filename = (char*)vec_get(&config->behavior.user_source, i);
|
||||
size_t filename_len = strlen(filename);
|
||||
|
||||
size_t path_len = home_len + 1 + filename_len + 1; // nullbyte and slash
|
||||
char* path = malloc(path_len);
|
||||
if (!path) continue; // can't bother
|
||||
|
||||
memcpy(path, home, home_len);
|
||||
path[home_len] = '/'; // assume pw_dir doesn't start with '/' :P
|
||||
memcpy(&path[home_len + 1], filename, filename_len);
|
||||
path[path_len - 1] = '\0';
|
||||
|
||||
sourceFileTry(path);
|
||||
free(path);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -238,7 +253,7 @@ bool launch(char* user, char* passwd, struct session session, void (*cb)(void),
|
||||
perror("execl error");
|
||||
(void)fputs("failure calling session\n", stderr);
|
||||
} else {
|
||||
__pid_t child_pid = (__pid_t)pid;
|
||||
pid_t child_pid = (pid_t)pid;
|
||||
waitpid(child_pid, NULL, 0);
|
||||
|
||||
pam_setcred(pamh, PAM_DELETE_CRED);
|
||||
|
43
src/config.c
43
src/config.c
@@ -1,14 +1,18 @@
|
||||
#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 "desktop.h"
|
||||
#include "log.h"
|
||||
#include "macros.h"
|
||||
#include "util.h"
|
||||
|
||||
#define UPPER_HALF_BYTE 4
|
||||
@@ -111,6 +115,7 @@ unfinished:
|
||||
#define NOFAIL return (struct parser_error){NULL, 0}
|
||||
union typ_ptr {
|
||||
char** string;
|
||||
long long* number;
|
||||
bool* boolean;
|
||||
enum keys* key;
|
||||
struct Vector* vec;
|
||||
@@ -126,7 +131,7 @@ struct parser_error parse_key(enum introspection_type typ, union typ_ptr at,
|
||||
aux_str = strdup(key);
|
||||
if (!aux_str) FAIL("allocation failure");
|
||||
aux_err = parse_str_inplace(aux_str);
|
||||
if (!aux_err.msg) {
|
||||
if (aux_err.msg) {
|
||||
free(aux_str);
|
||||
return aux_err;
|
||||
}
|
||||
@@ -147,6 +152,13 @@ struct parser_error parse_key(enum introspection_type typ, union typ_ptr at,
|
||||
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) {
|
||||
@@ -157,7 +169,7 @@ struct parser_error parse_key(enum introspection_type typ, union typ_ptr at,
|
||||
aux_str = strdup(key);
|
||||
if (!aux_str) FAIL("allocation failure");
|
||||
aux_err = parse_str_inplace(aux_str);
|
||||
if (!aux_err.msg) {
|
||||
if (aux_err.msg) {
|
||||
free(aux_str);
|
||||
return aux_err;
|
||||
}
|
||||
@@ -170,7 +182,7 @@ struct parser_error parse_key(enum introspection_type typ, union typ_ptr at,
|
||||
#undef FAIL
|
||||
#undef NOFAIL
|
||||
|
||||
// NOLINTBEGIN(readability-identifier-length,readability-function-cognitive-complexity,readability-identifier-length)
|
||||
// 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;
|
||||
@@ -205,6 +217,8 @@ struct status config_line_handler(void* _config, char* table, char* k,
|
||||
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, offset);
|
||||
if (err.msg != NULL) {
|
||||
log_printf("[E] cfg parser, failed to parse [%s.%s] (%s): %s\n", table, k,
|
||||
@@ -213,28 +227,29 @@ struct status config_line_handler(void* _config, char* table, char* k,
|
||||
return ret;
|
||||
}
|
||||
|
||||
log_printf("[I] cfg parsed [%s.%s]\n", table, k);
|
||||
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
|
||||
log_printf("[I] cfg parsed [%s.%s]\n", table, k);
|
||||
|
||||
return ret;
|
||||
}
|
||||
// NOLINTEND(readability-identifier-length,readability-function-cognitive-complexity,readability-identifier-length)
|
||||
// NOLINTEND(readability-identifier-length,readability-function-cognitive-complexity)
|
||||
|
||||
int parse_config(struct config* NNULLABLE config, char* NNULLABLE path) {
|
||||
FILE* fd = fopen(path, "r");
|
||||
if (fd == NULL) {
|
||||
perror("fopen");
|
||||
(void)fputs(
|
||||
"Please place a config file at /etc/lidm.ini or set the LIDM_CONF "
|
||||
"env variable",
|
||||
stderr);
|
||||
return -1;
|
||||
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
|
||||
}
|
||||
|
||||
bool ret = read_desktop(fd, config, config_line_handler);
|
||||
(void)fclose(fd);
|
||||
if (!ret) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!ret) return -1;
|
||||
return 0;
|
||||
}
|
||||
|
@@ -66,7 +66,7 @@ int read_desktop(FILE* fd, void* ctx,
|
||||
buf_start[eq_idx] = '\0'; // the equal
|
||||
key = trim_str(key);
|
||||
char* value = &buf_start[eq_idx + 1];
|
||||
buf_start[read_size - 1] = '\0'; // the newline
|
||||
if (buf_start[read_size - 1] == '\n') buf_start[read_size - 1] = '\0';
|
||||
value = trim_str(value);
|
||||
|
||||
// Callback
|
||||
|
52
src/launch_state.c
Normal file
52
src/launch_state.c
Normal file
@@ -0,0 +1,52 @@
|
||||
// Small file for saving last selection
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "launch_state.h"
|
||||
|
||||
#define STATE_DIR "/var/lib/lidm"
|
||||
#define STATE_FILE "/var/lib/lidm/state"
|
||||
|
||||
#define RWXR_X___ 0750
|
||||
|
||||
int read_launch_state(struct LaunchState* NNULLABLE state) {
|
||||
FILE* state_fd = fopen(STATE_FILE, "r");
|
||||
if (state_fd == NULL) return -1;
|
||||
|
||||
*state = (struct LaunchState){
|
||||
.username = NULL,
|
||||
.session_opt = NULL,
|
||||
};
|
||||
|
||||
size_t num = 0;
|
||||
if (getline(&state->username, &num, state_fd) < 0) goto fail;
|
||||
state->username[strcspn(state->username, "\n")] = 0;
|
||||
|
||||
num = 0;
|
||||
if (getline(&state->session_opt, &num, state_fd) < 0) {
|
||||
free(state->session_opt);
|
||||
goto fail;
|
||||
}
|
||||
state->session_opt[strcspn(state->session_opt, "\n")] = 0;
|
||||
|
||||
(void)fclose(state_fd);
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
(void)fclose(state_fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool write_launch_state(struct LaunchState state) {
|
||||
FILE* state_fd = fopen(STATE_FILE, "w");
|
||||
if (state_fd == NULL) {
|
||||
if (mkdir(STATE_DIR, RWXR_X___) == -1) return false;
|
||||
state_fd = fopen(STATE_FILE, "w");
|
||||
if (state_fd == NULL) return false;
|
||||
}
|
||||
(void)fprintf(state_fd, "%s\n%s\n", state.username, state.session_opt);
|
||||
(void)fclose(state_fd);
|
||||
return true;
|
||||
}
|
@@ -32,7 +32,7 @@ void log_perror(const char* s) {
|
||||
if (!logger_out) return;
|
||||
|
||||
if (s)
|
||||
(void)fprintf(logger_out, "%s: %s", s, strerror(errno));
|
||||
(void)fprintf(logger_out, "%s: %s\n", s, strerror(errno));
|
||||
else
|
||||
(void)fprintf(logger_out, "%s", strerror(errno));
|
||||
(void)fprintf(logger_out, "%s\n", strerror(errno));
|
||||
}
|
||||
|
49
src/main.c
49
src/main.c
@@ -1,18 +1,23 @@
|
||||
#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 "log.h"
|
||||
#include "macros.h"
|
||||
#include "sessions.h"
|
||||
#include "ui.h"
|
||||
#include "users.h"
|
||||
#include "util.h"
|
||||
#include "version.h"
|
||||
|
||||
#define DATESTR_MAXBUFSIZE 0x20
|
||||
int main(int argc, char* argv[]) {
|
||||
// Logger
|
||||
char* log_output = getenv("LIDM_LOG");
|
||||
@@ -27,12 +32,50 @@ int main(int argc, char* argv[]) {
|
||||
log_init(log_fd);
|
||||
}
|
||||
|
||||
// Chvt
|
||||
if (argc == 2) chvt_str(argv[1]);
|
||||
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]);
|
||||
}
|
||||
|
||||
// Copy
|
||||
struct config config = DEFAULT_CONFIG;
|
||||
char* conf_override = getenv("LIDM_CONF");
|
||||
char* conf_path = conf_override ? conf_override : "/etc/lidm.ini";
|
||||
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;
|
||||
|
@@ -16,9 +16,16 @@ struct source_dir {
|
||||
enum session_type type;
|
||||
char* dir;
|
||||
};
|
||||
|
||||
#ifndef SESSIONS_XSESSIONS
|
||||
#define SESSIONS_XSESSIONS "/usr/share/xsessions"
|
||||
#endif
|
||||
#ifndef SESSIONS_WAYLAND
|
||||
#define SESSIONS_WAYLAND "/usr/share/wayland-sessions"
|
||||
#endif
|
||||
static const struct source_dir SOURCES[] = {
|
||||
{XORG, "/usr/share/xsessions"},
|
||||
{WAYLAND, "/usr/share/wayland-sessions"},
|
||||
{XORG, SESSIONS_XSESSIONS},
|
||||
{WAYLAND, SESSIONS_WAYLAND},
|
||||
};
|
||||
|
||||
static struct Vector* cb_sessions = NULL;
|
||||
|
285
src/ui.c
285
src/ui.c
@@ -1,11 +1,14 @@
|
||||
// i'm sorry
|
||||
// really sorry
|
||||
|
||||
#include <asm-generic/errno.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <pwd.h>
|
||||
#include <signal.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -20,6 +23,8 @@
|
||||
#include "auth.h"
|
||||
#include "efield.h"
|
||||
#include "keys.h"
|
||||
#include "launch_state.h"
|
||||
#include "log.h"
|
||||
#include "ofield.h"
|
||||
#include "sessions.h"
|
||||
#include "ui.h"
|
||||
@@ -29,21 +34,21 @@
|
||||
|
||||
const u_char INPUTS_N = 3;
|
||||
|
||||
static void print_box();
|
||||
static void print_footer();
|
||||
static void restore_all();
|
||||
static void signal_handler(int code);
|
||||
|
||||
struct uint_point {
|
||||
uint x;
|
||||
uint y;
|
||||
};
|
||||
|
||||
static void print_session(struct uint_point origin, struct session session,
|
||||
bool multiple);
|
||||
static void print_user(struct uint_point origin, struct user user,
|
||||
bool multiple);
|
||||
static void print_passwd(struct uint_point origin, uint length, bool err);
|
||||
static void print_box();
|
||||
static void print_head();
|
||||
static void print_footer();
|
||||
static void restore_all();
|
||||
static void signal_handler(int code);
|
||||
|
||||
static void print_session(struct session session, bool multiple);
|
||||
static void print_user(struct user user, bool multiple);
|
||||
static void print_passwd(uint length, bool err);
|
||||
static void scratch_print_ui();
|
||||
|
||||
// ansi resource: https://gist.github.com/fnky/458719343aabd01cfb17a3a4f7296797
|
||||
static struct termios orig_term;
|
||||
@@ -52,18 +57,15 @@ static struct winsize window;
|
||||
|
||||
#define INNER_BOX_OUT_MARGIN 2
|
||||
struct config* g_config = NULL;
|
||||
|
||||
static volatile sig_atomic_t need_resize = 0;
|
||||
|
||||
static void process_sigwinch(int signal) {
|
||||
need_resize = 1;
|
||||
}
|
||||
|
||||
void setup(struct config* config) {
|
||||
g_config = config;
|
||||
ioctl(STDOUT_FILENO, TIOCGWINSZ, &window);
|
||||
|
||||
// at least
|
||||
// 2 padding top and bottom for footer and vertical compensation
|
||||
// 2 padding left & right to not overflow footer width
|
||||
if (window.ws_row < BOX_HEIGHT + INNER_BOX_OUT_MARGIN * 2 ||
|
||||
window.ws_col < BOX_WIDTH + INNER_BOX_OUT_MARGIN * 2) {
|
||||
(void)fprintf(stderr, "\x1b[1;31mScreen too small\x1b[0m\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
tcgetattr(STDOUT_FILENO, &orig_term);
|
||||
term = orig_term; // save term
|
||||
@@ -76,17 +78,13 @@ void setup(struct config* config) {
|
||||
printf("\x1b[s\x1b[?47h\x1b[%s;%sm\x1b[2J", g_config->colors.bg,
|
||||
g_config->colors.fg);
|
||||
|
||||
print_footer();
|
||||
(void)atexit(restore_all);
|
||||
(void)signal(SIGINT, signal_handler);
|
||||
(void)signal(SIGWINCH, process_sigwinch);
|
||||
(void)fflush(stdout);
|
||||
}
|
||||
|
||||
static struct uint_point box_start() {
|
||||
return (struct uint_point){
|
||||
.x = ((window.ws_col - BOX_WIDTH) / 2) + 1, // looks better
|
||||
.y = ((window.ws_row - BOX_HEIGHT) / 2), // leave more space under
|
||||
};
|
||||
}
|
||||
static struct uint_point box_start = {.x = 0, .y = 0};
|
||||
|
||||
#define STRFTIME_PREALLOC 64
|
||||
#define TM_YEAR_EPOCH 1900
|
||||
@@ -98,7 +96,8 @@ static char* fmt_time(const char* fmt) {
|
||||
char* buf = malloc(alloc_size);
|
||||
if (!buf) return NULL;
|
||||
while (true) {
|
||||
if (strftime(buf, alloc_size, fmt, &tm) != 0) return buf;
|
||||
if (strftime(buf, alloc_size, fmt, &tm) != 0 && strlen(fmt) != 0)
|
||||
return buf;
|
||||
|
||||
alloc_size *= 2;
|
||||
char* nbuf = realloc(buf, alloc_size);
|
||||
@@ -110,10 +109,27 @@ static char* fmt_time(const char* fmt) {
|
||||
}
|
||||
}
|
||||
|
||||
char* trunc_gethostname(const size_t MAXLEN, const char* const ELLIPSIS) {
|
||||
if (utf8len(ELLIPSIS) > MAXLEN) return NULL;
|
||||
size_t alloc_size = HOST_NAME_MAX + strlen(ELLIPSIS) + 1;
|
||||
char* buf = malloc(alloc_size);
|
||||
if (!buf) return NULL;
|
||||
|
||||
if (gethostname(buf, alloc_size) != 0) {
|
||||
free(buf);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (utf8len(buf) > MAXLEN) {
|
||||
size_t end = utf8trunc(buf, MAXLEN - utf8len(ELLIPSIS));
|
||||
strcpy(&buf[end], ELLIPSIS);
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
void ui_update_cursor_focus() {
|
||||
struct uint_point bstart = box_start();
|
||||
u_char line = bstart.y;
|
||||
u_char col = bstart.x + VALUES_COL;
|
||||
u_char line = box_start.y;
|
||||
u_char col = box_start.x + VALUES_COL;
|
||||
|
||||
struct opts_field* ofield = get_opts_ffield();
|
||||
u_char maxlen = VALUE_MAXLEN;
|
||||
@@ -133,19 +149,16 @@ void ui_update_cursor_focus() {
|
||||
line += PASSWD_ROW;
|
||||
|
||||
(void)printf("\x1b[%d;%dH", line, col);
|
||||
(void)fflush(stdout);
|
||||
}
|
||||
|
||||
void ui_update_field(enum input focused_input) {
|
||||
struct uint_point origin = box_start();
|
||||
|
||||
if (focused_input == PASSWD) {
|
||||
print_passwd(origin, utf8len(of_passwd.efield.content), false);
|
||||
print_passwd(utf8len(of_passwd.efield.content), false);
|
||||
} else if (focused_input == SESSION) {
|
||||
print_session(origin, st_session(g_config->behavior.include_defshell),
|
||||
print_session(st_session(g_config->behavior.include_defshell),
|
||||
of_session.opts > 1);
|
||||
} else if (focused_input == USER) {
|
||||
print_user(origin, st_user(), of_user.opts > 1);
|
||||
print_user(st_user(), of_user.opts > 1);
|
||||
ui_update_field(SESSION);
|
||||
}
|
||||
|
||||
@@ -170,63 +183,102 @@ void ui_update_ofield(struct opts_field* NNULLABLE self) {
|
||||
ui_update_field(input);
|
||||
}
|
||||
|
||||
static char* unknown_str = "unknown";
|
||||
void scratch_print_ui() {
|
||||
ioctl(STDOUT_FILENO, TIOCGWINSZ, &window);
|
||||
box_start = (struct uint_point){
|
||||
.x = ((window.ws_col - BOX_WIDTH) / 2) + 1, // looks better
|
||||
.y = ((window.ws_row - BOX_HEIGHT) / 2), // leave more space under
|
||||
};
|
||||
|
||||
if (window.ws_row < BOX_HEIGHT + INNER_BOX_OUT_MARGIN * 2 ||
|
||||
window.ws_col < BOX_WIDTH + INNER_BOX_OUT_MARGIN * 2) {
|
||||
printf("\033[2J\033[H"); // Clear screen
|
||||
printf("\x1b[1;31mScreen too small\x1b[0m\n");
|
||||
printf("\x1b[%s;%sm\x1b[2J", g_config->colors.bg, g_config->colors.fg);
|
||||
return;
|
||||
}
|
||||
|
||||
printf("\033[2J\033[H"); // Clear screen
|
||||
|
||||
/// PRINTING
|
||||
// printf box
|
||||
print_box();
|
||||
|
||||
print_head();
|
||||
print_footer();
|
||||
|
||||
ui_update_field(SESSION);
|
||||
ui_update_field(USER);
|
||||
ui_update_field(PASSWD);
|
||||
ui_update_cursor_focus();
|
||||
}
|
||||
|
||||
#define MS_PER_S 1000
|
||||
#define US_PER_MS 1000
|
||||
// NOLINTNEXTLINE(readability-function-cognitive-complexity)
|
||||
int load(struct Vector* users, struct Vector* sessions) {
|
||||
long long ms_time = g_config->behavior.refresh_rate;
|
||||
ms_time = ms_time < 0 ? 0 : ms_time;
|
||||
|
||||
/// SETUP
|
||||
gusers = users;
|
||||
gsessions = sessions;
|
||||
|
||||
// hostnames larger won't render properly
|
||||
const u_char HOSTNAME_SIZE = VALUES_COL - VALUES_SEPR - BOX_HMARGIN;
|
||||
char hostname_buf[HOSTNAME_SIZE];
|
||||
char* hostname = hostname_buf;
|
||||
if (gethostname(hostname_buf, HOSTNAME_SIZE) != 0) {
|
||||
hostname = unknown_str;
|
||||
} else {
|
||||
// Ig "successful completion" doesn't contemplate truncation case, so need
|
||||
// to append the unspecified nullbyte
|
||||
|
||||
// char* hidx =
|
||||
// (char*)utf8back(&hostname[VALUES_COL - VALUES_SEPR - BOX_HMARGIN -
|
||||
// 1]);
|
||||
// *hidx = '\0';
|
||||
}
|
||||
|
||||
of_session =
|
||||
ofield_new(sessions->length + g_config->behavior.include_defshell);
|
||||
of_user = ofield_new(users->length);
|
||||
of_passwd = ofield_new(0);
|
||||
|
||||
/// PRINTING
|
||||
const struct uint_point BOXSTART = box_start();
|
||||
of_user.current_opt = users->length > 0;
|
||||
of_session.current_opt = sessions->length > 0;
|
||||
struct LaunchState initial_state;
|
||||
if (read_launch_state(&initial_state) == 0) {
|
||||
for (size_t i = 0; i < users->length; i++) {
|
||||
struct user* user_i = (struct user*)vec_get(users, i);
|
||||
if (strcmp(user_i->username, initial_state.username) == 0) {
|
||||
of_user.current_opt = i + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// printf box
|
||||
print_box();
|
||||
for (size_t i = 0; i < sessions->length; i++) {
|
||||
struct session* session_i = (struct session*)vec_get(sessions, i);
|
||||
if (strcmp(session_i->name, initial_state.session_opt) == 0) {
|
||||
of_session.current_opt = i + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (g_config->behavior.include_defshell) {
|
||||
if (strcmp(st_user().shell, initial_state.session_opt) == 0)
|
||||
of_session.current_opt = sessions->length + 1;
|
||||
}
|
||||
|
||||
// put hostname
|
||||
printf("\x1b[%d;%dH\x1b[%sm%s\x1b[%sm", BOXSTART.y + HEAD_ROW,
|
||||
BOXSTART.x + VALUES_COL - VALUES_SEPR - (uint)utf8len(hostname),
|
||||
g_config->colors.e_hostname, hostname, g_config->colors.fg);
|
||||
free(initial_state.username);
|
||||
free(initial_state.session_opt);
|
||||
}
|
||||
|
||||
// put date
|
||||
char* fmtd_time = fmt_time(g_config->behavior.timefmt);
|
||||
printf("\x1b[%d;%dH\x1b[%sm%s\x1b[%sm", BOXSTART.y + HEAD_ROW,
|
||||
BOXSTART.x + BOX_WIDTH - 1 - BOX_HMARGIN - (uint)utf8len(fmtd_time),
|
||||
g_config->colors.e_date, fmtd_time, g_config->colors.fg);
|
||||
free(fmtd_time);
|
||||
|
||||
ui_update_field(SESSION);
|
||||
ui_update_field(USER);
|
||||
ui_update_field(PASSWD);
|
||||
ui_update_cursor_focus();
|
||||
scratch_print_ui();
|
||||
|
||||
/// INTERACTIVE
|
||||
u_char len;
|
||||
char seq[0xff];
|
||||
uint esc = 0;
|
||||
while (true) {
|
||||
read_press(&len, seq);
|
||||
if (need_resize) {
|
||||
need_resize = 0;
|
||||
scratch_print_ui();
|
||||
} else {
|
||||
// partial refresh
|
||||
print_head();
|
||||
ui_update_cursor_focus();
|
||||
}
|
||||
|
||||
struct timeval tv;
|
||||
tv.tv_usec = (ms_time % MS_PER_S) * US_PER_MS;
|
||||
tv.tv_sec = ms_time / MS_PER_S;
|
||||
|
||||
(void)fflush(stdout);
|
||||
if (!read_press_nb(&len, seq, &tv)) continue;
|
||||
if (*seq == '\x1b') {
|
||||
enum keys ansi_code = find_ansi(seq);
|
||||
if (ansi_code != -1) {
|
||||
@@ -254,10 +306,16 @@ int load(struct Vector* users, struct Vector* sessions) {
|
||||
}
|
||||
} else {
|
||||
if (len == 1 && *seq == '\n') {
|
||||
bool successful_write = write_launch_state((struct LaunchState){
|
||||
.username = st_user().username,
|
||||
.session_opt = st_session(g_config->behavior.include_defshell).name,
|
||||
});
|
||||
if (!successful_write) log_puts("[E] failed to write launch state");
|
||||
|
||||
if (!launch(st_user().username, of_passwd.efield.content,
|
||||
st_session(g_config->behavior.include_defshell),
|
||||
&restore_all, g_config)) {
|
||||
print_passwd(box_start(), utf8len(of_passwd.efield.content), true);
|
||||
print_passwd(utf8len(of_passwd.efield.content), true);
|
||||
ui_update_cursor_focus();
|
||||
}
|
||||
} else
|
||||
@@ -283,9 +341,30 @@ u_char get_render_pos_offset(struct opts_field* self, u_char maxlen) {
|
||||
return pos - ofield_display_cursor_col(self, maxlen);
|
||||
}
|
||||
|
||||
void print_session(struct uint_point origin, struct session session,
|
||||
bool multiple) {
|
||||
clean_line(origin, SESSION_ROW);
|
||||
#define HOSTNAME_SIZE (VALUES_COL - VALUES_SEPR - BOX_HMARGIN - 1)
|
||||
void print_head() {
|
||||
// hostname doesn't just change on runtime
|
||||
static char* hostname = NULL;
|
||||
if (!hostname)
|
||||
hostname = trunc_gethostname(HOSTNAME_SIZE, g_config->strings.ellipsis);
|
||||
if (!hostname) hostname = "unknown";
|
||||
|
||||
clean_line(box_start, HEAD_ROW);
|
||||
// put hostname
|
||||
printf("\x1b[%dG\x1b[%sm%s\x1b[%sm",
|
||||
box_start.x + VALUES_COL - VALUES_SEPR - (uint)utf8len(hostname),
|
||||
g_config->colors.e_hostname, hostname, g_config->colors.fg);
|
||||
|
||||
// put date
|
||||
char* fmtd_time = fmt_time(g_config->behavior.timefmt);
|
||||
printf("\x1b[%dG\x1b[%sm%s\x1b[%sm",
|
||||
box_start.x + BOX_WIDTH - 1 - BOX_HMARGIN - (uint)utf8len(fmtd_time),
|
||||
g_config->colors.e_date, fmtd_time, g_config->colors.fg);
|
||||
free(fmtd_time);
|
||||
}
|
||||
|
||||
void print_session(struct session session, bool multiple) {
|
||||
clean_line(box_start, SESSION_ROW);
|
||||
|
||||
const char* NNULLABLE session_type;
|
||||
if (session.type == XORG) {
|
||||
@@ -300,10 +379,10 @@ void print_session(struct uint_point origin, struct session session,
|
||||
|
||||
// already in the box, - 1 bcs no need to step over margin, same reasoning in
|
||||
// other places
|
||||
printf(
|
||||
"\r\x1b[%luC\x1b[%sm%s\x1b[%sm",
|
||||
(ulong)(origin.x + VALUES_COL - VALUES_SEPR - utf8len(session_type) - 1),
|
||||
g_config->colors.e_header, session_type, g_config->colors.fg);
|
||||
printf("\r\x1b[%luC\x1b[%sm%s\x1b[%sm",
|
||||
(ulong)(box_start.x + VALUES_COL - VALUES_SEPR -
|
||||
utf8len(session_type) - 1),
|
||||
g_config->colors.e_header, session_type, g_config->colors.fg);
|
||||
|
||||
char* session_color;
|
||||
if (session.type == XORG) {
|
||||
@@ -321,21 +400,21 @@ void print_session(struct uint_point origin, struct session session,
|
||||
toprint += get_render_pos_offset(&of_session, maxlen);
|
||||
size_t printlen = utf8seekn(toprint, maxlen) - toprint;
|
||||
|
||||
printf("\r\x1b[%dC%s\x1b[%sm%.*s\x1b[%sm%s", origin.x + VALUES_COL - 1,
|
||||
printf("\r\x1b[%dC%s\x1b[%sm%.*s\x1b[%sm%s", box_start.x + VALUES_COL - 1,
|
||||
g_config->strings.opts_pre, session_color, (int)printlen, toprint,
|
||||
g_config->colors.fg, g_config->strings.opts_post);
|
||||
} else {
|
||||
toprint += get_render_pos_offset(&of_session, VALUE_MAXLEN);
|
||||
size_t printlen = utf8seekn(toprint, VALUE_MAXLEN) - toprint;
|
||||
printf("\r\x1b[%dC\x1b[%sm%.*s\x1b[%sm", origin.x + VALUES_COL - 1,
|
||||
printf("\r\x1b[%dC\x1b[%sm%.*s\x1b[%sm", box_start.x + VALUES_COL - 1,
|
||||
session_color, (int)printlen, toprint, g_config->colors.fg);
|
||||
}
|
||||
}
|
||||
|
||||
void print_user(struct uint_point origin, struct user user, bool multiple) {
|
||||
clean_line(origin, USER_ROW);
|
||||
void print_user(struct user user, bool multiple) {
|
||||
clean_line(box_start, USER_ROW);
|
||||
printf("\r\x1b[%luC\x1b[%sm%s\x1b[%sm",
|
||||
(ulong)(origin.x + VALUES_COL - VALUES_SEPR -
|
||||
(ulong)(box_start.x + VALUES_COL - VALUES_SEPR -
|
||||
utf8len(g_config->strings.e_user) - 1),
|
||||
g_config->colors.e_header, g_config->strings.e_user,
|
||||
g_config->colors.fg);
|
||||
@@ -349,21 +428,21 @@ void print_user(struct uint_point origin, struct user user, bool multiple) {
|
||||
toprint += get_render_pos_offset(&of_session, maxlen);
|
||||
size_t printlen = utf8seekn(toprint, maxlen) - toprint;
|
||||
|
||||
printf("\r\x1b[%dC< \x1b[%sm%.*s\x1b[%sm >", origin.x + VALUES_COL - 1,
|
||||
printf("\r\x1b[%dC< \x1b[%sm%.*s\x1b[%sm >", box_start.x + VALUES_COL - 1,
|
||||
user_color, (int)printlen, toprint, g_config->colors.fg);
|
||||
} else {
|
||||
toprint += get_render_pos_offset(&of_user, VALUE_MAXLEN);
|
||||
size_t printlen = utf8seekn(toprint, VALUE_MAXLEN) - toprint;
|
||||
printf("\r\x1b[%dC\x1b[%sm%.*s\x1b[%sm", origin.x + VALUES_COL - 1,
|
||||
printf("\r\x1b[%dC\x1b[%sm%.*s\x1b[%sm", box_start.x + VALUES_COL - 1,
|
||||
user_color, (int)printlen, toprint, g_config->colors.fg);
|
||||
}
|
||||
}
|
||||
|
||||
void print_passwd(struct uint_point origin, uint length, bool err) {
|
||||
void print_passwd(uint length, bool err) {
|
||||
char passwd_prompt[VALUE_MAXLEN + 1];
|
||||
clean_line(origin, PASSWD_ROW);
|
||||
clean_line(box_start, PASSWD_ROW);
|
||||
printf("\r\x1b[%luC\x1b[%sm%s\x1b[%sm",
|
||||
(ulong)(origin.x + VALUES_COL - VALUES_SEPR -
|
||||
(ulong)(box_start.x + VALUES_COL - VALUES_SEPR -
|
||||
utf8len(g_config->strings.e_passwd) - 1),
|
||||
g_config->colors.e_header, g_config->strings.e_passwd,
|
||||
g_config->colors.fg);
|
||||
@@ -379,7 +458,7 @@ void print_passwd(struct uint_point origin, uint length, bool err) {
|
||||
memset(passwd_prompt, '*', actual_len);
|
||||
passwd_prompt[VALUE_MAXLEN] = '\0';
|
||||
|
||||
printf("\r\x1b[%dC\x1b[%sm", origin.x + VALUES_COL - 1, pass_color);
|
||||
printf("\r\x1b[%dC\x1b[%sm", box_start.x + VALUES_COL - 1, pass_color);
|
||||
printf("%s", passwd_prompt);
|
||||
|
||||
printf("\x1b[%sm", g_config->colors.fg);
|
||||
@@ -403,9 +482,8 @@ static void print_row(uint wid, uint n, char* edge1, char* edge2,
|
||||
}
|
||||
|
||||
static void print_box() {
|
||||
const struct uint_point BSTART = box_start();
|
||||
|
||||
printf("\x1b[%d;%dH\x1b[%sm", BSTART.y, BSTART.x, g_config->colors.e_box);
|
||||
printf("\x1b[%d;%dH\x1b[%sm", box_start.y, box_start.x,
|
||||
g_config->colors.e_box);
|
||||
print_row(BOX_WIDTH - 2, 1, g_config->chars.ctl, g_config->chars.ctr,
|
||||
g_config->chars.hb);
|
||||
print_empty_row(BOX_WIDTH - 2, BOX_HEIGHT - 2, g_config->chars.vb,
|
||||
@@ -413,7 +491,6 @@ static void print_box() {
|
||||
print_row(BOX_WIDTH - 2, 1, g_config->chars.cbl, g_config->chars.cbr,
|
||||
g_config->chars.hb);
|
||||
printf("\x1b[%sm", g_config->colors.fg);
|
||||
(void)fflush(stdout);
|
||||
}
|
||||
|
||||
static void print_footer() {
|
||||
@@ -437,24 +514,21 @@ static void print_footer() {
|
||||
KEY_NAMES[g_config->functions.reboot],
|
||||
KEY_NAMES[g_config->functions.refresh], g_config->strings.f_poweroff,
|
||||
g_config->strings.f_reboot, g_config->strings.f_refresh);
|
||||
(void)fflush(stdout);
|
||||
}
|
||||
|
||||
void print_err(const char* msg) {
|
||||
struct uint_point origin = box_start();
|
||||
(void)fprintf(stderr, "\x1b[%d;%dH%s(%d): %s", origin.y - 1, origin.x, msg,
|
||||
errno, strerror(errno));
|
||||
(void)fprintf(stderr, "\x1b[%d;%dH%s(%d): %s", box_start.y - 1, box_start.x,
|
||||
msg, errno, strerror(errno));
|
||||
}
|
||||
|
||||
void print_errno(const char* descr) {
|
||||
struct uint_point origin = box_start();
|
||||
if (descr == NULL)
|
||||
(void)fprintf(stderr, "\x1b[%d;%dH\x1b[%smunknown error(%d): %s",
|
||||
origin.y - 1, origin.x, g_config->colors.err, errno,
|
||||
box_start.y - 1, box_start.x, g_config->colors.err, errno,
|
||||
strerror(errno));
|
||||
else {
|
||||
(void)fprintf(stderr, "\x1b[%d;%dH\x1b[%sm%s(%d): %s", origin.y - 1,
|
||||
origin.x, g_config->colors.err, descr, errno,
|
||||
(void)fprintf(stderr, "\x1b[%d;%dH\x1b[%sm%s(%d): %s", box_start.y - 1,
|
||||
box_start.x, g_config->colors.err, descr, errno,
|
||||
strerror(errno));
|
||||
}
|
||||
}
|
||||
@@ -462,7 +536,6 @@ void print_errno(const char* descr) {
|
||||
void restore_all() {
|
||||
// restore cursor pos, restore screen and show cursor
|
||||
(void)printf("\x1b[u\x1b[?47l\x1b[?25h");
|
||||
(void)fflush(stdout);
|
||||
tcsetattr(STDOUT_FILENO, TCSANOW, &orig_term);
|
||||
}
|
||||
|
||||
|
32
src/util.c
32
src/util.c
@@ -1,3 +1,5 @@
|
||||
#include <asm-generic/errno-base.h>
|
||||
#include <errno.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -53,6 +55,18 @@ void read_press(u_char* length, char* out) {
|
||||
}
|
||||
}
|
||||
|
||||
bool read_press_nb(u_char* 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;
|
||||
@@ -89,6 +103,24 @@ size_t utf8len_until(const char* str, const char* until) {
|
||||
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))) {
|
||||
}
|
||||
|
@@ -38,10 +38,12 @@ e_key = "1;23;38;5;197"
|
||||
# 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"
|
||||
|
@@ -38,10 +38,12 @@
|
||||
# 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"
|
||||
|
@@ -38,10 +38,12 @@ e_user = "38;2;148;89;84"
|
||||
# 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"
|
||||
|
@@ -38,10 +38,12 @@ e_user = "38;2;211;137;88"
|
||||
# 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"
|
||||
|
@@ -39,10 +39,12 @@ s_xorg = "X"
|
||||
s_shell = "$"
|
||||
# opts_pre = "< "
|
||||
# opts_post = " >"
|
||||
# ellipsis = "…"
|
||||
|
||||
[behavior]
|
||||
# include_defshell = true
|
||||
timefmt = "\xef\x80\x97 %X \xef\x84\xb3 %x"
|
||||
# refresh_rate = 100
|
||||
source = "/etc/lidm.env"
|
||||
source = "/etc/locale.conf"
|
||||
user_source = ".lidm.env"
|
||||
|
@@ -38,10 +38,12 @@ e_key = "32"
|
||||
# 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"
|
||||
|
@@ -38,10 +38,12 @@ e_key = "34"
|
||||
# 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"
|
||||
|
@@ -40,10 +40,12 @@ s_xorg = ""
|
||||
s_shell = ""
|
||||
# opts_pre = "< "
|
||||
# opts_post = " >"
|
||||
# ellipsis = "…"
|
||||
|
||||
[behavior]
|
||||
# include_defshell = true
|
||||
timefmt = " "
|
||||
# refresh_rate = 100
|
||||
source = "/etc/lidm.env"
|
||||
source = "/etc/locale.conf"
|
||||
user_source = ".lidm.env"
|
||||
|
@@ -38,10 +38,12 @@ s_xorg = "xworg"
|
||||
s_shell = "swell"
|
||||
# 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"
|
||||
|
@@ -39,10 +39,12 @@ s_xorg = "xorg"
|
||||
s_shell = "sh"
|
||||
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"
|
||||
|
Reference in New Issue
Block a user