diff --git a/devices/binto/modules/gpu-replay.nix b/devices/binto/modules/gpu-replay.nix index c8fbed02..b87676d0 100644 --- a/devices/binto/modules/gpu-replay.nix +++ b/devices/binto/modules/gpu-replay.nix @@ -9,7 +9,6 @@ inherit (lib) concatStringsSep removePrefix; hyprPkgs = config.home-manager.users.${mainUser}.wayland.windowManager.hyprland.finalPackage; - # TODO: manage this with ags gsr = pkgs.stdenv.mkDerivation { name = "gpu-screen-recorder"; version = gpu-screen-recorder-src.rev; @@ -74,7 +73,6 @@ in { name = "gpu-save-replay"; runtimeInputs = [procps]; text = '' - # TODO: add notif on success pkill --signal SIGUSR1 -f gpu-screen-recorder ''; }) @@ -110,11 +108,7 @@ in { ]; wayland.windowManager.hyprland.settings = { - bind = [",F8, exec, gpu-save-replay"]; - - exec-once = [ - "sleep 10; tmux new-session -s gsr -d gsr-start" - ]; + bind = [",F8, exec, ags -r 'GSR.saveReplay()'"]; }; }; } diff --git a/modules/ags/config/binto.ts b/modules/ags/config/binto.ts index e9bd200a..729c3724 100644 --- a/modules/ags/config/binto.ts +++ b/modules/ags/config/binto.ts @@ -1,5 +1,6 @@ -import Pointers from './services/pointers.ts'; import Brightness from './services/brightness.ts'; +import GSR from './services/gpu-screen-recorder.ts'; +import Pointers from './services/pointers.ts'; import AppLauncher from './ts/applauncher/main.ts'; import Bar from './ts/bar/binto.ts'; @@ -13,10 +14,10 @@ App.config({ icons: './icons', onConfigParsed: () => { - globalThis.Pointers = Pointers; - Brightness.capsName = 'input30::capslock'; globalThis.Brightness = Brightness; + globalThis.Pointers = Pointers; + globalThis.GSR = GSR; }, windows: () => [ diff --git a/modules/ags/config/services/gpu-screen-recorder.ts b/modules/ags/config/services/gpu-screen-recorder.ts new file mode 100644 index 00000000..6310633e --- /dev/null +++ b/modules/ags/config/services/gpu-screen-recorder.ts @@ -0,0 +1,74 @@ +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}`, + ['folder', 'Open Folder', 'video', 'Open Video'], + {}, + 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); + } + }, + ); + }, + logError, + ); + } + + saveReplay() { + execAsync(['gpu-save-replay']).then(() => { + Notifications.Notify( + APP_NAME, + this.#appID, + ICON_NAME, + 'Saving Replay', + 'Last 20 minutes', + [], + {}, + Notifications.popupTimeout, + ); + }); + } +} + +const gsrService = new GSR(); + +export default gsrService; diff --git a/modules/ags/config/ts/notifications/popup.ts b/modules/ags/config/ts/notifications/popup.ts index 9df84562..253cd1d6 100644 --- a/modules/ags/config/ts/notifications/popup.ts +++ b/modules/ags/config/ts/notifications/popup.ts @@ -52,8 +52,6 @@ export default () => Box({ return; } - console.log(notif.attribute.hovered); - // If notif isn't hovered or was closed, slide away if (!notif.attribute.hovered || force) { notif.attribute.slideAway('Left');