ags(scripts/recording): use Notifications.sendNotification()

use new method instead of executing `notify-send` directly, the new method is pretty handy when using notification actions
This commit is contained in:
retrozinndev
2025-05-11 22:09:20 -03:00
parent 0a206ebd8d
commit 2298d91225
2 changed files with 19 additions and 16 deletions
-1
View File
@@ -3,7 +3,6 @@ import { Astal } from "astal/gtk3";
import AstalApps from "gi://AstalApps";
import AstalHyprland from "gi://AstalHyprland";
const astalApps: AstalApps.Apps = new AstalApps.Apps();
let appsList: Array<AstalApps.Application> = astalApps.get_list();
+17 -13
View File
@@ -3,6 +3,7 @@ import { property, register, signal } from "astal/gobject";
import { Gdk } from "astal/gtk3";
import { getDateTime } from "./time";
import { makeDirectory } from "./utils";
import { Notifications } from "./notifications";
export { Recording };
@@ -130,21 +131,24 @@ class Recording extends GObject.Object {
this.notify("recording");
this.emit("stopped");
execAsync([
"notify-send", "-A", "View",
"-A", "Open", "-a", "Screen Recording",
"Screen recording saved",
`Saved as ${path}/${output}`
]).then((stdout: string) => {
stdout = stdout.replaceAll('\n', "").trim();
if(stdout.length > 1 || stdout === "") return;
const selected = Number.parseInt(stdout);
if(selected === 0)
Notifications.getDefault().sendNotification({
actions: [
{
text: "View",
onAction: () => {
execAsync(["nautilus", "-s", output!, path]);
if(selected === 1)
}
},
{
text: "Open",
onAction: () => {
execAsync(["xdg-open", `${path}/${output}`]);
}
}
],
appName: "Screen Recording",
summary: "Screen Recording saved",
body: `Saved as ${path}/${output}`
});
}
};