diff --git a/.SRCINFO b/.SRCINFO deleted file mode 100644 index 1905f22..0000000 --- a/.SRCINFO +++ /dev/null @@ -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 diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..f4edc74 --- /dev/null +++ b/.clang-format @@ -0,0 +1,2 @@ +BasedOnStyle: LLVM +IndentWidth: 2 diff --git a/.codespellrc b/.codespellrc new file mode 100644 index 0000000..a8f0594 --- /dev/null +++ b/.codespellrc @@ -0,0 +1,2 @@ +[codespell] +skip = ./assets/pkg/aur/*/src diff --git a/.github/actions/build/action.yml b/.github/actions/build/action.yml deleted file mode 100644 index 08bf283..0000000 --- a/.github/actions/build/action.yml +++ /dev/null @@ -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 diff --git a/.github/workflows/build-check.yml b/.github/workflows/build-check.yml deleted file mode 100644 index 1ba7860..0000000 --- a/.github/workflows/build-check.yml +++ /dev/null @@ -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 }} diff --git a/.github/workflows/check-and-build.yml b/.github/workflows/check-and-build.yml new file mode 100644 index 0000000..f79e81b --- /dev/null +++ b/.github/workflows/check-and-build.yml @@ -0,0 +1,259 @@ +name: Check and Build + +on: + workflow_call: + inputs: + set-statuses: + required: false + default: true + type: boolean + +jobs: + spellcheck: + name: Check Grammar + runs-on: ubuntu-24.04 + + steps: + - uses: actions/checkout@v4 + - uses: awalsh128/cache-apt-pkgs-action@latest + with: + packages: "codespell" + version: 1.0 + - run: codespell + + shellcheck: + name: Shell Check + runs-on: ubuntu-24.04 + + steps: + - uses: actions/checkout@v4 + - uses: awalsh128/cache-apt-pkgs-action@latest + with: + packages: "shellcheck" + version: 1.0 + - run: find . -type f -name '*.sh' -not -path './assets/pkg/aur/*/src/*' | xargs shellcheck + + clangcheck: + name: Chang Check + runs-on: ubuntu-24.04 + + steps: + - uses: actions/checkout@v4 + - uses: awalsh128/cache-apt-pkgs-action@latest + with: + packages: "clang-format clang-tidy" + version: 1.0 + - run: clang-format -ni src/*.c include/*.h + # TODO: include when the errors/warnings are bearable + #- run: clang-tidy src/*.c include/*.h + + build-linux-amd64: + name: Build for amd64 + runs-on: ubuntu-24.04 + permissions: write-all + needs: [spellcheck, shellcheck, clangcheck] + + steps: + - uses: actions/checkout@v4 + - uses: awalsh128/cache-apt-pkgs-action@latest + with: + packages: "libpam0g-dev" + version: 1.0 + - id: build + run: | + make -j$(nproc) 2> /tmp/stderr + cat /tmp/stderr >&2 + + HSIZE="$(stat --printf="%s" lidm | numfmt --to=iec-i)B" + WARNS="$(cat /tmp/stderr | grep '^[^ ]*\.[ch]:' | wc -l)" + mv lidm lidm-amd64 + + echo "DESCR='$HSIZE, $WARNS warnings'" >> "$GITHUB_OUTPUT" + + - uses: myrotvorets/set-commit-status-action@master + if: inputs.set-statuses + with: + token: ${{ secrets.GITHUB_TOKEN }} + status: ${{ job.status }} + description: ${{ steps.build.outputs.DESCR }} + context: Build for amd64 + + - uses: actions/upload-artifact@v4 + with: + name: build-amd64 + path: lidm-amd64 + retention-days: 1 + + build-linux-i386: + name: Build for i386 + runs-on: ubuntu-24.04 + permissions: write-all + needs: [spellcheck, shellcheck, clangcheck] + + steps: + - uses: actions/checkout@v4 + - uses: awalsh128/cache-apt-pkgs-action@latest + with: + packages: "libpam0g-dev gcc-multilib" + version: 1.0 + - run: | + sudo dpkg --add-architecture i386 + sudo apt-get update -y + sudo apt-get install -y libpam0g-dev:i386 + + - id: build + run: | + make -j$(nproc) CFLAGS="-O3 -Wall -m32" 2> /tmp/stderr + cat /tmp/stderr >&2 + + HSIZE="$(stat --printf="%s" lidm | numfmt --to=iec-i)B" + WARNS="$(cat /tmp/stderr | grep '^[^ ]*\.[ch]:' | wc -l)" + mv lidm lidm-i386 + + echo "DESCR='$HSIZE, $WARNS warnings'" >> "$GITHUB_OUTPUT" + + - uses: myrotvorets/set-commit-status-action@master + if: inputs.set-statuses + with: + token: ${{ secrets.GITHUB_TOKEN }} + status: ${{ job.status }} + description: ${{ steps.build.outputs.DESCR }} + context: Build for i386 + + - uses: actions/upload-artifact@v4 + with: + name: build-i386 + path: lidm-i386 + retention-days: 1 + + build-linux-aarch64: + name: Build for aarch64 + runs-on: ubuntu-24.04 + permissions: write-all + needs: [spellcheck, shellcheck, clangcheck] + steps: + - uses: actions/checkout@v4 + + - uses: uraimo/run-on-arch-action@v2 + with: + arch: aarch64 + distro: ubuntu22.04 + githubToken: ${{ github.token }} + install: | + apt-get update && \ + apt-get install -y make gcc libpam0g-dev + run: | + make -j$(nproc) 2> /tmp/stderr + + cat /tmp/stderr >&2 + mv lidm lidm-aarch64 + + - if: inputs.set-statuses + id: status + run: | + HSIZE="$(stat --printf="%s" lidm-aarch64 | numfmt --to=iec-i)B" + WARNS="$(cat /tmp/stderr | grep '^[^ ]*\.[ch]:' | wc -l)" + + echo "DESCR='$HSIZE, $WARNS warnings'" >> "$GITHUB_OUTPUT" + + - uses: myrotvorets/set-commit-status-action@master + if: inputs.set-statuses + with: + token: ${{ secrets.GITHUB_TOKEN }} + status: ${{ job.status }} + description: ${{ steps.status.outputs.DESCR }} + context: Build for aarch64 + + - uses: actions/upload-artifact@v4 + with: + name: build-aarch64 + path: lidm-aarch64 + retention-days: 1 + + build-linux-armv7: + name: Build for armv7 + runs-on: ubuntu-24.04 + permissions: write-all + needs: [spellcheck, shellcheck, clangcheck] + steps: + - uses: actions/checkout@v4 + + - uses: uraimo/run-on-arch-action@v2 + with: + arch: armv7 + distro: ubuntu22.04 + githubToken: ${{ github.token }} + install: | + apt-get update && \ + apt-get install -y make gcc libpam0g-dev + run: | + make -j$(nproc) 2> /tmp/stderr + + cat /tmp/stderr >&2 + mv lidm lidm-armv7 + + - if: inputs.set-statuses + id: status + run: | + HSIZE="$(stat --printf="%s" lidm-armv7 | numfmt --to=iec-i)B" + WARNS="$(cat /tmp/stderr | grep '^[^ ]*\.[ch]:' | wc -l)" + + echo "DESCR='$HSIZE, $WARNS warnings'" >> "$GITHUB_OUTPUT" + + - uses: myrotvorets/set-commit-status-action@master + if: inputs.set-statuses + with: + token: ${{ secrets.GITHUB_TOKEN }} + status: ${{ job.status }} + description: ${{ steps.status.outputs.DESCR }} + context: Build for armv7 + + - uses: actions/upload-artifact@v4 + with: + name: build-armv7 + path: lidm-armv7 + retention-days: 1 + + build-linux-riscv64: + name: Build for riscv64 + runs-on: ubuntu-24.04 + permissions: write-all + needs: [spellcheck, shellcheck, clangcheck] + steps: + - uses: actions/checkout@v4 + + - uses: uraimo/run-on-arch-action@v2 + with: + arch: riscv64 + distro: ubuntu22.04 + githubToken: ${{ github.token }} + install: | + apt-get update && \ + apt-get install -y make gcc libpam0g-dev + run: | + make -j$(nproc) 2> /tmp/stderr + + cat /tmp/stderr >&2 + mv lidm lidm-riscv64 + + - if: inputs.set-statuses + id: status + run: | + HSIZE="$(stat --printf="%s" lidm-riscv64 | numfmt --to=iec-i)B" + WARNS="$(cat /tmp/stderr | grep '^[^ ]*\.[ch]:' | wc -l)" + + echo "DESCR='$HSIZE, $WARNS warnings'" >> "$GITHUB_OUTPUT" + + - uses: myrotvorets/set-commit-status-action@master + if: inputs.set-statuses + with: + token: ${{ secrets.GITHUB_TOKEN }} + status: ${{ job.status }} + description: ${{ steps.status.outputs.DESCR }} + context: Build for riscv64 + + - uses: actions/upload-artifact@v4 + with: + name: build-riscv64 + path: lidm-riscv64 + retention-days: 1 diff --git a/.github/workflows/make-release.yml b/.github/workflows/make-release.yml new file mode 100644 index 0000000..2a229ae --- /dev/null +++ b/.github/workflows/make-release.yml @@ -0,0 +1,39 @@ +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-* + artifactsErrorsFailBuild: true + body: Release notes not generated yet. + + # TODO: get checksums and commit new AUR pkgbuilds diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml new file mode 100644 index 0000000..db871fd --- /dev/null +++ b/.github/workflows/push.yml @@ -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 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index b3330cf..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -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 }} diff --git a/INSTALL.md b/INSTALL.md new file mode 100644 index 0000000..a9c2f02 --- /dev/null +++ b/INSTALL.md @@ -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). [more docs](./assets/services/README.md) + +```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 diff --git a/Makefile b/Makefile index c2800a9..a547c3f 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ ODIR=dist PREFIX=/usr CC?=gcc -CFLAGS?=-O3 +CFLAGS?=-O3 -Wall _CFLAGS=-I$(DIR) ALLFLAGS=$(CFLAGS) -I$(IDIR) @@ -31,25 +31,45 @@ clean: # 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'" diff --git a/PKGBUILD b/PKGBUILD deleted file mode 100644 index 0ee08c9..0000000 --- a/PKGBUILD +++ /dev/null @@ -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') diff --git a/README.md b/README.md index 57042c5..07e2a93 100644 --- a/README.md +++ b/README.md @@ -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).* +> *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,24 @@ 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. diff --git a/assets/man/lidm-config.5 b/assets/man/lidm-config.5 new file mode 100644 index 0000000..9fbb66a --- /dev/null +++ b/assets/man/lidm-config.5 @@ -0,0 +1,79 @@ +.\" 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 + + +.SH "SEE ALSO" +.BR lidm (1) diff --git a/assets/man/lidm.1 b/assets/man/lidm.1 new file mode 100644 index 0000000..b4c161a --- /dev/null +++ b/assets/man/lidm.1 @@ -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 diff --git a/assets/media/lidm.gif b/assets/media/lidm.gif index ee3e600..0d4e892 100644 Binary files a/assets/media/lidm.gif and b/assets/media/lidm.gif differ diff --git a/assets/media/lidm.png b/assets/media/lidm.png deleted file mode 100644 index 23a4bac..0000000 Binary files a/assets/media/lidm.png and /dev/null differ diff --git a/assets/pkg/aur/README.md b/assets/pkg/aur/README.md index 7df5f1a..e5df888 100644 --- a/assets/pkg/aur/README.md +++ b/assets/pkg/aur/README.md @@ -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). diff --git a/assets/pkg/aur/copy-gitignore.sh b/assets/pkg/aur/copy-gitignore.sh deleted file mode 100755 index 2c1f3e4..0000000 --- a/assets/pkg/aur/copy-gitignore.sh +++ /dev/null @@ -1,9 +0,0 @@ -#/usr/bin/env bash -set -e - -MYSELF=$(realpath "$0") -MYDIR=$(dirname "$MYSELF") - -for pkg in "$MYDIR"/*/; do - cp "$MYDIR/pkg.gitignore" "$pkg/.gitignore" -done diff --git a/assets/pkg/aur/lidm-bin/.SRCINFO b/assets/pkg/aur/lidm-bin/.SRCINFO index b8139f4..c859271 100644 --- a/assets/pkg/aur/lidm-bin/.SRCINFO +++ b/assets/pkg/aur/lidm-bin/.SRCINFO @@ -1,16 +1,21 @@ pkgbase = lidm-bin - pkgdesc = A fully colorful cutomizable TUI display manager made in C. (release binary) + pkgdesc = A fully colorful customizable TUI display manager made in C. (release binary) pkgver = 0.0.2 pkgrel = 1 url = https://github.com/javalsai/lidm arch = x86_64 license = GPL + makedepends = gzip depends = pam provides = lidm conflicts = lidm source = lidm::https://github.com/javalsai/lidm/releases/download/0.0.2/lidm-x86_64 source = default-theme.ini::https://raw.githubusercontent.com/javalsai/lidm/0.0.2/themes/default.ini + source = lidm.1::https://raw.githubusercontent.com/javalsai/lidm/0.0.2/assets/man/lidm.1 + source = lidm-config.5::https://raw.githubusercontent.com/javalsai/lidm/0.0.2/assets/man/lidm-config.5 sha256sums = b5d1dbdaa6b78da57be69ce5e2cc3366717a045de3cb316e66c1c3f36b796ee0 sha256sums = 27db9b0cd2da80c0c60dcb13dfad0f9d65e7dddbb7b344b859803b9ac3943cd7 + sha256sums = SKIP + sha256sums = SKIP pkgname = lidm-bin diff --git a/assets/pkg/aur/pkg.gitignore b/assets/pkg/aur/lidm-bin/.gitignore similarity index 100% rename from assets/pkg/aur/pkg.gitignore rename to assets/pkg/aur/lidm-bin/.gitignore diff --git a/assets/pkg/aur/lidm-bin/PKGBUILD b/assets/pkg/aur/lidm-bin/PKGBUILD index 24eac60..32ca650 100644 --- a/assets/pkg/aur/lidm-bin/PKGBUILD +++ b/assets/pkg/aur/lidm-bin/PKGBUILD @@ -3,7 +3,8 @@ pkgname=lidm-bin pkgver=0.0.2 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') @@ -12,13 +13,20 @@ conflicts=('lidm') source=( "lidm::$url/releases/download/$pkgver/lidm-$arch" "default-theme.ini::https://raw.githubusercontent.com/javalsai/lidm/$pkgver/themes/default.ini" + "lidm.1::https://raw.githubusercontent.com/javalsai/lidm/$pkgver/assets/man/lidm.1" + "lidm-config.5::https://raw.githubusercontent.com/javalsai/lidm/$pkgver/assets/man/lidm-config.5" ) sha256sums=( 'b5d1dbdaa6b78da57be69ce5e2cc3366717a045de3cb316e66c1c3f36b796ee0' '27db9b0cd2da80c0c60dcb13dfad0f9d65e7dddbb7b344b859803b9ac3943cd7' + 'SKIP' + 'SKIP' ) package() { install -Dm755 lidm "${pkgdir}/usr/bin/lidm" install -Dm644 default-theme.ini "${pkgdir}/etc/lidm.ini" + install -Dm644 lidm.1 "${pkgdir}/usr/share/man/man1/" + install -Dm644 lidm-config.5 "${pkgdir}/usr/share/man/man5/" + gzip -f "${pkgdir}"/share/man/man{1/lidm.1,5/lidm-config.5} } diff --git a/assets/pkg/aur/lidm-git/.SRCINFO b/assets/pkg/aur/lidm-git/.SRCINFO index 2e354dd..0b59546 100644 --- a/assets/pkg/aur/lidm-git/.SRCINFO +++ b/assets/pkg/aur/lidm-git/.SRCINFO @@ -1,6 +1,6 @@ pkgbase = lidm-git - pkgdesc = A fully colorful cutomizable TUI display manager made in C. (last git commit) - pkgver = 0.0.2.r0.ge3052ec + pkgdesc = A fully colorful customizable TUI display manager made in C. (last git commit) + pkgver = 0.0.2.r37.gf1f9d6b pkgrel = 1 url = https://github.com/javalsai/lidm arch = any diff --git a/assets/pkg/aur/lidm-git/.gitignore b/assets/pkg/aur/lidm-git/.gitignore new file mode 100644 index 0000000..1d65adf --- /dev/null +++ b/assets/pkg/aur/lidm-git/.gitignore @@ -0,0 +1,3 @@ +* +!PKGBUILD +!.SRCINFO diff --git a/assets/pkg/aur/lidm-git/PKGBUILD b/assets/pkg/aur/lidm-git/PKGBUILD index a223888..8d907a8 100644 --- a/assets/pkg/aur/lidm-git/PKGBUILD +++ b/assets/pkg/aur/lidm-git/PKGBUILD @@ -1,10 +1,10 @@ # Maintainer: javalsai pkgname=lidm-git -pkgver=0.0.1.r50.ge3052ec +pkgver=0.0.2.r37.gf1f9d6b 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 +26,5 @@ build() { package() { cd "lidm" - install -Dm755 lidm "${pkgdir}/usr/bin/lidm" - install -Dm644 themes/default.ini "${pkgdir}/etc/lidm.ini" + make install DESTDIR="${pkgdir}" } diff --git a/assets/pkg/aur/lidm/.SRCINFO b/assets/pkg/aur/lidm/.SRCINFO index 96101a8..4e71919 100644 --- a/assets/pkg/aur/lidm/.SRCINFO +++ b/assets/pkg/aur/lidm/.SRCINFO @@ -1,5 +1,5 @@ pkgbase = lidm - pkgdesc = A fully colorful cutomizable TUI display manager made in C. (build latest tag) + pkgdesc = A fully colorful customizable TUI display manager made in C. (build latest tag) pkgver = 0.0.2 pkgrel = 1 url = https://github.com/javalsai/lidm @@ -8,6 +8,7 @@ pkgbase = lidm makedepends = git makedepends = make makedepends = gcc + makedepends = gzip depends = pam source = tarball.tar.gz::https://github.com/javalsai/lidm/archive/refs/tags/0.0.2.tar.gz sha256sums = adf2d196969f6a2df8ceeb3564e1d51cc377f0deaeca31fee0bace58a3d2df2d diff --git a/assets/pkg/aur/lidm/.gitignore b/assets/pkg/aur/lidm/.gitignore new file mode 100644 index 0000000..1d65adf --- /dev/null +++ b/assets/pkg/aur/lidm/.gitignore @@ -0,0 +1,3 @@ +* +!PKGBUILD +!.SRCINFO diff --git a/assets/pkg/aur/lidm/PKGBUILD b/assets/pkg/aur/lidm/PKGBUILD index 913e8e3..192a283 100644 --- a/assets/pkg/aur/lidm/PKGBUILD +++ b/assets/pkg/aur/lidm/PKGBUILD @@ -3,8 +3,8 @@ pkgname=lidm pkgver=0.0.2 pkgrel=1 depends=('pam') -makedepends=('git' 'make' 'gcc') -pkgdesc="A fully colorful cutomizable TUI display manager made in C. (build latest tag)" +makedepends=('git' 'make' 'gcc' 'gzip') +pkgdesc="A fully colorful customizable TUI display manager made in C. (build latest tag)" arch=('any') url="https://github.com/javalsai/lidm" license=('GPL') @@ -20,7 +20,5 @@ build() { package() { cd "lidm-$pkgver" - - install -Dm755 lidm "${pkgdir}/usr/bin/lidm" - install -Dm644 themes/default.ini "${pkgdir}/etc/lidm.ini" + make install DESTDIR="${pkgdir}" } diff --git a/assets/pkg/aur/make-srcinfo.sh b/assets/pkg/aur/make-srcinfo.sh index bc700c4..6739191 100755 --- a/assets/pkg/aur/make-srcinfo.sh +++ b/assets/pkg/aur/make-srcinfo.sh @@ -1,4 +1,4 @@ -#/usr/bin/env bash +#!/usr/bin/env bash set -e MYSELF=$(realpath "$0") diff --git a/assets/pkg/aur/test-makepkg.sh b/assets/pkg/aur/test-makepkg.sh index 996a68f..302985c 100755 --- a/assets/pkg/aur/test-makepkg.sh +++ b/assets/pkg/aur/test-makepkg.sh @@ -1,4 +1,4 @@ -#/usr/bin/env bash +#!/usr/bin/env bash set -e MYSELF=$(realpath "$0") @@ -8,7 +8,7 @@ for pkg in "$MYDIR"/*/; do cd "$pkg" printf "\x1b[1mEntering '%s'\x1b[0m\n" "$pkg" - rm -rf *.{gz,zst} src pkg + rm -rf ./*.{gz,zst} src pkg makepkg -f . echo diff --git a/assets/services/README.md b/assets/services/README.md new file mode 100644 index 0000000..e99db11 --- /dev/null +++ b/assets/services/README.md @@ -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. diff --git a/assets/services/openrc b/assets/services/openrc new file mode 100755 index 0000000..969aab3 --- /dev/null +++ b/assets/services/openrc @@ -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}" +} diff --git a/assets/services/runit/conf b/assets/services/runit/conf new file mode 100755 index 0000000..f746645 --- /dev/null +++ b/assets/services/runit/conf @@ -0,0 +1,5 @@ +BAUD_RATE=38400 +TERM_NAME=linux + +TTY=tty7 +EXEC_PATH=/bin/lidm diff --git a/assets/services/runit/finish b/assets/services/runit/finish new file mode 100755 index 0000000..1fc9229 --- /dev/null +++ b/assets/services/runit/finish @@ -0,0 +1,5 @@ +#!/bin/sh + +[ -r conf ] && . ./conf + +exec utmpset -w $TTY diff --git a/assets/services/runit/run b/assets/services/runit/run new file mode 100755 index 0000000..1601cef --- /dev/null +++ b/assets/services/runit/run @@ -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 diff --git a/assets/services/s6/dependencies.d/hostname b/assets/services/s6/dependencies.d/hostname new file mode 100644 index 0000000..e69de29 diff --git a/assets/services/s6/dependencies.d/mount-devfs b/assets/services/s6/dependencies.d/mount-devfs new file mode 100644 index 0000000..e69de29 diff --git a/assets/services/s6/run b/assets/services/s6/run new file mode 100755 index 0000000..8d8a29e --- /dev/null +++ b/assets/services/s6/run @@ -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 diff --git a/assets/services/s6/type b/assets/services/s6/type new file mode 100644 index 0000000..5883cff --- /dev/null +++ b/assets/services/s6/type @@ -0,0 +1 @@ +longrun diff --git a/assets/services/systemd.service b/assets/services/systemd.service index ffe405c..39ef026 100644 --- a/assets/services/systemd.service +++ b/assets/services/systemd.service @@ -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 diff --git a/include/chvt.h b/include/chvt.h index a39af33..0637b22 100644 --- a/include/chvt.h +++ b/include/chvt.h @@ -20,6 +20,6 @@ int chvt(int n); * @param str virtual terminal number (string) * @return int non-negative value on success */ -int chvt_str(char* str); +int chvt_str(char *str); #endif diff --git a/include/config.h b/include/config.h index d6e086f..833fb46 100644 --- a/include/config.h +++ b/include/config.h @@ -14,10 +14,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,8 +56,8 @@ struct strings { char *f_refresh; char *e_user; char *e_passwd; - char *s_xorg; char *s_wayland; + char *s_xorg; char *s_shell; }; @@ -74,10 +73,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 diff --git a/include/efield.h b/include/efield.h index ed03c32..68b1db0 100644 --- a/include/efield.h +++ b/include/efield.h @@ -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 diff --git a/include/keys.h b/include/keys.h index 5933f32..cd34031 100644 --- a/include/keys.h +++ b/include/keys.h @@ -4,37 +4,37 @@ #include 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 diff --git a/include/ui.h b/include/ui.h index 56ddaaf..fdb08b1 100644 --- a/include/ui.h +++ b/include/ui.h @@ -4,8 +4,8 @@ #include 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 users_list *, struct sessions_list *); +void print_err(const char *); +void print_errno(const char *); #endif diff --git a/include/util.h b/include/util.h index 4759221..fcfca0c 100644 --- a/include/util.h +++ b/include/util.h @@ -5,9 +5,9 @@ #include #include -enum keys find_keyname(char*); -enum keys find_ansi(char*); -void read_press(u_char*, char*); +enum keys find_keyname(char *); +enum keys find_ansi(char *); +void read_press(u_char *, char *); void strcln(char **dest, const char *source); #endif diff --git a/src/auth.c b/src/auth.c index d5e1ff3..4038c72 100644 --- a/src/auth.c +++ b/src/auth.c @@ -1,7 +1,5 @@ #include #include -#include -#include #include #include #include @@ -37,6 +35,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}; @@ -59,7 +60,9 @@ void *shmalloc(size_t size) { } void moarEnv(char *user, struct session session, struct passwd *pw) { - chdir(pw->pw_dir); + 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,9 +76,9 @@ 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); /*char *buf;*/ @@ -166,10 +169,10 @@ 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 if (session.type == SHELL) { - system("clear"); + clear_screen(); execlp(session.exec, session.exec, NULL); } else if (session.type == XORG || session.type == WAYLAND) { - system("clear"); + clear_screen(); execlp(session.exec, session.exec, NULL); } perror("execl error"); diff --git a/src/config.c b/src/config.c index deb990f..c0788df 100644 --- a/src/config.c +++ b/src/config.c @@ -45,72 +45,70 @@ 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 return 0b1111; @@ -128,7 +126,7 @@ struct config *parse_config(char *path) { __config = malloc(sizeof(struct config)); 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; diff --git a/src/efield.c b/src/efield.c index 12f7bcf..daa798c 100644 --- a/src/efield.c +++ b/src/efield.c @@ -3,9 +3,9 @@ #include #include -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; } diff --git a/src/main.c b/src/main.c index de97cc7..c09ceba 100644 --- a/src/main.c +++ b/src/main.c @@ -14,7 +14,9 @@ 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; diff --git a/src/sessions.c b/src/sessions.c index 8b8f14b..4086ff1 100644 --- a/src/sessions.c +++ b/src/sessions.c @@ -40,7 +40,8 @@ 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 diff --git a/src/ui.c b/src/ui.c index 7d66a71..ac1e50f 100644 --- a/src/ui.c +++ b/src/ui.c @@ -2,12 +2,14 @@ // really sorry #include +#include #include #include #include #include #include #include +#include #include #include #include @@ -104,7 +106,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 { @@ -226,8 +228,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; @@ -374,11 +376,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); @@ -408,12 +410,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 +427,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 +457,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 +471,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 +485,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; - - 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); - } - snprintf(&row[nbytes1 + fillersize], nbytes2, "%s\x1b[%dD\x1b[1B", edge2, - w + 2); +static void print_empty_row(uint w, uint n, char *edge1, char *edge2) { + for (uint i = 0; i < n; i++) { + printf("%s\x1b[%dC%s\x1b[%dD\x1b[1B", edge1, w, edge2, w + 2); } +} +static void print_row(uint w, uint n, char *edge1, char *edge2, char *filler) { for (uint i = 0; i < n; i++) { - write(STDOUT_FILENO, row, row_size); + printf("%s", edge1); + for (uint i = 0; i < w; i++) { + printf("%s", filler); + } + printf("%s\x1b[%dD\x1b[1B", edge2, w + 2); } - free(row); } static void print_box() { @@ -532,9 +519,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); } diff --git a/src/util.c b/src/util.c index a7e95b8..a15ce80 100644 --- a/src/util.c +++ b/src/util.c @@ -15,9 +15,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; } diff --git a/themes/README.md b/themes/README.md index 5919f3f..ad54063 100644 --- a/themes/README.md +++ b/themes/README.md @@ -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) +![tasteless.ini theme](./screenshots/tasteless.png) diff --git a/themes/cherry.ini b/themes/cherry.ini index 74c4ae1..b2b1bc0 100644 --- a/themes/cherry.ini +++ b/themes/cherry.ini @@ -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,7 @@ 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 diff --git a/themes/default.ini b/themes/default.ini index 453f9a1..f9b59d2 100644 --- a/themes/default.ini +++ b/themes/default.ini @@ -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,12 @@ 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 diff --git a/themes/kanagawa-dragon.ini b/themes/kanagawa-dragon.ini new file mode 100644 index 0000000..30ca105 --- /dev/null +++ b/themes/kanagawa-dragon.ini @@ -0,0 +1,32 @@ +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 diff --git a/themes/kanagawa-wave.ini b/themes/kanagawa-wave.ini new file mode 100644 index 0000000..5b01c11 --- /dev/null +++ b/themes/kanagawa-wave.ini @@ -0,0 +1,32 @@ +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 diff --git a/themes/nature.ini b/themes/nature.ini index 25354d7..199dd6c 100644 --- a/themes/nature.ini +++ b/themes/nature.ini @@ -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,7 @@ 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 diff --git a/themes/nord.ini b/themes/nord.ini index f4cdea5..16c7073 100644 --- a/themes/nord.ini +++ b/themes/nord.ini @@ -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,7 @@ 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 diff --git a/themes/tastelessness.ini b/themes/nothing.ini similarity index 94% rename from themes/tastelessness.ini rename to themes/nothing.ini index d46ea4a..eac12ee 100644 --- a/themes/tastelessness.ini +++ b/themes/nothing.ini @@ -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,7 @@ 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 diff --git a/themes/old-blue-thick.ini b/themes/old-blue-thick.ini deleted file mode 100644 index 2b985b5..0000000 --- a/themes/old-blue-thick.ini +++ /dev/null @@ -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 diff --git a/themes/old-blue.ini b/themes/old-blue.ini index e127645..96fabe3 100644 --- a/themes/old-blue.ini +++ b/themes/old-blue.ini @@ -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,7 @@ 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 diff --git a/themes/pure-tastelessness.ini b/themes/pure-tastelessness.ini deleted file mode 100644 index 285cef3..0000000 --- a/themes/pure-tastelessness.ini +++ /dev/null @@ -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 diff --git a/themes/screenshots/cherry.png b/themes/screenshots/cherry.png index a034e32..ca47c17 100644 Binary files a/themes/screenshots/cherry.png and b/themes/screenshots/cherry.png differ diff --git a/themes/screenshots/default.png b/themes/screenshots/default.png index b52b33f..b732fe7 100644 Binary files a/themes/screenshots/default.png and b/themes/screenshots/default.png differ diff --git a/themes/screenshots/kanagawa-dragon.png b/themes/screenshots/kanagawa-dragon.png new file mode 100644 index 0000000..e816900 Binary files /dev/null and b/themes/screenshots/kanagawa-dragon.png differ diff --git a/themes/screenshots/kanagawa-wave.png b/themes/screenshots/kanagawa-wave.png new file mode 100644 index 0000000..ac8dbf9 Binary files /dev/null and b/themes/screenshots/kanagawa-wave.png differ diff --git a/themes/screenshots/nature.png b/themes/screenshots/nature.png index ae98504..1c3210b 100644 Binary files a/themes/screenshots/nature.png and b/themes/screenshots/nature.png differ diff --git a/themes/screenshots/nord.png b/themes/screenshots/nord.png index 1631ce8..52274bd 100644 Binary files a/themes/screenshots/nord.png and b/themes/screenshots/nord.png differ diff --git a/themes/screenshots/nothing.png b/themes/screenshots/nothing.png new file mode 100644 index 0000000..25cbb63 Binary files /dev/null and b/themes/screenshots/nothing.png differ diff --git a/themes/screenshots/old-blue-thick.png b/themes/screenshots/old-blue-thick.png deleted file mode 100644 index 4019a85..0000000 Binary files a/themes/screenshots/old-blue-thick.png and /dev/null differ diff --git a/themes/screenshots/old-blue.png b/themes/screenshots/old-blue.png index d449a3f..4e307d4 100644 Binary files a/themes/screenshots/old-blue.png and b/themes/screenshots/old-blue.png differ diff --git a/themes/screenshots/pure-tastelessness.png b/themes/screenshots/pure-tastelessness.png deleted file mode 100644 index cfeacf0..0000000 Binary files a/themes/screenshots/pure-tastelessness.png and /dev/null differ diff --git a/themes/screenshots/tasteless.png b/themes/screenshots/tasteless.png index a5d03e0..3f0902c 100644 Binary files a/themes/screenshots/tasteless.png and b/themes/screenshots/tasteless.png differ diff --git a/themes/screenshots/tastelessness.png b/themes/screenshots/tastelessness.png deleted file mode 100644 index 078a6a0..0000000 Binary files a/themes/screenshots/tastelessness.png and /dev/null differ diff --git a/themes/tasteless.ini b/themes/tasteless.ini index 2ad4206..ea50656 100644 --- a/themes/tasteless.ini +++ b/themes/tasteless.ini @@ -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,7 @@ 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