Download window
Dini
Status: New User - Welcome
Joined: 01 Jul 2008
Posts: 1
Reply Quote
Hi, I need to switch off the download window of c.a. 1500 thin cliens, that run mozilla.
Because of the number, and the number of locations it is impossible to do it each manually.

I need to use the prefs.js file, for this purpose.
Can anyone help me how can I configure it that way? I'd be really grateful!

thx
Back to top
jeffd
Status: Assistant
Joined: 04 Oct 2003
Posts: 594
Reply Quote
Hi Dini, how unusual here to get an actually interesting question ;-)

First, we need to know the setting, that's found at mozilla.org

:: Code ::
// Turn off the download manager (0=download manager, 1=simple dialog?)
user_pref("browser.downloadmanager.behavior", 1);


So that's easy enough for the first step. The next step is not as easy, and requires some cleverness. However, since you are not dealing with random naming conventions I assume in your thin clients, the next step is to create a script that will update or add this value to prefs.js, for all users, automatically.

However, since you didn't state if you are talking about windows or linux clients, I'd better stop now. I'm assuming linux based, and if it's windows, I have exactly zero idea of how to script this, but you can get an idea anyway.

The logic is simple:

Conveniently, we already have a mozilla prefs updating tool, though it's a bit more than you need, you can download it here. The function of interest to you is: tweak_gecko_prefs, about line 430.

Since this is designed to handle many prefs, it's overkill for you, so let's think about the logic, which is pretty simple:

find all files paths that you will be updating automatically like this:
Of course you'd have to adjust the path and wildcards until they correctly bring up the path for all the prefs.js on each home directory, or whatever they call it in windows now.
:: Code ::
ls /home/*/.mozilla/*/*/prefs.js


Once you have this information, you can first reset the pref if the downloads pref is set, use sed to update the value to false, like so:

:: Code ::
ls  /home/*/.mozilla/*/*/prefs.js | xargs -i sed -i '/user_pref("browser.downloadmanager.behavior",[[:space:]]*0);/user_pref("browser.downloadmanager.behavior",1);/' {}


This will have updated any previously set value, and ignored any not set, but it doesn't help us set it if it's missing, so we move on.

If it's not set, which default is not yet present, you need to test then update it:
:: Code ::
prefsLocations=$(ls  /home/*/.mozilla/*/*/prefs.js)
for prefs in $prefsLocations
do
  if [ -z "$( grep browser.downloadmanager.behavior $prefs)" ]
  then
    echo 'user_pref("browser.downloadmanager.behavior",1);' >> $prefs
 else
   sed -i '/user_pref("browser.downloadmanager.behavior",[[:space:]]*0);/user_pref("browser.downloadmanager.behavior",1);/' $prefs
 fi
done


Normally I don't write people's code for them, but because this is a fun and slightly tricky problem, and it's familiar, I don't mind.

Note, for windows, again, it's a crippled scripting environment and I have no interest in learning how to work within those limits, so you'll have to translate this logic to window siimplified if that's the case, yourself.

Now I'm not positive if this value is the correct one, you'll need to figure that out for yourself, it might just be a change in download manager window type, so experiment and google it a bit.

Now getting the stuff out to each machine just depends on how you access them in the first place, if they have a startup script that is connected to server type resources, you can just add this little script to their startup routine, otherwise I can't say.
Back to top
Display posts from previous:   

All times are GMT - 8 Hours