diff options
Diffstat (limited to '')
-rwxr-xr-x | home-manager/config/lf/cmds/trash | 33 | ||||
-rw-r--r-- | home-manager/config/lf/default.nix | 3 | ||||
-rw-r--r-- | system/default.nix | 1 | ||||
-rw-r--r-- | system/tempfiles/default.nix | 7 |
4 files changed, 26 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 diff --git a/home-manager/config/lf/default.nix b/home-manager/config/lf/default.nix index 6d5095e1..d0f6ba40 100644 --- a/home-manager/config/lf/default.nix +++ b/home-manager/config/lf/default.nix @@ -55,6 +55,8 @@ in { xdg.configFile."lf/icons".source = ./icons; xdg.configFile."lf/colors".source = ./colors; +# TODO add the systemd tempfile option here + programs.lf = { enable = true; @@ -89,6 +91,7 @@ in { (pkgs) fzf trashy + trash-cli ; }; }; diff --git a/system/default.nix b/system/default.nix index 13386a6d..23418312 100644 --- a/system/default.nix +++ b/system/default.nix @@ -11,6 +11,7 @@ ./polkit ./graphics ./services + ./tempfiles ]; # TODO does this really remove all the bloatware, nixos installs by default? environment = { diff --git a/system/tempfiles/default.nix b/system/tempfiles/default.nix new file mode 100644 index 00000000..f94ddcee --- /dev/null +++ b/system/tempfiles/default.nix @@ -0,0 +1,7 @@ +# vim: ts=2 +{config, ...}: { + systemd.tmpfiles.rules = [ + # this file is needed to trash stuff on the temp fs + "d /.Trash 1777 root root" # TODO move this to the lf config + ]; +} |