parent
3b32b5c302
commit
4dd98e97c1
4 changed files with 73 additions and 41 deletions
modules/ags/config/ts/lockscreen
|
@ -4,6 +4,9 @@ import Gdk from 'gi://Gdk?version=3.0';
|
|||
import Gtk from 'gi://Gtk?version=3.0';
|
||||
import Lock from 'gi://GtkSessionLock?version=0.1';
|
||||
|
||||
// This file is generated by Nix
|
||||
import Vars from './vars.ts';
|
||||
|
||||
import Separator from '../misc/separator.ts';
|
||||
|
||||
/* Types */
|
||||
|
@ -18,6 +21,7 @@ const transition_duration = 1000;
|
|||
const WINDOW_MARGINS = -2;
|
||||
const ENTRY_SPACING = 20;
|
||||
const CLOCK_SPACING = 60;
|
||||
|
||||
const bgCSS = ({ w = 1, h = 1 } = {}) => `
|
||||
border: 2px solid rgba(189, 147, 249, 0.8);
|
||||
background: rgba(0, 0, 0, 0.2);
|
||||
|
@ -59,7 +63,7 @@ const Clock = () => Label({ class_name: 'clock' })
|
|||
.replace('p.m.', 'PM');
|
||||
});
|
||||
|
||||
const PasswordPrompt = (monitor: Gdk.Monitor) => {
|
||||
const PasswordPrompt = (monitor: Gdk.Monitor, visible: boolean) => {
|
||||
const rev = Box({
|
||||
css: bgCSS(),
|
||||
attribute: {
|
||||
|
@ -108,57 +112,68 @@ const PasswordPrompt = (monitor: Gdk.Monitor) => {
|
|||
const label = Label('Enter password:');
|
||||
|
||||
return new Gtk.Window({
|
||||
child: Box({
|
||||
vertical: true,
|
||||
vpack: 'center',
|
||||
hpack: 'center',
|
||||
spacing: 16,
|
||||
child: visible ?
|
||||
Box({
|
||||
vertical: true,
|
||||
vpack: 'center',
|
||||
hpack: 'center',
|
||||
spacing: 16,
|
||||
|
||||
children: [
|
||||
Clock(),
|
||||
children: [
|
||||
Clock(),
|
||||
|
||||
Separator(CLOCK_SPACING, { vertical: true }),
|
||||
Separator(CLOCK_SPACING, { vertical: true }),
|
||||
|
||||
Box({
|
||||
hpack: 'center',
|
||||
class_name: 'avatar',
|
||||
}),
|
||||
Box({
|
||||
hpack: 'center',
|
||||
class_name: 'avatar',
|
||||
}),
|
||||
|
||||
Box({
|
||||
class_name: 'entry-box',
|
||||
vertical: true,
|
||||
children: [
|
||||
label,
|
||||
Box({
|
||||
class_name: 'entry-box',
|
||||
vertical: true,
|
||||
children: [
|
||||
label,
|
||||
|
||||
Separator(ENTRY_SPACING, { vertical: true }),
|
||||
Separator(ENTRY_SPACING, { vertical: true }),
|
||||
|
||||
Entry({
|
||||
hpack: 'center',
|
||||
xalign: 0.5,
|
||||
visibility: false,
|
||||
placeholder_text: 'password',
|
||||
Entry({
|
||||
hpack: 'center',
|
||||
xalign: 0.5,
|
||||
visibility: false,
|
||||
placeholder_text: 'password',
|
||||
|
||||
on_accept: (self) => {
|
||||
self.sensitive = false;
|
||||
on_accept: (self) => {
|
||||
self.sensitive = false;
|
||||
|
||||
Utils.authenticate(self.text ?? '')
|
||||
.then(() => unlock())
|
||||
.catch((e) => {
|
||||
self.text = '';
|
||||
label.label = e.message;
|
||||
self.sensitive = true;
|
||||
});
|
||||
},
|
||||
}).on('realize', (entry) => entry.grab_focus()),
|
||||
],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
Utils.authenticate(self.text ?? '')
|
||||
.then(() => unlock())
|
||||
.catch((e) => {
|
||||
self.text = '';
|
||||
label.label = e.message;
|
||||
self.sensitive = true;
|
||||
});
|
||||
},
|
||||
}).on('realize', (entry) => entry.grab_focus()),
|
||||
],
|
||||
}),
|
||||
],
|
||||
}) :
|
||||
Box(),
|
||||
});
|
||||
};
|
||||
|
||||
const getHyprlandMonitorDesc = (monitor: Gdk.Monitor) => {
|
||||
const manufacturer = monitor.manufacturer?.replace(',', '');
|
||||
const model = monitor.model?.replace(',', '');
|
||||
|
||||
return `desc:${manufacturer} ${model}`;
|
||||
};
|
||||
|
||||
const createWindow = (monitor: Gdk.Monitor) => {
|
||||
const win = PasswordPrompt(monitor);
|
||||
const hyprDesc = getHyprlandMonitorDesc(monitor);
|
||||
const entryVisible = Vars.mainMonitor.startsWith(hyprDesc) || Vars.dupeLockscreen;
|
||||
const win = PasswordPrompt(monitor, entryVisible);
|
||||
|
||||
windows.push(win);
|
||||
lock.new_surface(win, monitor);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue