You are not logged in.

Dear visitor, welcome to KDE-Forum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

kcsmith

Beginner

  • "kcsmith" started this thread

Posts: 7

Location: South Africa

Occupation: Student

  • Send private message

1

Wednesday, May 3rd 2006, 12:57pm

Proxy Settings

Hi, is there a way to change my proxy settings from a bash script.
I have been trying to find a dcop call, without success. I also tried editing the config file containing the settings and to make kde reread the config file, but that didn't work (yet).

bram85

Professional

Posts: 948

Location: Eindhoven

Occupation: Software Engineer

  • Send private message

2

Wednesday, May 3rd 2006, 1:29pm

RE: Proxy Settings

You mean Konqueror's Proxy settings? Make sure Konqueror is not running when you modify the configuration files, since they will be overwritten when Konqueror quits.
Bram Schoenmakers
KDE Netherlands (www.kde.nl)

kcsmith

Beginner

  • "kcsmith" started this thread

Posts: 7

Location: South Africa

Occupation: Student

  • Send private message

3

Wednesday, May 3rd 2006, 3:27pm

Well, the proxy settings apply to all kio slaves that will need the proxy settings (I think). So it isn't just a konqueror thing. Also if you change them in kcontrol, it applies the settings without need to restart anything. I want to duplicate that functionality.

bram85

Professional

Posts: 948

Location: Eindhoven

Occupation: Software Engineer

  • Send private message

4

Wednesday, May 3rd 2006, 3:47pm

OK, just modify the config file with your script. When you've made the modifications, you can update the already running IO slaves with the following script:

Source code

1
2
3
4
5
6
7
8
CLIENTS=`dcop`

for CLIENT in $CLIENTS; do
  dcop $CLIENT | grep KIO::Scheduler
  if [ $? = 0 ]; then
    dcop $CLIENT KIO::Scheduler reparseSlaveConfiguration
  fi
done


So, for each client which has a KIO::Scheduler available, read the slave configurion again.

(Disclaimer: I did not validate the Bash syntax, but I hope you get the idea :) )
Bram Schoenmakers
KDE Netherlands (www.kde.nl)

kcsmith

Beginner

  • "kcsmith" started this thread

Posts: 7

Location: South Africa

Occupation: Student

  • Send private message

5

Wednesday, May 3rd 2006, 8:50pm

Thanks,
I actually just worked that out a little after my last post, and I was posting now with the solution, but i see you beat me to it. I just read the source code for kcontrol in kde-base. The source for it was clean and easy to follow which was a bonus and a nice change from some of the source code I have read before.

From reading the source code I also picked up that I should also call:

Source code

1
dcop kded proxyscout reset


I think you can just do this everytime, and the call will just fail when you don't have to do it.

The whole point of this script is for changing my proxy settings & connections settings depending on where I am with my laptop. Do you maybe know of an application that already exists?

This post has been edited 1 times, last edit by "kcsmith" (May 4th 2006, 11:16am)


anda_skoa

Professional

Posts: 1,273

Location: Graz, Austria

Occupation: Software Developer

  • Send private message

6

Saturday, May 6th 2006, 5:06pm

There is a script on kde-apps,org which does this:
http://www.kde-apps.org/content/show.php?content=34605

Cheers,
_
Qt/KDE Developer
Debian User

kcsmith

Beginner

  • "kcsmith" started this thread

Posts: 7

Location: South Africa

Occupation: Student

  • Send private message

7

Saturday, May 6th 2006, 11:54pm

The script at the moment I have made at the moment switches between dhcp, static and (adhoc with wireless) pretty easily. It also changes firefoxes proxy settings. Do any of you guys know maybe of a project that uses iptables to redirect you requests to a proxy which just talks to other proxies. I know you could probably just install squid to do this, but squid can't handle javascript (for thoses auto proxy configs) and I don't know how easily it is to change the settings on the fly. (PS I am just guessing that squid doesn't know javascript). I was thinking that when the holidays start I could maybe start a project like this.

anda_skoa

Professional

Posts: 1,273

Location: Graz, Austria

Occupation: Software Developer

  • Send private message

8

Friday, May 12th 2006, 6:42pm

A proxy, e.g. squid, does not need to know about JavaScript, it is always the browser which will evaluate it and request/send data.

Cheers,
_
Qt/KDE Developer
Debian User

kcsmith

Beginner

  • "kcsmith" started this thread

Posts: 7

Location: South Africa

Occupation: Student

  • Send private message

9

Saturday, May 13th 2006, 5:30pm

Well if you have to make your proxy settings to a proxy configuration url, the url is a javascript that translates your request to a proxy server. At my university they have a few proxy servers depending on what website you want. So the proxy config url will decide what proxy to use on each request. Unless your program understands javascript, it will not know how to interpret the url. A good example: wget.

anda_skoa

Professional

Posts: 1,273

Location: Graz, Austria

Occupation: Software Developer

  • Send private message

10

Saturday, May 13th 2006, 10:41pm

Ah, yes, true. Automatic proxy configuration requires script capabilites, I thought you were talking about scripts inside web pages.

Sorry

Cheers,
_
Qt/KDE Developer
Debian User