Patches for Nautilus “move to trash” bug

Warning, this post contains a geek rant.

If you use the nautilus or nautilus-elementary filemanager (the default file manager in any gnome-based linux distro, including Ubuntu), you are probably aware of the annoying bug with file deletion.

Like any other file manager, nautilus allows you to delete your files using keyboard shortcuts: permanently (hit <Shift-Delete>) or temporarily by moving them to the trashbin (hit <Delete> on your keyboard). Removing files is always a critical action so any other file manager will make sure that you don’t do it accidentally: the file manager in MacOS, finder, will require you to hit the key combination <AppleKey+Delete>, difficult to perform by mistake. Microsoft Explorer, Konqueror, Thunar and many others will ask you to confirm that you really want to trash files with a dialog box.

Unfortunately nautilus lacks this ability: if you, your toddler or your cat accidentally hit the Delete key on the keyboard while a file or folder is selected, they go into the trashbin without warning. If you are not looking at the screen while this happens, the item is well gone. Obviously, this flaw was pointed out already long time ago. Users started asking for a fix already in 2004 (that is seven years ago!) and lots of people wanted to get that fixed: see for instance here, here, here, here, here, here

Surprisingly, reactions of the gnome developers to this problem were of two kinds: “I don’t think this is a real problem”[¹] or “I don’t think you are proposing the perfect solution”[²].  Back in 2009, I accidentaly lost some file and wrote a patch to fix this bug. The patch simply gave the user the option to activate a warning dialog if they wanted to. I figured “people who want the dialog will enable it and be happy, people who don’t will leave it alone and keep discussing about what is really truly the best solution for the next 7 years“. Believe it or not, the problem still exists,  so I thought of raising the issue once again (this time, I also proposed a patch to change Delete in Control-Delete).

Guess what: even after 7 years and hundred of people begging for a fix, we are sitting on the same attitude:

This is a real problem, but I don’t think the solution is a windows-like alert dialog. […] An animation with the file becoming red and/or flying to the trash would be a nice addition.

Or maybe a small cluebar with an embedded undo button would already be enough. I like how Google does it in its webapps.

What if deleted files were visible as some ghost-like-icon in the directory they used to be? And it could be possible to turn on/off the visibility of deleted files? And you can have your animation then as well; of an icon that dies.

I think your use case is a real concern, and something we should fix indeed, but as others said in this thread, I don’t think a confirmation dialog is how we want this to be implemented, especially when it carries a new preference with it.

Personality i like my delete and it would felt awkward if the delete didn’t delete anything.

We will rather keep the hole than having a solution we don’t like. Little does it matter if any other browser is actually using that solution or if lots of people want to see the thing fixed.

This attitude is amazingly complicated to understand for my simple brain. For me, getting things done means finding the meeting point between the optimal solution and the best outcome. If my car gets a flat tire on the way, I will accept any new tire a rescuer would give me and I won’t be sitting 7 years waiting for one that really matches the other three. And I like to think this is not Linux true philosophy either.

Anyway, here you can download the patches to fix this issue.

I am using the second one on nautilus-elementary (which also sports a very convenient Undo feature).

Edit 1 April 2011. To much of my pleasure, the patch has now been accepted and from next version on, Control<Delete> will be the shortcut to send stuff to trash. No more accidental  deletions! Open Source wins again.

Edit June 2011. If you arrive to this page because you freaked out finding the new nautilus behaviour, this is how to get back to the old key combo

Notes:

1. You are all familiar with the “how many people it takes to change a light-bulb?” jokes.
The one about software developers goes like this:

Q: How many developers does it take to change a lightbulb?
A: The lightbulb works fine on the system in my office. NOT REPRO.

2. The one about C++ programmers goes like this:

Q: How many C++ programmers does it take to change a lightbulb?

A: You’re still thinking procedurally. A properly-designed lightbulb object would inherit a change method from a generic lightbulb class, so all you’d have to do is send it a bulb.change message.

 

40 Comments

  1. Reply
    Roshan 30 March 2011

    Thank you, Giorgio, for fixing this long-standing bug that renders Nautilus less useful than Win 98’s explorer.

  2. Reply
    Squirrelinahurry 4 April 2011

    I just noticed the keyboard shortcut to move files to the Trash has been changed to and now I’m really pissed because I can’t figure out how to change it back to .

    This is even worse than having a dialog enabled by default and configurable to disable! Thanks a lot whiners!

  3. Reply
    Tonic 10 April 2011

    Thanks, I preferred the old behaviour.

  4. Reply
    Your Name 24 April 2011

    this should have remained a patch not a default behaviour.There is always a recycle bin or trash bin whatever you call it from where one can “restore” files.Is there a way to restore default delete behaviour ?

  5. Reply
    Leif Gruenwoldt 19 June 2011

    Worst idea ever. In Windows pressing del prompts the user. Now in gnome 3 pressing del does NOTHING. I didn’t even realize there was a new shortcut to delete. I had been right clicking – > move to trash. Did I mention I hate this feature?

    Luckily a search for “gnome 3 nautilus delete key” brings up tons of results to restore the old behaviour. There is a trash can for a reason. And there is an undo button for a reason.

    A compromising solution would have been some sort of visual effect, sound, or desktop notification that you deleted a file.

    • Reply
      Giorgio 20 June 2011

      Leif, if you read the post again you’ll see why trash can and undo are useless for avoiding accidental deletion.

      • Reply
        Niczar 20 August 2011

        I don’t see where you make this argument. 

        The fact that you advocate the use of more modal dialogs makes me doubt your sanity. I’m half kidding; modal dialogs are truly evil and are extremely, utterly and maddeningly frustrating. 

  6. Reply
    Azad 2 July 2011

    I downloaded the patch (Nautilus- Confirmation upon deleting a file). How can I apply it? I am just a beginner using Ubuntu 10.04. Thanks.

    • Reply
      gg 2 July 2011

      You need to open the terminal and issue the following commands:

      sudo apt-get build-dep nautilus
      apt-get source nautilus
      cd nautilus-*
      wget -O - http://gilest.ro/various/software/nautilus-patches/nautilus-2.32.2.1-confirmtotrash.patch | patch -p1
      dpkg-buildpackage -rfakeroot
      sudo dpkg -i ../*nautilus*deb

      This way you end up with a patched deb package that will be installed as if it was the regular one. You need to do this every time nautilus get upgraded though. If you manage to get this working please send me an email with the deb package in attachment and I can put it up on the website for others to download. Ubuntuforums is the best place to go if you need advices. Cheers

    • Reply
      gg 2 July 2011

      You need to open the terminal and issue the following commands: 

      sudo apt-get build-dep nautilus
      apt-get source nautilus
      cd nautilus-*
      wget -O - http://gilest.ro/various/software/nautilus-patches/nautilus-2.32.2.1-confirmtotrash.patch | patch -p1
      dpkg-buildpackage -rfakeroot
      sudo dpkg -i ../*nautilus*deb

      This way you end up with a patched deb package that will be installed as if it was the regular one. You need to do this every time nautilus get upgraded though. If you manage to get this working please send me an email with the deb package in attachment and I can put it up on the website for others to download. Ubuntuforums is the best place to go if you need advices. Cheers

  7. Reply

    […] why this “feature” is there in Gnome3, just follow the link below: http://gilest.ro/2011/patches-for-nautilus-move-to-trash-bug GA_googleAddAttr("AdOpt", "1"); GA_googleAddAttr("Origin", "other"); […]

  8. Reply
    Niczar 20 August 2011

    This is a stupid rant, and the move to Ctrl-Delete is completely idiotic. Why? 

    1. Simple delete is reversible … That’s why there’s a trashcan! 

    2. Shift-Delete is, as you say, permanent delete, unrecoverable. Now it’s as easy to perform as a normal delete, blurring the distinction. You are also now going to make the mistake of hitting the wrong mod key and _will lose files for good_.

    3. You seem to think asking for a confirmation for _every_ move to trash is a good idea. It’s terrible UI! It contributes to warning dialog fatigue, and it provably results in MORE errors by the user. After clicking “Ok” a thousand times pointlessly for a reversible operation, the user will click Ok no matter what when something genuinely important occurs. 

    This is terrible UX. Absolutely terrible. 

    • Reply
      shintakezou 8 October 2013

      I totally, wholly, strongly agree: fighting with that 2years later, and found it just one of the many disappointing behaviours/features of GNOME3 and its “components”. I wonder how is it possible that a single user thought is enforced in such a way that it’s hard (for an average user) to have back the “normal” behaviour (Delete = move to trash, Modifier/Shift + Delete = rm permanently). And how is it possible that the ill idea that moving to trash must be confirmed was not rejected immediately?

    • Reply
      Christian A. Reiter 22 November 2013

      Full ACK.
      Where’s the problem with:

      * Delete (=move to trash, undelete/undo//recover easy)

      * Shift+Delete (permanent delete, if I so wish. do it intentionally)

      The easiest default behaviour should be the delete key. With the same “walking cats” argument we could argue that, to be secure, normal typing in Office software should be just allowed by holding the right Ctrl Key because then a cat could not scramble our (unintentionally left open) letter. So typing generally should be more secure in Gnome3, Ctrl+j Ctrl+u Ctrl+s Ctrl+t Ctrl+” ” Ctrl+h Ctrl+o Ctrl+l Ctrl+d Ctrl+” ” Ctrl+t Ctrl+h Ctrl+e Ctrl+” ” Ctrl+C Ctrl+t Ctrl+r Ctrl+l Ctrl+” ” Ctrl+k Ctrl+e Ctrl+y Ctrl+” ” Ctrl+d Ctrl+o Ctrl+w Ctrl+n.

      Cheers.

  9. Reply
    Torsten Leander 4 October 2011

    You are my hero 🙂 Which Nautilus version is the first to use your patch?

    • Reply
      gg 5 October 2011

      The one that came out with the new gnome 3.0

  10. Reply
    Eugén Jung 9 October 2011

    Don’t take this the wrong way, but this is ridiculous.  On many laptops the Ctrl key and the Delete key are on OPPOSITE ENDS OF THE KEYBOARD (instead of having two Ctrl keys, like most desktop keyboards have).

    To delete a file with the Ctrl+Del key combo requires moving your mouse hand off the mouse to the keyboard.  This is NOT a good user experience.

    Personally, I would much rather have a confirmation box.

    If there is no way to do this in Nautilus 3.2 by default, I’ll see if I can do it myself (unless your patch still works in 3.2?).

  11. Reply
    Parlapipas 28 November 2011

    Selfish arrogantism… The worst idea ever! And because macs do it we should like it?
    Opensource is not mac.
    Buy a mac and leave as alone!

  12. Reply
    Parlapipas 28 November 2011

    Sorry leave us alone.
    By the way. Gnome should fork. Gnome for users and gnome for sistas.

  13. Reply
    Montex 4 December 2011

    I don’t understand your point, and I don’t think it’s has been a good idea. Fortunately there is a simple way to change this behavior… simple as it was to change the old behavior without the need of a patch, I think?

    When I switched from Windows to Gnome, I found the ability to move files to the trash by just tapping Del was great… now I’m completely disappointed with the new behavior. Concerning the confirmation dialog, isn’t it true that while you are not looking your “cat” (or something) would also be able to press “Return” and thus confirm the deletion? After all Del and Return are very near in the keyboard..

  14. Reply
    Michael 14 December 2011

    First off, thanks for caring and thanks for putting in the work.
    However… This “fix” has been driving me insane. I understand there can be multiple opinions on these things but then couldn’t you have added this counter-intuitive, non-standard, new behaviour as an option?
    Any change I make to accelerators is undone after the next reboot so I’m really stuck with this (on two machines, so I’m pretty sure it’s a common bug).
    “Delete” just means delete to me. It moves things to the trash which is already a safeguard and there’s lots of other things around me I shouldn’t accidentally hit either. Between windows and gnome2 I’m sure the vast majority of users don’t expect this behaviour either.

  15. Reply
    Isaac David Reyes González 30 December 2011

    So you are responsible for the new nautilus shortcut. Nice job.

  16. Reply
    Billy Larlad 11 January 2012

    With my caps lock key rebound to serve as control, now I only have to slip my finger down to shift to permanently delete a file. Great addition!

  17. Reply
    Bubbahutson 13 February 2012

    if u didnt like it, change the key bindings on your pc. and leave the rest of us alone. 

  18. Reply

    […] Arch Linux Forums: I can not delete with the delete key in Gnome 3 gg: Patches for Nautilus “move to trash” bug Tags: gnome3, […]

  19. Reply
    T3STY 25 February 2012

    What??! We’re having a DELETE key on the keyboard that IS NOT DOING ITS WORK!
    Why would someone want to change the delete key behaviour? Moving files to trash won’t make idiots loose their accidentally deleted files, emptying the trash still requires confirmation.
    Also, if YOU (the one who had this awful idea…) really like this new behaviour, AT LEAST LET US MAKE OUR CHOICE.

    Iidiots on this planet ruin the life of everyone…

  20. Reply
    T3STY 25 February 2012

    Oh, I almost forgot:
    The solution at the link won’t work, after restarting the user session the accelerator will restore to CTRL+Delete (and SHIFT+Delete)

  21. Reply
    Daniel 16 March 2012

    If I press the delete key, I want to delete things. Get out of my way. Or maybe we should add a confirm pop-up and require the user to type “DELETE”? 

  22. Reply
    Stephen J Alexander 7 April 2012

    you have a terrible attitude about this and you have articulated yourself poorly; as a result, many suffer.

  23. Reply
    hb 9 April 2012

    It’s hillarious to read your blog post ranting about how GNOME developers are allegedly torturing the masses, and then the comments turning this completely upside down.

    I agree to the masses (as received in the comments) that this is a horrible change.

  24. Reply
    Daniel Dupriest 28 October 2012

    There seem to be plenty of opinions on this change to the Delete key. I think Niczar, however, brought up the most important point in his #2: One key+Delete combo will move your files to the trash, while the other key+Delete combo will irreversibly delete them. Which was it again.. Ctrl or Shift? For people who do any amount of file management this seems like a dangerous situation.

  25. Reply
    Vasile 10 August 2013

    I don’t like what you’ve done. It wasn’t a good idea.
    I prefer the old way of deleting files.

  26. Reply
    Norm 4 October 2013

    I don’t even know who you are, but know that the rest of the world hates you for this.

  27. Reply
    i-am-able-to-use-the-trash 2 November 2013

    Your “solution” is just stupid. Maybe you should learn how to restore files from the trashfolder.
    Furthermore, the link you provide for restoring the old, CORRECT behaviour is outdated and won’t work in Gnome 3.10.

    Please stop “contributing” to open source software. Just use OS X if you like it that much.

  28. Reply
    tired 16 January 2014

    …after not upgrading for a longer time, I just spent the evening reversing such improvements as this one:(

  29. Reply
    Adonis K. 18 March 2014

    Seriously, wtf man?
    If you are scared of your cat’s walking habits then take off the godamn DEL key off the keyboard, don’t screw the rest of the world…

  30. Reply
    Angry-at-you user 24 June 2014

    Sorry, but Damn you, man! DEL-only deletion has never been any problem to me, but now CTRL+DEL is more of an annoyance than any kind of solution. I was almost switching to another browser because of you! D:<

  31. Reply
    victor 26 June 2014

    Oh dear! I landed here after spending 1hr to revert your non-fix to a non-bug! I have no cat: was it all because of yours?! How can you claim that “opensource wins again” when your patch just complicates things for so many people? Just google for the number of threads where confused users try to revert to the old behavior… If at least there was some choice in the preferences to revert to the behavior!
    Actually the delete thing in itself is not important of course. It is rather about your idea of opensource software. Opensource has always been about *information*, not about restricting choices. You could for example educate those few users who may not know what a trash bin is. Complicating things “for our own safety” is not opensource mentality at all! I hope at least your cat is happy…

  32. Reply
    Brian Napoletano 6 January 2016

    It’s hard to criticize your work when you’ve gone ahead and written a patch while I couldn’t code my way out of a paper bag, but I do confess to being a bit surprised that this argument was enough to change the function of something as basic as a the function of a keyboard—key? As I imagine most of the other commentators here have done, I arrived here after running a search on a combination of “gnome delete key wtf,” and while I see the logic of adding a layer of protection around a function as powerful as “delete,” I also thought that this was the reason we have a “trash” folder rather than just having files disappear on “delete.” Given this existing layer of security, I have to admit that I find the switch to “Ctrl + Del” a bit counter-intuitive. First, it seems to negate the purpose of the “delete” key outside of text editing. Second, it seems to break parity with the command line, where “rm” removes a file and the more explicit “shred” ensures that said file is unrecoverable — i.e., this seems to more logically parallel the concept of “Del” to remove a file and “Shift + Del” to permanently wipe it. Third, it seems to violate the principle of not fixing things that aren’t broken, or at least making sure that the fix will be a welcome one. Granted, I just switched from Ubuntu to Debian, and so there are many changes I’m adjusting to. Still, this one seemed a bit odd.

  33. Reply

    […] for example this smart guy, who took it upon himself to save you from all the cats running around pressing buttons on your […]

Leave a Reply

Your email address will not be published. Required fields are marked *