Active Topics

 


Reply
Thread Tools
Posts: 1,224 | Thanked: 1,763 times | Joined on Jul 2007
#31
You create a file (say /usr/local/bin/scriptname) with this content, make sure it is executable (with a command like)

chmod a+x /usr/local/bin/scriptname

First, you should run it to see if it does what you want.

If you are sure you want it to start at boot time, the easiest way is probably to create a file /etc/event.d/autodisconnect, containing:
Code:
description "Run a script to disconnect idle networks"

start on started icd2

console none

script
        /usr/local/bin/scriptname
end script
About the script itself:
It can be up to 10 minutes, if last transfer happens a few seconds after the sleep starts, because the next check will see this transfer.

I believe using received makes more sense, since sometime the network appears up, but the other side is not there. In that case applications might continually send data, but nothing will be received.

I don't know of a wiki explaining all this, but you seem to be on the right track for understanding. I can think of no better way to do it than looking at simple scripts, and playing with them. If you don't have a Linux desktop, search for "manual page" of each command you need to learn.
 

The Following User Says Thank You to Matan For This Useful Post:
stopgap's Avatar
Posts: 139 | Thanked: 135 times | Joined on Jan 2010 @ Cambridgeshire, UK
#32
Ok, so I've gotten quite far acutally. I have tailored the script a little and after testing that it worked, have now got it installed as a startup, as per your instructions above.

Should I wish to terminate this script - what would I need to do? I have HTOP installed and was poking around with that. I'm also aware of kill and ps now, but don't know what it is I'm supposed to be killing. Should the process be listed in there with a PID?

Thanks again for your help here, you've really opened up the gateway here re: linux scripting. I never knew where to start and this has been a brilliant introduction. Cheers

** EDIT
Ok, so it didn't run. Did I need to CHMOD the file which ran the script file in the same way too? That's the only thing that I didn't do...

Last edited by stopgap; 2010-01-21 at 03:12.
 
Posts: 318 | Thanked: 49 times | Joined on Nov 2009
#33
Let us know if your battery life has improved with everyday usage after using the script.
 
Posts: 1,224 | Thanked: 1,763 times | Joined on Jul 2007
#34
Do you mean that the script runs when you run it manually, but does not start automatically? I am not sure about the operation of the upstart system. Perhaps you need to add an ampersand after the call to the script, so the line should be:
/usr/local/bin/scriptname &
Also /usr/local/bin/scriptname needs to be executable, not the file in /etc/event.d
 

The Following User Says Thank You to Matan For This Useful Post:
Posts: 518 | Thanked: 160 times | Joined on Dec 2009
#35
Originally Posted by woodyear99 View Post
I do not want to manually connect to the internet, I want it to automatically connect when widgets/apps request data at their intervals, once data transfers have been done I want it to disconnect the gprs connection. That would improve battery life since I noticed that just leaving the gprs connection running all day drains the battery faster even when not in use.
FWIW, this was a setting in the web browser (pocket IE) for my Motorola Q. One could set the length of "inactivity" before disconnecting. I had two different "3G" icons...one for "voice", the other "data", which confirmed connection state. If the "data" session was disconnected, and the icon not visible, if I open the browser, or checked email, the icon would appear, and disapear again, after the preconfigured inactivity period.
 
stopgap's Avatar
Posts: 139 | Thanked: 135 times | Joined on Jan 2010 @ Cambridgeshire, UK
#36
Yes... the script runs fine manually. I can't get upstart to start it - it just doesn't work. Is there some way I could get my script to set a variable or something to show it is running? I tried using export to set a global variable but it seems to be limited to the shell in which the script is running... unless I misunderstanding (this is only my second day writing shell scripts so it could well be that!

How would I go about piping the time to a text file for example, or is there a way to set a variable that I could check this way?

Thanks again for your help
 
Posts: 1,224 | Thanked: 1,763 times | Joined on Jul 2007
#37
Use something like

date >> /tmp/a.log
__________________
My repository

"N900 community support for the MeeGo-Harmattan" Is the new "Mer is Fremantle for N810".

No more Nokia devices for me.
 

The Following 2 Users Say Thank You to Matan For This Useful Post:
Posts: 41 | Thanked: 15 times | Joined on Jan 2010 @ Finland, Aaland Islands
#38
This is an interesting idea, I hate to forgetting turning wifi off before going to bed and find my phone dead in the morning.

Installed script and it works fairly good for 3G.

Seems like wlan keeps sending packets although the device is idle.

A more accurate way to turn connections off would be to check for user inactivity but I have no idea how to check that via a shell script.
 
stopgap's Avatar
Posts: 139 | Thanked: 135 times | Joined on Jan 2010 @ Cambridgeshire, UK
#39
Originally Posted by snookh View Post
This is an interesting idea, I hate to forgetting turning wifi off before going to bed and find my phone dead in the morning.

Installed script and it works fairly good for 3G.

Seems like wlan keeps sending packets although the device is idle.

A more accurate way to turn connections off would be to check for user inactivity but I have no idea how to check that via a shell script.
You got it to install... may I ask what exactly you did? I'm just not getting it to work... I've followed the instructions above and I just can't seem to get it to auto start when the phone boots.

As it stands I have an executable script which disconnects properly and logs startup and disconnections to a text file. It executes manually without error but I just cannot autostart it.

Also, does anyone know if there's a way to send a notification message from a script? I'm talking about the notifications which confirm an SMS delivery or a website's security or "code accepted" when you unlock - the pop up ones which fade & slide away automatically.

Thanks again for all the help!
 
qwerty12's Avatar
Posts: 4,274 | Thanked: 5,358 times | Joined on Sep 2007 @ Looking at y'all and sighing
#40
Originally Posted by stopgap View Post
Also, does anyone know if there's a way to send a notification message from a script? I'm talking about the notifications which confirm an SMS delivery or a website's security or "code accepted" when you unlock - the pop up ones which fade & slide away automatically.
Code:
run-standalone.sh dbus-send --type=method_call --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.SystemNoteInfoprint string:"Message goes here"
 

The Following 6 Users Say Thank You to qwerty12 For This Useful Post:
Reply

Tags
automatic, connect, connect automatically, connect on activity, connect on demand, connect on use, data, data connection, disconnect, disconnect automatically, disconnect when idle, fremantle, gprs, internet, maemo, maemo 5, n900, on demand, on use


 
Forum Jump


All times are GMT. The time now is 20:05.