You are not logged in.

#1 2010-04-16 20:01:33

demian
Member
From: Frankfurt, Germany
Registered: 2009-05-06
Posts: 709

[solved (twice)] Unwanted folders "Desktop" and "Downloads" in $HOME

Hey guys,

I didn't want to bother you but i can't seem to find a solution.
From time to time one of or both the folders "Desktop" and "Downloads" appear in my /home/user directory. One or more applications must be creating these but i can't really pin it down because the creation time seems random to me and not connected to an application at all.
I'm using no desktop environment, just standalone Openbox. I use both PCManFM and Firefox frequently, sometimes Mirage.
Firefox downloads in a specified folder which is not "Downloads". Neither do i use PCManFM to manage my desktop. Actually I'm not using desktop symbols at all, it's just a wallpaper. I haven't found anything in the Openbox configuration either. I'm not using many other apps, just feh, epdfview, medit and those basics.
Clues as to who the mischief here might be would be much appreciated.

Regards,
demian

Last edited by demian (2010-04-17 14:07:14)


no place like /home
github

Offline

#2 2010-04-16 20:05:02

Peasantoid
Member
Registered: 2009-04-26
Posts: 928
Website

Re: [solved (twice)] Unwanted folders "Desktop" and "Downloads" in $HOME

Stupidly, Firefox creates ~/Desktop/ when you open the 'General' preferences pane. If you use Transmission, that might be what's creating ~/Downloads/.

Offline

#3 2010-04-16 20:10:08

demian
Member
From: Frankfurt, Germany
Registered: 2009-05-06
Posts: 709

Re: [solved (twice)] Unwanted folders "Desktop" and "Downloads" in $HOME

Ah, thanks, so it's Firefox! One down. Guess I'll have to create a cronjob for deleting that directory then as there's probably nothing i can do about it.
I'm not using Transmission though.

Last edited by demian (2010-04-16 20:13:13)


no place like /home
github

Offline

#4 2010-04-16 20:14:38

Peasantoid
Member
Registered: 2009-04-26
Posts: 928
Website

Re: [solved (twice)] Unwanted folders "Desktop" and "Downloads" in $HOME

Can you enumerate all the download-capable applications you use? Generally the culprits are the graphical, cross-platform ones.

// As for the 'nothing you can do' thing - just avoid the General pane. I almost never need to delve into the preferences anyway since I got FF configured ages ago.

// The cronjob idea is good, if a bit over{kill,blown}. tongue

Last edited by Peasantoid (2010-04-16 20:15:52)

Offline

#5 2010-04-16 20:15:04

cesura
Package Maintainer (PM)
From: Tallinn, Estonia
Registered: 2010-01-23
Posts: 1,867

Re: [solved (twice)] Unwanted folders "Desktop" and "Downloads" in $HOME

demian wrote:

Ah, thanks, so it's Firefox! One down. Guess I'll have to create a cronjob for deleting that directory then as there's probably nothing i can do about it.
I'm not using Transmission though.

Or something along the lines of:

alias firefox='firefox && rm -r ~/Desktop/'

in ~/.bashrc

OR EVEN:

mv /usr/bin/firefox /usr/bin/firefox_exec

and create a /usr/bin/firefox script:

#!/bin/sh
/usr/bin/firefox_exec &
rm -r ~/Desktop

and:

chmod +x /usr/bin/firefox

I like the second one better

Last edited by cesura (2010-04-16 20:25:14)

Offline

#6 2010-04-16 20:16:54

Peasantoid
Member
Registered: 2009-04-26
Posts: 928
Website

Re: [solved (twice)] Unwanted folders "Desktop" and "Downloads" in $HOME

itsbrad212 wrote:
demian wrote:

Ah, thanks, so it's Firefox! One down. Guess I'll have to create a cronjob for deleting that directory then as there's probably nothing i can do about it.
I'm not using Transmission though.

Or something along the lines of:

alias firefox='firefox && rm -r ~/Desktop/'

But if the user has deliberately created ~/Desktop/, that blows away his files.
Better to use rmdir rather than rm -r.

Last edited by Peasantoid (2010-04-16 20:18:16)

Offline

#7 2010-04-16 20:22:56

cesura
Package Maintainer (PM)
From: Tallinn, Estonia
Registered: 2010-01-23
Posts: 1,867

Re: [solved (twice)] Unwanted folders "Desktop" and "Downloads" in $HOME

Peasantoid wrote:
itsbrad212 wrote:
demian wrote:

Ah, thanks, so it's Firefox! One down. Guess I'll have to create a cronjob for deleting that directory then as there's probably nothing i can do about it.
I'm not using Transmission though.

Or something along the lines of:

alias firefox='firefox && rm -r ~/Desktop/'

But if the user has deliberately created ~/Desktop/, that blows away his files.
Better to use rmdir rather than rm -r.

Well, obviously this user isn't using the folder. cool

Offline

#8 2010-04-16 20:23:11

demian
Member
From: Frankfurt, Germany
Registered: 2009-05-06
Posts: 709

Re: [solved (twice)] Unwanted folders "Desktop" and "Downloads" in $HOME

Those are sweet ideas too, itsbrad212. Thanks.
I'm using Openbox shortcuts in rc.xml to start most of my applications though so the alias won't work for me. But maybe i'll add that "rmdir /home/user/Desktop/ /home/user/Downloads/"-part to a function or alias i'm using regularly in my terminal.
I'll try the redirect script now.

As for download applications I'm using Firefox, rtorrent, lynx, wget and curl. Not big a downloader.

Greets,
demian

Last edited by demian (2010-04-16 20:26:31)


no place like /home
github

Offline

#9 2010-04-16 20:27:57

cesura
Package Maintainer (PM)
From: Tallinn, Estonia
Registered: 2010-01-23
Posts: 1,867

Re: [solved (twice)] Unwanted folders "Desktop" and "Downloads" in $HOME

Thanks big_smile Be warned though. If you use one of the methods, you will not be able to use options on firefox, i.e. 'firefox --help'. You would do, for example, 'firefox_exec --help' for the second method

Last edited by cesura (2010-04-16 20:29:41)

Offline

#10 2010-04-16 20:33:26

Peasantoid
Member
Registered: 2009-04-26
Posts: 928
Website

Re: [solved (twice)] Unwanted folders "Desktop" and "Downloads" in $HOME

itsbrad212 wrote:

Thanks big_smile Be warned though. If you use one of the methods, you will not be able to use options on firefox, i.e. 'firefox --help'. You would do, for example, 'firefox_exec --help' for the second method

Fix for that (put in .bashrc):

firefox() {
    /usr/bin/firefox "$@" && rmdir ~/{Desktop,Downloads}
}

Note that you must write out the full path to firefox or you will get nasty recursion.

Actually it would be better to put the above as a script in a $PATH directory (~/bin on my system), so you can use it from non-interactive scripts that don't source .bashrc.

Also I do *not* recommend moving binaries around on the system. Especially pacman-controlled ones.

Last edited by Peasantoid (2010-04-16 20:35:21)

Offline

#11 2010-04-16 20:34:13

demian
Member
From: Frankfurt, Germany
Registered: 2009-05-06
Posts: 709

Re: [solved (twice)] Unwanted folders "Desktop" and "Downloads" in $HOME

So, I'm using the firefox-exec way but instead of moving firefox to firefox-exec i just created /usr/bin/firefox-exec and linked to /usr/bin/firefox.

/usr/bin/firefox-exec :

#!/bin/sh
/usr/bin/firefox "$@" &
rmdir /home/user/Desktop /home/user/Downloads >/dev/null

Would be nice to insert a function that checks whether or not the directories are empty before deleting them. That has to wait though since I'm not using the directories and got more pressing concerns tongue.

Thanks for the help, guys! smile

Last edited by demian (2010-04-16 21:36:08)


no place like /home
github

Offline

#12 2010-04-16 20:34:19

skanky
Member
From: WAIS
Registered: 2009-10-23
Posts: 1,847

Re: [solved (twice)] Unwanted folders "Desktop" and "Downloads" in $HOME

Okay, it's Friday night so forgive me any stupidity in what I'm about to ask, but won't the second one (the new firefox script) get over-written in the next Firefox update?

Last edited by skanky (2010-04-16 20:35:32)


"...one cannot be angry when one looks at a penguin."  - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle

Offline

#13 2010-04-16 20:36:51

Peasantoid
Member
Registered: 2009-04-26
Posts: 928
Website

Re: [solved (twice)] Unwanted folders "Desktop" and "Downloads" in $HOME

skanky wrote:

Okay, it's Friday night so forgive me any stupidity in what I'm about to ask, but won't the second one (the new firefox script) get over-written in the next Firefox update?

What I said above - it's an ugly hack that will in all likelihood get fragged by pacman. Better to put it in a user-specific directory such as ~/bin/ (having added this to the front of $PATH).

Last edited by Peasantoid (2010-04-16 20:38:22)

Offline

#14 2010-04-16 20:38:20

demian
Member
From: Frankfurt, Germany
Registered: 2009-05-06
Posts: 709

Re: [solved (twice)] Unwanted folders "Desktop" and "Downloads" in $HOME

skanky wrote:

Okay, it's Friday night so forgive me any stupidity in what I'm about to ask, but won't the second one (the new firefox script) get over-written in the next Firefox update?

In case you're referring to me: I'm using /usr/bin/firefox-exec to redirect to /usr/bin/firefox.
But /usr/bin/firefox is just a symlink anyway. I think it'd only be changed (i.e. removed) if i removed the package firefox.

Last edited by demian (2010-04-16 21:37:32)


no place like /home
github

Offline

#15 2010-04-16 20:38:51

skanky
Member
From: WAIS
Registered: 2009-10-23
Posts: 1,847

Re: [solved (twice)] Unwanted folders "Desktop" and "Downloads" in $HOME

Peasantoid wrote:
skanky wrote:

Okay, it's Friday night so forgive me any stupidity in what I'm about to ask, but won't the second one (the new firefox script) get over-written in the next Firefox update?

What I said above - it's an ugly hack that will in all likelihood get fragged by pacman. Better to put it in a user-specific directory such as ~/bin/ (having added this to the front of $PATH).

Think you posted while I was writing. smile


"...one cannot be angry when one looks at a penguin."  - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle

Offline

#16 2010-04-16 20:41:38

Peasantoid
Member
Registered: 2009-04-26
Posts: 928
Website

Re: [solved (twice)] Unwanted folders "Desktop" and "Downloads" in $HOME

demian wrote:

So, I'm using the firefox-exec way but instead of moving firefox to firefox-exec i just created /usr/bin/firefox-exec and linked to /usr/bin/firefox.

/usr/bin/firefox-exec :

#!/bin/sh
/usr/bin/firefox "$@" &
rmdir /home/slave/Desktop /home/slave/Downloads 2>/dev/null

Thanks, guys! smile

Hold on a minute. If another user runs this, it'll attempt to remove the directories in *your* home. Then the script will fail silently because you redirected stderr to /dev/null (not a bad thing in itself) - remember, the last command in the script is the one that determines the overall exit status.

Even if there aren't other users on your system, that's still monumentally bad practice.

Offline

#17 2010-04-16 20:44:41

Acecero
Member
Registered: 2008-06-21
Posts: 1,373

Re: [solved (twice)] Unwanted folders "Desktop" and "Downloads" in $HOME

Umm...

You guys don't need a script for that. The reason firefox creates a ~/Desktop/ is because in the preferences menu under the general tab, by default it automatically creates the directory for your downloads. All you have to is adjust the path to where you want the files to go or you can have it prompt to where you want to save files. That will take away the ~/Desktop directory.

Offline

#18 2010-04-16 20:47:04

demian
Member
From: Frankfurt, Germany
Registered: 2009-05-06
Posts: 709

Re: [solved (twice)] Unwanted folders "Desktop" and "Downloads" in $HOME

I am the only user besides root so it doesn't really matter but how about this:

#!/bin/sh
/usr/bin/firefox "$@" &
if [ $UID == 1000 ]; then
rmdir /home/user/Desktop /home/user/Downloads >/dev/null
fi
exit 0

1000 is my user id.

Acecero wrote:

Umm...

You guys don't need a script for that. The reason firefox creates a ~/Desktop/ is because in the preferences menu under the general tab, by default it automatically creates the directory for your downloads. All you have to is adjust the path to where you want the files to go or you can have it prompt to where you want to save files. That will take away the ~/Desktop directory.

I already have the autosave option enabled. It's like Peasantoid said. Whenever i enter the genereal options tab in the preferences the folder Desktop gets created.

Last edited by demian (2010-04-16 21:37:56)


no place like /home
github

Offline

#19 2010-04-16 20:48:00

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [solved (twice)] Unwanted folders "Desktop" and "Downloads" in $HOME

<warning: I didn't read the whole thread; sorry, my eyes are killing me>

@OP
chromium by default saves to ~/Downloads. If  you're not using chromium, maybe some other browser?

Offline

#20 2010-04-16 20:53:56

Peasantoid
Member
Registered: 2009-04-26
Posts: 928
Website

Re: [solved (twice)] Unwanted folders "Desktop" and "Downloads" in $HOME

demian wrote:

How about this:

#!/bin/sh
/usr/bin/firefox "$@" &
if [ $UID == 1000 ]; then
rmdir /home/slave/Desktop /home/slave/Downloads >/dev/null
fi
exit 0

My uid is 1000.

Uhhh... better, but still bad practice. You're still putting user-specific stuff outside your own home. Create something like ~/bin/, add it to the front of $PATH in your .bashrc, and create the script there.

Hypothetical ~/bin/firefox:

#!/bin/bash
/usr/bin/firefox "$@"
rmdir ~/{Desktop,Downloads}

Offline

#21 2010-04-16 20:54:44

demian
Member
From: Frankfurt, Germany
Registered: 2009-05-06
Posts: 709

Re: [solved (twice)] Unwanted folders "Desktop" and "Downloads" in $HOME

I used Chromium yesterday but I've had those folder problems before using chromium.
They're solved now anyway, i guess.
On a sidenote:
Chromium gave me trouble when maximizing the windows in Openbox. I had to enable an option where the top bar was activated. Just in case someone wants to try Chromium with Openbox.

Greets,
demian

Last edited by demian (2010-04-16 21:26:55)


no place like /home
github

Offline

#22 2010-04-16 20:57:54

demian
Member
From: Frankfurt, Germany
Registered: 2009-05-06
Posts: 709

Re: [solved (twice)] Unwanted folders "Desktop" and "Downloads" in $HOME

Uhhh... better, but still bad practice. You're still putting user-specific stuff outside your own home. Create something like ~/bin/, add it to the front of $PATH in your .bashrc, and create the script there.

I actually have a .bin folder with scripts already roll Thanks for the suggestion.
Can't think straight this late.

P.S.: q.e.d.  I just posted twice in a row.

This is what it looks like now. If anybody still has suggestions please go ahead. Otherwise the thread is solved now.

/home/user/.bin/firefox

#!/bin/sh
/usr/bin/firefox "$@" &
if [ $USER == user ]; then
rmdir $HOME/{Desktop,Downloads} 2>/dev/null &
fi
exit 0

To make terminal run .bin/firefox instead of /usr/bin/firefox i use this in my .bashrc:

PATH=/home/slave/.bin:$PATH

The corresponding hotkey in rc.xml:

   <keybind key="A-f">
      <action name="Execute">
        <command>.bin/firefox</command>
      </action>
    </keybind>

So, thanks again guys. This is working fine for me now.

Regards,
demian

Last edited by demian (2010-04-16 21:22:32)


no place like /home
github

Offline

#23 2010-04-16 20:58:47

Acecero
Member
Registered: 2008-06-21
Posts: 1,373

Re: [solved (twice)] Unwanted folders "Desktop" and "Downloads" in $HOME

demian wrote:

I already have the autosave option enabled. It's like Peasantoid said. Whenever i enter the genereal options tab in the preferences the folder Desktop gets created.

Ah, I didn't read the whole thread thoroughly.

On another note, would it be better to put the script in the /usr/local/bin directory and PATH it there, just for organization?

Offline

#24 2010-04-16 21:23:13

cesura
Package Maintainer (PM)
From: Tallinn, Estonia
Registered: 2010-01-23
Posts: 1,867

Re: [solved (twice)] Unwanted folders "Desktop" and "Downloads" in $HOME

I leave for a short time and it's already solved cool

I posted that little thing with the sheer intention of having people take it and make it what they need. Obviously, it wouldn't work well in that form because pacman would have a sissy fit.

Offline

#25 2010-04-16 22:06:21

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

Re: [solved (twice)] Unwanted folders "Desktop" and "Downloads" in $HOME

I'm sorry I couldn't help earlier, I was at work and didn't read this thread until now.

The creation of a "Desktop" and some other directories is a feature of free.desktop.org's xdg-user-dirs.    This link, https://support.mozilla.com/tiki-view_f … tId=428359, should give you a solution to stop the creation of unwanted directories.

This solution is also linked from the Arch wiki, http://wiki.archlinux.org/index.php/Fir … want_it.21

Offline

Board footer

Powered by FluxBB