View Single Post
Estel's Avatar
Posts: 5,028 | Thanked: 8,613 times | Joined on Mar 2011
#1
Hello, and excuse me in advance, if this was covered before - ho ever, despite extensive searching, I wasn't able to find an answer. This explanation is going to be quite long, but I want to provide as much info as I can.

I develop some simple script (showing certain "glance" info derived from i2cget, based on shadowjk's bq27200 script), which put output to screen as maemo native notify. Basically, script contains 2 part - one for gathering and calculating info - based (mostly) on work by shadowjk - and second, forwarding output to screen.

For printing output, I use:

Code:
dbus-send --type=method_call --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.SystemNoteDialog string:"content-here-blablabla" uint32:0 string:""
The idea is that, after creating correct .desktop file pointing to script, shortcut can be placed on home desktop and/or it may be assigned to some hardware button (via third party applications, i.e. shortcutd). So, when needed, independently of device state (i.e. using fullscreen application), I can call my little script to provide info as notification.

Side note: I was using this method before to show notification info, derived from bq27x00 module (cat sys/class/power_supply/bq27200 etc.), and it worked like a charm - thanks to Nicolai, who helped me to understand calling upon notifications.

Gathering data from i2cget require root privileges - and here, the problem begin. For unknown reason, script works as it should when called from terminal, after "root" command (via rootsh package), but refuse to work when privileges were gained by "sudo gainroot". Furthermore, adding script as .sudoers result in same output, as when called after "sudo gainroot" - it prove that sudoers file is created properly (I think), but doesn't solve problem.

When called after "root", no errors, and notification info pop-out with correct data. When called after "sudo gainroot", or with "sudo" after .sudoers created, output in terminal is:

Code:
Failed to open connection to "session" message bus: (null)
I've checked what "root" script (that we get via rootsh, so we can use "root" in terminal to, well, gain root) contain - its "exec sudo gainroot --use-su". I've tried many combinations with --use-su together with "sudo gainroot" from terminal, to no avail (maybe I'm missing something here?).

What even more strange, bq27200.sh (script by shadowjk, that I used as base) works flawlessly with "sudo" after creating .sudoer for it. Also, using notification pop-up method (dbus-send etc), inside script that doesn't contain parts requiring root access (so, in my case, particularly parts from bq27200.sh, that works stand-alone) also result in no-problem. So, I got troubles only, when using script that contain *BOTH* gathering data requiring root, and displaying via aforementioned dbus-send method.

As result, I can't use this script from any kind of shortcut (desktop, hardware, whatever) - only from terminal, after "root". I've searched solid few days for possible solution - hence the "discovery" about it performing well with "root", but failing after "sudo gainroot" - but I'm still scratching my head clueless.

I'm attaching current version of script here (renamed to .sh.txt, to upload via forum mechanism), in case anyone want to try on her/his device (it may be little messy, it's developing version :P ). Any help/clues *really* much appreciated.
Attached Files
File Type: txt bnf.sh.txt (6.1 KB, 225 views)
__________________
N900's aluminum backcover / body replacement
-
N900's HDMI-Out
-
Camera cover MOD
-
Measure battery's real capacity on-device
-
TrueCrypt 7.1 | ereswap | bnf
-
Hardware's mods research is costly. To support my work, please consider donating. Thank You!

Last edited by Estel; 2011-09-11 at 16:00.
 

The Following 4 Users Say Thank You to Estel For This Useful Post: