diff --git a/.config/sway/config b/.config/sway/config index 01b3631..e8b8661 100644 --- a/.config/sway/config +++ b/.config/sway/config @@ -8,7 +8,7 @@ set $right l # wf-recorder -set $screenrecorder `bash $HOME/.config/sway/scripts/open-screen-recorder.sh` +set $screenrecorder `bash $HOME/.config/sway/scripts/screen-recorder.sh` bindsym --to-code $mod+Shift+R exec $screenrecorder # background diff --git a/.config/sway/scripts/open-screen-recorder.sh b/.config/sway/scripts/open-screen-recorder.sh deleted file mode 100755 index c805219..0000000 --- a/.config/sway/scripts/open-screen-recorder.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -main() { - pid="$(pgrep "wf-recorder" || pgrep "slurp")" - status=$? - - if [[ $status != 0 ]]; then - GEO="$(slurp)" && wf-recorder -g "$GEO" -f "$HOME/Videos/$(date +'recording_%Y-%m-%d-%H%M%S.mp4')" - else - pkill --signal SIGINT wf-recorder - fi -} - -main $@ \ No newline at end of file diff --git a/.config/sway/scripts/screen-recorder.sh b/.config/sway/scripts/screen-recorder.sh new file mode 100755 index 0000000..0dbea51 --- /dev/null +++ b/.config/sway/scripts/screen-recorder.sh @@ -0,0 +1,27 @@ +#! /usr/bin/env bash + +main() { + pid="$(pgrep "wf-recorder" || pgrep "slurp")" + status=$? + + if [[ $status != 0 ]]; then + if [[ -f ~/.config/user-dirs.dirs ]]; then + source ~/.config/user-dirs.dirs + fi + + output_dir="${XDG_VIDEOS_DIR:-$HOME/Videos}" + + if [[ ! -d "$output_dir" ]]; then + notify-send "Screen recording output directory does not exist: $output_dir" -u critical -t 3000 + exit 1 + fi + + filename="$output_dir/$(date +'recording_%Y-%m-%d-%H%M%S.mp4')" + + region="$(slurp)" && wf-recorder -g "$region" -f "$filename" + else + pkill --signal SIGINT wf-recorder + fi +} + +main $@ diff --git a/.config/waybar/config.jsonc b/.config/waybar/config.jsonc index 94fb2b9..9544ae4 100644 --- a/.config/waybar/config.jsonc +++ b/.config/waybar/config.jsonc @@ -104,7 +104,7 @@ "return-type": "json", "exec": "echo '{\"class\": \"recording\"}'", "exec-if": "pgrep wf-recorder", - "on-click": "$HOME/.config/waybar/scripts/close-screen-recorder.sh" + "on-click": "$HOME/.config/sway/scripts/screen-recorder.sh" }, "privacy": { "icon-spacing": 4, diff --git a/.config/waybar/scripts/close-screen-recorder.sh b/.config/waybar/scripts/close-screen-recorder.sh deleted file mode 100755 index 1bb613c..0000000 --- a/.config/waybar/scripts/close-screen-recorder.sh +++ /dev/null @@ -1,12 +0,0 @@ -#! /usr/bin/env bash - -main() { - pid="$(pgrep "wf-recorder" || pgrep "slurp")" - status=$? - - if [[ $status == 0 ]]; then - pkill --signal SIGINT wf-recorder - fi -} - -main $@ \ No newline at end of file