You are not logged in.

#1 2011-04-30 05:20:49

gavinhungry
Member
Registered: 2011-02-13
Posts: 10
Website

[SOLVED] Firefox recreating Desktop folder

I run Xfce with no desktop icons, so I have no use for the ~/Desktop folder, which I've removed.  I've noticed that occasionally the Desktop folder will reappear in my home folder.  I saw a thread where a user claimed they saw this behavior after clicking "the upload button" in Firefox.  It does seem that clicking "Browse" on an <input type='file'> element will default to your Desktop folder if there's no "last viewed" folder available, and recreate the Desktop folder otherwise.

Source for Firefox/xulrunner:

mozilla-2.0/content/html/content/src/nsHTMLInputElement.cpp:

    // Attempt to retrieve the last used directory from the content pref service
    nsCOMPtr<nsILocalFile> localFile;
    nsHTMLInputElement::gUploadLastDir->FetchLastUsedDirectory(doc->GetDocumentURI(),
                                                               getter_AddRefs(localFile));
    if (!localFile) {
      // Default to "desktop" directory for each platform
      nsCOMPtr<nsIFile> homeDir;
      NS_GetSpecialDirectory(NS_OS_DESKTOP_DIR, getter_AddRefs(homeDir));
      localFile = do_QueryInterface(homeDir);
    }
    filePicker->SetDisplayDirectory(localFile);

Last edited by gavinhungry (2011-04-30 06:20:46)

Offline

#2 2011-04-30 06:07:03

thisoldman
Member
From: Pittsburgh
Registered: 2009-04-25
Posts: 1,172

Re: [SOLVED] Firefox recreating Desktop folder

The creation of a ~/Desktop directory by Firefox is a feature; Mozilla is following freedesktop.org implied guidelines.  You can stop the creation of the ~/Desktop directory by editing or creating a file, ~/.config/user-dirs.dirs

In that file you specify which directories are defaults for the common directories (common as specified by freedesktop.org).  After the user-dirs.dirs file is written, Firefox won't create a Desktop directory again.  Here's my user's user-dirs.dirs:

XDG_DESKTOP_DIR="/home/casey/"
XDG_DOWNLOAD_DIR="/home/casey/downloads"
XDG_TEMPLATES_DIR="/home/casey/"
XDG_PUBLICSHARE_DIR="/home/casey/shared/"
XDG_DOCUMENTS_DIR="/home/casey/working"
XDG_MUSIC_DIR="/home/casey/music"
XDG_PICTURES_DIR="/home/casey/pictures"
XDG_VIDEOS_DIR="/home/casey/pictures/videos"

I believe the package xdg-utils must be installed for this to work.  See http://www.freedesktop.org/wiki/Software/xdg-user-dirs.

Offline

#3 2011-04-30 06:18:42

gavinhungry
Member
Registered: 2011-02-13
Posts: 10
Website

Re: [SOLVED] Firefox recreating Desktop folder

thisoldman wrote:

You can stop the creation of the ~/Desktop directory by editing or creating a file, ~/.config/user-dirs.dirs

Thanks, that's much simpler.

Offline

Board footer

Powered by FluxBB