From 2c485ce2b43bd810a88278215b771136a2a17881 Mon Sep 17 00:00:00 2001 From: Martin Michalec Date: Wed, 11 Feb 2026 05:47:33 +0300 Subject: add scripts --- .../bin/executable_toggle-screen-capture | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 private_dot_local/bin/executable_toggle-screen-capture (limited to 'private_dot_local/bin/executable_toggle-screen-capture') diff --git a/private_dot_local/bin/executable_toggle-screen-capture b/private_dot_local/bin/executable_toggle-screen-capture new file mode 100644 index 0000000..10dff96 --- /dev/null +++ b/private_dot_local/bin/executable_toggle-screen-capture @@ -0,0 +1,39 @@ +#!/bin/sh + +PID=`pgrep wf-recorder` +FILE="$HOME/multimedia/screencasts/`date '+%Y%m%d-%H%M%S'`.mkv" + +if [ "$PID" ]; then + kill -INT $PID + for module in `pactl list short modules | grep wf-recorder | cut -f1`; do + pactl unload-module $module + done + while `pgrep wf-recorder`; do sleep 0.01; done + pkill -SIGRTMIN+8 waybar + sleep 0.01 + pkill -SIGRTMIN+8 waybar +else + TYPE=${1:-output} + case $TYPE in + output) + GEOMETRY=`slurp -o -b "303030AA" -B "303030AA"` + ;; + window) + GEOMETRY=`swaymsg -t get_tree | jq -r '.. | select(.pid? and .visible?) | "\(.rect.x+.window_rect.x),\(.rect.y+.window_rect.y) \(.window_rect.width)x\(.window_rect.height)"' | slurp -b "303030AA" -B "303030AA"` + ;; + *) + echo "Usage: $0 [output|window]" + exit 1 + ;; + esac + if [ -z "$GEOMETRY" ]; then exit; fi + pactl load-module module-null-sink sink_name=wf-recorder + pactl load-module module-loopback sink=wf-recorder source=alsa_output.pci-0000_00_1b.0.analog-stereo.monitor + pactl load-module module-loopback sink=wf-recorder source=alsa_input.pci-0000_00_1b.0.analog-stereo + wf-recorder --audio=wf-recorder.monitor \ + --geometry="$GEOMETRY" \ + --pixel-format=yuv420p \ + --file="$FILE" & + disown $! + pkill -SIGRTMIN+8 waybar +fi -- cgit v1.3