diff --git a/nixosModules/ags/config/widgets/screenshot/capture.sh b/nixosModules/ags/config/widgets/screenshot/capture.sh new file mode 100755 index 00000000..d3a1e729 --- /dev/null +++ b/nixosModules/ags/config/widgets/screenshot/capture.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +if [[ "$1" == "region" ]]; then + if [[ "$2" == "true" ]]; then + wayfreeze & PID=$! + sleep .1 + fi + + selection="$(slurp)" + + if [[ "$2" == "true" ]]; then + kill "$PID" + fi + + exec grim -g "$selection" - | satty -f - || true +else + exec grim "$@" - | satty -f - || true +fi diff --git a/nixosModules/ags/config/widgets/screenshot/main.tsx b/nixosModules/ags/config/widgets/screenshot/main.tsx index 4c800512..13192b7a 100644 --- a/nixosModules/ags/config/widgets/screenshot/main.tsx +++ b/nixosModules/ags/config/widgets/screenshot/main.tsx @@ -14,15 +14,13 @@ import { hyprMessage } from '../../lib'; const ICON_SEP = 6; -const takeScreenshot = (selector: string, delay = 1000): void => { +const takeScreenshot = (selector: string[], delay = 1000): void => { App.get_window('win-screenshot')?.set_visible(false); setTimeout(() => { execAsync([ - 'bash', - '-c', - `grim ${selector} - | satty -f - || true`, - ]).catch(console.error); + `${SRC}/widgets/screenshot/capture.sh`, + ].concat(selector)).catch(console.error); }, delay); }; @@ -42,7 +40,7 @@ export default () => { cursor="pointer" onButtonReleaseEvent={() => { - takeScreenshot(`-w ${client.address}`); + takeScreenshot(['-w', client.address]); }} > @@ -78,7 +76,7 @@ export default () => { cursor="pointer" onButtonReleaseEvent={() => { - takeScreenshot(`-o ${monitor.name}`); + takeScreenshot(['-o', monitor.name]); }} > {stack} diff --git a/nixosModules/ags/packages.nix b/nixosModules/ags/packages.nix index ee8f7026..6ee938ae 100644 --- a/nixosModules/ags/packages.nix +++ b/nixosModules/ags/packages.nix @@ -77,6 +77,7 @@ in { (pkgs) playerctl pavucontrol # TODO: replace with ags widget + wayfreeze ; }) ++ (optionals cfgDesktop.isTouchscreen (builtins.attrValues {