diff --git a/flake.lock b/flake.lock index 8dbe042..a3f7ad0 100644 --- a/flake.lock +++ b/flake.lock @@ -935,10 +935,10 @@ "niri-mobile": { "flake": false, "locked": { - "lastModified": 1794856587, - "narHash": "sha256-3QcIjmE7szOtZKpWXg36lcPZ/v8vFW3SkYrg59M9GT4=", + "lastModified": 1794866348, + "narHash": "sha256-xOlwRx2pt3b/XGu7C1HBF8OljMrRV1whr+PL5o+czlM=", "ref": "quad/mobile-testing", - "rev": "9256350fa5b80e7420661e369a2bca91522a1690", + "rev": "fb33c8f8fa9ed74ea5477d6f6caf258f5733aae4", "shallow": true, "type": "git", "url": "file:///home/quadradical/Documents/Code/niri" diff --git a/modules/desktop/wm/fht-compositor/default.nix b/modules/desktop/wm/fht-compositor/default.nix index 8a87cad..1813821 100644 --- a/modules/desktop/wm/fht-compositor/default.nix +++ b/modules/desktop/wm/fht-compositor/default.nix @@ -63,6 +63,8 @@ in "org.freedesktop.impl.portal.ScreenCast" = [ "fht-compositor" ]; }; + quad.session = lib.getExe' cfg.package "fht-compositor-session"; + environment = { # Called by name (rather than by store path), so Super+Ctrl+R after a rebuild runs the new version systemPackages = [ session-programs ]; diff --git a/modules/desktop/wm/lockscreen.nix b/modules/desktop/wm/lockscreen.nix index 6afec7a..ee6b0d4 100644 --- a/modules/desktop/wm/lockscreen.nix +++ b/modules/desktop/wm/lockscreen.nix @@ -4,49 +4,21 @@ lib, ... }: +let + lock = "pidof gtklock || ${lib.getExe config.programs.gtklock.package}"; +in { services.logind.settings.Login.HandlePowerKey = "suspend"; - programs = { - hyprlock.enable = true; + programs.fht-compositor = { + # We log in automatically, so lock straight away. + settings.autostart = [ lock ]; - fht-compositor.sessionPrograms.hypridle = - "${lib.getExe pkgs.hypridle} --config ${pkgs.writeText "hypridle.conf" '' - general { - lock_cmd = pidof hyprlock || ${lib.getExe pkgs.hyprlock} --config ${ - let - inherit (config.lib.stylix) colors; - in - pkgs.writeText "hyprlock.conf" '' - background { - path = screenshot - blur_passes = 3 - } - - label { - text = $TIME - font_size = 96 - position = 0, 200 - } - - label { - text = cmd[update:60000] date +"%A, %B %-d" - font_size = 20 - position = 0, 110 - } - - input-field { - size = 300, 50 - outline_thickness = 0 - inner_color = rgb(${colors.base01}) - font_color = rgb(${colors.base05}) - check_color = rgb(${colors.base0D}) - fade_on_empty = false - } - '' - } - before_sleep_cmd = loginctl lock-session - } - ''}"; + sessionPrograms.hypridle = "${lib.getExe pkgs.hypridle} --config ${pkgs.writeText "hypridle.conf" '' + general { + lock_cmd = ${lock} + before_sleep_cmd = loginctl lock-session + } + ''}"; }; } diff --git a/modules/graphical/gnome/default.nix b/modules/graphical/gnome.nix similarity index 72% rename from modules/graphical/gnome/default.nix rename to modules/graphical/gnome.nix index 1448271..f0334ac 100644 --- a/modules/graphical/gnome/default.nix +++ b/modules/graphical/gnome.nix @@ -6,8 +6,6 @@ }: { services = { - displayManager.gdm.enable = true; - gnome = { core-os-services.enable = true; core-apps.enable = true; @@ -16,6 +14,23 @@ gvfs.enable = true; }; + systemd.user.tmpfiles.users.quadradical.rules = + let + keyring = pkgs.writeText "login.keyring" '' + [keyring] + display-name=Login + ctime=0 + mtime=0 + lock-on-idle=false + lock-after=false + ''; + in + [ + "d %h/.local/share/keyrings 0700 - - -" + "C %h/.local/share/keyrings/login.keyring 0600 - - - ${keyring}" + "f %h/.local/share/keyrings/default 0600 - - - login" + ]; + environment.sessionVariables.NAUTILUS_4_EXTENSION_DIR = lib.mkForce "${config.system.path}/lib/nautilus/extensions-4"; environment.gnome.excludePackages = with pkgs; [ diff --git a/modules/graphical/gtklock.nix b/modules/graphical/gtklock.nix new file mode 100644 index 0000000..6af55e2 --- /dev/null +++ b/modules/graphical/gtklock.nix @@ -0,0 +1,175 @@ +{ + config, + pkgs, + ... +}: +let + inherit (config.lib.stylix) colors; + + background = + pkgs.runCommand "lock-background.jpg" { nativeBuildInputs = [ pkgs.buildPackages.imagemagick ]; } + '' + magick ${../../background.jpg} -resize 50% -blur 0x16 -modulate 80 $out + ''; + + layout = pkgs.writeText "gtklock.ui" '' + + + + window-box + center + center + vertical + + + info-box + vertical + + + time-box + vertical + + + clock-label + + + + + date-label + + + + + + + + + none + + + center + 8 + + + 1 + + + + + input-field + 300 + 0.5 + 0 + 0 + password + Input Password + + + + 0 + + + + + none + 1 + + + never + 256 + 1 + + + + + vertical + 1 + + + + + + + + + 1 + + + + + center + 8 + + + warning-label + + + + + error-label + + + + + 1 + + + + + + 2 + + + + + + + + + ''; +in +{ + programs.gtklock = { + enable = true; + + config.main = { + layout = "${layout}"; + time-format = "%H:%M"; + date-format = "%A, %B %-d"; + }; + + style = '' + window { + background-image: url("${background}"); + background-size: cover; + background-position: center; + } + + #clock-label { + font-size: 96pt; + color: white; + } + + #date-label { + font-size: 20pt; + color: white; + margin-bottom: 80px; + } + + #input-field { + min-height: 50px; + padding: 0 20px; + border: none; + border-radius: 25px; + box-shadow: none; + background: #${colors.base01}; + color: #${colors.base05}; + } + + #error-label, + #warning-label { + color: #${colors.base08}; + } + ''; + }; +} diff --git a/modules/graphical/login.nix b/modules/graphical/login.nix new file mode 100644 index 0000000..135004b --- /dev/null +++ b/modules/graphical/login.nix @@ -0,0 +1,23 @@ +{ config, lib, ... }: +{ + options.quad.session = lib.mkOption { + type = lib.types.str; + description = "Command for the graphical session. greetd logs straight into it, and the session is expected to lock itself."; + }; + + config.services.greetd = { + enable = true; + settings = + let + initial_session = { + command = config.quad.session; + user = "quadradical"; + }; + in + { + inherit initial_session; + + default_session = initial_session; + }; + }; +} diff --git a/modules/mobile/niri.nix b/modules/mobile/niri.nix index d527c9c..13d20b7 100644 --- a/modules/mobile/niri.nix +++ b/modules/mobile/niri.nix @@ -1,4 +1,5 @@ { + config, inputs, lib, pkgs, @@ -54,6 +55,15 @@ let ''; swayosd-client = lib.getExe' pkgs.swayosd "swayosd-client"; + + # Stevia normally needs a phoc-only protocol to start. + stevia = pkgs.stevia.overrideAttrs (old: { + patches = (old.patches or [ ]) ++ [ ./stevia-optional-device-state.patch ]; + }); + + lock = pkgs.writeShellScript "lock" '' + ${lib.getExe' pkgs.procps "pidof"} gtklock || exec ${lib.getExe config.programs.gtklock.package} + ''; in { programs.niri = { @@ -101,15 +111,20 @@ in spawn-at-startup "${lib.getExe pkgs.swaybg}" "-i" "${../../background.jpg}" "-m" "fill" spawn-at-startup "${lib.getExe grid}" - spawn-at-startup "${lib.getExe pkgs.stevia}" + spawn-at-startup "${lib.getExe stevia}" spawn-at-startup "${lib.getExe' pkgs.swayosd "swayosd-server"}" "--style" "${swayosdStyle}" + // We log in automatically, so lock straight away. + spawn-at-startup "${lock}" binds { + XF86PowerOff { spawn "${lock}"; } XF86AudioRaiseVolume allow-when-locked=true { spawn "${swayosd-client}" "--output-volume" "raise"; } XF86AudioLowerVolume allow-when-locked=true { spawn "${swayosd-client}" "--output-volume" "lower"; } } ''; + quad.session = lib.getExe' niri "niri-session"; + services.logind.settings.Login = { HandlePowerKey = "ignore"; HandlePowerKeyLongPress = "poweroff"; diff --git a/modules/mobile/stevia-optional-device-state.patch b/modules/mobile/stevia-optional-device-state.patch new file mode 100644 index 0000000..b0cbbcb --- /dev/null +++ b/modules/mobile/stevia-optional-device-state.patch @@ -0,0 +1,22 @@ +--- a/src/pos-hw-tracker.c ++++ b/src/pos-hw-tracker.c +@@ -72,7 +72,9 @@ + gpointer device_state) + { + self->device_state = device_state; +- zphoc_device_state_v1_add_listener (self->device_state, &device_state_listener, self); ++ /* Only phoc has the device state protocol. Without it, assume there is no hardware keyboard. */ ++ if (self->device_state) ++ zphoc_device_state_v1_add_listener (self->device_state, &device_state_listener, self); + } + + +--- a/src/pos-wayland.c ++++ b/src/pos-wayland.c +@@ -387,6 +387,5 @@ + self->zwlr_foreign_toplevel_manager_v1 && + self->layer_shell && + self->zxdg_output_manager_v1 && +- self->zphoc_device_state_v1 && + self->wlr_data_control_manager); + }