View Single Post
joerg_rw's Avatar
Posts: 2,222 | Thanked: 12,651 times | Joined on Mar 2010 @ SOL 3
#25
Originally Posted by biketool View Post
[...]
Put this in MyDocs so it is easy to use leafpad edit the wait time for how long you thing charging should last.
Code:
#!/bin/sh
sudo gainroot
stop bme
modprobe bq2415x_charger
# edit dumb mode charge mode time below in seconds
wait 21600
rmmod bq2415x_charger
start bme
exit
save the script name as qi_charge
make it executable
Code:
sudo chmod +x qi_charge
This is regularly going to fail, you cannot chmod +x any file on MyDocs since MyDocs is a FAT fs.
I alternatively suggest to create a folder /usr/local/bin in /-fs and place the files there.

You also need to take care about /etc/sudoers.d/*, you should create entires/files there that allow exactly the commands you do via "sudo xxxxx" in your scripts. Afaik "sudo gainroot" doesn't work in a script, and generally shouldn't get used. You should use "sudo stop bme" and "sudo modprobe bq2415x_charger" etc in script, and enable exactly those commands via files you add there in /etc/sudoers.d/, like

cat <<ETX >/etc/sudoers.d/qicharger1.sudoers;
Code:
user ALL = NOPASSWD: /sbin/stop bme
user ALL = NOPASSWD: /sbin/modprobe bq2415x_charger
user ALL = NOPASSWD: /sbin/rmmod bq2415x_charger
user ALL = NOPASSWD: /sbin/start bme
ETX

[edit]
the command is "sleep <seconds>", NOT "wait <seconds>"
jr@saturn:~> help wait
wait: wait [id]
Wait for process completion and return exit status.

Waits for the specified process and reports its termination status. If
PID is not given, all currently active child processes are waited for,
and the return code is zero. PID must be a process ID.

Exit Status:
Returns the status of ID; fails if ID is invalid or an invalid option is
given.
versus
jr@saturn:~> LANG=C sleep --help
Usage: sleep NUMBER[SUFFIX]...
or: sleep OPTION
Pause for NUMBER seconds. SUFFIX may be 's' for seconds (the default),
'm' for minutes, 'h' for hours or 'd' for days. Unlike most implementations
that require NUMBER be an integer, here NUMBER may be an arbitrary floating
point number. Given two or more arguments, pause for the amount of time
specified by the sum of their values.

--help display this help and exit
--version output version information and exit

Report sleep bugs to bug-coreutils@gnu.org
GNU coreutils home page: <http://www.gnu.org/software/coreutils/>
(this is gnu sleep which is more versatile than busybox sleep, on busybox only SECONDS is allowed as parameter, and only integer)


[edit2]
Originally Posted by biketool View Post
Code:
[Desktop Entry]
Encoding=UTF-8
Type=Application
Name=qi_charge
Comment=charge for a set time at full speed from an unshorted data pins dumb USB charger like the universal Qi ones and then reload BME to get battery meter back
Exec=sudo /bin/sh /home/user/MyDocs/qi_charge
Icon=make a PNG and put the path here
you also shouldn't do this (use sudo in .desktop), better style is what I suggested above. So the whole line in .desktop simply looks like:
Code:
Exec=/usr/local/bin/qi_charge
hth
jOERG
__________________
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; 2014-08-28 at 19:11.
 

The Following 2 Users Say Thank You to joerg_rw For This Useful Post: