Screenshot : Use "unknown" dir when no window is in focus.

This commit is contained in:
Dmitry Voronin 2024-09-14 20:30:03 +03:00
parent de7cbef664
commit 6ca438ed37
Signed by: voronind
SSH key fingerprint: SHA256:3kBb4iV2ahufEBNq+vFbUe4QYfHt98DHQjN7QaptY9k

View file

@ -21,8 +21,16 @@ in {
vidStop = ''pkill -SIGINT wf-recorder'';
prepFile = path: ext: ''
# Focused app id by default.
curWindow=$(parse_snake $(swaymsg -t get_tree | jq '.. | select(.type?) | select(.focused==true) | .app_id'))
# If no id (i.e. xwayland), then use a name (title).
[[ "''${curWindow}" = "null" ]] && curWindow=$(parse_snake $(swaymsg -t get_tree | jq '.. | select(.type?) | select(.focused==true) | .name'))
# If no app in focus, use "unknown" dir.
[[ "''${curWindow}" -eq "''${curWindow}" ]] && curWindow="unknown"
# Prepare dir and file path.
scrDir="${path}/''${curWindow}"
mkdir -p "''${scrDir}"
scrFile="''${scrDir}/$(date +${format}).${ext}"