Active Topics

 


Reply
Thread Tools
santiago's Avatar
Posts: 518 | Thanked: 334 times | Joined on Mar 2010 @ italy
#1
hi guys, i'm working with bash, i'm creating a script that check the battery status and the wall carger status to do some things like keep battery life disabling some features (wifi, 3g mode, ringtone, vibration, bluetooth, fmradio, etc)

can somone help me? the script has to save the current profile if different from silent, i made some mistakes and i'm a little bit confused with it becouse it doesnt save the right used profile.

this is the code i made

**** the code is in test for that i left "battery.charge_level.percentage = " empty to test it better

Last edited by santiago; 2011-11-23 at 13:42. Reason: update
 
bingomion's Avatar
Posts: 528 | Thanked: 345 times | Joined on Aug 2010 @ MLB.AU
#2
good script
I googled, found this:
http://talk.maemo.org/showthread.php?t=49904
hope it helps
 
santiago's Avatar
Posts: 518 | Thanked: 334 times | Joined on Mar 2010 @ italy
#3
Originally Posted by bingomion View Post
good script
I googled, found this:
http://talk.maemo.org/showthread.php?t=49904
hope it helps
it's yet in the code, the problem is not this, but the check code and the restore code about the used profile
 
Zas's Avatar
Posts: 196 | Thanked: 113 times | Joined on Jun 2010 @ Finland
#4
You could try "cp /home/user/.profiled/current /home/user/profilo.txt"
 
santiago's Avatar
Posts: 518 | Thanked: 334 times | Joined on Mar 2010 @ italy
#5
Originally Posted by Zas View Post
You could try "cp /home/user/.profiled/current /home/user/profilo.txt"
i'm using this line

Code:
         run-standalone.sh dbus-send --type=method_call --print-reply --dest=com.nokia.profiled /com/nokia/profiled com.nokia.profiled.get_profile | grep "string" | sed s/'   string '/''/g > /home/user/profilo.txt && sleep 2
becouse i have to remove the "string" output line and keep just the profile in the quotations.. The problem that i have is that the script does everythin i wrote, but it doesnt load the right profile couse i cant find the error..
 
santiago's Avatar
Posts: 518 | Thanked: 334 times | Joined on Mar 2010 @ italy
#6
Originally Posted by Zas View Post
You could try "cp /home/user/.profiled/current /home/user/profilo.txt"
Oh my god u saved my life thx!!!!!!!! u made my day!!!!!
i was doing a stupid work it was not needed
 
joerg_rw's Avatar
Posts: 2,222 | Thanked: 12,651 times | Joined on Mar 2010 @ SOL 3
#7
For God's sake please use functions () { }; in your script
And attach scripts here to tmo as attachment, rather than using pastebin which will vanisch in a week, or month, or year the latest

BTW if you definitely need bash then you should use
#!/bin/bash
Your shebang is calling ash aka messybox on a standard maemo system

/j
__________________
Maemo Community Council member [2012-10, 2013-05, 2013-11, 2014-06 terms]
Hildon Foundation Council inaugural member.
MCe.V. foundation member

EX Hildon Foundation approved
Maemo Administration Coordinator (stepped down due to bullying 2014-04-05)
aka "techstaff" - the guys who keep your infra running - Devotion to Duty http://xkcd.com/705/

IRC(freenode): DocScrutinizer*
First USB hostmode fanatic, father of H-E-N
 

The Following User Says Thank You to joerg_rw For This Useful Post:
santiago's Avatar
Posts: 518 | Thanked: 334 times | Joined on Mar 2010 @ italy
#8
Originally Posted by joerg_rw View Post
For God's sake please use functions () { }; in your script
And attach scripts here to tmo as attachment, rather than using pastebin which will vanisch in a week, or month, or year the latest

BTW if you definitely need bash then you should use
#!/bin/bash
Your shebang is calling ash aka messybox on a standard maemo system

/j
i tried using functions but i was worse for me
 
joerg_rw's Avatar
Posts: 2,222 | Thanked: 12,651 times | Joined on Mar 2010 @ SOL 3
#9
Originally Posted by santiago View Post
i tried using functions but i was worse for me
where's the problem?

If you got 2 or more locations that look like

Code:
...
A
B
C
D
...
then you get *one*

Code:
myABCDfunction() 
{
  A
  B
  C
  D
}
and replace each occurrence of the four lines A B C D by
Code:
...
myABCDfunction
...



If you got
Code:
B 1
at one location and
Code:
B 2
at another, then do
Code:
myABCDfunction() 
{
  A
  B $1
  C
  D
}
and call like
Code:
...
myABCDfunction 1
...
myABCDfunction 2
...

[edit]
another comment: when you need to use sudo then you obviously don't run the script under root, so you don't need to use run-standalone (though it doesn't hurt).
To do arbitrary commands via sudo you probably need to tweak sudoers config in /etc/sudores.d/yourfile a bit.
[/edit]
__________________
Maemo Community Council member [2012-10, 2013-05, 2013-11, 2014-06 terms]
Hildon Foundation Council inaugural member.
MCe.V. foundation member

EX Hildon Foundation approved
Maemo Administration Coordinator (stepped down due to bullying 2014-04-05)
aka "techstaff" - the guys who keep your infra running - Devotion to Duty http://xkcd.com/705/

IRC(freenode): DocScrutinizer*
First USB hostmode fanatic, father of H-E-N

Last edited by joerg_rw; 2011-11-20 at 12:53.
 
santiago's Avatar
Posts: 518 | Thanked: 334 times | Joined on Mar 2010 @ italy
#10
Originally Posted by joerg_rw View Post
where's the problem?

If you got 2 or more locations that look like

Code:
...
A
B
C
D
...
then you get *one*

Code:
myABCDfunction() 
{
  A
  B
  C
  D
}
and replace each occurrence of the four lines A B C D by
Code:
...
myABCDfunction
...
If you got
Code:
B 1
at one location and
Code:
B 2
at another, then do
Code:
myABCDfunction() 
{
  A
  B $1
  C
  D
}
and call like
Code:
...
myABCDfunction 1
...
myABCDfunction 2
...
i did it i didnt rest for one night i was linea vampire ... now i try and i'll add a code here in a zip file
 
Reply


 
Forum Jump


All times are GMT. The time now is 22:40.