maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Applications (https://talk.maemo.org/forumdisplay.php?f=41)
-   -   How to do something to make cmd-shortcuts be root ? (https://talk.maemo.org/showthread.php?t=71976)

cooperpeng 2011-04-10 15:34

How to do something to make cmd-shortcuts be root ?
 
I use cmd-shortcuts to do a commandline with terminal. But it always permission deny. Can I do something to get root with cmd-shortcuts app?

nicholes 2011-04-10 15:44

Re: Hot to do something to make cmd-shortcuts be root ?
 
i use shorcut maker (but did not work with rooot) actually i am also looking somethig wich can make a shortcut for rooted cmd and one for python

here are code i want to make shortcut for them

1> echo 0 >/sys/class/backlight/acx565akm/brightness (need sudo gainroot)


2>from my own thread where nicolai helped me to make n900's camera a spy cam(thanks to nicolai)

http://talk.maemo.org/showthread.php?t=71326&page=2


python


import gst
bin = gst.element_factory_make("camerabin")
bin.set_property("videoenc", gst.element_factory_make("dspmp4venc"))
bin.set_property("videomux", gst.element_factory_make("hantromp4mux"))
bin.set_property("audioenc", gst.element_factory_make("nokiaaacenc"))
bin.set_state(gst.STATE_PLAYING)
bin.set_property("filename", "test.mp4")
bin.set_property("mode",1)
#starts recording
bin.emit("user-start")

# wait some time

# stops recording
bin.emit("user-stop")
bin.set_state(gst.STATE_PAUSED)
bin.set_state(gst.STATE_NULL)

JohnLF 2011-04-10 15:50

Re: Hot to do something to make cmd-shortcuts be root ?
 
use
Code:

sudo gainroot < "your command here"
e.g.
Code:

sudo gainroot < "echo This is root"

nicholes 2011-04-10 15:56

Re: Hot to do something to make cmd-shortcuts be root ?
 
Quote:

Originally Posted by JohnLF (Post 985096)
use
Code:

sudo gainroot < "your command here"
e.g.
Code:

sudo gainroot < "echo This is root"

does it makes shortcut inthe menu?????????

cooperpeng 2011-04-11 02:45

Re: How to do something to make cmd-shortcuts be root ?
 
Hi,
I do
Code:

sudo gainroot < "echo 0 >/sys/class/backlight/acx565akm/brightness"
Result is
-sh: cannot open echo 0 >/sys/class/backlight/acx565akm/brightness: no such file
so that it is no work in shortcuts by user mode.

Another way, how to do cmd shortcuts become to root mode? Have any idea?

kitwalker 2011-04-11 03:07

Re: How to do something to make cmd-shortcuts be root ?
 
I've mentioned a trick to do this in another thread post here. See if that works for you.

cooperpeng 2011-04-11 05:45

Re: How to do something to make cmd-shortcuts be root ?
 
Quote:

I've mentioned a trick to do this in another thread post here. See if that works for you.
It like good idea, but it didn't work.:(
I try
Code:

sh -c 'echo 0 > /sys/class/backlight/acx565akm/brightness | sudo gainroot'
sh: cannot create /sys/class/backlight/acx565akm/brightness: Permission denied
Root shell enabled

I see the link, get the file "disable_ts.desktop". The code is " Exec=/bin/busybox sh -c 'echo "sleep 15; echo 1 > /sys/devices/platform/omap2_mcspi.1/spi1.0/disable_ts" | sudo gainroot' "
so I try
Code:

/bin/busybox sh -c 'echo 0 > /sys/class/backlight/acx565akm/brightness | sudo gainroot'
But it was the same.:(
In fact, I just run my app.py using by cmd shortcuts launching. But it will modify /sys file so that be permission deny. If it's running in terminal is good by root privilege.

nicholes 2011-04-11 06:25

Re: How to do something to make cmd-shortcuts be root ?
 
@cooperpeng

does this code makes shortcut in the emnu?? can i make shortcut for my code mentioned in ur thread?or you are talking about queen becon or something?

kitwalker 2011-04-11 06:30

Re: How to do something to make cmd-shortcuts be root ?
 
Quote:

Originally Posted by cooperpeng (Post 985359)
It like good idea, but it didn't work.:(
I try
Code:

sh -c 'echo 0 > /sys/class/backlight/acx565akm/brightness | sudo gainroot'
sh: cannot create /sys/class/backlight/acx565akm/brightness: Permission denied
Root shell enabled

I see the link, get the file "disable_ts.desktop". The code is " Exec=/bin/busybox sh -c 'echo "sleep 15; echo 1 > /sys/devices/platform/omap2_mcspi.1/spi1.0/disable_ts" | sudo gainroot' "
so I try
Code:

/bin/busybox sh -c 'echo 0 > /sys/class/backlight/acx565akm/brightness | sudo gainroot'
But it was the same.:(
In fact, I just run my app.py using by cmd shortcuts launching. But it will modify /sys file so that be permission deny. If it's running in terminal is good by root privilege.

Use it this way:

Code:

sh -c 'echo "sleep 1; echo 0 > /sys/class/backlight/acx565akm/brightness" | sudo gainroot'

cooperpeng 2011-04-11 07:08

Re: How to do something to make cmd-shortcuts be root ?
 
Quote:

Use it this way:

Code:

sh -c 'echo "sleep 1; echo 0 > /sys/class/backlight/acx565akm/brightness" | sudo gainroot'

Oh! My god!!!
It is work. :D
Very thanks by kitwalker.

What's diff.? It's amazing!!
Code:

sh -c 'echo "sleep 1; echo 0 > /sys/class/backlight/acx565akm/brightness" | sudo gainroot'
"sleep 1;" is key point.

nicholes 2011-04-11 07:15

Re: How to do something to make cmd-shortcuts be root ?
 
Quote:

Originally Posted by kitwalker (Post 985374)
Use it this way:

Code:

sh -c 'echo "sleep 1; echo 0 > /sys/class/backlight/acx565akm/brightness" | sudo gainroot'

i used shorcut maker and created a shortcut for this thanks!!

how can i make shortcut for python????? se my code in post #2

cooperpeng 2011-04-11 07:44

Re: How to do something to make cmd-shortcuts be root ?
 
I use this way.
In your app.py python file.
Code:

import os
os.system('sh -c \'echo "sleep 1; echo 0 > /sys/class/backlight/acx565akm/brightness" | sudo gainroot\'')

I just change my code like this way. You can try it.
PS: note \'

nicholes 2011-04-11 08:37

Re: How to do something to make cmd-shortcuts be root ?
 
i don't have any .py file, i just type this in xterminal


python


import gst
bin = gst.element_factory_make("camerabin")
bin.set_property("videoenc", gst.element_factory_make("dspmp4venc"))
bin.set_property("videomux", gst.element_factory_make("hantromp4mux"))
bin.set_property("audioenc", gst.element_factory_make("nokiaaacenc"))
bin.set_state(gst.STATE_PLAYING)
bin.set_property("filename", "test.mp4")
bin.set_property("mode",1)
#starts recording
bin.emit("user-start")

# wait some time

# stops recording
bin.emit("user-stop")
bin.set_state(gst.STATE_PAUSED)
bin.set_state(gst.STATE_NULL)

this code starts n900s camera and u can lock screen while video rec.
and now i want one shortcut for this. plz help

xantoz 2011-09-09 17:07

Re: How to do something to make cmd-shortcuts be root ?
 
Hello, since I do develop/maintain/something cmd-shortcuts I thought it good to reply.

I used to assume just typing in "sudo command" would work for most people, but realised it was because of the file /etc/sudoers.d/chroot.sudoers, added by package easy-chroot (dependency of easy-debian), containing a line allowing anything to be run as root. As a solution one might try to add something similar to:
Code:

user ALL = NOPASSWD: ALL
to a new file in /etc/sudoers.d/ (maybe cmd-shortcuts.sudoers).
Otherwise a workaround that seems to work is:
Code:

echo 'your command' | sudo gainroot
in the command field of the button/shortcut you're creating in case your setup doesn't allow just any command to be run with sudo without giving any password (don't know if this "running any command without password with sudo"-business actually is too good of an idea, but easy-chroot added it for me as I said).

I might add a checkbox "Run as root" implementing a commonly working workaround, maybe intelligently sensing what could work out of a set of alternatives even, in a future version. Hopefully I'll come around to it soon since I've started to notice other tweaks that could be useful (like having a tree structure to sort stuff out when you have many buttons). Alternatively I might do something like adding a /etc/sudoers.d/cmd-shortcuts.sudoers in the default install (hey, easy-chroot does it...).


All times are GMT. The time now is 23:08.

vBulletin® Version 3.8.8