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 AstalApps from "gi://AstalApps";
import AstalHyprland from "gi://AstalHyprland"; import AstalHyprland from "gi://AstalHyprland";
const astalApps: AstalApps.Apps = new AstalApps.Apps(); const astalApps: AstalApps.Apps = new AstalApps.Apps();
let appsList: Array<AstalApps.Application> = astalApps.get_list(); let appsList: Array<AstalApps.Application> = astalApps.get_list();
+19 -15
View File
@@ -3,6 +3,7 @@ import { property, register, signal } from "astal/gobject";
import { Gdk } from "astal/gtk3"; import { Gdk } from "astal/gtk3";
import { getDateTime } from "./time"; import { getDateTime } from "./time";
import { makeDirectory } from "./utils"; import { makeDirectory } from "./utils";
import { Notifications } from "./notifications";
export { Recording }; export { Recording };
@@ -130,21 +131,24 @@ class Recording extends GObject.Object {
this.notify("recording"); this.notify("recording");
this.emit("stopped"); this.emit("stopped");
execAsync([ Notifications.getDefault().sendNotification({
"notify-send", "-A", "View", actions: [
"-A", "Open", "-a", "Screen Recording", {
"Screen recording saved", text: "View",
`Saved as ${path}/${output}` onAction: () => {
]).then((stdout: string) => { execAsync(["nautilus", "-s", output!, path]);
stdout = stdout.replaceAll('\n', "").trim(); }
if(stdout.length > 1 || stdout === "") return; },
{
const selected = Number.parseInt(stdout); text: "Open",
if(selected === 0) onAction: () => {
execAsync(["nautilus", "-s", output!, path]); execAsync(["xdg-open", `${path}/${output}`]);
}
if(selected === 1) }
execAsync(["xdg-open", `${path}/${output}`]); ],
appName: "Screen Recording",
summary: "Screen Recording saved",
body: `Saved as ${path}/${output}`
}); });
} }
}; };