Remove ags lockscreen and switch to hyprlock

This commit is contained in:
2024-07-09 17:21:11 +07:00
parent c23ace74e6
commit cd5b0d73ad
9 changed files with 58 additions and 268 deletions
-4
View File
@@ -26,10 +26,6 @@ in {
];
services.cliphist.enable = true;
home.sessionVariables = {
XDG_CURRENT_DESKTOP = "GNOME";
};
wayland.windowManager.river = {
enable = true;
settings = {
Generated
-42
View File
@@ -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",
-8
View File
@@ -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 = {
-4
View File
@@ -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
-3
View File
@@ -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 {
-202
View File
@@ -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;
}),
),
],
}),
});
-4
View File
@@ -4,10 +4,6 @@
margin: 0;
}
window {
all: unset;
}
button {
all: unset;
}
+1 -1
View File
@@ -40,5 +40,5 @@
polkit_gnome
];
security.pam.services.astal-auth = {};
security.pam.services.hyprlock = {};
}
+57
View File
@@ -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 = "<i>Password...</i>";
hide_input = false;
check_color = "rgb(40, 200, 250)";
position = "0, 50";
halign = "center";
valign = "bottom";
};
label = [
{
monitor = "";
text = ''cmd[update:1000] echo "<b><big> $(date +"%H:%M") </big></b>"'';
color = "#ff0000";
font_size = 64;
font_family = "monospace";
position = "0, -70";
halign = "center";
valign = "center";
}
{
monitor = "";
text = ''cmd[update:18000000] echo "<b> "$(date +'%A, %-d %B %Y')" </b>"'';
color = "#ff0000";
font_size = 24;
font_family = "monospace";
position = "0, -120";
halign = "center";
valign = "center";
}
];
};
};
}