{"id":830,"date":"2013-12-08T23:31:30","date_gmt":"2013-12-09T04:31:30","guid":{"rendered":"http:\/\/blog.alanporter.com\/?p=830"},"modified":"2013-12-08T23:31:30","modified_gmt":"2013-12-09T04:31:30","slug":"thunar-trash","status":"publish","type":"post","link":"https:\/\/alanporter.com\/blog\/2013\/12\/08\/thunar-trash\/","title":{"rendered":"The obstinate trash man"},"content":{"rendered":"<p>This weekend&#8217;s pet project was to set up <strong>Ubuntu Studio<\/strong> to run on my Macbook Pro.<\/p>\n<p>Ubuntu Studio is a Linux distribution, based on Ubuntu, that comes with lots of audio and video software installed and configured.\u00a0 I have been wanted to play with Ardour, an open source digital audio workstation, and although it will run on a Mac, it runs much better on Linux.\u00a0 So I downloaded and burned a copy of the Ubuntu Studio &#8220;Live DVD&#8221;.\u00a0 This would allow me to test drive Ubuntu Studio on the Macbook without installing anything on the Macbook&#8217;s hard disk.\u00a0 It worked wonderfully, and so I decided to make a bootable &#8220;Live USB&#8221; stick as well.\u00a0 The Live USB stick acts just like the Live DVD, except it also allows you to save files back to the USB stick (obviously, you can&#8217;t save files to a read-only DVD).\u00a0 So I would be able to do my studio work in Linux and save my work when I reboot back into OSX.<\/p>\n<p>I was greeted with a very weird bug in Ubuntu Studio&#8217;s desktop system.\u00a0 Whenever I tried to delete a file, I would get the following error:<\/p>\n<blockquote><p>Unable to find or create trash directory<\/p><\/blockquote>\n<p>What a weird error message!<\/p>\n<p>Ubuntu Studio uses the XFCE desktop environment, which follows the Free Desktop&#8217;s &#8220;<a href=\"http:\/\/www.freedesktop.org\/wiki\/Specifications\/trash-spec\/\">Desktop Trash Can Specification<\/a>&#8220;.\u00a0 Yes, there are people who write specifications about how trash cans are supposed to work.\u00a0 There is a utility called &#8220;gvfs-trash&#8221; that actually handles moving deleted files to the appropriate trash can area.\u00a0 You can run this command from a shell prompt.<\/p>\n<pre><code>$ gvfs-trash somefile\nError trashing file: Unable to find or create trash directory<\/code><\/pre>\n<p>There&#8217;s that same error message.<\/p>\n<p>I ran the same command with &#8220;strace&#8221; to figure out what it was doing, and I did a little bit of Googling.\u00a0 I found <a href=\"http:\/\/mynixworld.wordpress.com\/2012\/09\/16\/fix-the-unable-to-find-or-create-trash-directory-in-thunar\/\">this blog post<\/a>, which told me most of what I needed.<\/p>\n<p>The gvfs-trash system wanted to find a directory called &#8220;.Trash-999&#8221; in the top level of the filesystem.\u00a0 It wanted 999 because my user ID number was 999 (run the &#8220;id&#8221; command to see what your user ID number is).\u00a0 Inside the \/.Trash-999 folder, it also wanted two sub-folders named &#8220;files&#8221; and &#8220;info&#8221;.\u00a0 All three of these needed to have 700 permissions.<\/p>\n<p>Here&#8217;s a one-liner that will do it all:<\/p>\n<pre><code>u=$(id -u) ; g=$(id -g) ; sudo mkdir -m700 \/.Trash-$u ; sudo chown $u:$g \/.Trash-$u ; mkdir -m700 \/.Trash-$u\/{files,info}<\/code><\/pre>\n<p>After that, the desktop system could remove files OK, and the <code>gvfs-trash<\/code> command could as well.<\/p>\n<p>That gvfs-trash command might make a good alias!<\/p>\n<pre><code>alias rm='gvfs-trash'<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>This weekend&#8217;s pet project was to set up Ubuntu Studio to run on my Macbook Pro. Ubuntu Studio is a Linux distribution, based on Ubuntu, that comes with lots of audio and video software installed and configured.\u00a0 I have been wanted to play with Ardour, an open source digital audio workstation, and although it will [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,8,15],"tags":[],"class_list":["post-830","post","type-post","status-publish","format-standard","hentry","category-software","category-madness","category-tips-tricks","count-0","even alt","author-alan","last"],"_links":{"self":[{"href":"https:\/\/alanporter.com\/blog\/wp-json\/wp\/v2\/posts\/830","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/alanporter.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/alanporter.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/alanporter.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/alanporter.com\/blog\/wp-json\/wp\/v2\/comments?post=830"}],"version-history":[{"count":0,"href":"https:\/\/alanporter.com\/blog\/wp-json\/wp\/v2\/posts\/830\/revisions"}],"wp:attachment":[{"href":"https:\/\/alanporter.com\/blog\/wp-json\/wp\/v2\/media?parent=830"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/alanporter.com\/blog\/wp-json\/wp\/v2\/categories?post=830"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/alanporter.com\/blog\/wp-json\/wp\/v2\/tags?post=830"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}