refactor(ags): switch to astal-tray
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2024-07-08 21:15:11 -04:00
parent c6dea3b93d
commit 3412b79c1b
15 changed files with 1799 additions and 3616 deletions

View file

@ -99,6 +99,26 @@
"type": "github" "type": "github"
} }
}, },
"astal-tray": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1719587238,
"narHash": "sha256-6DfK50lMbMLVgqL3IyCe6zMAGnB5V5cTTPsMIf80GVE=",
"owner": "astal-sh",
"repo": "tray",
"rev": "9a484bdee02904034449961612fd5b2cdbe6a337",
"type": "github"
},
"original": {
"owner": "astal-sh",
"repo": "tray",
"type": "github"
}
},
"bat-theme-src": { "bat-theme-src": {
"flake": false, "flake": false,
"locked": { "locked": {
@ -1989,6 +2009,7 @@
"ags": "ags", "ags": "ags",
"arion": "arion", "arion": "arion",
"astal": "astal", "astal": "astal",
"astal-tray": "astal-tray",
"bat-theme-src": "bat-theme-src", "bat-theme-src": "bat-theme-src",
"bazarr-bulk": "bazarr-bulk", "bazarr-bulk": "bazarr-bulk",
"caddy-plugins": "caddy-plugins", "caddy-plugins": "caddy-plugins",

View file

@ -25,6 +25,12 @@
repo = "Astal"; repo = "Astal";
type = "github"; type = "github";
}; };
astal-tray = {
inputs.nixpkgs.follows = "nixpkgs";
owner = "astal-sh";
repo = "tray";
type = "github";
};
bat-theme-src = { bat-theme-src = {
flake = false; flake = false;
owner = "matt1432"; owner = "matt1432";

View file

@ -168,15 +168,20 @@ let
repo = "ags"; repo = "ags";
}; };
astal = mkDep { astal-tray = mkDep {
owner = "Aylur"; owner = "astal-sh";
repo = "Astal"; repo = "tray";
}; };
gtk-session-lock = mkDep { gtk-session-lock = mkDep {
owner = "Cu3PO42"; owner = "Cu3PO42";
repo = "gtk-session-lock"; repo = "gtk-session-lock";
}; };
astal = mkDep {
owner = "Aylur";
repo = "Astal";
};
}; };
}; };

File diff suppressed because it is too large Load diff

View file

@ -7,12 +7,6 @@
"eslint": "^8.52.0", "eslint": "^8.52.0",
"@typescript-eslint/eslint-plugin": "^6.9.1", "@typescript-eslint/eslint-plugin": "^6.9.1",
"@typescript-eslint/parser": "^6.9.1", "@typescript-eslint/parser": "^6.9.1",
"stylelint-config-standard-scss": "^11.0.0", "@stylistic/eslint-plugin": "^1.4.0"
"@stylistic/eslint-plugin": "^1.4.0",
"@girs/dbusmenugtk3-0.4": "^0.4.0-3.2.0",
"@girs/gobject-2.0": "^2.76.1-3.2.3",
"@girs/gtk-3.0": "^3.24.39-3.2.2",
"@girs/gvc-1.0": "^1.0.0-3.1.0",
"@girs/nm-1.0": "^1.43.1-3.1.0"
} }
} }

View file

@ -1,4 +1,6 @@
const SystemTray = await Service.import('systemtray'); import Tray from 'gi://AstalTray?version=0.1';
const SystemTray = Tray.Tray.get_default();
const { timeout } = Utils; const { timeout } = Utils;
const { Box, Icon, MenuItem, MenuBar, Revealer } = Widget; const { Box, Icon, MenuItem, MenuBar, Revealer } = Widget;
@ -8,26 +10,32 @@ import Separator from '../../misc/separator.ts';
const REVEAL_DURATION = 500; const REVEAL_DURATION = 500;
const SPACING = 12; const SPACING = 12;
// Types /* Types */
import { TrayItem } from 'types/service/systemtray.ts'; // FIXME: get types from 'gi://AstalTray'
import type AstalTray from 'types/astal-tray/astaltray-0.1.d.ts';
const SysTrayItem = (item: TrayItem) => { const SysTrayItem = (item: AstalTray.TrayItem) => {
if (item.id === 'spotify-client') { if (item.id === 'spotify-client') {
return; return;
} }
return MenuItem({ return MenuItem({
submenu: item.menu, submenu: item.create_menu(),
tooltip_markup: item.bind('tooltip_markup'),
child: Revealer({ child: Revealer({
transition: 'slide_right', transition: 'slide_right',
transition_duration: REVEAL_DURATION, transition_duration: REVEAL_DURATION,
child: Icon({ size: 24 }).bind('icon', item, 'icon'), child: Icon({
size: 24,
icon: Utils.watch(
item.iconPixbuf || item.iconName || 'image-missing',
item,
() => item.iconPixbuf || item.iconName || 'image-missing',
),
}),
}), }),
}); }).bind('tooltip_markup', item, 'tooltipMarkup');
}; };
const SysTray = () => MenuBar({ const SysTray = () => MenuBar({
@ -36,7 +44,11 @@ const SysTray = () => MenuBar({
setup: (self) => { setup: (self) => {
self self
.hook(SystemTray, (_, id) => { .hook(SystemTray, (_, id) => {
const item = SystemTray.getItem(id); if (!id) {
return;
}
const item = SystemTray.get_item(id);
if (self.attribute.items.has(id) || !item) { if (self.attribute.items.has(id) || !item) {
return; return;
@ -54,10 +66,10 @@ const SysTray = () => MenuBar({
self.show_all(); self.show_all();
w.child.reveal_child = true; w.child.reveal_child = true;
}, 'added') }, 'item_added')
.hook(SystemTray, (_, id) => { .hook(SystemTray, (_, id) => {
if (!self.attribute.items.has(id)) { if (!id || !self.attribute.items.has(id)) {
return; return;
} }
@ -66,7 +78,7 @@ const SysTray = () => MenuBar({
self.attribute.items.get(id).destroy(); self.attribute.items.get(id).destroy();
self.attribute.items.delete(id); self.attribute.items.delete(id);
}); });
}, 'removed'); }, 'item_removed');
}, },
}); });
@ -88,5 +100,5 @@ export default () => {
}), }),
}).hook(SystemTray, (self) => { }).hook(SystemTray, (self) => {
self.reveal_child = systray.get_children().length > 0; self.reveal_child = systray.get_children().length > 0;
}); }, 'item_added');
}; };

View file

@ -1,6 +1,6 @@
{ {
ags, ags,
astal, astal-tray,
config, config,
gtk-session-lock, gtk-session-lock,
lib, lib,
@ -9,29 +9,31 @@
... ...
}: let }: let
inherit (lib) boolToString; inherit (lib) boolToString;
# Configs
inherit (config.vars) mainUser hostName; inherit (config.vars) mainUser hostName;
cfgDesktop = config.roles.desktop; cfgDesktop = config.roles.desktop;
flakeDir = config.environment.variables.FLAKE; flakeDir = config.environment.variables.FLAKE;
isTouchscreen = config.hardware.sensor.iio.enable; isTouchscreen = config.hardware.sensor.iio.enable;
# Packages
astalTray = astal-tray.packages.${pkgs.system}.tray;
gtkSessionLock = gtk-session-lock.packages.${pkgs.system}.default; gtkSessionLock = gtk-session-lock.packages.${pkgs.system}.default;
in { in {
# Enable pam for ags and astal # Enable pam for ags and astal
security.pam.services.ags = {}; security.pam.services.ags = {};
security.pam.services.astal = {};
services.upower.enable = true; services.upower.enable = true;
home-manager.users.${mainUser}.imports = [ home-manager.users.${mainUser}.imports = [
ags.homeManagerModules.default ags.homeManagerModules.default
astal.homeManagerModules.default
({ ({
config, config,
lib, lib,
... ...
}: let }: let
symlink = config.lib.file.mkOutOfStoreSymlink; inherit (config.lib.file) mkOutOfStoreSymlink;
inherit (lib) hasPrefix optionals removePrefix; inherit (lib) hasPrefix optionals removePrefix;
configJs = configJs =
@ -54,17 +56,10 @@ in {
} }
]; ];
# Experimental Gtk4 ags
programs.astal = {
enable = true;
extraPackages = with pkgs; [
libadwaita
];
};
programs.ags = { programs.ags = {
enable = true; enable = true;
extraPackages = [ extraPackages = [
astalTray
gtkSessionLock gtkSessionLock
]; ];
}; };
@ -72,24 +67,24 @@ in {
home = { home = {
file = file =
{ {
# Astal symlinks. ${./astal}, types and config.js # Out of store symlinks
".config/astal".source = symlink "${flakeDir}/modules/ags/astal"; ".config/ags".source = mkOutOfStoreSymlink "${flakeDir}/modules/ags/config";
"${agsConfigDir}/astal/types".source = "${config.programs.astal.finalPackage}/share/io.Aylur.Astal/types";
"${agsConfigDir}/astal/config.js".text = configJs;
# AGS symlinks. ${./config}, types and config.js # Generated types
".config/ags".source = symlink "${flakeDir}/modules/ags/config";
"${agsConfigDir}/config/types" = { "${agsConfigDir}/config/types" = {
source = "${config.programs.ags.finalPackage}/share/com.github.Aylur.ags/types"; source = "${config.programs.ags.finalPackage}/share/com.github.Aylur.ags/types";
recursive = true; recursive = true; # To add other types inside the folder
}; };
"${agsConfigDir}/config/types/gtk-session-lock".source = pkgs.callPackage ./gtk-session-lock-types {inherit gtkSessionLock;}; "${agsConfigDir}/config/types/gtk-session-lock".source =
"${agsConfigDir}/config/config.js".text = configJs; pkgs.callPackage ./third-party-types/lock.nix {inherit gtkSessionLock;};
"${agsConfigDir}/config/types/astal-tray".source =
pkgs.callPackage ./third-party-types/tray.nix {inherit astalTray;};
# Generated JavaScript files
"${agsConfigDir}/config/config.js".text = configJs;
"${agsConfigDir}/config/ts/lockscreen/vars.ts".text = "${agsConfigDir}/config/ts/lockscreen/vars.ts".text =
# javascript # javascript
'' ''
//
export default { export default {
mainMonitor: '${cfgDesktop.mainMonitor}', mainMonitor: '${cfgDesktop.mainMonitor}',
dupeLockscreen: ${boolToString cfgDesktop.displayManager.duplicateScreen}, dupeLockscreen: ${boolToString cfgDesktop.displayManager.duplicateScreen},

File diff suppressed because it is too large Load diff

View file

@ -1,5 +0,0 @@
{
"dependencies": {
"@ts-for-gir/cli": "^3.3.0"
}
}

View file

@ -11,9 +11,9 @@
}: }:
buildNpmPackage { buildNpmPackage {
pname = "gtk-session-lock-types"; pname = "gtk-session-lock-types";
version = "0.0"; inherit (gtkSessionLock) version;
npmDepsHash = "sha256-HtQUmDnq0344Ef8W8jW8idSYGj02q/DB4p/gpmWL3iA="; npmDepsHash = import ./npmDepsHash.nix;
src = ./.; src = ./.;
dontNpmBuild = true; dontNpmBuild = true;

View file

@ -0,0 +1 @@
"sha256-moEiTMb0HC/LOhOaGM6NBi54fisRW5vigsXvFSqURyg="

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,5 @@
{
"dependencies": {
"@ts-for-gir/cli": "^3.3.0"
}
}

View file

@ -0,0 +1,43 @@
{
astalTray,
atk,
buildNpmPackage,
gdk-pixbuf,
glib,
gobject-introspection,
gtk3,
harfbuzz,
libdbusmenu-gtk3,
pango,
...
}:
buildNpmPackage {
pname = "astal-tray-types";
inherit (astalTray) version;
npmDepsHash = import ./npmDepsHash.nix;
src = ./.;
dontNpmBuild = true;
installPhase = ''
npx @ts-for-gir/cli generate ${builtins.concatStringsSep " " [
"-g ${astalTray.dev}/share/gir-1.0"
"-g ${atk.dev}/share/gir-1.0"
"-g ${gdk-pixbuf.dev}/share/gir-1.0"
"-g ${glib.dev}/share/gir-1.0"
"-g ${gobject-introspection.dev}/share/gir-1.0"
"-g ${gtk3.dev}/share/gir-1.0"
"-g ${harfbuzz.dev}/share/gir-1.0"
"-g ${libdbusmenu-gtk3}/share/gir-1.0"
"-g ${pango.dev}/share/gir-1.0"
"--ignoreVersionConflicts"
]} -e gjs -o ./types
mkdir -p $out
cp ./types/astaltray* $out/
substituteInPlace $out/astaltray* --replace-warn \
"from '." "from '@girs"
'';
}