about summary refs log tree commit diff stats
path: root/home-manager/config/lf/cmds
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xhome-manager/config/lf/cmds/trash33
1 files changed, 15 insertions, 18 deletions
diff --git a/home-manager/config/lf/cmds/trash b/home-manager/config/lf/cmds/trash
index cbe6ab63..78018721 100755
--- a/home-manager/config/lf/cmds/trash
+++ b/home-manager/config/lf/cmds/trash
@@ -4,22 +4,19 @@
 # . ~/.local/lib/shell/lib
 . %SHELL_LIBRARY_PATH
 
-#files=$(printf "$fx" | tr '\n' ';')
-#
-#while [ "$files" ]; do
-#    # extract the substring from start of string up to delimiter.
-#    # this is the first "element" of the string.
-#    file=${files%%;*}
-#
-#    trash-put "$(basename "$file")"
-#    # if there's only one element left, set `files` to an empty string.
-#    # this causes us to exit this `while` loop.
-#    # else, we delete the first "element" of the string from files, and move onto the next.
-#    if [ "$files" = "$file" ]; then
-#        files=''
-#    else
-#        files="${files#*;}"
-#    fi
-#done
-trash put "$fx";
+trash_output=$(mktmp);
+expected_error_output=$(mktmp);
+
+# try trashy first
+nix run nixpkgs#trashy -- put "$fx" 2> $trash_output;
+
+cat << EOF > $expected_error_output;
+error: Error during a \`trash\` operation: Unknown { description: "Path: '\"/.Trash-1000\"'. Message: Permission denied (os error 13)" }
+EOF
+
+if [ "$(cat $expected_error_output)" = "$(cat $trash_output)" ];then
+    warning "Deleting with trash-cli to the /.Trash folder";
+    # this file could not be trashed because it is on the tempfs volume, trash-cli can do this this
+    printf "%s" "$fx" | tr '\n' ' ' | xargs trash-put;
+fi
 # vim: ft=sh