feat(ags): update to official agsV2
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2024-11-13 19:39:01 -05:00
parent 5d27b3d975
commit f3e06554e4
105 changed files with 233 additions and 240 deletions

View file

@ -4,9 +4,9 @@
You might find it weird that most of my config is written in TypeScript.
That's because all my desktops run
[AGSv2](https://github.com/Aylur/ags/tree/v2)
[AGS](https://github.com/Aylur/ags)
for UI. Click on
[this](https://git.nelim.org/matt1432/nixos-configs/src/branch/master/nixosModules/ags-v2)
[this](https://git.nelim.org/matt1432/nixos-configs/src/branch/master/nixosModules/ags)
to see my configuration.
I'm also a victim of Stockholm syndrome at this point and make my scripts

View file

@ -17,7 +17,7 @@ This directory encompasses every device's main configuration file.
## Global Vars
In every device's `default.nix`, you'll find these [settings](https://git.nelim.org/matt1432/nixos-configs/src/branch/master/common/vars.nix)
In every device's `default.nix`, you'll find these [settings](https://git.nelim.org/matt1432/nixos-configs/src/branch/master/common/vars/default.nix)
```nix
# $FLAKE/devices/<name>/default.nix

View file

@ -61,7 +61,7 @@ in {
roles.desktop = {
user = mainUser;
ags-v2.enable = true;
ags.enable = true;
mainMonitor = "desc:GIGA-BYTE TECHNOLOGY CO. LTD. G27QC 0x00000B1D";
displayManager.duplicateScreen = false;

View file

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

Binary file not shown.

BIN
flake.nix

Binary file not shown.

View file

@ -160,19 +160,18 @@ let
};
agsInputs = {
agsV2 = mkDep {
owner = "Aylur";
repo = "ags";
ref = "v2";
inputs.astal.follows = "astal";
};
astal = mkDep {
owner = "Aylur";
repo = "astal";
};
ags = mkDep {
owner = "Aylur";
repo = "ags";
inputs.astal.follows = "astal";
};
gtk-session-lock = mkDep {
owner = "Cu3PO42";
repo = "gtk-session-lock";

View file

@ -8,4 +8,4 @@ This directory encompasses every derivation scopes for packages exposed by my fl
| --------------- | ----------- |
| `dracula` | Themes for many apps from the [Dracula GitHub Org](https://github.com/dracula) |
| `firefoxAddons` | Firefox extensions updated with [mozilla-addons-to-nix](https://git.sr.ht/~rycee/mozilla-addons-to-nix) |
| `mpvScripts` | MPV scripts that I use that are not in nixpkgs |
| `mpvScripts` | MPV scripts I use that are not in nixpkgs |

View file

@ -1,38 +0,0 @@
self: {
config,
lib,
...
}: {
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

@ -1,150 +0,0 @@
{
self,
agsConfigDir,
}: {
lib,
osConfig,
pkgs,
...
}: let
# Inputs
inherit (self.inputs) agsV2 gtk-session-lock;
# Libs
inherit (lib) attrValues boolToString optionals removeAttrs;
# Cfg info
inherit (osConfig.networking) hostName;
cfgDesktop = osConfig.roles.desktop;
fullConfPath = "/home/${cfgDesktop.user}/${agsConfigDir}";
# Astal libraries
gtkSessionLock = gtk-session-lock.packages.${pkgs.system}.default;
agsV2Packages = agsV2.packages.${pkgs.system};
astalLibs = attrValues (removeAttrs agsV2.inputs.astal.packages.${pkgs.system} ["docs" "gjs"]) ++ [gtkSessionLock];
# Final ags package
agsFull = agsV2Packages.ags.override {extraPackages = astalLibs;};
in {
options.programs.ags-v2 = {
package = lib.mkOption {
type = with lib.types; nullOr package;
default = null;
};
lockPkg = lib.mkOption {
type = with lib.types; nullOr package;
default = null;
};
};
config = {
# Make these accessible outside these files
programs.ags-v2 = {
package = agsFull;
lockPkg = pkgs.writeShellApplication {
name = "lock";
runtimeInputs = [agsFull];
text = ''
export CONF="lock"
if [ "$#" == 0 ]; then
exec ags run ${fullConfPath}
else
exec ags "$@" -i lock
fi
'';
};
};
home = {
packages =
[
(pkgs.writeShellApplication {
name = "ags";
runtimeInputs = [agsFull];
text = ''
export CONF="${hostName}"
if [ "$#" == 0 ]; then
exec ags run ${fullConfPath}
else
exec ags "$@"
fi
'';
})
(pkgs.writeShellApplication {
name = "agsConf";
runtimeInputs = [agsFull];
text = ''
export CONF="$1"
exec ${agsFull}/bin/ags run ${fullConfPath}
'';
})
]
++ (builtins.attrValues {
inherit
(pkgs)
playerctl
pavucontrol # TODO: replace with ags widget
;
})
++ (optionals cfgDesktop.isTouchscreen (builtins.attrValues {
inherit
(pkgs)
ydotool
;
}));
file = let
inherit
(import "${self}/lib" {inherit pkgs self;})
buildNodeModules
buildGirTypes
;
in (
(buildGirTypes {
pname = "agsV2";
configPath = "${agsConfigDir}/@girs";
packages = astalLibs;
})
// {
"${agsConfigDir}/node_modules".source =
buildNodeModules ./config "sha256-cyVdjRV1o/UvAPzXigNzXATq1mRmsXhDqnG4wnBzSXE=";
"${agsConfigDir}/tsconfig.json".source = pkgs.writers.writeJSON "tsconfig.json" {
"$schema" = "https://json.schemastore.org/tsconfig";
"compilerOptions" = {
"experimentalDecorators" = true;
"strict" = true;
"target" = "ES2023";
"moduleResolution" = "Bundler";
"jsx" = "react-jsx";
"jsxImportSource" = "${agsV2Packages.gjs}/share/astal/gjs/gtk3";
"paths" = {
"astal" = ["${agsV2Packages.gjs}/share/astal/gjs"];
"astal/*" = ["${agsV2Packages.gjs}/share/astal/gjs/*"];
};
"skipLibCheck" = true;
"module" = "ES2022";
"lib" = ["ES2023"];
};
};
"${agsConfigDir}/widgets/lockscreen/vars.ts".text =
# javascript
''
export default {
mainMonitor: '${cfgDesktop.mainMonitor}',
dupeLockscreen: ${boolToString cfgDesktop.displayManager.duplicateScreen},
hasFprintd: ${boolToString (hostName == "wim")},
};
'';
}
);
};
};
# For accurate stack trace
_file = ./default.nix;
}

View file

@ -1 +0,0 @@
# Moving to [AGSv2](https://github.com/Aylur/ags/tree/v2)

View file

@ -80,13 +80,11 @@ export const hyprMessage = (message: string) => new Promise<string>((
}
});
export const centerCursor = async(): Promise<void> => {
export const centerCursor = (): void => {
let x: number;
let y: number;
const monitor = (JSON.parse(await hyprMessage('j/monitors')) as AstalHyprland.Monitor[])
.find((m) => m.focused) as AstalHyprland.Monitor;
const monitor = Hyprland.get_monitors().find((m) => m.focused) as AstalHyprland.Monitor;
// @ts-expect-error this should be good
switch (monitor.transform) {
case 1:
x = monitor.x - (monitor.height / 2);
@ -109,7 +107,7 @@ export const centerCursor = async(): Promise<void> => {
break;
}
await hyprMessage(`dispatch movecursor ${x} ${y}`);
hyprMessage(`dispatch movecursor ${x} ${y}`);
};
export const closeAll = () => {

View file

@ -1,5 +1,5 @@
{
"name": "ags-v2",
"name": "ags",
"version": "0.0.0",
"main": "app.ts",
"dependencies": {
@ -7,7 +7,7 @@
"@stylistic/eslint-plugin": "2.10.1",
"@types/node": "22.9.0",
"eslint": "9.14.0",
"eslint-plugin-jsdoc": "50.4.3",
"eslint-plugin-jsdoc": "50.5.0",
"fzf": "0.5.2",
"jiti": "2.4.0",
"typescript-eslint": "8.14.0"

View file

@ -2,10 +2,9 @@ import { App, Astal, Gtk, Widget } from 'astal/gtk3';
import { property, register } from 'astal/gobject';
import { Binding, idle } from 'astal';
import { hyprMessage } from '../../lib';
import { get_hyprland_monitor, hyprMessage } from '../../lib';
/* Types */
import AstalHyprland from 'gi://AstalHyprland';
type CloseType = 'none' | 'stay' | 'released' | 'clicked';
type HyprTransition = 'slide' | 'slide top' | 'slide bottom' | 'slide left' |
'slide right' | 'popin' | 'fade';
@ -88,15 +87,7 @@ export class PopupWindow extends Widget.Window {
const monitor = this.gdkmonitor ??
this.get_display().get_monitor_at_point(alloc.x, alloc.y);
// FIXME: switch back to this when it's fixed upstream
// const transform = get_hyprland_monitor(monitor)?.transform;
const manufacturer = monitor.manufacturer?.replace(',', '');
const model = monitor.model?.replace(',', '');
const start = `${manufacturer} ${model}`;
const transform = (JSON.parse(await hyprMessage('j/monitors')) as AstalHyprland.Monitor[])
// @ts-expect-error this will be fixed soon
.find((m) => m.description?.startsWith(start))?.transform;
const transform = get_hyprland_monitor(monitor)?.transform;
let width: number;

View file

@ -0,0 +1,62 @@
self: {
config,
lib,
...
}: let
inherit (lib) hasPrefix mkIf removePrefix;
# Configs
cfgDesktop = config.roles.desktop;
flakeDir = config.environment.variables.FLAKE;
agsConfigDir = "${removePrefix "/home/${cfgDesktop.user}/" flakeDir}/nixosModules/ags/config";
hmOpts = {lib, ...}: {
options.programs.ags = {
package = lib.mkOption {
type = with lib.types; nullOr package;
default = null;
};
astalLibs = lib.mkOption {
type = with lib.types; nullOr (listOf package);
default = null;
};
lockPkg = lib.mkOption {
type = with lib.types; nullOr package;
default = null;
};
configDir = lib.mkOption {
type = lib.types.str;
default = agsConfigDir;
};
};
};
in {
config = mkIf cfgDesktop.ags.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 = [
hmOpts
(import ./packages.nix self)
./hyprland.nix
];
};
# For accurate stack trace
_file = ./default.nix;
}

View file

@ -0,0 +1,137 @@
self: {
config,
lib,
osConfig,
pkgs,
...
}: let
inherit (self.inputs) ags gtk-session-lock;
inherit (lib) attrValues boolToString optionals removeAttrs;
inherit (osConfig.networking) hostName;
cfg = config.programs.ags;
cfgDesktop = osConfig.roles.desktop;
in {
config = {
# Make these accessible outside these files
programs.ags = {
package = ags.packages.${pkgs.system}.ags.override {
extraPackages = cfg.astalLibs;
};
astalLibs =
attrValues (
removeAttrs ags.inputs.astal.packages.${pkgs.system} ["docs" "gjs"]
)
++ [gtk-session-lock.packages.${pkgs.system}.default];
lockPkg = pkgs.writeShellApplication {
name = "lock";
runtimeInputs = [cfg.package];
text = ''
export CONF="lock"
if [ "$#" == 0 ]; then
exec ags run ~/${cfg.configDir}
else
exec ags "$@" -i lock
fi
'';
};
};
home = {
packages =
[
(pkgs.writeShellApplication {
name = "ags";
runtimeInputs = [cfg.package];
text = ''
export CONF="${hostName}"
if [ "$#" == 0 ]; then
exec ags run ~/${cfg.configDir}
else
exec ags "$@"
fi
'';
})
(pkgs.writeShellApplication {
name = "agsConf";
runtimeInputs = [cfg.package];
text = ''
export CONF="$1"
exec ${cfg.package}/bin/ags run ~/${cfg.configDir}
'';
})
]
++ (builtins.attrValues {
inherit
(pkgs)
playerctl
pavucontrol # TODO: replace with ags widget
;
})
++ (optionals cfgDesktop.isTouchscreen (builtins.attrValues {
inherit
(pkgs)
ydotool
;
}));
file = let
inherit
(import "${self}/lib" {inherit pkgs self;})
buildNodeModules
buildGirTypes
;
in (
(buildGirTypes {
pname = "ags";
configPath = "${cfg.configDir}/@girs";
packages = cfg.astalLibs;
})
// {
"${cfg.configDir}/node_modules".source =
buildNodeModules ./config "sha256-DtrSplIOSudRgBCfKsDAtok0/21xzHiTJNrKLYy4mfY=";
"${cfg.configDir}/tsconfig.json".source = let
inherit (ags.packages.${pkgs.system}) gjs;
in
pkgs.writers.writeJSON "tsconfig.json" {
"$schema" = "https://json.schemastore.org/tsconfig";
"compilerOptions" = {
"experimentalDecorators" = true;
"strict" = true;
"target" = "ES2023";
"moduleResolution" = "Bundler";
"jsx" = "react-jsx";
"jsxImportSource" = "${gjs}/share/astal/gjs/gtk3";
"paths" = {
"astal" = ["${gjs}/share/astal/gjs"];
"astal/*" = ["${gjs}/share/astal/gjs/*"];
};
"skipLibCheck" = true;
"module" = "ES2022";
"lib" = ["ES2023"];
};
};
"${cfg.configDir}/widgets/lockscreen/vars.ts".text =
# javascript
''
export default {
mainMonitor: '${cfgDesktop.mainMonitor}',
dupeLockscreen: ${boolToString cfgDesktop.displayManager.duplicateScreen},
hasFprintd: ${boolToString (hostName == "wim")},
};
'';
}
);
};
};
# For accurate stack trace
_file = ./default.nix;
}

Some files were not shown because too many files have changed in this diff Show more