aboutsummaryrefslogtreecommitdiffstats
path: root/modules/by-name/ly
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--modules/by-name/ly/ly/blackhole-smooth-240x67.durbin0 -> 484298 bytes
-rw-r--r--modules/by-name/ly/ly/module.nix130
-rw-r--r--modules/by-name/ly/ly/setup.sh47
3 files changed, 177 insertions, 0 deletions
diff --git a/modules/by-name/ly/ly/blackhole-smooth-240x67.dur b/modules/by-name/ly/ly/blackhole-smooth-240x67.dur
new file mode 100644
index 00000000..d65c878f
--- /dev/null
+++ b/modules/by-name/ly/ly/blackhole-smooth-240x67.dur
Binary files differ
diff --git a/modules/by-name/ly/ly/module.nix b/modules/by-name/ly/ly/module.nix
new file mode 100644
index 00000000..e2d3b0ae
--- /dev/null
+++ b/modules/by-name/ly/ly/module.nix
@@ -0,0 +1,130 @@
+# nixos-config - My current NixOS configuration
+#
+# Copyright (C) 2025 Benedikt Peetz <benedikt.peetz@b-peetz.de>
+# SPDX-License-Identifier: GPL-3.0-or-later
+#
+# This file is part of my nixos-config.
+#
+# You should have received a copy of the License along with this program.
+# If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.
+{
+ lib,
+ config,
+ pkgs,
+ ...
+}: let
+ cfg = config.soispha.programs.ly;
+
+ # HACK: We search for the generate river desktop file, which should exist <2026-03-13>
+ riverDesktop =
+ lib.lists.findFirst
+ (x: lib.strings.hasSuffix "river.desktop" x)
+ null
+ config.home-manager.users.soispha.home.packages;
+
+ shellDesktop = pkgs.writeText "zsh.desktop" ''
+ [Desktop Entry]
+ Comment=A simple shell session
+ DesktopNames=null
+ Exec=zsh
+ Name=zsh shell
+ Terminal=true
+ '';
+
+ # TODO: This could use the `services.display-manager.sessionPackages` option <2026-06-23>
+ customSessionsDir =
+ pkgs.runCommand "custom-sessions" {}
+ /*
+ bash
+ */
+ ''
+ mkdir "$out";
+ cp "${riverDesktop}/share/applications/river.desktop" "$out"
+ cp "${shellDesktop}" "$out/zsh.desktop"
+ '';
+
+ setup = pkgs.writeShellApplication {
+ name = "setup";
+
+ bashOptions = [];
+
+ runtimeInputs = [
+ pkgs.findutils
+ pkgs.systemd
+ ];
+ inheritPath = true;
+
+ text = builtins.readFile ./setup.sh;
+ };
+in {
+ options.soispha.programs.ly = {
+ enable = lib.mkEnableOption "ly";
+
+ batteryName = lib.mkOption {
+ type = lib.types.nullOr lib.types.str;
+ example = "BAT0";
+ default = null;
+ description = "The name of the battery, if null, will not show a batter percentage.";
+ };
+ };
+
+ config = lib.mkIf cfg.enable {
+ assertions = [
+ {
+ assertion = riverDesktop != null;
+ message = ''
+ There seems to be no `river.desktop` file generated. You will not be able to
+ log-into river without it.
+ '';
+ }
+ ];
+
+ home-manager.users.soispha = {
+ home.sessionVariables = {
+ XCOMPOSECACHE = "${config.home-manager.users.soispha.xdg.cacheHome}/X11/xcompose";
+ };
+ };
+
+ services.displayManager.ly = {
+ enable = true;
+ x11Support = false;
+
+ settings = {
+ battery_id = cfg.batteryName;
+
+ # Stop animations after 10 secs.
+ animation_timeout_sec = 60;
+
+ animation = "dur_file";
+ dur_file_path = "${./blackhole-smooth-240x67.dur}";
+ full_color = true;
+
+ # NOTE: This does the same as the default nixos setup cmd, but we don't
+ # immidiately start the `graphical-session.target`. That is started by river's
+ # init. <2026-06-23>
+ setup_cmd = "${lib.getExe setup}";
+
+ custom_sessions = "${customSessionsDir}";
+
+ # Clear the screen before starting up (otherwise error messages might linger on
+ # it.)
+ start_cmd = "clear";
+
+ # Clear the password on failure.
+ clear_password = true;
+
+ session_log = "${config.home-manager.users.soispha.xdg.dataHome}/ly/ly-session.log";
+
+ clock = "%c";
+
+ hibernate_cmd = "systemctl hibernate";
+ inactivity_cmd = "systemctl suspend-then-hibernate";
+ restart_cmd = "reboot";
+ shutdown_cmd = "shutdown $PLATFORM_SHUTDOWN_ARG now";
+ sleep_cmd = "systemctl suspend";
+
+ inactivity_delay = 120; # unit is seconds
+ };
+ };
+ };
+}
diff --git a/modules/by-name/ly/ly/setup.sh b/modules/by-name/ly/ly/setup.sh
new file mode 100644
index 00000000..6e8bed2b
--- /dev/null
+++ b/modules/by-name/ly/ly/setup.sh
@@ -0,0 +1,47 @@
+#! /usr/bin/env bash
+
+# Shared environment setup for graphical sessions.
+
+# shellcheck disable=1091
+. /etc/profile
+
+cd "$HOME" || {
+ echo 1>&2 "No HOME :("
+ exit 1
+}
+
+if [ -z "$_DID_SYSTEMD_CAT" ]; then
+ export _DID_SYSTEMD_CAT=1
+ exec systemd-cat -t xsession "$0" "$@"
+fi
+
+
+# Import environment variables into the systemd user environment.
+/run/current-system/systemd/bin/systemctl --user import-environment DBUS_SESSION_BUS_ADDRESS DISPLAY XAUTHORITY XDG_SESSION_ID
+
+# Speed up application start by 50-150ms according to
+# https://kdemonkey.blogspot.com/2008/04/magic-trick.html
+compose_cache="${XCOMPOSECACHE:-$HOME/.compose-cache}"
+mkdir -p "$compose_cache"
+# To avoid accidentally deleting a wrongly set up XCOMPOSECACHE directory,
+# defensively try to delete cache *files* only, following the file format specified in
+# https://gitlab.freedesktop.org/xorg/lib/libx11/-/blob/master/modules/im/ximcp/imLcIm.c#L353-358
+# sprintf (*res, "%s/%c%d_%03x_%08x_%08x", dir, _XimGetMyEndian(), XIM_CACHE_VERSION, (unsigned int)sizeof (DefTree), hash, hash2);
+find "$compose_cache" -maxdepth 1 -regextype posix-extended -regex '.*/[Bl][0-9]+_[0-9a-f]{3}_[0-9a-f]{8}_[0-9a-f]{8}' -delete
+unset compose_cache
+
+# Work around KDE errors when a user first logs in and
+# .local/share doesn't exist yet.
+mkdir -p "${XDG_DATA_HOME:-$HOME/.local/share}"
+
+unset _DID_SYSTEMD_CAT
+
+
+if test "$1"; then
+ # Run the supplied session command.
+ exec "$@"
+else
+ # TODO: Do we need this? Should not the session always exist?
+ echo "error: unknown session $1" 1>&2
+ exit 1
+fi