diff options
| -rwxr-xr-x | install/scripts.fish | 2 | ||||
| -rwxr-xr-x | record.fish | 78 |
2 files changed, 25 insertions, 55 deletions
diff --git a/install/scripts.fish b/install/scripts.fish index 8da6221..573a74c 100755 --- a/install/scripts.fish +++ b/install/scripts.fish @@ -3,7 +3,7 @@ . (dirname (status filename))/util.fish install-deps git hyprland-git hyprpaper-git imagemagick wl-clipboard fuzzel-git socat foot jq python xdg-user-dirs python-materialyoucolor-git app2unit-git -install-optional-deps 'equibop-bin (discord client)' 'btop (system monitor)' 'wf-recorder (screen recorder)' 'grim (screenshot tool)' 'zen-browser (web browser)' 'spotify-adblock (music player)' +install-optional-deps 'equibop-bin (discord client)' 'btop (system monitor)' 'wl-screenrec (screen recorder)' 'grim (screenshot tool)' 'zen-browser (web browser)' set -l dist $C_DATA/scripts diff --git a/record.fish b/record.fish index 79e8d59..e3860e3 100755 --- a/record.fish +++ b/record.fish @@ -1,31 +1,22 @@ #!/bin/fish function get-audio-source - pactl list sources | grep 'Name' | grep 'monitor' | cut -d ' ' -f2 + pactl list short sources | grep '\.monitor.*RUNNING' | cut -f 2 | head -1 end -function get-active-monitor - hyprctl monitors -j | jq -r '.[] | select(.focused == true) | .name' -end - -function has-gpu - test -e /dev/dri/renderD128 -end - -function supports-codec -a codec - ffmpeg -hide_banner -encoders | grep -E '^ V' | grep -F '(codec' | grep $codec >/dev/null +function get-region + slurp || exit 0 end -function supports-gpu-codecs - supports-codec hevc_vaapi || supports-codec h264_vaapi +function get-active-monitor + hyprctl monitors -j | jq -r '.[] | select(.focused == true) | .name' end argparse -n 'caelestia-record' -X 0 \ 'h/help' \ 's/sound' \ 'r/region=?' \ - 'c/compression=!_validate_int' \ - 'H/hwaccel' \ + 'n/no-hwaccel' \ -- $argv or exit @@ -35,29 +26,28 @@ if set -q _flag_h echo ' caelestia record [ -s | --sound ] [ -r | --region ] [ -c | --compression ] [ -H | --hwaccel ]' echo echo 'Options:' - echo ' -h, --help Print this help message and exit' - echo ' -s, --sound Enable audio capturing' - echo ' -r, --region [ <region> ] The region to capture, current monitor if option not given, default region slurp' - echo ' -c, --compression <compression> Use given compression level, lower = better quality, higher = better compression' - echo ' -H, --hwaccel Use hardware acceleration if available' + echo ' -h, --help Print this help message and exit' + echo ' -s, --sound Enable audio capturing' + echo ' -r, --region [ <region> ] The region to capture, current monitor if option not given, default region slurp' + echo ' -N, --no-hwaccel Do not use the GPU encoder' exit end . (dirname (status filename))/util.fish -set storage_dir (xdg-user-dir VIDEOS)/Recordings -set state_dir $C_STATE/record +set -l storage_dir (xdg-user-dir VIDEOS)/Recordings +set -l state_dir $C_STATE/record mkdir -p $storage_dir mkdir -p $state_dir -set file_ext 'mp4' -set recording_path "$state_dir/recording.$file_ext" -set notif_id_path "$state_dir/notifid.txt" +set -l file_ext 'mp4' +set -l recording_path "$state_dir/recording.$file_ext" +set -l notif_id_path "$state_dir/notifid.txt" -if pgrep wf-recorder > /dev/null - pkill wf-recorder +if pgrep wl-screenrec > /dev/null + pkill wl-screenrec # Move to recordings folder set -l new_recording_path "$storage_dir/recording_$(date '+%Y%m%d_%H-%M-%S').$file_ext" @@ -73,7 +63,7 @@ if pgrep wf-recorder > /dev/null end # Notification with actions - set -l action (notify-send 'Recording stopped' "Stopped recording $new_recording_path" -i 'video-x-generic-symbolic' -a 'caelestia-record' \ + set -l action (notify-send 'Recording stopped' "Stopped recording $new_recording_path" -i 'video-x-generic' -a 'caelestia-record' \ --action='watch=Watch' --action='open=Open' --action='save=Save As') switch $action @@ -90,38 +80,18 @@ else # Set region if flag given otherwise active monitor if set -q _flag_r # Use given region if value otherwise slurp - set region -g (test -n "$_flag_r" && echo $_flag_r || slurp) - - # No hardware encoding when smaller than 256x128 cause unsupported - if set -q _flag_H - set -l size (echo $region[2] | string split -n -f 2 ' ' | string split x) - if test $size[1] -lt 256 -o $size[2] -lt 128 - warn 'Hardware encoding unsupported below size 256x128. Falling back to software encoding.' - set -e _flag_H - end - end + set region -g (test -n "$_flag_r" && echo $_flag_r || get-region) else set region -o (get-active-monitor) end # Sound if enabled - set -q _flag_s && set audio --audio=(get-audio-source) + set -q _flag_s && set -l audio --audio --audio-device (get-audio-source) - # Codec stuff - if set -q _flag_H && has-gpu && supports-gpu-codecs - # Hardware encoding (GPU) - supports-codec hevc_vaapi && set codec hevc_vaapi || set codec h264_vaapi - set -q _flag_c && set compression -p qp=$_flag_c -p rc_mode=CQP - set codec_flags -d /dev/dri/renderD128 - else - # Software encoding (CPU) - set -q _flag_H && warn 'Unable to use hardware acceleration. Falling back to software encoding.' - supports-codec libx265 && set codec libx265 || set codec libx264 - set -q _flag_c && set compression -p crf=$_flag_c - set codec_flags -x yuv420p - end + # No hardware accel + set -q _flag_n && set -l hwaccel --no-hw - wf-recorder -c $codec $codec_flags $compression $region $audio -f $recording_path & disown + wl-screenrec $region $audio $hwaccel -f $recording_path & disown - notify-send 'Recording started' 'Recording...' -i 'video-x-generic-symbolic' -a 'caelestia-record' -p > $notif_id_path + notify-send 'Recording started' 'Recording...' -i 'video-x-generic' -a 'caelestia-record' -p > $notif_id_path end |