Reply
Thread Tools
Saturn's Avatar
Posts: 1,648 | Thanked: 2,122 times | Joined on Mar 2007 @ UNKLE's Never Never Land
#11
Check if you really have an entry in sudoers.

e.g.:
Code:
Nokia-N900:/# cat /etc/sudoers | grep yamas
user ALL = NOPASSWD: /opt/yamas/yamas.sh, /usr/bin/yamas
Nokia-N900:/#
If it helps, for yamas I have the following code that works:

the sudoers file:

Code:
# cat /etc/sudoers.d/yamas.sudoers
user ALL = NOPASSWD: /opt/yamas/yamas.sh, /usr/bin/yamas
the desktop file:

Code:
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Name=YAMAS
Comment=YAMAS - Yet Another Man In The Middle Automation Script  
Terminal=true
Type=application
Exec=osso-xterm -e "sudo yamas" &
Icon=yamas
X-Icon-path=/usr/share/icons
X-Window-Icon=yamas
X-Window-Icon-Dimmed=yamas
X-HildonDesk-ShowInToolbar=true
Type=Application
X-Osso-Type=application/x-executable
 

The Following User Says Thank You to Saturn For This Useful Post:
Estel's Avatar
Posts: 5,028 | Thanked: 8,613 times | Joined on Mar 2011
#12
Thanks for interest in this and trying to help.

cat /etc/sudoers | grep bnf
Result in:
Code:
user ALL = NOPASSWD: /usr/bin/bnf.sh
Ho ever, there is some strange things I've noticed. Obviously, 'sudo bnf;sh' invoked from terminal works, but if I copy and rename (or any other) script, for example 'test-bnf.sh', I can:
Code:
sudo test-bnf.sh
successfully, even given fact, that there is *no* sudoers file for test-bnf.sh! Of course I'm sure this script requires root privileges, it doesn't work without sudo (it's basically copy of bnf.sh, with different name). Maybe it's default behavior, when rootsh package is installed?

I've also tried Your desktop file, but it doesn't make any difference - if i set
Code:
Exec=sudo bnf.sh
...(or any combination involving quotations, single or double), it does literally nothing. If i set
Code:
Exec=osso-xterm -e "sudo bnf.sh"
...(inclusion of & at the end doesn't seems to make difference for desktop file, but I've checked it anyway), it works, but first it show terminal window for a ~1,5 second, terminal disappear, and only after that notification pop-up is shown. so, it's quite slow for it's purpose. BTW, that's what I've called "flash" terminal window for a second.

At the same time, using ShortcutD with:
Code:
Exec=sudo bnf.sh
...result in it working as it should, i.e. pop-up notification appear immediately, without terminal window in-between (obviously, cause it doesn't call osso-xterm). Meanwhile, using queen beecon widget (snippet or beecon, doesn't matter) with exact same command (sudo bnf.sh), result in nothing, just like 'Exec=sudo bnf.sh' in .desktop file.

Yea, I can live with desktop shortcut that show terminal before pop-up and is quite slow, but I'm just curious why it looks like that. What I don't get is why 'sudo bnf.sh' work flawlessly from terminal and ShortcutD, but doesn't from .desktop file 'Exec=sudo bnf.sh', or other tools like Queen Beecon Widget or Desktop Execution Widget... Are .desktop files supposed to work like that (deny to work with 'sudo'), but ShortcutD do it different way (it says, that it's just invoke custom command, so it *shouldn't* be different from what QBW or DEW are doing...)?
__________________
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!
 
peterleinchen's Avatar
Posts: 4,117 | Thanked: 8,901 times | Joined on Aug 2010 @ Ruhrgebiet, Germany
#13
Hey Estel.

sudo within desktop file works (for Saturn as well as for me )

Two/three possible reasons I can think of
sudo called twice (from desktop file AND within script)
location of script is not in path
script file does not have exec flag

Can You check these? And hopefully this solves already...
 
peterleinchen's Avatar
Posts: 4,117 | Thanked: 8,901 times | Joined on Aug 2010 @ Ruhrgebiet, Germany
#14
Just checked it once again and it seems, that there is only on line missung in script
cd /usr/sbin

As the i2cget is called like ./i2cget, You should first enter this specific directory....

P.S.L for me it works now with desktop file (and fast)
BTW: what do I call here??? Just joking, of course had a look earlier
 
Estel's Avatar
Posts: 5,028 | Thanked: 8,613 times | Joined on Mar 2011
#15
Thanks, cd'ing inside script solved it!

there is one thing I don't understand, ho ever. Given the fact, that you point is true (it seems that i2cget wasn't called properly from script, when invoked from .desktop file with sudo), why it worked via:
Code:
osso-xterm -e "sudo bnf.sh"
...ShortcutD, or from terminal? everything without cd'ing?

Anyway, enormous thank You and MAG for solving this issue, it was making me scratch my head for a long time. I think it's time to get to work on some scripts

// Edit

If someone think it may be useful, here is "final" version of little script from this thread, alongside correct .desktop file. It shows most important bq27200 info at a glance, and hide/show part of them depending on state (i.e. charger type is irrelevant, if You have no charger/USB cable connected at all).

This one got issue solved + should have correct permission set. As I've said, I use mainly to check battery usage (current now) of fullscreen programs (notification pop-up goes through fullscreen without problem, without pushing you to task manager), or other things that can't be properly checked via 'bq27200.sh 5' running in background, or going to terminal and executing bq27200.sh itself.

It was also only one method I'm aware of, that allowed me to check current of 'echo mem >/sys/power/state', other than checking available mAh, getting it into sleep for an hour, checking mAh after that, and calculating (current we get via i2cget is average from 5 seconds, but it's updated inside fuel gauge in certain intervals - so, getting into hardest power saving state for a while, then getting out of it and executing this pop-up script fast enough, gives You current from 5 seconds inside hardest sleep state).

/Estel

(Actual version is here:
http://talk.maemo.org/showpost.php?p...3&postcount=17)
__________________
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 19:51.
 

The Following User Says Thank You to Estel For This Useful Post:
peterleinchen's Avatar
Posts: 4,117 | Thanked: 8,901 times | Joined on Aug 2010 @ Ruhrgebiet, Germany
#16
Hey Estel.

Thanks for thanks
And thanks for this script.

Just one question/remark:
why don't You put it directly in /usr/sbin/, as this script requires root privileges anyway?

and another hint for output of notifications:
You do not need to fiddle around with spaces, tabs for nice formatting. New lines can be achieved by just new line inside string (not \n). Like:
############## Printing output ##############
run-standalone.sh dbus-send --type=method_call --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.SystemNoteDialog string:"Temperature: $(($TEMP * 250 / 1000 - 273))°C
Voltage: $VOLT mV
Current: $AI mA
Status: $STS, SoC: $CSOC%
Charge: $CACT mAh, Full Charge: $LMD mAh
Remaining Time: $RT minutes
$HL
Calibration needed: $FLAGS_CI, VDQ: $FLAGS_VDQ" uint32:0 string:""

Last edited by peterleinchen; 2011-09-11 at 19:00.
 
Estel's Avatar
Posts: 5,028 | Thanked: 8,613 times | Joined on Mar 2011
#17
Originally Posted by peterleinchen View Post
Just one question/remark:
why don't You put it directly in /usr/sbin/, as this script requires root privileges anyway?
Good point, I've moved it to '/usr/sbin/'
Ho ever, even there, it need cd /usr/sbin/ inside script to work via desktop shortcut.

And huge thanks for advice about line formatting - I wasn't able to figure it out, never thought about trying regular next line, instead of \n. It was somehow tricky job to format it properly using spaces - many variables here got different output length on different states, so many times everything "collapsed" on changes, until I've found correct number of spaces for every line. Thankfully, it's not needed now. I've also modified things related to "hidden line", because in "new line" approach, it was show as totally empty line, when it should be hidden at all.

BTW, does anyone know why script work from terminal/ShortcutD without cd'ing to /usr/sbin (outside or inside script), but does not when invoked from .desktop shortcut/QBW/DEW?

---

If someone got use for it, here's updated version - alongside .desktop file (that one was not changed) and with correct sudoers file, missing from last upload. Correct placement of files:
Code:
/usr/sbin/bnf.sh
/usr/share/applications/hildon/bnf.desktop
/etc/sudoers.d/bnf.sudoers
Attached Files
File Type: tar bnf.tar (10.0 KB, 81 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 19:53.
 
Reply


 
Forum Jump


All times are GMT. The time now is 16:31.