diff --git a/scripts/screenshot/screenshot_area.sh b/scripts/screenshot/screenshot_area.sh index bc3a285..648d113 100755 --- a/scripts/screenshot/screenshot_area.sh +++ b/scripts/screenshot/screenshot_area.sh @@ -22,9 +22,17 @@ fi # Open the editor if swappy is available (blocks until it is closed). # swappy never overwrites the opened file on Ctrl+s (it saves a new -# timestamped copy to save_dir), so -o writes the final surface back here. +# timestamped copy to save_dir), so pass it a temporary config pointing +# save_dir/save_filename_format at our exact file: Ctrl+s then saves and +# exits (early_exit). -o writes the final surface when quitting with Esc/q. +# Note: closing with Ctrl+w or the X button quits without saving (swappy). if command -v swappy >/dev/null 2>&1; then - swappy -f "$dir/$file" -o "$dir/$file" + cfg=$(mktemp -d) + mkdir -p "$cfg/swappy" + printf '[Default]\nsave_dir=%s\nsave_filename_format=%s\nearly_exit=true\n' \ + "$dir" "$file" > "$cfg/swappy/config" + XDG_CONFIG_HOME="$cfg" swappy -f "$dir/$file" -o "$dir/$file" + rm -rf "$cfg" wl-copy -t image/png < "$dir/$file" fi diff --git a/scripts/screenshot/screenshot_monitor.sh b/scripts/screenshot/screenshot_monitor.sh index 990bffc..3733912 100755 --- a/scripts/screenshot/screenshot_monitor.sh +++ b/scripts/screenshot/screenshot_monitor.sh @@ -23,9 +23,17 @@ fi # Open the editor if swappy is available (blocks until it is closed). # swappy never overwrites the opened file on Ctrl+s (it saves a new -# timestamped copy to save_dir), so -o writes the final surface back here. +# timestamped copy to save_dir), so pass it a temporary config pointing +# save_dir/save_filename_format at our exact file: Ctrl+s then saves and +# exits (early_exit). -o writes the final surface when quitting with Esc/q. +# Note: closing with Ctrl+w or the X button quits without saving (swappy). if command -v swappy >/dev/null 2>&1; then - swappy -f "$dir/$file" -o "$dir/$file" + cfg=$(mktemp -d) + mkdir -p "$cfg/swappy" + printf '[Default]\nsave_dir=%s\nsave_filename_format=%s\nearly_exit=true\n' \ + "$dir" "$file" > "$cfg/swappy/config" + XDG_CONFIG_HOME="$cfg" swappy -f "$dir/$file" -o "$dir/$file" + rm -rf "$cfg" wl-copy -t image/png < "$dir/$file" fi diff --git a/scripts/screenshot/screenshot_window.sh b/scripts/screenshot/screenshot_window.sh index 10e5828..6cf25a3 100755 --- a/scripts/screenshot/screenshot_window.sh +++ b/scripts/screenshot/screenshot_window.sh @@ -42,9 +42,17 @@ fi # Open the editor if swappy is available (blocks until it is closed). # swappy never overwrites the opened file on Ctrl+s (it saves a new -# timestamped copy to save_dir), so -o writes the final surface back here. +# timestamped copy to save_dir), so pass it a temporary config pointing +# save_dir/save_filename_format at our exact file: Ctrl+s then saves and +# exits (early_exit). -o writes the final surface when quitting with Esc/q. +# Note: closing with Ctrl+w or the X button quits without saving (swappy). if command -v swappy >/dev/null 2>&1; then - swappy -f "$dir/$file" -o "$dir/$file" + cfg=$(mktemp -d) + mkdir -p "$cfg/swappy" + printf '[Default]\nsave_dir=%s\nsave_filename_format=%s\nearly_exit=true\n' \ + "$dir" "$file" > "$cfg/swappy/config" + XDG_CONFIG_HOME="$cfg" swappy -f "$dir/$file" -o "$dir/$file" + rm -rf "$cfg" wl-copy -t image/png < "$dir/$file" fi