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 *config.js
*icons *icons
*.direnv/ *.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 Gtk from 'gi://Gtk?version=3.0';
import Lock from 'gi://GtkSessionLock?version=0.1'; 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'; import Separator from '../misc/separator.ts';
/* Types */ /* Types */
@ -18,6 +21,7 @@ const transition_duration = 1000;
const WINDOW_MARGINS = -2; const WINDOW_MARGINS = -2;
const ENTRY_SPACING = 20; const ENTRY_SPACING = 20;
const CLOCK_SPACING = 60; const CLOCK_SPACING = 60;
const bgCSS = ({ w = 1, h = 1 } = {}) => ` const bgCSS = ({ w = 1, h = 1 } = {}) => `
border: 2px solid rgba(189, 147, 249, 0.8); border: 2px solid rgba(189, 147, 249, 0.8);
background: rgba(0, 0, 0, 0.2); background: rgba(0, 0, 0, 0.2);
@ -59,7 +63,7 @@ const Clock = () => Label({ class_name: 'clock' })
.replace('p.m.', 'PM'); .replace('p.m.', 'PM');
}); });
const PasswordPrompt = (monitor: Gdk.Monitor) => { const PasswordPrompt = (monitor: Gdk.Monitor, visible: boolean) => {
const rev = Box({ const rev = Box({
css: bgCSS(), css: bgCSS(),
attribute: { attribute: {
@ -108,57 +112,68 @@ const PasswordPrompt = (monitor: Gdk.Monitor) => {
const label = Label('Enter password:'); const label = Label('Enter password:');
return new Gtk.Window({ return new Gtk.Window({
child: Box({ child: visible ?
vertical: true, Box({
vpack: 'center', vertical: true,
hpack: 'center', vpack: 'center',
spacing: 16, hpack: 'center',
spacing: 16,
children: [ children: [
Clock(), Clock(),
Separator(CLOCK_SPACING, { vertical: true }), Separator(CLOCK_SPACING, { vertical: true }),
Box({ Box({
hpack: 'center', hpack: 'center',
class_name: 'avatar', class_name: 'avatar',
}), }),
Box({ Box({
class_name: 'entry-box', class_name: 'entry-box',
vertical: true, vertical: true,
children: [ children: [
label, label,
Separator(ENTRY_SPACING, { vertical: true }), Separator(ENTRY_SPACING, { vertical: true }),
Entry({ Entry({
hpack: 'center', hpack: 'center',
xalign: 0.5, xalign: 0.5,
visibility: false, visibility: false,
placeholder_text: 'password', placeholder_text: 'password',
on_accept: (self) => { on_accept: (self) => {
self.sensitive = false; self.sensitive = false;
Utils.authenticate(self.text ?? '') Utils.authenticate(self.text ?? '')
.then(() => unlock()) .then(() => unlock())
.catch((e) => { .catch((e) => {
self.text = ''; self.text = '';
label.label = e.message; label.label = e.message;
self.sensitive = true; self.sensitive = true;
}); });
}, },
}).on('realize', (entry) => entry.grab_focus()), }).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 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); windows.push(win);
lock.new_surface(win, monitor); lock.new_surface(win, monitor);

View file

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

View file

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