feat(agsV2): separate from agsV1
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2024-10-30 23:43:37 -04:00
parent 1fc5a48bf9
commit f522c984c4
64 changed files with 182 additions and 50 deletions

View file

@ -71,7 +71,7 @@ in {
roles.desktop = { roles.desktop = {
user = mainUser; user = mainUser;
ags.enable = true; ags-v2.enable = true;
mainMonitor = "eDP-1"; mainMonitor = "eDP-1";
isLaptop = true; isLaptop = true;
isTouchscreen = true; isTouchscreen = true;

View file

@ -1,3 +1,4 @@
import { execAsync } from 'astal';
import { App } from 'astal/gtk3'; import { App } from 'astal/gtk3';
import GLib from 'gi://GLib'; import GLib from 'gi://GLib';
@ -56,6 +57,8 @@ switch (CONF) {
}, },
main: () => { main: () => {
execAsync('hyprpaper').catch(print);
AppLauncher(); AppLauncher();
Bar(); Bar();
BgFade(); BgFade();
@ -74,6 +77,10 @@ switch (CONF) {
caps: 'input1::capslock', caps: 'input1::capslock',
}); });
new MonitorClicks(); new MonitorClicks();
setTimeout(() => {
App.get_window('win-applauncher')?.set_visible(true);
}, 3 * 1000);
}, },
}); });

View file

@ -0,0 +1,39 @@
self: {
config,
lib,
pkgs,
...
}: {
config = let
inherit (lib) hasPrefix mkIf removePrefix;
# Configs
cfgDesktop = config.roles.desktop;
flakeDir = config.environment.variables.FLAKE;
agsConfigDir = "${removePrefix "/home/${cfgDesktop.user}/" flakeDir}/nixosModules/ags-v2/config";
in
mkIf cfgDesktop.ags-v2.enable {
assertions = [
{
assertion = hasPrefix "/home/${cfgDesktop.user}/" flakeDir;
message = ''
Your $FLAKE environment variable needs to point to a directory in
the main users' home to use the AGS module.
'';
}
];
# Machine config
security.pam.services.astal-auth = {};
services.upower.enable = true;
home-manager.users.${cfgDesktop.user}.imports = [
(import ./packages.nix {inherit self agsConfigDir;})
./hyprland.nix
];
};
# For accurate stack trace
_file = ./default.nix;
}

View file

@ -0,0 +1,46 @@
{...}: {
wayland.windowManager.hyprland = {
settings = {
animations = {
bezier = [
"easeInOutQuart, 0.77, 0 , 0.175, 1"
"easeInExpo , 0.95, 0.05, 0.795, 0.035"
];
animation = [
"fadeLayersIn , 0"
"fadeLayersOut, 1, 3000, easeInExpo"
"layers , 1, 4 , easeInOutQuart, slide left"
];
};
layerrule = [
"noanim, ^(?!win-).*"
# Lockscreen blur
"blur, ^(blur-bg.*)"
"ignorealpha 0.19, ^(blur-bg.*)"
];
exec-once = ["ags"];
bind = [
"$mainMod SHIFT, E , exec, ags -t win-powermenu"
"$mainMod , D , exec, ags -t win-applauncher"
"$mainMod , V , exec, ags -t win-clipboard"
" , Print, exec, ags -t win-screenshot"
];
binde = [
## Brightness control
", XF86MonBrightnessUp , exec, ags -m 'Brightness.screen += 0.05'"
", XF86MonBrightnessDown, exec, ags -m 'Brightness.screen -= 0.05'"
## Volume control
", XF86AudioRaiseVolume , exec, wpctl set-volume -l 1 @DEFAULT_AUDIO_SINK@ 5%+ & ags -m 'popup_osd(\"speaker\")' &"
", XF86AudioLowerVolume , exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%- & ags -m 'popup_osd(\"speaker\")' &"
];
bindn = [" , Escape , exec, ags -m 'closeAll()'"];
bindr = ["CAPS, Caps_Lock, exec, ags -m 'Brightness.fetchCapsState()'"];
};
};
}

View file

@ -1,41 +1,75 @@
self: { {
self,
agsConfigDir,
}: {
lib, lib,
osConfig, osConfig,
pkgs, pkgs,
... ...
}: { }: {
options.programs.ags-v2.lockPkg = lib.mkOption {
type = with lib.types; nullOr package;
default = null;
};
config = let config = let
inherit (lib) attrValues boolToString removeAttrs; # Inputs
inherit (osConfig.vars) hostName;
cfgDesktop = osConfig.roles.desktop;
inherit (self.inputs) agsV2 gtk-session-lock; inherit (self.inputs) agsV2 gtk-session-lock;
gtkSessionLock = gtk-session-lock.packages.${pkgs.system}.default; # Libs
inherit (lib) attrValues boolToString optionals removeAttrs;
# Cfg info
inherit (osConfig.networking) hostName;
cfgDesktop = osConfig.roles.desktop;
# Astal libraries
gtkSessionLock = gtk-session-lock.packages.${pkgs.system}.default;
agsV2Packages = agsV2.packages.${pkgs.system}; agsV2Packages = agsV2.packages.${pkgs.system};
astalLibs = attrValues (removeAttrs agsV2.inputs.astal.packages.${pkgs.system} ["docs" "gjs"]) ++ [gtkSessionLock]; astalLibs = attrValues (removeAttrs agsV2.inputs.astal.packages.${pkgs.system} ["docs" "gjs"]) ++ [gtkSessionLock];
# Final ags package
agsFull = agsV2Packages.ags.override {extraPackages = astalLibs;}; agsFull = agsV2Packages.ags.override {extraPackages = astalLibs;};
configDir = "/home/matt/.nix/nixosModules/ags/v2";
in { in {
programs.ags-v2.lockPkg = pkgs.writeShellApplication {
name = "lock";
text = ''
export CONF="lock"
exec ${agsFull}/bin/ags --config ${agsConfigDir} "$@"
'';
};
home = { home = {
packages = [ packages =
(pkgs.writeShellApplication { [
name = "agsV2"; (pkgs.writeShellApplication {
text = '' name = "ags";
export CONF="wim" text = ''
exec ${agsFull}/bin/ags --config ${configDir} "$@" export CONF="${hostName}"
''; exec ${agsFull}/bin/ags --config ${agsConfigDir} "$@"
'';
})
(pkgs.writeShellApplication {
name = "agsConf";
text = ''
export CONF="$1"
exec ${agsFull}/bin/ags --config ${agsConfigDir}
'';
})
]
++ (builtins.attrValues {
inherit
(pkgs)
playerctl
pavucontrol # TODO: replace with ags widget
;
}) })
(pkgs.writeShellApplication { ++ (optionals cfgDesktop.isTouchscreen (builtins.attrValues {
name = "agsConf"; inherit
text = '' (pkgs)
export CONF="$1" ydotool
exec ${agsFull}/bin/ags --config ${configDir} ;
''; }));
})
];
file = let file = let
inherit inherit
@ -46,14 +80,14 @@ self: {
in ( in (
(buildNodeTypes { (buildNodeTypes {
pname = "agsV2"; pname = "agsV2";
configPath = "${configDir}/@girs"; configPath = "${agsConfigDir}/@girs";
packages = astalLibs; packages = astalLibs;
}) })
// { // {
"${configDir}/node_modules".source = "${agsConfigDir}/node_modules".source =
buildNodeModules ./. "sha256-pK9S6qUjTIL0JDegYJlHSY5XEpLFKfA98MfZ59Q3IL4="; buildNodeModules ./config "sha256-pK9S6qUjTIL0JDegYJlHSY5XEpLFKfA98MfZ59Q3IL4=";
"${configDir}/tsconfig.json".source = pkgs.writers.writeJSON "tsconfig.json" { "${agsConfigDir}/tsconfig.json".source = pkgs.writers.writeJSON "tsconfig.json" {
"$schema" = "https://json.schemastore.org/tsconfig"; "$schema" = "https://json.schemastore.org/tsconfig";
"compilerOptions" = { "compilerOptions" = {
"experimentalDecorators" = true; "experimentalDecorators" = true;
@ -72,7 +106,7 @@ self: {
}; };
}; };
"${configDir}/widgets/lockscreen/vars.ts".text = "${agsConfigDir}/widgets/lockscreen/vars.ts".text =
# javascript # javascript
'' ''
export default { export default {

View file

@ -19,10 +19,7 @@ in {
gtkSessionLock = gtk-session-lock.packages.${pkgs.system}.default; gtkSessionLock = gtk-session-lock.packages.${pkgs.system}.default;
in in
mkIf cfgDesktop.ags.enable { mkIf cfgDesktop.ags.enable {
# Enable pam for ags
security.pam.services.ags = {}; security.pam.services.ags = {};
security.pam.services.astal-auth = {};
services.upower.enable = true; services.upower.enable = true;
home-manager.users.${cfgDesktop.user}.imports = [ home-manager.users.${cfgDesktop.user}.imports = [
@ -59,8 +56,6 @@ in {
} }
]; ];
imports = [(import ./v2 self)];
programs.ags = { programs.ags = {
enable = true; enable = true;
extraPackages = [ extraPackages = [

View file

@ -44,6 +44,14 @@ in {
''; '';
}; };
ags-v2.enable = mkOption {
type = types.bool;
default = false;
description = ''
Whether we want to enable AGSv2 for the DE shell.
'';
};
mainMonitor = mkOption { mainMonitor = mkOption {
type = types.str; type = types.str;
description = '' description = ''

View file

@ -8,6 +8,7 @@ self: {
in { in {
imports = [ imports = [
(import ../../ags self) (import ../../ags self)
(import ../../ags-v2 self)
./modules/dconf.nix ./modules/dconf.nix
./modules/printer.nix ./modules/printer.nix

View file

@ -10,14 +10,26 @@
cfg = config.roles.desktop; cfg = config.roles.desktop;
hmCfg = config.home-manager.users.${cfg.user}; hmCfg = config.home-manager.users.${cfg.user};
agsPkg = hmCfg.programs.ags.finalPackage;
hyprPkg = hmCfg.wayland.windowManager.hyprland.finalPackage; hyprPkg = hmCfg.wayland.windowManager.hyprland.finalPackage;
lockPkg =
if cfg.ags.enable
then
pkgs.writeShellApplication {
name = "lock";
runtimeInputs = [hmCfg.programs.ags.finalPackage];
text = ''
ags -r 'Tablet.setLaptopMode()'
ags -b lockscreen -c /home/${cfg.user}/.config/ags/lockscreen.js
'';
}
else hmCfg.programs.ags-v2.lockPkg;
runInDesktop = pkgs.writeShellApplication { runInDesktop = pkgs.writeShellApplication {
name = "runInDesktop"; name = "runInDesktop";
runtimeInputs = [ runtimeInputs = [
pkgs.sudo pkgs.sudo
agsPkg
hyprPkg hyprPkg
]; ];
@ -38,18 +50,6 @@
done done
''; '';
}; };
lockPkg = pkgs.writeShellApplication {
name = "lock";
runtimeInputs = [
agsPkg
];
text = ''
ags -r 'Tablet.setLaptopMode()'
ags -b lockscreen -c /home/${cfg.user}/.config/ags/lockscreen.js
'';
};
in { in {
services.acpid = mkIf cfg.isLaptop { services.acpid = mkIf cfg.isLaptop {
enable = true; enable = true;
@ -62,7 +62,7 @@
case "$state" in case "$state" in
*open*) *open*)
${getExe runInDesktop} "ags -b lockscreen -r 'authFinger()'" ${getExe runInDesktop} "${getExe lockPkg} -m 'authFinger()'"
;; ;;
*close*) *close*)

View file

@ -29,7 +29,9 @@ in {
home-manager.users.${cfg.user}.home.file = let home-manager.users.${cfg.user}.home.file = let
flakeDir = config.environment.variables.FLAKE; flakeDir = config.environment.variables.FLAKE;
modulesDir = "${lib.removePrefix "/home/${cfg.user}/" flakeDir}/nixosModules"; modulesDir = "${lib.removePrefix "/home/${cfg.user}/" flakeDir}/nixosModules";
nodeModules = config.home-manager.users.${cfg.user}.home.file."${modulesDir}/ags/config/node_modules".source; nodeModules =
config.home-manager.users.${cfg.user}.home.file."${modulesDir}/ags/config/node_modules".source
or config.home-manager.users.${cfg.user}.home.file."${modulesDir}/ags-v2/config/node_modules".source;
in { in {
"${modulesDir}/desktop/manager/ags/node_modules".source = nodeModules; "${modulesDir}/desktop/manager/ags/node_modules".source = nodeModules;
}; };