about summary refs log tree commit diff stats
path: root/home-manager/config/lf/cmds/trash
diff options
context:
space:
mode:
authorene <ene@sils.li>2023-03-18 15:27:08 +0100
committerene <ene@sils.li>2023-03-18 15:28:49 +0100
commit7ef945bfa4dfb2d1330ec441161796a4462a2d98 (patch)
tree7a793351a4d89cf1dd851d73a4e53d076fa825a1 /home-manager/config/lf/cmds/trash
parentFix(flake): Update (diff)
downloadnixos-config-7ef945bfa4dfb2d1330ec441161796a4462a2d98.tar.gz
nixos-config-7ef945bfa4dfb2d1330ec441161796a4462a2d98.zip
Fix(hm/conf/lf): Allow trashing of files on the temp fs
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