Skip to content

Commit

Permalink
Use /var/lib/ instead of /var/cache/
Browse files Browse the repository at this point in the history
- Resolves #33.
- The ReGreet cache is more of a state, especially with the skipping
  selection option.
- NOTE: This does break backwards-compat.
  • Loading branch information
rharish101 committed Aug 4, 2024
1 parent 716fb2b commit c55bfbc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,15 @@ These are:
Environment Variable | Default | Use
-- | -- | --
GREETD\_CONFIG\_DIR | `/etc/greetd` | The configuration directory used by greetd
CACHE\_DIR | `/var/cache/regreet` | The directory used to store cache
STATE\_DIR | `/var/lib/regreet` | The directory used to store the ReGreet state/cache
LOG\_DIR | `/var/log/regreet` | The directory used to store logs
SESSION\_DIRS | `/usr/share/xsessions:/usr/share/wayland-sessions` | A colon (:) separated list of directories where the greeter looks for session files
REBOOT\_CMD | `reboot` | The default command used to reboot the system
POWEROFF\_CMD | `poweroff` | The default command used to shut down the system

The greeter can be installed by copying the file `target/release/regreet` to `/usr/bin` (or similar directories like `/bin`).

Optionally, to set up the log and cache directories using systemd-tmpfiles, do either of the following:
Optionally, to set up the log and state directories using systemd-tmpfiles, do either of the following:
* Copy the configuration given in [systemd-tmpfiles.conf](./systemd-tmpfiles.conf) to `/etc/tmpfiles.d/regreet.conf` or `/usr/lib/tmpfiles.d/regreet.conf`.
* Run the `systemd-tmpfiles` CLI:
```sh
Expand Down Expand Up @@ -208,7 +208,7 @@ Here, each command needs to be separated into a list containing the main command
These commands can also be specified during compilation using the `REBOOT_CMD` and `POWEROFF_CMD` environment variables.

### Logging and Caching
The cache is are stored in `/var/cache/regreet/cache.toml` (configurable during installation).
The state is are stored in `/var/lib/regreet/state.toml` (configurable during installation).
It contains the last authenticated user and the last used session per user, which are automatically selected on next login.
If the greeter is unable to write to this file, then it reverts to the default behaviour.

Expand All @@ -229,7 +229,7 @@ regreet --verbose
```

The recommended configuration is to run greetd greeters as a separate user (`greeter` in the above examples).
This can lead to insufficient permissions for either creating the cache/log directories, or writing to them.
This can lead to insufficient permissions for either creating the state/log directories, or writing to them.
To make use of the caching and logging features, please create the directories manually with the correct permissions, if not done during installation with systemd-tmpfiles.

## Contributing
Expand Down
4 changes: 2 additions & 2 deletions src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ pub const CONFIG_PATH: &str = concatcp!(GREETD_CONFIG_DIR, "/", GREETER_NAME, ".
pub const CSS_PATH: &str = concatcp!(GREETD_CONFIG_DIR, "/", GREETER_NAME, ".css");

/// The directory for system cache files
const CACHE_DIR: &str = env_or!("CACHE_DIR", concatcp!("/var/cache/", GREETER_NAME));
const CACHE_DIR: &str = env_or!("STATE_DIR", concatcp!("/var/lib/", GREETER_NAME));
/// Path to the cache file
pub const CACHE_PATH: &str = concatcp!(CACHE_DIR, "/cache.toml");
pub const CACHE_PATH: &str = concatcp!(CACHE_DIR, "/state.toml");

/// The directory for system log files
const LOG_DIR: &str = env_or!("LOG_DIR", concatcp!("/var/log/", GREETER_NAME));
Expand Down
4 changes: 2 additions & 2 deletions systemd-tmpfiles.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
#
# SPDX-License-Identifier: CC0-1.0

# Create the log and cache directories.
# Create the log and state directories.
d /var/log/regreet 0755 greeter greeter - -
d /var/cache/regreet 0755 greeter greeter - -
d /var/lib/regreet 0755 greeter greeter - -

0 comments on commit c55bfbc

Please sign in to comment.