✨ 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 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();
|
||||||
|
|
||||||
|
|||||||
+17
-13
@@ -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) => {
|
|
||||||
stdout = stdout.replaceAll('\n', "").trim();
|
|
||||||
if(stdout.length > 1 || stdout === "") return;
|
|
||||||
|
|
||||||
const selected = Number.parseInt(stdout);
|
|
||||||
if(selected === 0)
|
|
||||||
execAsync(["nautilus", "-s", output!, path]);
|
execAsync(["nautilus", "-s", output!, path]);
|
||||||
|
}
|
||||||
if(selected === 1)
|
},
|
||||||
|
{
|
||||||
|
text: "Open",
|
||||||
|
onAction: () => {
|
||||||
execAsync(["xdg-open", `${path}/${output}`]);
|
execAsync(["xdg-open", `${path}/${output}`]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
appName: "Screen Recording",
|
||||||
|
summary: "Screen Recording saved",
|
||||||
|
body: `Saved as ${path}/${output}`
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user