67 Commits

Author SHA1 Message Date
4fb2bb2d62 Merge pull request #26 from javalsai/env-fixes
feat: add behavior.{source,user_source} for custom env
2024-12-25 22:26:52 +01:00
2c283a14fe docs: threaten ppl to star 2024-12-25 20:32:18 +01:00
f34a71195e chore: use size_t for indexing and iterating 2024-12-25 20:22:28 +01:00
e13a8ff79c fix: #includes 👀 2024-12-25 20:16:25 +01:00
4c7d221a17 dev: use #includes according to error's concerns 2024-12-25 20:00:09 +01:00
6d9b02e6de grammer: codespell 🤓 2024-12-25 19:34:40 +01:00
f03656f509 chore: add basic source paths to default themes 2024-12-25 19:30:23 +01:00
9495bd5afe chore: write man pages 2024-12-25 19:28:31 +01:00
0ba5519937 feat: add behavior.{source,user_source} for custom env 2024-12-25 19:25:09 +01:00
1e0ffcdf2f Merge pull request #24 from javalsai/code-quality
Code quality & Fixes
2024-11-01 13:33:20 +01:00
b8caf5b7d7 chore: readable vec_pop 2024-11-01 13:28:32 +01:00
06fa419a6c fix: logic 👍 (tf was i thinking here?) 2024-11-01 13:25:38 +01:00
49e3ad528f add: safety bound checks for vec_get 2024-11-01 13:11:01 +01:00
d7bfa79284 finally fix? 2024-10-19 18:49:26 +02:00
6489df2e41 fix: idk lol, versions again? 2024-10-19 18:31:52 +02:00
ab6703416f fix: still fails (version?) 2024-10-19 18:16:40 +02:00
43447ca415 grammar 👍 (again) 2024-10-19 18:15:55 +02:00
2c606cda2c fix: ci builds (hopefully 🤞)
https://github.com/uraimo/run-on-arch-action/issues/152#issuecomment-2401981347
2024-10-19 18:12:49 +02:00
d30d5a8884 grammar 👍 2024-10-19 17:52:33 +02:00
a0b68491ba chore: implement vectors
also seems to address several of these:
https://github.com/javalsai/lidm/issues/3#issuecomment-2423933131

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

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

folder which was not present.

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

View File

@@ -1,11 +0,0 @@
pkgbase = lidm
pkgdesc = A ✨fully✨ colorful cutomizable TUI display manager made in C for simplicity.
pkgver = 0.0.0
pkgrel = 1
url = https://github.com/javalsai/lidm
arch = any
license = GPL
source = lidm::https://github.com/javalsai/lidm/releases/download/0.0.0/lidm
sha256sums = 2771ca603fb02520cb1ea2dac10400fd4f512d7a8883a7ecffefe6595a93dcf5
pkgname = lidm

2
.clang-format Normal file
View File

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

2
.codespellrc Normal file
View File

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

View File

@@ -1,54 +0,0 @@
name: Build Project
on:
workflow_call:
# TODO: make arch_name optional (dont upload artifact)
inputs:
arch_name:
description: "Architecture Name"
required: true
cc:
description: "The compiler to use"
required: false
default: "gcc"
cflags:
description: "Compiler flags"
required: false
default: ""
runs:
using: "composite"
steps:
- uses: actions/checkout@v4
# cache-apt-pkgs-action try to cache :i386 packages challenge impossible
- if: ${{ inputs.arch_name == 'x86' }}
shell: bash
run: |
sudo dpkg --add-architecture i386
sudo apt-get update -y
sudo apt-get install -y libpam0g-dev:i386
- uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: "libpam0g-dev gcc-multilib"
version: 1.0
- name: Build Code
shell: bash
run: |
make CC=${{ inputs.cc }} CFLAGS="-O3 ${{ inputs.cflags }}" \
2> stderr-${{ inputs.arch_name }}
mv lidm lidm-${{ inputs.arch_name }}
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: build-${{ inputs.arch_name }}
path: |
lidm-${{ inputs.arch_name }}
stderr-${{ inputs.arch_name }}
retention-days: 1

View File

@@ -1,65 +0,0 @@
name: Test Build
on: push
jobs:
check_build:
permissions: write-all
strategy:
matrix:
include:
- arch_name: x86_64
cc: gcc
cflags:
- arch_name: x86
cc: gcc
cflags: -m32
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: myrotvorets/set-commit-status-action@master
with:
token: ${{ secrets.GITHUB_TOKEN }}
status: pending
context: Build (${{ matrix.arch_name }})
- name: Attempt Build (${{ matrix.arch_name }})
uses: ./.github/actions/build
with:
arch_name: ${{ matrix.arch_name }}
cc: ${{ matrix.cc }}
cflags: "-Wall ${{ matrix.cflags }}"
- name: Download Build Results
uses: actions/download-artifact@v4
with:
name: build-${{ matrix.arch_name }}
path: build-results
- name: Process Results
id: get-stats
if: always()
run: |
if ! [ -d "build-results" ]; then
# Build failed
echo "DESCR=" >> "$GITHUB_OUTPUT"
else
# Build Succeeded
cd "build-results"
ls -lah
cat stderr-* >&2
WARNS="$(cat stderr-* | grep '^[^ ]*\.[ch]:' | wc -l)"
HSIZE="$(stat --printf="%s" lidm-* | numfmt --to=iec-i)B"
echo "DESCR='$HSIZE, $WARNS warnings'" >> "$GITHUB_OUTPUT"
fi
- name: Set final commit status
uses: myrotvorets/set-commit-status-action@master
if: always()
with:
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}
context: Build (${{ matrix.arch_name }})
description: ${{ steps.get-stats.outputs.DESCR }}

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

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

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

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

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

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

View File

@@ -1,56 +0,0 @@
name: Build for Release
on:
release:
types: [created]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- arch_name: x86_64
cc: gcc
cflags:
- arch_name: x86
cc: gcc
cflags: -m32
steps:
- uses: actions/checkout@v4
- name: Build Project
uses: ./.github/actions/build
with:
arch_name: ${{ matrix.arch_name }}
cc: ${{ matrix.cc }}
cflags: ${{ matrix.cflags }}
upload:
permissions: write-all
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
- name: Merge Build Artifacts
uses: actions/upload-artifact/merge@v4
with:
name: all-builds
pattern: build-*
delete-merged: true
retention-days: 1
- uses: actions/download-artifact@v4
with:
name: all-builds
path: builds
- name: Upload Builds to Release
run: |
cd builds
for file in ./*; do
echo "Uploading $file..."
gh release upload ${{ github.event.release.tag_name }} "$file" --clobber
done
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

69
INSTALL.md Normal file
View File

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

View File

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

View File

@@ -1,14 +0,0 @@
pkgname=lidm
pkgver=0.0.0
pkgrel=1
pkgdesc="A ✨fully✨ colorful cutomizable TUI display manager made in C for simplicity."
arch=('any')
url="https://github.com/javalsai/lidm"
license=('GPL')
source=("lidm::https://github.com/javalsai/lidm/releases/download/v$pkgver.zip")
sha256sums=('2771ca603fb02520cb1ea2dac10400fd4f512d7a8883a7ecffefe6595a93dcf5')
package() {
install -d "$pkgdir/usr/bin/lidm"
}
sha256sums=('5eb72f7d0425e81f9b42f70159ecc44d1b6ca5cfd4fde845d01348964273ab64')

View File

@@ -3,16 +3,19 @@
[![Latest Release](https://badgen.net/github/release/javalsai/lidm)](https://github.com/javalsai/lidm/releases)
# LiDM
LiDM is a really light UI portion a unix [login manager](https://en.wikipedia.org/wiki/Login_manager) made in C, highly customizable and held together by hopes and prayers 🙏.
LiDM is like any [X Display Manager](https://en.wikipedia.org/wiki/X_display_manager) you have seen such as SDDM or GDM but without using X org graphics, instead being a purely [text based interface](https://en.wikipedia.org/wiki/Text-based_user_interface).
![demo gif](assets/media/lidm.gif)
> *shown as in a featured terminal emulator, actual linux console doesn't support as much color and decorations*
> *however, all colors and strings are fully customizable*
## Features
* Builds **FAST**.
* `a32e4a5`:
* `2.830s`: laptop, -O3, -j2, `AMD E-450 APU with Radeon(tm) HD Graphics`
@@ -24,9 +27,10 @@ LiDM is like any [X Display Manager](https://en.wikipedia.org/wiki/X_display_man
* Fast and possibly efficient.
* Fully customizable, from strings, including action keys, to colors (I hope you know ansi escape codes)
* Automatically detects xorg and wayland sessions, plus allowing to launch the default user shell (if enabled in config)
* Starts with many init systems eg: systemd and dinit.
* Starts with many init systems (systemd, dinit, runit, openrc and s6).
## WIP
* Desktop's file `TryExec` key.
* Save last selection.
* Show/hide passwd switch.
@@ -34,6 +38,7 @@ LiDM is like any [X Display Manager](https://en.wikipedia.org/wiki/X_display_man
* UTF characters or any multi-byte character, not yet supported properly, everything treats characters as a single byte, some chars might work or not depending on the context, but it's not designed to.
# Index
- [LiDM](#lidm)
- [Features](#features)
- [WIP](#wip)
@@ -44,26 +49,29 @@ LiDM is like any [X Display Manager](https://en.wikipedia.org/wiki/X_display_man
- [Program](#program)
- [Requirements](#requirements)
- [Installation](#installation)
- [Manually](#manually)
- [AUR](#aur)
- [Configuring](#configuring)
- [Contributing](#contributing)
- [Backstory](#backstory)
- [Contributors](#contributors)
# Ideology
We all know that the most important thing in a project is the ideology of the author and the movements he wants to support, so [**#stopchatcontrol**](https://stopchatcontrol.eu).
[ ![stopchatcontrol](https://stopchatcontrol.eu/wp-content/uploads/2023/09/1-1-1024x1024.png) ](https://stopchatcontrol.eu)
> *there's also a [change.org post](https://www.change.org/p/stoppt-die-chatkontrolle-grundrechte-gelten-auch-im-netz).*
# Usage
### Arguments
If a single argument is provided (don't even do `--` or standard parsing...), it passes that argument to `chvt` on startup, used (at least) by the dinit service.
If a single argument is provided (don't even do `--` or standard parsing...), it passes that argument to `chvt` on startup, used (at least) by most service files.
### Program
On top of pure intuition:
* You can change focus of session/user/passwd with up/down arrows.
* In case arrow keys do nothing on the focused input (Either is empty text or doesn't have more options), it tries to change session and if there's only one session it changes user.
* Typing anything will allow to put a custom user or shell command too, you can use arrow keys to move.
@@ -71,47 +79,22 @@ On top of pure intuition:
* Editing a predefined option on a user or a shell session, will put you in edit mode preserving the original value, other cases start from scratch.
# Requirements
* A computer with unix based system.
* That system should have the resources neccessary for this program to make sense (Sessions, users...).
* That system should have the resources necessary for this program to make sense (Sessions, users...).
* A compiler (optional, you can compile by hand, but I doubt you want to see the code).
* Make (Also optional, but does things atomatically, make sure `gcc` and `mkdir -p` work as expected).
* Make (Also optional, but does things automatically, make sure `gcc` and `mkdir -p` work as expected).
* PAM, used for user authentication, just what `login` or `su` use internally. Don't worry, it's surely pre-installed.
# Installation
## Manually
* Build the package (you can download automatic builds from the [releases page](https://github.com/javalsai/lidm/releases)):
```sh
git clone https://github.com/javalsai/lidm.git
cd lidm
make # 👍
```
* Install the files (see [configuration](#configuring) for more themeing info).
```sh
# place binary in /usr/bin and copy
# default theme to /etc
make install
```
* Make a service file for this if you want it on launch, just check how ly does it, this works pretty much the same way.
```sh
# automatically detects init system
# and installs service file (for tty7)
make install-service
# or if you don't like autodetection
make install-service-systemd # systemd
make install-service-dinit # dinit
```
## AUR
[AUR packages](https://aur.archlinux.org/packages?K=lidm&SeB=n) will automatically install the binary and config. But I recommend reading [installing manually](#manually) to understand the install process.
> [!CAUTION]
> [service files](./assets/pkg/aur#services) have to be manually installed by now.
Check the [installation guide](./INSTALL.md) to use your preferred installation source.
# Configuring
Copy any `.ini` file from [`themes/`](./themes/) (`default.ini` will always be updated) to `/etc/lidm.ini` and/or configure it to your liking. Also, don't place empty lines (for now).
Configurated colors are just gonna be put inside `\x1b[...m`, ofc you can add an 'm' to break this and this can f\*ck up really bad or even make some nice UI effect possible, you should also be able to embed the `\x1b` byte in the config as I won't parse escape codes, I think that the parser is just gonna grab anything in the config file from the space after the `=` (yes, I'ma enforce that space, get good taste if you don't like it) until the newline, you can put any abomination in there. But please, keep in mind this might break easily.
Copy any `.ini` file from [`themes/`](./themes/) (`default.ini` will always be updated) to `/etc/lidm.ini` and/or configure it to your liking. Also, don't place empty lines (for now). You can also set `LIDM_CONF` environment variable to specify a config path.
Configured colors are just gonna be put inside `\x1b[...m`, ofc you can add an 'm' to break this and this can f\*ck up really bad or even make some nice UI effect possible, you should also be able to embed the `\x1b` byte in the config as I won't parse escape codes, I think that the parser is just gonna grab anything in the config file from the space after the `=` (yes, I'ma enforce that space, get good taste if you don't like it) until the newline, you can put any abomination in there. But please, keep in mind this might break easily.
The default fg style should disable decorators set up in other elements (cursive, underline... it's just adding 20 to the number btw, so if cursive is 4 (iirc), disabling it is 24).
@@ -119,21 +102,30 @@ The default fg style should disable decorators set up in other elements (cursive
> If you don't like seeing an element, you can change the fg color of it to be the same as the bg, making it invisible.
# Contributing
If you want to contribute check the [CONTRIBUTING.md](docs/CONTRIBUTING.md)
# Backstory
Summer travelling to visit family with an old laptop that barely supports x86_64, and ly recently added some avx2 instructions I think (invalid op codes), manually building (any previous commit too) didn't work because of something in the `build.zig` file, so out of boredom I decided to craft up my own simple display manager on the only language this thing can handle... **C** (I hate this and reserve the right for the rust rewrite, actually solid).
Summer travelling to visit family with an old laptop that barely supports x86\_64, and ly recently added some avx2 instructions I think (invalid op codes), manually building (any previous commit too) didn't work because of something in the `build.zig` file, so out of boredom I decided to craft up my own simple display manager on the only language this thing can handle... **C** (I hate this and reserve the right for the rust rewrite, actually solid).
I spedrun it in roughly 3 days and I'm bad af in C, so this is spaghetti code on **another** level. I think it doesn't do almost anything unsafe, I mean, I didn't check allocations and it's capable of reallocating memory until your username uses all memory, crashing the system due to a off-by-one error, but pretty consistent otherwise (probably).
The name is just ly but changing "y" with "i", that had a reason but forgot it, (maybe the i in *simple*), so I remembered this sh*tty laptop with a lid, this thing is also a display manager (dm, ly command is also `ly-dm`), so just did lidm due to all that.
The name is just ly but changing "y" with "i", that had a reason but forgot it, (maybe the i in *simple*), so I remembered this sh\*tty laptop with a lid, this thing is also a display manager (dm, ly command is also `ly-dm`), so just did lidm due to all that.
# Contributors
[![GitHub Contributors](https://contrib.rocks/image?repo=javalsai/lidm&max=20)](https://github.com/javalsai/lidm/graphs/contributors)
[![GitHub Contributors](https://contrib.rocks/image?repo=javalsai/lidm\&max=20)](https://github.com/javalsai/lidm/graphs/contributors)
* KillerTofus, [made the AUR package](https://github.com/javalsai/lidm/pull/2)! Saved me from reading the Arch Wiki 💀.
* DeaDvey, the most awesomest of all, did some pretty HARDCORE gramer cheking. (and trolling, he wrote that, 33 commits of just readme changes ffs)
* DeaDvey, the most awesomest of all, did some pretty HARDCORE gramer checking. (and trolling, he wrote that, 33 commits of just readme changes ffs)
* grialion, made a simple C implementation of `chvt` instead of insecurely relying on `kbd utils`'s command.
* cerealexperiments_, found a missing newline (had the guts to read the source code, crazy ik)
* cerealexperiments\_, found a missing newline (had the guts to read the source code, crazy ik)
* ChatGPT, in times of slow laptops where pages take ages to load, a single tab connected to a bunch of burning cloud GPUs feeding corporate hype is all you need to get quick answers for your questions, as long as you know how to filter AI crap ofc.
* [My lack of gf](https://www.instagram.com/reel/C8sa3Gltmtq), can't imagine this project being possible if somebody actually cared about me daily.
---
🌟 Finally, consider starring this repo or... 🔪
![star-history](https://api.star-history.com/svg?repos=javalsai/lidm&type=Date)

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

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

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

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 496 KiB

After

Width:  |  Height:  |  Size: 148 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

View File

@@ -1,17 +1,12 @@
# AUR Packages
These files are just for reference, I'll manually edit and publish them, at least until I automate it with github actions (like updating version automatically on a release).
There are three packages that follow standard conventions:
* [`lidm`](https://aur.archlinux.org/packages/lidm): Builds latest release (manually updated per release basis)
* [`lidm-bin`](https://aur.archlinux.org/packages/lidm-bin): Fetches latest release binary (compiled by GitHub Actions, also updated per release)
* [`lidm-git`](https://aur.archlinux.org/packages/lidm-git): Fetches latest commit and builds it (should be updated automatically)
> [!IMPORTANT]
> None of those packages include the service files, I'm considering automatically detecting it on the package function or providing it as separate services (standard practice again).
>
> Depending on how good these packages go (my first packages :P) I'll make service ones too.
## Services
Summary of what to do to install service files anyways:
* **systemd:** Copy `assets/services/systemd.service` to `/etc/systemd/system/lidm.service` and enable the service (`systemctl enable lidm`)
* **dinit:** Copy `assets/services/dinit` to `/etc/dinit.d/lidm` and enable the service (`dinitctl enable lidm`)
> \[!IMPORTANT]
> None of those packages include the service files. [You have to do this yourself](../../services/README.md).

View File

@@ -1,16 +1,21 @@
pkgbase = lidm-bin
pkgdesc = A fully colorful cutomizable TUI display manager made in C. (release binary)
pkgver = 0.0.1
pkgrel = 4
pkgdesc = A fully colorful customizable TUI display manager made in C. (release binary)
pkgver = 0.1.0
pkgrel = 1
url = https://github.com/javalsai/lidm
arch = x86_64
license = GPL
makedepends = gzip
depends = pam
provides = lidm
conflicts = lidm
source = lidm::https://github.com/javalsai/lidm/releases/download/0.0.1/lidm-x86_64
source = default-theme.ini::https://raw.githubusercontent.com/javalsai/lidm/0.0.1/themes/default.ini
sha256sums = 4969018d527613729336abd51e37283ce77d7c7a2233434642804b88e550e622
source = lidm::https://github.com/javalsai/lidm/releases/download/v0.1.0/lidm-amd64
source = default-theme.ini::https://raw.githubusercontent.com/javalsai/lidm/v0.1.0/themes/default.ini
source = lidm.1::https://raw.githubusercontent.com/javalsai/lidm/v0.1.0/assets/man/lidm.1
source = lidm-config.5::https://raw.githubusercontent.com/javalsai/lidm/v0.1.0/assets/man/lidm-config.5
sha256sums = b5d1dbdaa6b78da57be69ce5e2cc3366717a045de3cb316e66c1c3f36b796ee0
sha256sums = 27db9b0cd2da80c0c60dcb13dfad0f9d65e7dddbb7b344b859803b9ac3943cd7
sha256sums = a6807a55ff72ec5a5678583156b3efd0d367f0bcb79854094132771f0cb86bce
sha256sums = c44f78940212b946e157eac02e159b215376d291d11adfe4925b594405ad85da
pkgname = lidm-bin

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

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

View File

@@ -1,24 +1,31 @@
# shellcheck disable=SC2034,SC2148,SC2128,SC2154,SC2164
# Maintainer: javalsai <javalsai@proton.me>
pkgname=lidm-bin
pkgver=0.0.1
pkgrel=4
pkgver=0.1.0
pkgrel=1
depends=('pam')
pkgdesc="A fully colorful cutomizable TUI display manager made in C. (release binary)"
makedepends=('gzip')
pkgdesc="A fully colorful customizable TUI display manager made in C. (release binary)"
arch=('x86_64')
url="https://github.com/javalsai/lidm"
license=('GPL')
provides=('lidm')
conflicts=('lidm')
source=(
"lidm::$url/releases/download/$pkgver/lidm-$arch"
"default-theme.ini::https://raw.githubusercontent.com/javalsai/lidm/$pkgver/themes/default.ini"
)
sha256sums=(
'4969018d527613729336abd51e37283ce77d7c7a2233434642804b88e550e622'
'27db9b0cd2da80c0c60dcb13dfad0f9d65e7dddbb7b344b859803b9ac3943cd7'
"lidm::$url/releases/download/v$pkgver/lidm-amd64"
"default-theme.ini::https://raw.githubusercontent.com/javalsai/lidm/v$pkgver/themes/default.ini"
"lidm.1::https://raw.githubusercontent.com/javalsai/lidm/v$pkgver/assets/man/lidm.1"
"lidm-config.5::https://raw.githubusercontent.com/javalsai/lidm/v$pkgver/assets/man/lidm-config.5"
)
sha256sums=('b5d1dbdaa6b78da57be69ce5e2cc3366717a045de3cb316e66c1c3f36b796ee0'
'27db9b0cd2da80c0c60dcb13dfad0f9d65e7dddbb7b344b859803b9ac3943cd7'
'a6807a55ff72ec5a5678583156b3efd0d367f0bcb79854094132771f0cb86bce'
'c44f78940212b946e157eac02e159b215376d291d11adfe4925b594405ad85da')
package() {
install -Dm755 lidm "${pkgdir}/usr/bin/lidm"
install -Dm755 default-theme.ini "${pkgdir}/etc/lidm.ini"
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"
gzip -f "${pkgdir}"/usr/share/man/man{1/lidm.1,5/lidm-config.5}
}

View File

@@ -1,7 +1,7 @@
pkgbase = lidm-git
pkgdesc = A fully colorful cutomizable TUI display manager made in C. (last git commit)
pkgver = 0.0.1.r0.gd6b165b
pkgrel = 6
pkgdesc = A fully colorful customizable TUI display manager made in C. (last git commit)
pkgver = 0.1.0.r0.g8071694
pkgrel = 1
url = https://github.com/javalsai/lidm
arch = any
license = GPL

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

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

View File

@@ -1,10 +1,11 @@
# shellcheck disable=SC2034,SC2148,SC2128,SC2154,SC2164
# Maintainer: javalsai <javalsai@proton.me>
pkgname=lidm-git
pkgver=0.0.1.r0.gd6b165b
pkgrel=6
pkgver=0.1.0.r0.g8071694
pkgrel=1
depends=('pam')
makedepends=('git' 'make' 'gcc')
pkgdesc="A fully colorful cutomizable TUI display manager made in C. (last git commit)"
pkgdesc="A fully colorful customizable TUI display manager made in C. (last git commit)"
arch=('any')
url="https://github.com/javalsai/lidm"
license=('GPL')
@@ -26,6 +27,5 @@ build() {
package() {
cd "lidm"
install -Dm755 lidm "${pkgdir}/usr/bin/lidm"
install -Dm755 themes/default.ini "${pkgdir}/etc/lidm.ini"
make install DESTDIR="${pkgdir}"
}

View File

@@ -1,15 +1,15 @@
pkgbase = lidm
pkgdesc = A fully colorful cutomizable TUI display manager made in C. (build latest tag)
pkgver = 0.0.1
pkgrel = 5
pkgdesc = A fully colorful customizable TUI display manager made in C. (build latest tag)
pkgver = 0.1.0
pkgrel = 2
url = https://github.com/javalsai/lidm
arch = any
license = GPL
makedepends = git
makedepends = make
makedepends = gcc
makedepends = gzip
depends = pam
source = lidm::git+https://github.com/javalsai/lidm
sha256sums = SKIP
source = tarball.tar.gz::https://github.com/javalsai/lidm/archive/refs/tags/v0.1.0.tar.gz
sha256sums = de1981603f3fa54caacfcd68cc07d650c186990175baf210ba5275d6450e5030
pkgname = lidm

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

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

View File

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

View File

@@ -1,4 +1,4 @@
#/usr/bin/env bash
#!/usr/bin/env bash
set -e
MYSELF=$(realpath "$0")

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

@@ -0,0 +1,15 @@
#!/usr/bin/env bash
set -e
MYSELF=$(realpath "$0")
MYDIR=$(dirname "$MYSELF")
for pkg in "$MYDIR"/*/; do
cd "$pkg"
printf "\x1b[1mEntering '%s'\x1b[0m\n" "$pkg"
rm -rf ./*.{gz,zst} src pkg
makepkg -f .
echo
done

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

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

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

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

31
assets/services/openrc Executable file
View File

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

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

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

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

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

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

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

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

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

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

@@ -0,0 +1 @@
longrun

View File

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

View File

@@ -10,8 +10,8 @@
let
pkgs = import nixpkgs { inherit system; };
name = "LiDM";
version = "0.0.1";
name = "lidm";
version = "0.0.2";
lidm = (
pkgs.stdenv.mkDerivation {

View File

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

View File

@@ -20,6 +20,6 @@ int chvt(int n);
* @param str virtual terminal number (string)
* @return int non-negative value on success
*/
int chvt_str(char* str);
int chvt_str(char *str);
#endif

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -3,7 +3,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <chvt.h>
#include "chvt.h"
static char *vterms[] = {"/dev/tty", "/dev/tty0", "/dev/vc/0", "/dev/systty",
"/dev/console"};
@@ -26,7 +26,7 @@ int chvt_str(char *str) {
int chvt(int n) {
fprintf(stderr, "activating vt %d\n", n);
char c = 0;
for (int i = 0; i < sizeof(vterms) / sizeof(vterms[0]); i++) {
for (size_t i = 0; i < sizeof(vterms) / sizeof(vterms[0]); i++) {
int fd = open(vterms[i], O_RDWR);
if (fd >= 0 && isatty(fd) && ioctl(fd, KDGKBTYPE, &c) == 0 && c < 3) {
if (ioctl(fd, VT_ACTIVATE, n) < 0 || ioctl(fd, VT_WAITACTIVE, n) < 0) {

View File

@@ -1,8 +1,8 @@
#include "util.h"
#include <string.h>
#include <sys/stat.h>
#include <config.h>
#include "config.h"
#include "util.h"
bool line_parser(FILE *fd, ssize_t *blksize,
u_char (*cb)(char *key, char *value)) {
@@ -45,72 +45,74 @@ bool line_parser(FILE *fd, ssize_t *blksize,
struct config *__config;
u_char config_line_handler(char *k, char *v) {
if(strcmp(k, "colors.bg") == 0)
if (strcmp(k, "colors.bg") == 0)
__config->theme.colors.bg = v;
else if(strcmp(k, "colors.fg") == 0)
else if (strcmp(k, "colors.fg") == 0)
__config->theme.colors.fg = v;
else if(strcmp(k, "colors.err") == 0)
else if (strcmp(k, "colors.err") == 0)
__config->theme.colors.err = v;
else if(strcmp(k, "colors.s_wl") == 0)
__config->theme.colors.s_wl = v;
else if(strcmp(k, "colors.s_xorg") == 0)
else if (strcmp(k, "colors.s_wayland") == 0)
__config->theme.colors.s_wayland = v;
else if (strcmp(k, "colors.s_xorg") == 0)
__config->theme.colors.s_xorg = v;
else if(strcmp(k, "colors.s_shell") == 0)
else if (strcmp(k, "colors.s_shell") == 0)
__config->theme.colors.s_shell = v;
else if(strcmp(k, "colors.f_other") == 0)
__config->theme.colors.f_other = v;
else if(strcmp(k, "colors.e_hostname") == 0)
else if (strcmp(k, "colors.e_hostname") == 0)
__config->theme.colors.e_hostname = v;
else if(strcmp(k, "colors.e_date") == 0)
else if (strcmp(k, "colors.e_date") == 0)
__config->theme.colors.e_date = v;
else if(strcmp(k, "colors.e_box") == 0)
else if (strcmp(k, "colors.e_box") == 0)
__config->theme.colors.e_box = v;
else if(strcmp(k, "colors.e_header") == 0)
else if (strcmp(k, "colors.e_header") == 0)
__config->theme.colors.e_header = v;
else if(strcmp(k, "colors.e_user") == 0)
else if (strcmp(k, "colors.e_user") == 0)
__config->theme.colors.e_user = v;
else if(strcmp(k, "colors.e_passwd") == 0)
else if (strcmp(k, "colors.e_passwd") == 0)
__config->theme.colors.e_passwd = v;
else if(strcmp(k, "colors.e_badpasswd") == 0)
else if (strcmp(k, "colors.e_badpasswd") == 0)
__config->theme.colors.e_badpasswd = v;
else if(strcmp(k, "colors.e_key") == 0)
else if (strcmp(k, "colors.e_key") == 0)
__config->theme.colors.e_key = v;
else if(strcmp(k, "chars.hb") == 0)
else if (strcmp(k, "chars.hb") == 0)
__config->theme.chars.hb = v;
else if(strcmp(k, "chars.vb") == 0)
else if (strcmp(k, "chars.vb") == 0)
__config->theme.chars.vb = v;
else if(strcmp(k, "chars.ctl") == 0)
else if (strcmp(k, "chars.ctl") == 0)
__config->theme.chars.ctl = v;
else if(strcmp(k, "chars.ctr") == 0)
else if (strcmp(k, "chars.ctr") == 0)
__config->theme.chars.ctr = v;
else if(strcmp(k, "chars.cbl") == 0)
else if (strcmp(k, "chars.cbl") == 0)
__config->theme.chars.cbl = v;
else if(strcmp(k, "chars.cbr") == 0)
else if (strcmp(k, "chars.cbr") == 0)
__config->theme.chars.cbr = v;
else if(strcmp(k, "functions.poweroff") == 0)
else if (strcmp(k, "functions.poweroff") == 0)
__config->functions.poweroff = find_keyname(v);
else if(strcmp(k, "functions.reboot") == 0)
else if (strcmp(k, "functions.reboot") == 0)
__config->functions.reboot = find_keyname(v);
else if(strcmp(k, "functions.refresh") == 0)
else if (strcmp(k, "functions.refresh") == 0)
__config->functions.refresh = find_keyname(v);
else if(strcmp(k, "strings.f_poweroff") == 0)
__config->strings.f_poweroff= v;
else if(strcmp(k, "strings.f_reboot") == 0)
__config->strings.f_reboot= v;
else if(strcmp(k, "strings.f_refresh") == 0)
__config->strings.f_refresh= v;
else if(strcmp(k, "strings.e_user") == 0)
__config->strings.e_user= v;
else if(strcmp(k, "strings.e_passwd") == 0)
__config->strings.e_passwd= v;
else if(strcmp(k, "strings.s_xorg") == 0)
__config->strings.s_xorg= v;
else if(strcmp(k, "strings.s_wayland") == 0)
__config->strings.s_wayland= v;
else if(strcmp(k, "strings.s_shell") == 0)
__config->strings.s_shell= v;
else if(strcmp(k, "behavior.include_defshell") == 0)
__config->behavior.include_defshell= strcmp(v, "true") == 0;
else if (strcmp(k, "strings.f_poweroff") == 0)
__config->strings.f_poweroff = v;
else if (strcmp(k, "strings.f_reboot") == 0)
__config->strings.f_reboot = v;
else if (strcmp(k, "strings.f_refresh") == 0)
__config->strings.f_refresh = v;
else if (strcmp(k, "strings.e_user") == 0)
__config->strings.e_user = v;
else if (strcmp(k, "strings.e_passwd") == 0)
__config->strings.e_passwd = v;
else if (strcmp(k, "strings.s_wayland") == 0)
__config->strings.s_wayland = v;
else if (strcmp(k, "strings.s_xorg") == 0)
__config->strings.s_xorg = v;
else if (strcmp(k, "strings.s_shell") == 0)
__config->strings.s_shell = v;
else if (strcmp(k, "behavior.include_defshell") == 0)
__config->behavior.include_defshell = strcmp(v, "true") == 0;
else if (strcmp(k, "behavior.source") == 0)
vec_push(&__config->behavior.source, v);
else if (strcmp(k, "behavior.user_source") == 0)
vec_push(&__config->behavior.user_source, v);
else
return 0b1111;
@@ -126,9 +128,12 @@ struct config *parse_config(char *path) {
}
__config = malloc(sizeof(struct config));
__config->behavior.source = vec_new();
__config->behavior.user_source = vec_new();
if (__config == NULL)
return NULL;
bool ret = line_parser(fd, (ssize_t*)&sb.st_blksize, config_line_handler);
bool ret = line_parser(fd, (ssize_t *)&sb.st_blksize, config_line_handler);
if (!ret) {
free(__config);
return NULL;

View File

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

View File

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

View File

@@ -7,8 +7,8 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <sessions.h>
#include <util.h>
#include "sessions.h"
#include "util.h"
struct source_dir {
enum session_type type;
@@ -18,7 +18,6 @@ static const struct source_dir sources[] = {
{XORG, "/usr/share/xsessions"},
{WAYLAND, "/usr/share/wayland-sessions"},
};
static const size_t sources_size = sizeof(sources) / sizeof(sources[0]);
static struct session __new_session(enum session_type type, char *name,
const char *exec, const char *tryexec) {
@@ -31,23 +30,12 @@ static struct session __new_session(enum session_type type, char *name,
return __session;
}
static const u_int8_t bs = 16;
static const u_int8_t unit_size = sizeof(struct session);
static struct Vector *cb_sessions = NULL;
static u_int16_t alloc_size = bs;
static u_int16_t used_size = 0;
static struct session *sessions = NULL;
static struct sessions_list *__sessions_list = NULL;
// NOTE: commented printf's here would be nice to have debug logs if I ever implement it
// NOTE: commented printf's here would be nice to have debug logs if I ever
// implement it
static enum session_type session_type;
static int fn(const char *fpath, const struct stat *sb, int typeflag) {
// practically impossible to reach this
// but will prevent break
if (used_size == 0xffff)
return 0;
if (sb == NULL || !S_ISREG(sb->st_mode))
return 0;
@@ -55,7 +43,7 @@ static int fn(const char *fpath, const struct stat *sb, int typeflag) {
FILE *fd = fopen(fpath, "r");
if (fd == NULL) {
perror("fopen");
fprintf(stderr, "error opening file (r) %s\n", fpath);
fprintf(stderr, "error opening file (r) '%s'\n", fpath);
return 0;
}
@@ -65,8 +53,8 @@ static int fn(const char *fpath, const struct stat *sb, int typeflag) {
char *name_buf = NULL;
char *exec_buf = NULL;
char *tryexec_buf = NULL;
// This should be made a specific function
while (true) {
/*printf(".");*/
char *buf = malloc(sb->st_blksize);
ssize_t read_size = getline(&buf, &alloc_size, fd);
if (read_size == -1) {
@@ -101,17 +89,10 @@ static int fn(const char *fpath, const struct stat *sb, int typeflag) {
// just add this to the list
if (name_buf != NULL && exec_buf != NULL) {
/*printf("gonna add to session list\n");*/
if (used_size >= alloc_size) {
alloc_size += bs;
sessions = realloc(sessions, alloc_size * unit_size);
}
/*printf("n %s\ne %s\nte %s\n", name_buf, exec_buf, tryexec_buf);*/
sessions[used_size] = __new_session(session_type, name_buf, exec_buf,
tryexec_buf == NULL ? "" : tryexec_buf);
used_size++;
struct session *session_i = malloc(sizeof (struct session));
*session_i = __new_session(session_type, name_buf, exec_buf,
tryexec_buf == NULL ? "" : tryexec_buf);
vec_push(cb_sessions, session_i);
}
if (name_buf != NULL)
@@ -124,23 +105,17 @@ static int fn(const char *fpath, const struct stat *sb, int typeflag) {
return 0;
}
static struct sessions_list __list;
// This code is designed to be run purely single threaded
struct sessions_list *get_avaliable_sessions() {
if (sessions != NULL)
return __sessions_list;
else
sessions = malloc(alloc_size * unit_size);
struct Vector get_avaliable_sessions() {
struct Vector sessions = vec_new();
for (uint i = 0; i < sources_size; i++) {
session_type = sources[i].type;
cb_sessions = &sessions;
for (size_t i = 0; i < (sizeof(sources) / sizeof(sources[0])); i++) {
/*printf("recurring into %s\n", sources[i].dir);*/
session_type = sources[i].type;
ftw(sources[i].dir, &fn, 1);
}
cb_sessions = NULL;
sessions = realloc(sessions, used_size * unit_size);
__list.length = used_size;
__list.sessions = sessions;
return __sessions_list = &__list;
return sessions;
}

121
src/ui.c
View File

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

View File

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

View File

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

View File

@@ -1,29 +1,37 @@
# Themes
## cherry.ini
![cherry.ini theme](./screenshots/cherry.png)
## default.ini
![default.ini theme](./screenshots/default.png)
## kanagawa-dragon.ini
![kanagawa-dragon.ini theme](./screenshots/kanagawa-dragon.png)
## kanagawa-wave.ini
![kanagawa-wave.ini theme](./screenshots/kanagawa-wave.png)
## nature.ini
![nature.ini theme](./screenshots/nature.png)
## nord.ini
![nord.ini theme](./screenshots/nord.png)
## old-blue.ini
![old-blue.ini theme](./screenshots/old-blue.png)
## old-blue-thick.ini
![old-blue-thick.ini theme](./screenshots/old-blue-thick.png)
## nothing.ini
## pure-tastelessness.ini
![pure-tastelessness.ini theme](./screenshots/pure-tastelessness.png)
![nothing.ini theme](./screenshots/nothing.png)
## tasteless.ini
![tasteless.ini theme](./screenshots/tasteless.png)
## tastelessness.ini
![tastelessness.ini theme](./screenshots/tastelessness.png)

View File

@@ -1,10 +1,9 @@
colors.bg = 48;2;77;33;55
colors.fg = 22;3;24;38;2;245;245;245
colors.err = 1;31
colors.s_wl = 38;2;255;174;66
colors.s_wayland = 38;2;255;174;66
colors.s_xorg = 38;2;37;175;255
colors.s_shell = 32
colors.f_other = 38;2;255;64;64
colors.e_hostname = 1;23;38;5;197
colors.e_date = 31
colors.e_box = 31
@@ -27,7 +26,10 @@ strings.f_reboot = reboot
strings.f_refresh = refresh
strings.e_user = user
strings.e_passwd = password
strings.s_xorg = xorg
strings.s_wayland = wayland
strings.s_xorg = xorg
strings.s_shell = shell
behavior.include_defshell = true
behavior.source = /etc/lidm.env
behavior.source = /etc/locale.conf
behavior.user_source = .lidm.env

View File

@@ -1,10 +1,9 @@
colors.bg = 48;2;38;28;28
colors.fg = 22;24;38;2;245;245;245
colors.err = 1;31
colors.s_wl = 38;2;255;174;66
colors.s_wayland = 38;2;255;174;66
colors.s_xorg = 38;2;37;175;255
colors.s_shell = 38;2;34;140;34
colors.f_other = 38;2;255;64;64
colors.e_hostname = 38;2;255;64;64
colors.e_date = 38;2;144;144;144
colors.e_box = 38;2;122;122;122
@@ -22,12 +21,15 @@ chars.cbr = ┘
functions.poweroff = F1
functions.reboot = F2
functions.refresh = F5
strings.f_poweroff = powewoff
strings.f_reboot = rewoot
strings.f_refresh = rewresh
strings.e_user = wuser
strings.e_passwd = passwd
strings.s_xorg = xworg
strings.s_wayland = waywand
strings.s_shell = swell
strings.f_poweroff = poweroff
strings.f_reboot = reboot
strings.f_refresh = refresh
strings.e_user = user
strings.e_passwd = password
strings.s_wayland = wayland
strings.s_xorg = xorg
strings.s_shell = shell
behavior.include_defshell = true
behavior.source = /etc/lidm.env
behavior.source = /etc/locale.conf
behavior.user_source = .lidm.env

View File

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

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

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

View File

@@ -1,10 +1,9 @@
colors.bg = 48;2;15;22;15
colors.fg = 22;23;24;38;2;245;245;245
colors.err = 1;31
colors.s_wl = 38;2;255;174;66
colors.s_wayland = 38;2;255;174;66
colors.s_xorg = 38;2;37;175;255
colors.s_shell = 32
colors.f_other = 38;2;255;64;64
colors.e_hostname = 38;5;28
colors.e_date = 32
colors.e_box = 32
@@ -27,7 +26,10 @@ strings.f_reboot = reboot
strings.f_refresh = refresh
strings.e_user = user
strings.e_passwd = password
strings.s_xorg = xorg
strings.s_wayland = wayland
strings.s_xorg = xorg
strings.s_shell = shell
behavior.include_defshell = true
behavior.source = /etc/lidm.env
behavior.source = /etc/locale.conf
behavior.user_source = .lidm.env

View File

@@ -1,10 +1,9 @@
colors.bg = 48;2;19;19;22
colors.fg = 22;24;38;2;245;245;245
colors.err = 1;31
colors.s_wl = 38;2;255;174;66
colors.s_wayland = 38;2;255;174;66
colors.s_xorg = 38;2;37;175;255
colors.s_shell = 32
colors.f_other = 38;2;255;64;64
colors.e_hostname = 34
colors.e_date = 38;2;66;66;88
colors.e_box = 38;2;122;122;122
@@ -27,7 +26,10 @@ strings.f_reboot = reboot
strings.f_refresh = refresh
strings.e_user = user
strings.e_passwd = password
strings.s_xorg = xorg
strings.s_wayland = wayland
strings.s_xorg = xorg
strings.s_shell = shell
behavior.include_defshell = true
behavior.source = /etc/lidm.env
behavior.source = /etc/locale.conf
behavior.user_source = .lidm.env

View File

@@ -1,10 +1,9 @@
colors.bg = -
colors.fg = 24;39m[?25l[-
colors.err = -
colors.s_wl = -
colors.s_wayland = -
colors.s_xorg = -
colors.s_shell = -
colors.f_other = -
colors.e_hostname = -
colors.e_date = 30
colors.e_box = -
@@ -27,7 +26,10 @@ strings.f_reboot = reboot
strings.f_refresh = refresh
strings.e_user = user
strings.e_passwd = password
strings.s_xorg = xorg
strings.s_wayland = wayland
strings.s_xorg = xorg
strings.s_shell = shell
behavior.include_defshell = true
behavior.source = /etc/lidm.env
behavior.source = /etc/locale.conf
behavior.user_source = .lidm.env

View File

@@ -1,33 +0,0 @@
colors.bg = 48;2;0;0;255
colors.fg = 22;24;39;48;2;0;0;255
colors.err = 1;31
colors.s_wl = 38;2;255;174;66
colors.s_xorg = 38;2;37;175;255
colors.s_shell = 38;2;34;140;34
colors.f_other = 38;2;255;64;64
colors.e_hostname = 38;2;255;64;64
colors.e_date = 38;2;144;144;144
colors.e_box = 34
colors.e_header = 4;38;2;0;255;0
colors.e_user = 36
colors.e_passwd = 4;38;2;245;245;205
colors.e_badpasswd = 3;4;31
colors.e_key = 1;31;48;2;255;174;66
chars.hb =
chars.vb = ███
chars.ctl = ███
chars.ctr = ███
chars.cbl = ███
chars.cbr = ███
functions.poweroff = F1
functions.reboot = F2
functions.refresh = F5
strings.f_poweroff = powewoff
strings.f_reboot = rewoot
strings.f_refresh = rewresh
strings.e_user = wuser
strings.e_passwd = passwd
strings.s_xorg = xworg
strings.s_wayland = waywand
strings.s_shell = swell
behavior.include_defshell = true

View File

@@ -1,10 +1,9 @@
colors.bg = 48;2;0;0;255
colors.fg = 22;24;39;48;2;0;0;255
colors.err = 1;31
colors.s_wl = 38;2;255;174;66
colors.s_wayland = 38;2;255;174;66
colors.s_xorg = 38;2;37;175;255
colors.s_shell = 38;2;34;140;34
colors.f_other = 38;2;255;64;64
colors.e_hostname = 38;2;255;64;64
colors.e_date = 38;2;144;144;144
colors.e_box = 34
@@ -27,7 +26,10 @@ strings.f_reboot = rewoot
strings.f_refresh = rewresh
strings.e_user = wuser
strings.e_passwd = passwd
strings.s_xorg = xworg
strings.s_wayland = waywand
strings.s_xorg = xworg
strings.s_shell = swell
behavior.include_defshell = true
behavior.source = /etc/lidm.env
behavior.source = /etc/locale.conf
behavior.user_source = .lidm.env

View File

@@ -1,33 +0,0 @@
colors.bg = -
colors.fg = 24;39m[?25l[-
colors.err = -
colors.s_wl = -
colors.s_xorg = -
colors.s_shell = -
colors.f_other = -
colors.e_hostname = 30
colors.e_date = 30
colors.e_box = -
colors.e_header = 30
colors.e_user = -
colors.e_passwd = 24;30
colors.e_badpasswd = -
colors.e_key = 30
chars.hb = -
chars.vb = -
chars.ctl = -
chars.ctr = -
chars.cbl = -
chars.cbr = -
functions.poweroff = F1
functions.reboot = F2
functions.refresh = F5
strings.f_poweroff = -
strings.f_reboot = -
strings.f_refresh = -
strings.e_user = -
strings.e_passwd = -
strings.s_xorg = -
strings.s_wayland = -
strings.s_shell = -
behavior.include_defshell = false

Binary file not shown.

Before

Width:  |  Height:  |  Size: 261 KiB

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 267 KiB

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 262 KiB

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 262 KiB

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 273 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 267 KiB

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 333 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 344 KiB

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 347 KiB

View File

@@ -1,10 +1,9 @@
colors.bg = -
colors.fg = 24
colors.err = -
colors.s_wl = -
colors.s_wayland = -
colors.s_xorg = -
colors.s_shell = -
colors.f_other = -
colors.e_hostname = -
colors.e_date = -
colors.e_box = -
@@ -27,7 +26,10 @@ strings.f_reboot = reboot
strings.f_refresh = refresh
strings.e_user = user
strings.e_passwd = password
strings.s_xorg = xorg
strings.s_wayland = wayland
strings.s_xorg = xorg
strings.s_shell = shell
behavior.include_defshell = true
behavior.source = /etc/lidm.env
behavior.source = /etc/locale.conf
behavior.user_source = .lidm.env