2024-03-24 20:30:17 -04:00
|
|
|
const { execAsync, subprocess } = Utils;
|
|
|
|
|
|
|
|
const Notifications = await Service.import('notifications');
|
|
|
|
|
|
|
|
const APP_NAME = 'gpu-screen-recorder';
|
|
|
|
const START_APP_ID = 2345;
|
|
|
|
const ICON_NAME = 'nvidia';
|
|
|
|
|
|
|
|
|
|
|
|
class GSR extends Service {
|
|
|
|
static {
|
|
|
|
Service.register(this, {}, {});
|
|
|
|
}
|
|
|
|
|
|
|
|
#appID = START_APP_ID;
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
|
|
|
|
subprocess(
|
|
|
|
['gsr-start'],
|
|
|
|
(path) => {
|
|
|
|
Notifications.getNotification(this.#appID)?.close();
|
|
|
|
|
|
|
|
const notifId = Notifications.Notify(
|
|
|
|
APP_NAME,
|
|
|
|
++this.#appID,
|
|
|
|
ICON_NAME,
|
|
|
|
'Replay Saved',
|
|
|
|
`Saved to ${path}`,
|
2024-07-24 12:04:50 -04:00
|
|
|
['folder', 'Open Folder', 'video', 'Open Video', 'kdenlive', 'Edit in kdenlive'],
|
2024-03-24 20:30:17 -04:00
|
|
|
{},
|
|
|
|
Notifications.popupTimeout,
|
|
|
|
);
|
|
|
|
|
|
|
|
Notifications.getNotification(notifId)?.connect(
|
|
|
|
'invoked',
|
|
|
|
(_, actionId: string) => {
|
|
|
|
if (actionId === 'folder') {
|
|
|
|
execAsync([
|
|
|
|
'xdg-open',
|
|
|
|
path.substring(0, path.lastIndexOf('/')),
|
|
|
|
]).catch(print);
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (actionId === 'video') {
|
|
|
|
execAsync(['xdg-open', path]).catch(print);
|
|
|
|
}
|
2024-07-24 12:04:50 -04:00
|
|
|
|
|
|
|
else if (actionId === 'kdenlive') {
|
|
|
|
execAsync([
|
|
|
|
'bash',
|
|
|
|
'-c',
|
|
|
|
`kdenlive -i ${path}`,
|
|
|
|
]).catch(print);
|
|
|
|
}
|
2024-03-24 20:30:17 -04:00
|
|
|
},
|
|
|
|
);
|
|
|
|
},
|
2024-08-01 12:54:32 -04:00
|
|
|
() => { /**/ },
|
2024-03-24 20:30:17 -04:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
saveReplay() {
|
|
|
|
execAsync(['gpu-save-replay']).then(() => {
|
|
|
|
Notifications.Notify(
|
|
|
|
APP_NAME,
|
|
|
|
this.#appID,
|
|
|
|
ICON_NAME,
|
|
|
|
'Saving Replay',
|
|
|
|
'Last 20 minutes',
|
|
|
|
[],
|
|
|
|
{},
|
|
|
|
Notifications.popupTimeout,
|
|
|
|
);
|
2024-05-01 10:21:28 -04:00
|
|
|
}).catch(console.error);
|
2024-03-24 20:30:17 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-04-07 16:18:43 -04:00
|
|
|
export default GSR;
|