@@ -72,13 +72,27 @@ MouseArea {
7272 }
7373
7474 function save (): void {
75- const tmpfile = Qt .resolvedUrl (` /tmp/caelestia-picker-${ Quickshell .processId } -${ Date .now ()} .png` );
76- CUtils .saveItem (screencopy, tmpfile, Qt .rect (Math .ceil (rsx), Math .ceil (rsy), Math .floor (sw), Math .floor (sh)), path => {
75+ const targetTmpFile = Qt .resolvedUrl (` /tmp/caelestia-picker-${ Quickshell .processId } -${ Date .now ()} .png` );
76+ CUtils .saveItem (screencopy, targetTmpFile, Qt .rect (Math .ceil (rsx), Math .ceil (rsy), Math .floor (sw), Math .floor (sh)), tmpFile => {
77+ const timestamp = Qt .formatDateTime (new Date (), " yyyyMMddhhmmss" );
78+ const saveDir = " $HOME/Pictures/Screenshots" ;
79+ const fileName = ` ${ timestamp} .png` ;
7780 if (root .loader .clipboardOnly ) {
78- Quickshell .execDetached ([" sh" , " -c" , " wl-copy --type image/png < " + path]);
79- Quickshell .execDetached ([" notify-send" , " -a" , " caelestia-cli" , " -i" , path, " Screenshot taken" , " Screenshot copied to clipboard" ]);
81+ Quickshell .execDetached ([" sh" , " -c" , " wl-copy --type image/png < " + tmpFile]);
82+ const bgScript = `
83+ action=$(notify-send -a "caelestia-cli" -i "${ tmpFile} " "Screenshot Taken" "Copied to clipboard." --action=open="Open" --action=save="Save");
84+ mkdir -p ${ saveDir} ;
85+ if [ "$action" = "save" ]; then
86+ mv "${ tmpFile} " "${ saveDir} /${ fileName} ";
87+ notify-send -a "caelestia-cli" -i "${ saveDir} /${ fileName} " "Screenshot Saved" "Image saved to ${ saveDir} /${ fileName} ";
88+ elif [ "$action" = "open" ]; then
89+ swappy -f "${ tmpFile} " -o "${ saveDir} /${ fileName} ";
90+ fi
91+ rm "${ tmpFile} ";
92+ ` ;
93+ Quickshell .execDetached ([" sh" , " -c" , bgScript]);
8094 } else {
81- Quickshell .execDetached ([" swappy" , " -f" , path ]);
95+ Quickshell .execDetached ([" swappy" , " -f" , tmpFile ]);
8296 }
8397 });
8498 closeAnim .start ();
0 commit comments