✨ 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:
@@ -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
@@ -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}`
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user