feat(ags): add freeze option for screenshot
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2024-11-19 22:05:12 -05:00
parent b1eeb4308d
commit 4e6e73a213
3 changed files with 54 additions and 14 deletions

View file

@ -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

View file

@ -14,15 +14,13 @@ import { hyprMessage } from '../../lib';
const ICON_SEP = 6; 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); App.get_window('win-screenshot')?.set_visible(false);
setTimeout(() => { setTimeout(() => {
execAsync([ execAsync([
'bash', `${SRC}/widgets/screenshot/capture.sh`,
'-c', ].concat(selector)).catch(console.error);
`grim ${selector} - | satty -f - || true`,
]).catch(console.error);
}, delay); }, delay);
}; };
@ -42,7 +40,7 @@ export default () => {
cursor="pointer" cursor="pointer"
onButtonReleaseEvent={() => { onButtonReleaseEvent={() => {
takeScreenshot(`-w ${client.address}`); takeScreenshot(['-w', client.address]);
}} }}
> >
<box halign={Gtk.Align.CENTER}> <box halign={Gtk.Align.CENTER}>
@ -78,7 +76,7 @@ export default () => {
cursor="pointer" cursor="pointer"
onButtonReleaseEvent={() => { onButtonReleaseEvent={() => {
takeScreenshot(`-o ${monitor.name}`); takeScreenshot(['-o', monitor.name]);
}} }}
> >
<label <label
@ -117,21 +115,41 @@ export default () => {
</button> </button>
) as Widget.Button; ) as Widget.Button;
let frozen = false;
const freezeIcon = <icon icon="checkbox-symbolic" /> as Widget.Icon;
const freezeButton = (
<button
cursor="pointer"
className="header-btn"
onButtonReleaseEvent={() => {
frozen = !frozen;
freezeIcon.icon = frozen ?
'checkbox-checked-symbolic' :
'checkbox-symbolic';
}}
>
<box halign={Gtk.Align.CENTER}>
{freezeIcon}
<Separator size={ICON_SEP} />
freeze
</box>
</button>
) as Widget.Button;
const regionButton = ( const regionButton = (
<button <button
cursor="pointer" cursor="pointer"
className="header-btn" className="header-btn"
onButtonReleaseEvent={() => { onButtonReleaseEvent={() => {
takeScreenshot('-g "$(slurp)"', 0); takeScreenshot(['region', frozen ? 'true' : 'false'], 0);
}} }}
> >
<box halign={Gtk.Align.CENTER}> <box halign={Gtk.Align.CENTER}>
<icon icon="tool-pencil-symbolic" /> <icon icon="tool-crop-symbolic" />
<Separator size={ICON_SEP} />
region
</box> </box>
</button> </button>
) as Widget.Button; ) as Widget.Button;
@ -153,7 +171,10 @@ export default () => {
> >
<StackButton label="monitors" iconName="display-symbolic" /> <StackButton label="monitors" iconName="display-symbolic" />
<StackButton label="windows" iconName="window-symbolic" /> <StackButton label="windows" iconName="window-symbolic" />
<box>
{regionButton} {regionButton}
{freezeButton}
</box>
</box> </box>
{stack} {stack}

View file

@ -77,6 +77,7 @@ in {
(pkgs) (pkgs)
playerctl playerctl
pavucontrol # TODO: replace with ags widget pavucontrol # TODO: replace with ags widget
wayfreeze
; ;
}) })
++ (optionals cfgDesktop.isTouchscreen (builtins.attrValues { ++ (optionals cfgDesktop.isTouchscreen (builtins.attrValues {