refactor(ags): switch to astal-tray
All checks were successful
Discord / discord commits (push) Has been skipped
All checks were successful
Discord / discord commits (push) Has been skipped
This commit is contained in:
parent
c6dea3b93d
commit
3412b79c1b
15 changed files with 104 additions and 54 deletions
BIN
flake.lock
BIN
flake.lock
Binary file not shown.
BIN
flake.nix
BIN
flake.nix
Binary file not shown.
11
inputs.nix
11
inputs.nix
|
@ -168,15 +168,20 @@ let
|
|||
repo = "ags";
|
||||
};
|
||||
|
||||
astal = mkDep {
|
||||
owner = "Aylur";
|
||||
repo = "Astal";
|
||||
astal-tray = mkDep {
|
||||
owner = "astal-sh";
|
||||
repo = "tray";
|
||||
};
|
||||
|
||||
gtk-session-lock = mkDep {
|
||||
owner = "Cu3PO42";
|
||||
repo = "gtk-session-lock";
|
||||
};
|
||||
|
||||
astal = mkDep {
|
||||
owner = "Aylur";
|
||||
repo = "Astal";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
|
BIN
modules/ags/config/package-lock.json
generated
BIN
modules/ags/config/package-lock.json
generated
Binary file not shown.
|
@ -7,12 +7,6 @@
|
|||
"eslint": "^8.52.0",
|
||||
"@typescript-eslint/eslint-plugin": "^6.9.1",
|
||||
"@typescript-eslint/parser": "^6.9.1",
|
||||
"stylelint-config-standard-scss": "^11.0.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"
|
||||
"@stylistic/eslint-plugin": "^1.4.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 { Box, Icon, MenuItem, MenuBar, Revealer } = Widget;
|
||||
|
@ -8,26 +10,32 @@ import Separator from '../../misc/separator.ts';
|
|||
const REVEAL_DURATION = 500;
|
||||
const SPACING = 12;
|
||||
|
||||
// Types
|
||||
import { TrayItem } from 'types/service/systemtray.ts';
|
||||
/* Types */
|
||||
// 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') {
|
||||
return;
|
||||
}
|
||||
|
||||
return MenuItem({
|
||||
submenu: item.menu,
|
||||
tooltip_markup: item.bind('tooltip_markup'),
|
||||
|
||||
submenu: item.create_menu(),
|
||||
child: Revealer({
|
||||
transition: 'slide_right',
|
||||
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({
|
||||
|
@ -36,7 +44,11 @@ const SysTray = () => MenuBar({
|
|||
setup: (self) => {
|
||||
self
|
||||
.hook(SystemTray, (_, id) => {
|
||||
const item = SystemTray.getItem(id);
|
||||
if (!id) {
|
||||
return;
|
||||
}
|
||||
|
||||
const item = SystemTray.get_item(id);
|
||||
|
||||
if (self.attribute.items.has(id) || !item) {
|
||||
return;
|
||||
|
@ -54,10 +66,10 @@ const SysTray = () => MenuBar({
|
|||
self.show_all();
|
||||
|
||||
w.child.reveal_child = true;
|
||||
}, 'added')
|
||||
}, 'item_added')
|
||||
|
||||
.hook(SystemTray, (_, id) => {
|
||||
if (!self.attribute.items.has(id)) {
|
||||
if (!id || !self.attribute.items.has(id)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -66,7 +78,7 @@ const SysTray = () => MenuBar({
|
|||
self.attribute.items.get(id).destroy();
|
||||
self.attribute.items.delete(id);
|
||||
});
|
||||
}, 'removed');
|
||||
}, 'item_removed');
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -88,5 +100,5 @@ export default () => {
|
|||
}),
|
||||
}).hook(SystemTray, (self) => {
|
||||
self.reveal_child = systray.get_children().length > 0;
|
||||
});
|
||||
}, 'item_added');
|
||||
};
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
ags,
|
||||
astal,
|
||||
astal-tray,
|
||||
config,
|
||||
gtk-session-lock,
|
||||
lib,
|
||||
|
@ -9,29 +9,31 @@
|
|||
...
|
||||
}: let
|
||||
inherit (lib) boolToString;
|
||||
|
||||
# Configs
|
||||
inherit (config.vars) mainUser hostName;
|
||||
cfgDesktop = config.roles.desktop;
|
||||
|
||||
flakeDir = config.environment.variables.FLAKE;
|
||||
isTouchscreen = config.hardware.sensor.iio.enable;
|
||||
|
||||
# Packages
|
||||
astalTray = astal-tray.packages.${pkgs.system}.tray;
|
||||
gtkSessionLock = gtk-session-lock.packages.${pkgs.system}.default;
|
||||
in {
|
||||
# Enable pam for ags and astal
|
||||
security.pam.services.ags = {};
|
||||
security.pam.services.astal = {};
|
||||
|
||||
services.upower.enable = true;
|
||||
|
||||
home-manager.users.${mainUser}.imports = [
|
||||
ags.homeManagerModules.default
|
||||
astal.homeManagerModules.default
|
||||
|
||||
({
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
symlink = config.lib.file.mkOutOfStoreSymlink;
|
||||
inherit (config.lib.file) mkOutOfStoreSymlink;
|
||||
inherit (lib) hasPrefix optionals removePrefix;
|
||||
|
||||
configJs =
|
||||
|
@ -54,17 +56,10 @@ in {
|
|||
}
|
||||
];
|
||||
|
||||
# Experimental Gtk4 ags
|
||||
programs.astal = {
|
||||
enable = true;
|
||||
extraPackages = with pkgs; [
|
||||
libadwaita
|
||||
];
|
||||
};
|
||||
|
||||
programs.ags = {
|
||||
enable = true;
|
||||
extraPackages = [
|
||||
astalTray
|
||||
gtkSessionLock
|
||||
];
|
||||
};
|
||||
|
@ -72,24 +67,24 @@ in {
|
|||
home = {
|
||||
file =
|
||||
{
|
||||
# Astal symlinks. ${./astal}, types and config.js
|
||||
".config/astal".source = symlink "${flakeDir}/modules/ags/astal";
|
||||
"${agsConfigDir}/astal/types".source = "${config.programs.astal.finalPackage}/share/io.Aylur.Astal/types";
|
||||
"${agsConfigDir}/astal/config.js".text = configJs;
|
||||
# Out of store symlinks
|
||||
".config/ags".source = mkOutOfStoreSymlink "${flakeDir}/modules/ags/config";
|
||||
|
||||
# AGS symlinks. ${./config}, types and config.js
|
||||
".config/ags".source = symlink "${flakeDir}/modules/ags/config";
|
||||
# Generated types
|
||||
"${agsConfigDir}/config/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/config.js".text = configJs;
|
||||
"${agsConfigDir}/config/types/gtk-session-lock".source =
|
||||
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 =
|
||||
# javascript
|
||||
''
|
||||
//
|
||||
export default {
|
||||
mainMonitor: '${cfgDesktop.mainMonitor}',
|
||||
dupeLockscreen: ${boolToString cfgDesktop.displayManager.duplicateScreen},
|
||||
|
|
BIN
modules/ags/gtk-session-lock-types/package-lock.json
generated
BIN
modules/ags/gtk-session-lock-types/package-lock.json
generated
Binary file not shown.
|
@ -1,5 +0,0 @@
|
|||
{
|
||||
"dependencies": {
|
||||
"@ts-for-gir/cli": "^3.3.0"
|
||||
}
|
||||
}
|
|
@ -11,9 +11,9 @@
|
|||
}:
|
||||
buildNpmPackage {
|
||||
pname = "gtk-session-lock-types";
|
||||
version = "0.0";
|
||||
inherit (gtkSessionLock) version;
|
||||
|
||||
npmDepsHash = "sha256-HtQUmDnq0344Ef8W8jW8idSYGj02q/DB4p/gpmWL3iA=";
|
||||
npmDepsHash = import ./npmDepsHash.nix;
|
||||
|
||||
src = ./.;
|
||||
dontNpmBuild = true;
|
1
modules/ags/third-party-types/npmDepsHash.nix
Normal file
1
modules/ags/third-party-types/npmDepsHash.nix
Normal file
|
@ -0,0 +1 @@
|
|||
"sha256-moEiTMb0HC/LOhOaGM6NBi54fisRW5vigsXvFSqURyg="
|
BIN
modules/ags/third-party-types/package-lock.json
generated
Normal file
BIN
modules/ags/third-party-types/package-lock.json
generated
Normal file
Binary file not shown.
5
modules/ags/third-party-types/package.json
Normal file
5
modules/ags/third-party-types/package.json
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"dependencies": {
|
||||
"@ts-for-gir/cli": "^3.3.0"
|
||||
}
|
||||
}
|
43
modules/ags/third-party-types/tray.nix
Normal file
43
modules/ags/third-party-types/tray.nix
Normal 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"
|
||||
'';
|
||||
}
|
Loading…
Reference in a new issue