fix(ags): only show one entry for lockscreen if !greetdDupe
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2024-04-19 20:31:17 -04:00
parent 3b32b5c302
commit 4dd98e97c1
4 changed files with 73 additions and 41 deletions

1
.gitignore vendored
View file

@ -7,3 +7,4 @@ result*
*config.js
*icons
*.direnv/
modules/ags/config/ts/lockscreen/vars.ts

View file

@ -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);

View file

@ -3,10 +3,12 @@
astal,
config,
gtk-session-lock,
lib,
pkgs,
...
}: let
inherit (config.vars) mainUser hostName;
inherit (lib) boolToString;
inherit (config.vars) mainUser hostName mainMonitor greetdDupe;
flakeDir = config.environment.variables.FLAKE;
isTouchscreen = config.hardware.sensor.iio.enable;
@ -83,6 +85,17 @@ in {
};
"${agsConfigDir}/config/types/gtk-session-lock".source = pkgs.callPackage ./gtk-session-lock-types {inherit gtkSessionLock;};
"${agsConfigDir}/config/config.js".text = configJs;
"${agsConfigDir}/config/ts/lockscreen/vars.ts".text =
/*
javascript
*/
''
export default {
mainMonitor: '${mainMonitor}',
dupeLockscreen: ${boolToString greetdDupe},
};
'';
}
// (import ./icons.nix {inherit pkgs agsConfigDir;});
@ -119,6 +132,8 @@ in {
layerrule = [
"noanim, ^(?!win-).*"
# Lockscreen blur
"blur, ^(blur-bg.*)"
"ignorealpha 0.19, ^(blur-bg.*)"
];

View file

@ -35,6 +35,7 @@ in {
home.packages = with pkgs; [
gnome.seahorse
lockPkg
];
services.hypridle = mkIf isLaptop {