diff options
author | awy <awy@awy.one> | 2025-01-26 23:33:00 +0300 |
---|---|---|
committer | awy <awy@awy.one> | 2025-01-26 23:33:00 +0300 |
commit | fc195aa0960fc4c9cd53c1a101925566f5ae0cbb (patch) | |
tree | afdec07ed81de3ae24a13a167117d920e2af8e3d /.local/bin | |
parent | 00a071b2388f59142b79443dfeb58fe1feaab431 (diff) |
update
Diffstat (limited to '.local/bin')
-rwxr-xr-x | .local/bin/hyprshot | 28 | ||||
-rwxr-xr-x | .local/bin/menurecord | 123 |
2 files changed, 123 insertions, 28 deletions
diff --git a/.local/bin/hyprshot b/.local/bin/hyprshot deleted file mode 100755 index 7036c84..0000000 --- a/.local/bin/hyprshot +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh - -part() { - geometry="$(slurp)" - sleep "0.5" - grim -g "${geometry}" -t jpeg - | wl-copy -} - -full() { - grim -t jpeg - | wl-copy -} - -rec() { - killall -SIGINT gpu-screen-recorder - homeuser='/home/awy' - availableDisplay=$(hyprctl monitors | grep Monitor | cut -d' ' -f2) - filename=$(date +"%Y-%m-%d %H:%M:%S") - choice="$(printf "$availableDisplay\nExit\n" | rofi -dmenu -l "5")" - [ "${choice}" != "Exit" ] || [ -z "${choice}" ] && - gpu-screen-recorder -w $choice -f 60 -a default_output -a default_input -o "$homeuser/$filename.mp4" - -} - -case $1 in - 1) part ;; - 2) full ;; - 3) rec ;; -esac diff --git a/.local/bin/menurecord b/.local/bin/menurecord new file mode 100755 index 0000000..b301dd9 --- /dev/null +++ b/.local/bin/menurecord @@ -0,0 +1,123 @@ +#!/bin/sh + +# Usage: +# `$0`: Ask for recording type via dmenu +# `$0 screencast`: Record both audio and screen +# `$0 video`: Record only screen +# `$0 audio`: Record only audio +# `$0 kill`: Kill existing recording +# +# If there is already a running instance, user will be prompted to end it. +menu="rofi -dmenu" + +getdim() { + screens=$(hyprctl monitors | grep Monitor | cut -d' ' -f2) + choice=$(printf "$screens\nExit\n" | $menu) + [ "${choice}" != "Exit" ] || [ -z "${choice}" ] || exit && + echo $choice +} + +updateicon() { \ + echo "$1" > /tmp/recordingicon + pkill -RTMIN+9 "${STATUSBAR:-i3blocks}" +} + +killrecording() { + recpid="$(cat /tmp/recordingpid)" + echo $recpid + kill -2 "$recpid" + rm -f /tmp/recordingpid + updateicon "" + pkill -RTMIN+9 "${STATUSBAR:-i3blocks}" +} + +screencast() { gpu-screen-recorder \ + -w "$(getdim)" \ + -f 60 \ + -a default_output \ + -a default_input \ + -o "$HOME/screencast-$(date '+%y%m%d-%H%M-%S').mp4" & + echo $! > /tmp/recordingpid + updateicon "⏺️🎙️" +} + +video() { gpu-screen-recorder \ + -w "$(getdim)" \ + -f 60 \ + -o "$HOME/video-$(date '+%y%m%d-%H%M-%S').mkv" & + echo $! > /tmp/recordingpid + updateicon "⏺️" +} + +webcamhidef() { ffmpeg \ + -f v4l2 \ + -i /dev/video0 \ + -video_size 1920x1080 \ + "$HOME/webcam-$(date '+%y%m%d-%H%M-%S').mkv" & + echo $! > /tmp/recordingpid + updateicon "🎥" +} + +webcam() { ffmpeg \ + -f v4l2 \ + -i /dev/video0 \ + -video_size 640x480 \ + "$HOME/webcam-$(date '+%y%m%d-%H%M-%S').mkv" & + echo $! > /tmp/recordingpid + updateicon "🎥" +} + + +audio() { \ + ffmpeg \ + -f alsa -i default \ + -c:a flac \ + "$HOME/audio-$(date '+%y%m%d-%H%M-%S').flac" & + echo $! > /tmp/recordingpid + updateicon "🎙️" +} + +askrecording() { \ + choice=$(printf "screencast\\nvideo\\nvideo selected\\naudio\\nwebcam\\nwebcam (hi-def)" | $menu -i -p "Select recording style:") + case "$choice" in + screencast) screencast;; + audio) audio;; + video) video;; + *selected) videoselected;; + webcam) webcam;; + "webcam (hi-def)") webcamhidef;; + esac +} + +asktoend() { \ + response=$(printf "No\\nYes" | $menu -i -p "Recording still active. End recording?") && + [ "$response" = "Yes" ] && killrecording +} + +# needs rewrite and support by gpu-screen-recorder + +# videoselected() +# { +# slop -f "%x %y %w %h" > /tmp/slop +# read -r X Y W H < /tmp/slop +# rm /tmp/slop +# +# ffmpeg \ +# -f x11grab \ +# -framerate 30 \ +# -video_size "$W"x"$H" \ +# -i :0.0+"$X,$Y" \ +# -c:v libx264 -qp 0 -r 30 \ +# "$HOME/box-$(date '+%y%m%d-%H%M-%S').mkv" & +# echo $! > /tmp/recordingpid +# updateicon "⏺️" +# } + +case "$1" in + screencast) screencast;; + audio) audio;; + video) video;; + # *selected) videoselected;; + kill) killrecording;; + *) ([ -f /tmp/recordingpid ] && asktoend && exit) || askrecording;; +esac |