diff --git a/environments/river/home.nix b/environments/river/home.nix index 214522e..ce0e7db 100644 --- a/environments/river/home.nix +++ b/environments/river/home.nix @@ -26,10 +26,6 @@ in { ]; services.cliphist.enable = true; - home.sessionVariables = { - XDG_CURRENT_DESKTOP = "GNOME"; - }; - wayland.windowManager.river = { enable = true; settings = { diff --git a/flake.lock b/flake.lock index aa35fae..f4a7bca 100644 --- a/flake.lock +++ b/flake.lock @@ -1,25 +1,5 @@ { "nodes": { - "astal-auth": { - "inputs": { - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1718556609, - "narHash": "sha256-EeYnp9HEpQXNGweF/Ea6ZfjTSV6biHFSsZV010nDHaM=", - "owner": "astal-sh", - "repo": "auth", - "rev": "b35a38aa93670f6be06202f2ad3066a227f0a1b9", - "type": "github" - }, - "original": { - "owner": "astal-sh", - "repo": "auth", - "type": "github" - } - }, "astal-river": { "inputs": { "nixpkgs": [ @@ -326,26 +306,6 @@ "type": "github" } }, - "gtk-session-lock": { - "inputs": { - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1713713322, - "narHash": "sha256-A9U/BnzdypE1rt53uhw5X4JQkayR8CkD2Qhn/vhmUSU=", - "owner": "Cu3PO42", - "repo": "gtk-session-lock", - "rev": "b9ddb2792b613d14622acada73c64f16a2635b40", - "type": "github" - }, - "original": { - "owner": "Cu3PO42", - "repo": "gtk-session-lock", - "type": "github" - } - }, "hercules-ci-effects": { "inputs": { "flake-parts": "flake-parts_2", @@ -563,11 +523,9 @@ }, "root": { "inputs": { - "astal-auth": "astal-auth", "astal-river": "astal-river", "flood": "flood", "ghostty": "ghostty", - "gtk-session-lock": "gtk-session-lock", "home-manager": "home-manager", "impermanence": "impermanence", "neovim-nightly": "neovim-nightly", diff --git a/flake.nix b/flake.nix index 451b732..9614802 100644 --- a/flake.nix +++ b/flake.nix @@ -32,14 +32,6 @@ url = "github:zoriya/astal-river"; inputs.nixpkgs.follows = "nixpkgs"; }; - astal-auth = { - url = "github:astal-sh/auth"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - gtk-session-lock = { - url = "github:Cu3PO42/gtk-session-lock"; - inputs.nixpkgs.follows = "nixpkgs"; - }; }; outputs = { diff --git a/modules/wm/ags/config.js b/modules/wm/ags/config.js index 4d9d361..d1f85e5 100644 --- a/modules/wm/ags/config.js +++ b/modules/wm/ags/config.js @@ -5,10 +5,6 @@ import { Bar } from "./layouts/bar.js"; import { Notifications } from "./layouts/notifications.js"; import { OSD } from "./layouts/osd.js"; import { Quicksettings } from "./layouts/quicksettings.js"; -import { lockscreen } from "./lockscreen.js"; - -// @ts-ignore -App.lock = lockscreen; /** * @param {Array<(monitor: number) => Gtk.Window>} widgets diff --git a/modules/wm/ags/default.nix b/modules/wm/ags/default.nix index fbc5d7d..7bfe01a 100644 --- a/modules/wm/ags/default.nix +++ b/modules/wm/ags/default.nix @@ -16,7 +16,6 @@ installPhase = "install -Dm755 ${./covercolors.py} $out/bin/covercolors"; }; systemdTarget = "graphical-session.target"; - # TODO: Add this in the offcial ags derivation ags = pkgs.ags.overrideAttrs (_: prev: { buildInputs = prev.buildInputs @@ -24,8 +23,6 @@ pkgs.bash pkgs.libdbusmenu-gtk3 inputs.astal-river.packages.x86_64-linux.default - inputs.astal-auth.packages.x86_64-linux.default - inputs.gtk-session-lock.packages.x86_64-linux.default ]; }); in { diff --git a/modules/wm/ags/lockscreen.js b/modules/wm/ags/lockscreen.js deleted file mode 100644 index cd96d2e..0000000 --- a/modules/wm/ags/lockscreen.js +++ /dev/null @@ -1,202 +0,0 @@ -import Gdk from "gi://Gdk?version=3.0"; -import Gtk from "gi://Gtk?version=3.0"; -import Lock from "gi://GtkSessionLock"; -import AstalAuth from "gi://AstalAuth"; - -import { Clock } from "./modules/clock.js"; - -export const DELAY = 500; - -export const isLocked = Variable(false); -export const prompt = Variable(""); -export const inputVisible = Variable(false); -export const inputNeeded = Variable(false); -export const error = Variable( - /** @type {{type: "info" | "error" | "fail", message: string} | null} */ ( - null - ), -); - -const auth = new AstalAuth.Pam(); -let lock; -let windows = []; - -let hasInit = false; - -function init() { - if (hasInit) return; - hasInit = true; - auth.connect("auth-prompt-visible", (auth, msg) => { - prompt.setValue(msg); - inputVisible.setValue(true); - inputNeeded.setValue(true); - }); - auth.connect("auth-prompt-hidden", (auth, msg) => { - prompt.setValue(msg); - inputVisible.setValue(false); - inputNeeded.setValue(true); - }); - - auth.connect("auth-error", (_, msg) => { - error.setValue({ message: msg, type: "error" }); - auth.supply_secret(null); - }); - auth.connect("auth-info", (_, msg) => { - error.setValue({ message: msg, type: "info" }); - auth.supply_secret(null); - }); - - auth.connect("success", unlock); - auth.connect("fail", (p, msg) => { - error.setValue({ message: msg, type: "fail" }); - auth.start_authenticate(); - }); - - const display = Gdk.Display.get_default(); - display?.connect("monitor-added", (disp, monitor) => { - if (!isLocked.value) return; - const w = createWindow(monitor); - lock.new_surface(w.window, w.monitor); - w.window.show(); - }); - display?.connect("monitor-removed", (disp, monitor) => { - if (!isLocked.value) return; - windows.forEach((win) => { - lock.unmap_lock_window(win.window); - win.window.destroy(); - }); - }); -} - -export function lockscreen() { - init(); - lock = Lock.prepare_lock(); - lock.connect("locked", () => {}); - lock.connect("finished", unlock); - - const display = Gdk.Display.get_default(); - const n = display?.get_n_monitors() || 1; - for (let m = 0; m < n; m++) { - const monitor = display?.get_monitor(m); - // @ts-ignore - createWindow(monitor); - } - - lock.lock_lock(); - isLocked.value = true; - windows.map((w) => { - lock.new_surface(w.window, w.monitor); - w.window.show(); - }); - auth.start_authenticate(); -} - -/** - * @param {string} password - */ -export function login(password) { - inputNeeded.setValue(false); - auth.supply_secret(password); -} - -function unlock() { - isLocked.value = false; - - // Wait for window's hide animations to finish - Utils.timeout(DELAY, () => { - windows.forEach((w) => { - Lock.unmap_lock_window(w.window); - }); - lock.unlock_and_destroy(); - windows.forEach((w) => { - w.window.destroy(); - }); - windows = []; - lock = undefined; - - Gdk.Display.get_default()?.sync(); - }); -} - -/** - * @param {Gdk.Monitor} monitor - */ -function createWindow(monitor) { - const window = LockWindow(); - const win = { window, monitor }; - windows.push(win); - return win; -} - -const LoginBox = () => - Widget.Box({ - vertical: true, - vpack: "center", - hpack: "center", - spacing: 16, - children: [ - Widget.Box({ - hpack: "center", - className: "avatar", - css: `background-image: url("/home/${Utils.USER}/.face");`, - }), - Widget.Box({ - className: inputNeeded - .bind() - .as((n) => `entry-box ${n ? "" : "hidden"}`), - vertical: true, - children: [ - Widget.Label({ - label: prompt.bind(), - }), - Widget.Separator(), - Widget.Entry({ - hpack: "center", - xalign: 0.5, - visibility: inputVisible.bind(), - sensitive: inputNeeded.bind(), - onAccept: (self) => { - login(self.text || ""); - self.text = ""; - }, - }).on("realize", (entry) => entry.grab_focus()), - Widget.Label({ - label: error.bind().as((x) => x?.message || ""), - visible: error.bind().as((x) => !!x), - }), - ], - }), - ], - }); - -export const LockWindow = () => - new Gtk.Window({ - child: Widget.Box({ - hexpand: true, - vexpand: true, - children: [ - Widget.Revealer({ - reveal_child: false, - transition: "crossfade", - transition_duration: DELAY, - hexpand: true, - vexpand: true, - child: Widget.Box({ - css: ` - background-image: url("/home/${Utils.USER}/.cache/current-wallpaper"); - background-position: center; - background-size: cover; - `, - vertical: true, - hexpand: true, - vexpand: true, - child: LoginBox(), - }), - }).on("realize", (self) => - Utils.idle(() => { - self.reveal_child = true; - }), - ), - ], - }), - }); diff --git a/modules/wm/ags/style.css b/modules/wm/ags/style.css index 2a64ce3..fcce45c 100644 --- a/modules/wm/ags/style.css +++ b/modules/wm/ags/style.css @@ -4,10 +4,6 @@ margin: 0; } -window { - all: unset; -} - button { all: unset; } diff --git a/modules/wm/default.nix b/modules/wm/default.nix index c444465..a2e72c5 100644 --- a/modules/wm/default.nix +++ b/modules/wm/default.nix @@ -40,5 +40,5 @@ polkit_gnome ]; - security.pam.services.astal-auth = {}; + security.pam.services.hyprlock = {}; } diff --git a/modules/wm/home.nix b/modules/wm/home.nix index 9152491..05cb048 100644 --- a/modules/wm/home.nix +++ b/modules/wm/home.nix @@ -16,4 +16,61 @@ in { home.packages = [ wallpaper ]; + + programs.hyprlock = { + enable = true; + settings = { + general = { + grace = 10; + ignore_emauthpty_input = true; + }; + background = { + monitor = ""; + path = "/home/zoriya/.cache/current-wallpaper"; + }; + input-field = { + monitor = ""; + size = "250, 50"; + outline_thickness = 0; + dots_size = 0.26; + inner_color = "#ff0000"; + dots_spacing = 0.64; + dots_center = true; + fade_on_empty = true; + placeholder_text = "Password..."; + hide_input = false; + check_color = "rgb(40, 200, 250)"; + position = "0, 50"; + halign = "center"; + valign = "bottom"; + }; + label = [ + { + monitor = ""; + text = ''cmd[update:1000] echo " $(date +"%H:%M") "''; + color = "#ff0000"; + + font_size = 64; + font_family = "monospace"; + + position = "0, -70"; + halign = "center"; + valign = "center"; + } + + { + monitor = ""; + text = ''cmd[update:18000000] echo " "$(date +'%A, %-d %B %Y')" "''; + color = "#ff0000"; + + font_size = 24; + font_family = "monospace"; + + position = "0, -120"; + halign = "center"; + valign = "center"; + } + ]; + }; + }; }