Skip to content

Commit

Permalink
Next version (#76)
Browse files Browse the repository at this point in the history
* Caching Post-Login Environment (#75)

* Add a configuration option for focus behaviour (#74)

* Add a configuration option for focus behaviour

* Rust fmt

* Add caching for post login environment

* Fmt

* Clippy

* Fix the status message (#77)

* Fix status message
* Handle render unwraps
* Add comment
* FMT and Clippy

* Switch arg parsing to clap-derive (#78)

* Switch arg parsing to clap-derive
* RustFmt

Co-authored-by: Gijs Burghoorn <g.burghoorn@gmail.com>

* Make nightly the default toolchain

* Enable building with stable toolchain (#79)

* Adjust code so that it builds with stable Rust
* Move unsafety to only wrap the 'pre_exec'
* Fix PERMERR by reordering to set{groups, gid, uid}
* Remove +nightly from install script

Co-authored-by: Gijs Burghoorn <g.burghoorn@gmail.com>

* Add command to show possible environments

* Exclude non-executable environments

* Add subcommand to view cached information

* Add --tty CLI flag to override TTY configuration (#81)

* Add TTY Shell environment (#82)

Add TTY shell environment

* Always display TTYSHELL if no wms are found (#83)

* Add AUR installation instructions (#87)

* File overview in README (#88)

Add file overview in README

* [FIX]: Show TTY Shell on dir misconfiguration (#89)

* Wayland support (#84)

* Get started on wayland support

* Add AUR installation instructions (#87)

* File overview in README (#88)

Add file overview in README

* Working Wayland

* Improve the README to reflect changes

* Version Bump and Document Dependencies

* Change power control commands to systemd

* Change cover image

* Crop cover image

* [FEATURE]: Add UTMPX support

* RUSTFMT and add libc dependency

* UTMPX Support (#90)

* [FEATURE]: Add UTMPX support
* RUSTFMT and add libc dependency

* Clippy and include Cargo.lock

Co-authored-by: Marcin Puc <tranzystorek.io@protonmail.com>
  • Loading branch information
coastalwhite and tranzystorekk authored Nov 22, 2022
1 parent d65b1c3 commit bd2d827
Show file tree
Hide file tree
Showing 18 changed files with 1,121 additions and 366 deletions.
44 changes: 27 additions & 17 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 28 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "lemurs"
authors = ["Gijs Burghoorn <me@gburghoorn.com>"]
description = "A TUI Display/Login Manager"
version = "0.2.0"
version = "0.3.0"

edition = "2021"

Expand All @@ -16,21 +16,39 @@ readme = "README.md"
license = "MIT or APACHE"

[dependencies]
# CLI Argument Parsing
clap = { version = "3.2", features = ["derive"] }

# UI and TUI interface
tui = { version = "0.16.0", features = [ "crossterm" ] }
unicode-width = "0.1"
crossterm = { version = "0.22" }

# Parsing cached information
lazy_static = "1.4.0"
regex = "1.5"

# Interacting with the kernel interfaces
rand = "0.8.4"
nix = "0.23.1"

# UTMPX
libc = "0.2"

# Switching TTYs
chvt = "0.2.0"

# Authentication and Fetching User Data
pam = "0.7.0"
pgs-files = "0.0.7"
log = "0.4.0"
users = "0.11.0"
lazy_static = "1.4.0"
regex = "1.5"

# Logging
log = "0.4.0"
fern = "0.5.2"
chvt = "0.2.0"
rand = "0.8.4"
chrono = "0.4"
nix = "0.23.1"
clap = { version = "3.0.0", features = ["derive"] }
serde = { version = "1.0", features = ["derive"] }

# Configuration File Parsing
toml = "0.5"
hex = "0.4.3"
serde = { version = "1.0", features = ["derive"] }
hex = "0.4.3" # Colors
103 changes: 88 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,30 +22,58 @@ Lemurs uses Linux PAM as its method of authentication.

## Installation

There are two different ways to install Lemurs. Both require the rust toolchain
to be installed. I.e. there is currently no precompiled option.

### Arch Linux --- AUR

Lemurs can be installed from the [AUR](https://aur.archlinux.org). This will
build the package on your local machine. It will automatically pull in rustup,
but you might have to set the default toolchain with `rustup default stable`.

```bash
paru -S lemurs-git # paru can be replaced by any other AUR helper
```

or

```bash
git clone https://aur.archlinux.org/lemurs-git.git
cd lemurs-git
makepkg -si
```

### Compiling from source

The `install.sh` script can be used to compile and setup the display manager on
your Unix machine. This will perform multiple steps:

1. Build the project in release mode (requires Rust's _cargo_)
2. Setup the `/etc/lemurs` folder which contains some of the configuration and
necessary files such as your selection of window managers.
3. Disables the previous Display Manager
4. Copy over the _systemd_ service and enables it.
4. Copies over the _systemd_ service and enables it.

Although you might first want to set up some window managers (see
[Usage](#Usage)), upon rebooting you should now see Lemurs.

## Usage

After running the installation script you can add your window managers by
creating runnable scripts also known as
[xinitrc](https://wiki.archlinux.org/title/Xinit)s under the `/etc/lemurs/wms`
folders. The name of the script is used as the name within lemurs. For example,
for the [bspwm](https://github.com/baskerville/bspwm) window manager, you might
After installation you can add your environments by creating runnable scripts.

For your Xorg put your [xinitrc](https://wiki.archlinux.org/title/Xinit) scripts
in the `/etc/lemurs/wms` directory. For Wayland, put a script that starts your
compositor in the `/etc/lemurs/wayland` directory. For both cases, the name of
the runnable script file is the name that is shown in the environment switcher
within lemurs. Multiple Xorg and Wayland environments can exist at the same time.

### Example 1: BSPWM

For the [bspwm](https://github.com/baskerville/bspwm) window manager, you might
add the script `/etc/lemurs/wms/bspwm`.

```bash
#! /bin/sh

sxhkd &
exec bspwm
```
Expand All @@ -55,28 +83,73 @@ Remember to make this script runnable. This is done with the `chmod +x

Upon rebooting your new `bspwm` should show up within Lemurs.

### Example 2: Sway

For the [sway](https://swaywm.org/) compositor and window manager, you might
add the script `/etc/lemurs/wayland/sway`. Ensure that you have sway installed
and added yourself to the `seat` group.

```bash
#! /bin/sh
exec sway
```

Remember to make this script runnable. This is done with the `chmod +x
/etc/lemurs/wayland/sway` command.

Upon rebooting your new `sway` should show up within Lemurs.

## Configuration

Many parts for the UI can be configured with the `/etc/lemurs/config.toml`
file. This file contains all the options and explanations of their purpose.
The flag `--config <CONFIG FIlE>` can be used to select another configuration
file instead. An example configuration can be found in the `/extra` folder.

## License
file instead. An example configuration can be found in the `extra` folder in
this repository.

The project is made available under the MIT and APACHE license. See the
`LICENSE-MIT` and `LICENSE-APACHE` files, respectively, for more information.

## Debugging / Logging
## Preview & Debugging

Lemurs logs a lot of information of it running to a logging file. This is
located by default at `/var/log/lemurs.log`, but can be turned of by running
with the `--nolog` flag.
with the `--no-log` flag.

If you want to test your configuration file you can also run `lemurs
--preview`. This will run a preview instance of your configuration. This will
automatically create a `lemurs.log` in the working directory.

## File Structure

Below is overview of the source files in this project and a short description of
each of them and their use. This can be used by people who want to contribute or
want to tweak details for their own installation.

```
|- src: Rust Source Code
| |- main.rs: CLI argument parsing & main logic
| |- auth: Interaction with PAM modules
| |- config.rs: Configuration file format and options
| |- info_caching.rs: Reading and writing cached login information
| |- post_login: All logic after authentication
| | |- env_variables.rs: General environment variables settings
| | |- x.rs: Logic concerning Xorg
| |- ui: TUI code
| | |- mod.rs: UI calling logic, separated over 2 threads
| | |- input_field.rs: TUI input field used for username and password
| | |- power_menu.rs: Shutdown and Reboot options UI
| | |- status_message.rs: UI for error and information messages
| | |- switcher.rs: UI for environment switcher
| | |- chunks.rs: Division of the TUI screen
|- extra: Configuration and extra files needed
| |- config.toml: The default configuration file
| |- xsetup.sh: Script used to setup a Xorg session
| |- lemurs.service: The systemd service used to start at boot
```

## License

The project is made available under the MIT and APACHE license. See the
`LICENSE-MIT` and `LICENSE-APACHE` files, respectively, for more information.

## Contributions

Please report any bugs and possible improvements as an issue within this
Expand Down
Binary file modified cover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 10 additions & 3 deletions extra/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ shutdown_hint_modifiers = ""
# The key used to shutdown. Possibilities are F1 to F12.
shutdown_key = "F1"
# The command that is executed when the key is pressed
shutdown_cmd = "shutdown now"
shutdown_cmd = "systemctl poweroff -l"

# Allow for the reboot option to be used
allow_reboot = true
Expand All @@ -81,7 +81,7 @@ reboot_hint_modifiers = ""
# The key used to reboot. Possibilities are F1 to F12.
reboot_key = "F2"
# The command that is executed when the key is pressed
reboot_cmd = "reboot"
reboot_cmd = "systemctl reboot -l"

# The margin between the shutdown and reboot hints
hint_margin = 2
Expand All @@ -107,6 +107,13 @@ hint_margin = 2
# ---------
#

# Show an option for the TTY shell when logging in as one of the environments.
# NOTE: it is always shown when no viable options are found.
include_tty_shell = false

# Remember the selected environment after logging in for the next time
remember = true

# Enables showing the movers
show_movers = true

Expand Down Expand Up @@ -171,7 +178,7 @@ no_envs_modifiers_focused = ""
[username_field]

# Remember the username for the next time after a successful login attempt.
remember_username = true
remember = true

[username_field.style]
# Enables showing a title
Expand Down
4 changes: 3 additions & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ echo

# Compile lemurs
echo 'Step 1: Compile Lemurs'
cargo +nightly build --release
cargo build --release
if [ $? -ne 0 ]; then exit 1; fi

# Move lemurs to /usr/bin
Expand All @@ -30,7 +30,9 @@ if [ $? -ne 0 ]; then exit 1; fi

# Create lemurs directory
echo 'Step 3: Create lemurs configuration directory'
echo 'NOTE: You still have to move your X or Wayland startup into the proper directories'
$ROOT_CMD mkdir -p "/etc/lemurs/wms"
$ROOT_CMD mkdir -p "/etc/lemurs/wayland"
if [ $? -ne 0 ]; then exit 1; fi

# Copy over configuration file
Expand Down
1 change: 1 addition & 0 deletions src/auth/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
mod pam;
pub mod utmpx;

use ::pam::{Authenticator, PasswordConv};
use log::info;
Expand Down
2 changes: 1 addition & 1 deletion src/auth/pam.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use log::info;

use pam::{Authenticator, PasswordConv};

const PAM_SERVICE: &str = "login";
const PAM_SERVICE: &str = "system-login";

use pgs_files::passwd::{get_entry_by_name, PasswdEntry};

Expand Down
Loading

0 comments on commit bd2d827

Please sign in to comment.