From c55bfbc8c08b730d8e556d100c454dcb97902c20 Mon Sep 17 00:00:00 2001 From: Harish Rajagopal Date: Sun, 4 Aug 2024 11:41:59 +0200 Subject: [PATCH] Use `/var/lib/` instead of `/var/cache/` - Resolves #33. - The ReGreet cache is more of a state, especially with the skipping selection option. - NOTE: This does break backwards-compat. --- README.md | 8 ++++---- src/constants.rs | 4 ++-- systemd-tmpfiles.conf | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 07b0276..643586d 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,7 @@ 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 @@ -98,7 +98,7 @@ 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 @@ -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. @@ -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 diff --git a/src/constants.rs b/src/constants.rs index ef442d6..5154f48 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -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)); diff --git a/systemd-tmpfiles.conf b/systemd-tmpfiles.conf index baf61b8..195ea3f 100644 --- a/systemd-tmpfiles.conf +++ b/systemd-tmpfiles.conf @@ -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 - -