feat(ags): replace hyprlock with ags
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2024-04-19 17:01:09 -04:00
parent d98290a6e4
commit 94ce797784
11 changed files with 202 additions and 159 deletions

View file

@ -36,6 +36,6 @@ in {
polkit-1.text = mkDefault (mkBefore grosshackConf);
# FIXME: sometimes can't use password
hyprlock.text = mkDefault (mkBefore grosshackConf);
ags.text = mkDefault (mkBefore grosshackConf);
};
}

View file

@ -330,7 +330,7 @@
},
"flake-utils_3": {
"inputs": {
"systems": "systems_8"
"systems": "systems_6"
},
"locked": {
"lastModified": 1710146030,
@ -669,50 +669,6 @@
"type": "github"
}
},
"hyprlang_3": {
"inputs": {
"nixpkgs": [
"hyprlock",
"nixpkgs"
],
"systems": "systems_6"
},
"locked": {
"lastModified": 1713121246,
"narHash": "sha256-502X0Q0fhN6tJK7iEUA8CghONKSatW/Mqj4Wappd++0=",
"owner": "hyprwm",
"repo": "hyprlang",
"rev": "78fcaa27ae9e1d782faa3ff06c8ea55ddce63706",
"type": "github"
},
"original": {
"owner": "hyprwm",
"repo": "hyprlang",
"type": "github"
}
},
"hyprlock": {
"inputs": {
"hyprlang": "hyprlang_3",
"nixpkgs": [
"nixpkgs"
],
"systems": "systems_7"
},
"locked": {
"lastModified": 1713214544,
"narHash": "sha256-36qa6MOhCBd39YPC0FgapwGRHZXjstw8BQuKdFzwQ4k=",
"owner": "hyprwm",
"repo": "hyprlock",
"rev": "2bce52f094c49109520ad37fc8f0d051acaace55",
"type": "github"
},
"original": {
"owner": "hyprwm",
"repo": "hyprlock",
"type": "github"
}
},
"jellyfin-flake": {
"inputs": {
"nixpkgs": [
@ -1541,7 +1497,6 @@
"home-manager": "home-manager",
"hypridle": "hypridle",
"hyprland": "hyprland",
"hyprlock": "hyprlock",
"jellyfin-flake": "jellyfin-flake",
"jellyfin-ultrachromic-src": "jellyfin-ultrachromic-src",
"modernx-src": "modernx-src",
@ -1743,36 +1698,6 @@
}
},
"systems_6": {
"locked": {
"lastModified": 1689347949,
"narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=",
"owner": "nix-systems",
"repo": "default-linux",
"rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default-linux",
"type": "github"
}
},
"systems_7": {
"locked": {
"lastModified": 1689347949,
"narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=",
"owner": "nix-systems",
"repo": "default-linux",
"rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default-linux",
"type": "github"
}
},
"systems_8": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",

View file

@ -244,14 +244,6 @@
inputs.nixpkgs.follows = "nixpkgs";
};
hyprlock = {
type = "github";
owner = "hyprwm";
repo = "hyprlock";
inputs.nixpkgs.follows = "nixpkgs";
};
Hyprspace = {
type = "github";
owner = "KZDKM";

View file

@ -0,0 +1,3 @@
import { transpileTypeScript } from './js/utils.js';
export default (await transpileTypeScript('lockscreen')).default;

View file

@ -0,0 +1,8 @@
import LaunchLockscreen from './ts/lockscreen/main.ts';
LaunchLockscreen();
App.config({
icons: './icons',
});

View file

@ -0,0 +1,5 @@
@import './common';
window {
background-color: transparent;
}

View file

@ -0,0 +1,175 @@
const { Box, Entry, Label, Separator, Window } = Widget;
import Gdk from 'gi://Gdk?version=3.0';
import Gtk from 'gi://Gtk?version=3.0';
import Lock from 'gi://GtkSessionLock?version=0.1';
/* Types */
import { Box as AgsBox } from 'types/widgets/box';
const lock = Lock.prepare_lock();
const windows: Gtk.Window[] = [];
const blurBGs: AgsBox<Gtk.Widget, { geometry: { w: number, h: number }; }>[] = [];
const transition_duration = 1000;
const windowMargins = -2;
const bgCSS = ({ w = 1, h = 1 } = {}) =>`
border: 2px solid rgba(189, 147, 249, 0.8);
background: rgba(0, 0, 0, 0.2);
min-height: ${h}px;
min-width: ${w}px;
transition: min-height ${transition_duration / 2}ms,
min-width ${transition_duration / 2}ms;
`;
const unlock = () => {
blurBGs.forEach((b) => {
b.css = bgCSS({
w: b.attribute.geometry.w,
h: 1,
});
Utils.timeout(transition_duration / 2, () => {
b.css = bgCSS({
w: 1,
h: 1,
});
});
});
Utils.timeout(transition_duration, () => {
lock.unlock_and_destroy();
Gdk.Display.get_default()?.sync();
App.quit();
});
};
const PasswordPrompt = (monitor: Gdk.Monitor) => {
const rev = Box({
css: bgCSS(),
attribute: {
geometry: {} as { w: number, h: number },
},
setup: (self) => Utils.idle(() => {
self.attribute.geometry = {
w: monitor.geometry.width,
h: monitor.geometry.height,
};
self.css = bgCSS({
w: self.attribute.geometry.w,
h: 1,
});
Utils.timeout(transition_duration / 2, () => {
self.css = bgCSS({
w: self.attribute.geometry.w,
h: self.attribute.geometry.h,
});
});
}),
});
blurBGs.push(rev);
Window({
name: `blur-bg-${monitor.get_model()}`,
gdkmonitor: monitor,
layer: 'overlay',
anchor: ['top', 'bottom', 'right', 'left'],
margins: [windowMargins],
exclusivity: 'ignore',
child: Box({
hexpand: false,
vexpand: false,
hpack: 'center',
vpack: 'center',
child: rev,
}),
});
const label = Label('Enter password:');
return new Gtk.Window({
child: Widget.Box({
vertical: true,
vpack: 'center',
hpack: 'center',
spacing: 16,
children: [
Box({
hpack: 'center',
class_name: 'avatar',
}),
Box({
class_name: 'entry-box',
vertical: true,
children: [
label,
Separator(),
Entry({
hpack: 'center',
xalign: 0.5,
visibility: false,
placeholder_text: 'password',
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()),
],
}),
],
}),
});
};
const createWindow = (monitor: Gdk.Monitor) => {
const win = PasswordPrompt(monitor);
windows.push(win);
// @ts-expect-error should be fine
lock.new_surface(win, monitor);
win.show();
};
const on_locked = () => {
const display = Gdk.Display.get_default();
for (let m = 0; m < (display?.get_n_monitors() ?? 0); m++) {
const monitor = display?.get_monitor(m);
if (monitor) {
createWindow(monitor);
}
}
display?.connect('monitor-added', (_, monitor) => {
createWindow(monitor);
});
};
const on_finished = () => {
lock.destroy();
Gdk.Display.get_default()?.sync();
App.quit();
};
lock.connect('locked', on_locked);
lock.connect('finished', on_finished);
export default () => lock.lock_lock();

View file

@ -10,7 +10,7 @@
flakeDir = config.environment.variables.FLAKE;
isTouchscreen = config.hardware.sensor.iio.enable;
gtk-lock = gtk-session-lock.packages.${pkgs.system}.default;
gtkSessionLock = gtk-session-lock.packages.${pkgs.system}.default;
in {
# Enable pam for ags and astal
security.pam.services.ags = {};
@ -57,14 +57,14 @@ in {
enable = true;
extraPackages = with pkgs; [
libadwaita
gtk-lock
gtkSessionLock
];
};
programs.ags = {
enable = true;
extraPackages = [
gtk-lock
gtkSessionLock
];
};
@ -82,7 +82,7 @@ in {
source = "${config.programs.ags.finalPackage}/share/com.github.Aylur.ags/types";
recursive = true;
};
"${agsConfigDir}/config/types/gtk-session-lock".source = pkgs.callPackage ./gtk-session-lock-types {inherit gtk-lock;};
"${agsConfigDir}/config/types/gtk-session-lock".source = pkgs.callPackage ./gtk-session-lock-types {inherit gtkSessionLock;};
"${agsConfigDir}/config/config.js".text = configJs;
}
// (import ./icons.nix {inherit pkgs agsConfigDir;});
@ -120,6 +120,8 @@ in {
layerrule = [
"noanim, ^(?!win-).*"
"blur, ^(blur-bg.*)"
"ignorealpha 0.19, ^(blur-bg.*)"
];
exec-once = [

View file

@ -4,7 +4,7 @@
gdk-pixbuf,
gobject-introspection,
gtk3,
gtk-lock,
gtkSessionLock,
harfbuzz,
pango,
...
@ -20,7 +20,7 @@ buildNpmPackage {
installPhase = ''
npx @ts-for-gir/cli generate ${builtins.concatStringsSep " " [
"-g ${gtk-lock.dev}/share/gir-1.0"
"-g ${gtkSessionLock.dev}/share/gir-1.0"
"-g ${gobject-introspection.dev}/share/gir-1.0"
"-g ${gtk3.dev}/share/gir-1.0"
"-g ${pango.dev}/share/gir-1.0"

View file

@ -1,64 +0,0 @@
{
config,
hyprlock,
lib,
...
}: let
inherit (lib) optionalString;
inherit (config.vars) mainMonitor;
monitor = optionalString (mainMonitor != null) mainMonitor;
in {
imports = [hyprlock.homeManagerModules.default];
programs.hyprlock = {
enable = true;
general = {
hide_cursor = false;
};
backgrounds = [
{
path = "screenshot";
blur_size = 5;
blur_passes = 2;
vibrancy_darkness = 0.0;
brightness = 1.0;
}
];
input-fields = [
{
inherit monitor;
size.height = 70;
fade_on_empty = false;
outer_color = "rgba(10, 10, 10, 1.0)";
inner_color = "rgb(151515)";
font_color = "rgba(240, 240, 240, 1.0)"; # This is the dot color
capslock_color = "rgba(171, 12, 8, 1.0)";
placeholder_text = let
span = "<span foreground='##cccccc' style='italic' size='15pt' allow_breaks='true'>";
mkSpan = s: "${span}${s}</span>";
in
mkSpan "\r$PROMPT";
}
];
labels = [
{
inherit monitor;
text = "$TIME";
font_size = 80;
font_family = "Ubuntu Mono";
position.y = 240;
shadow_passes = 3;
}
{
inherit monitor;
text = "<i> Groovy </i>";
font_family = "Ubuntu Mono";
shadow_passes = 3;
}
];
};
}

View file

@ -14,7 +14,6 @@ in {
../greetd
];
security.pam.services.hyprlock = {};
services.gnome.gnome-keyring.enable = true;
home-manager.users.${mainUser} = let
@ -23,16 +22,14 @@ in {
name = "lock";
runtimeInputs = [
hmCfg.programs.ags.finalPackage
hmCfg.programs.hyprlock.package
];
text = ''
ags -r 'Tablet.setLaptopMode()'
hyprlock
ags -b lockscreen -c ~/.config/ags/lockscreen.js
'';
};
in {
imports = [
./hyprlock.nix
hypridle.homeManagerModules.default
];