maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   [N900] Script with desktop shortcut (https://talk.maemo.org/showthread.php?t=58613)

blwthompson 2010-07-17 03:36

[N900] Script with desktop shortcut
 
Hi All,

Basically i want to the following commands to run as a script when i press the shortcut on my desktop.

Code:

sudo gconftool -s /apps/osso/hildon-home/task-shortcuts-size -t int 62
sudo cd /usr/share/icons/blue-sky-icons/64x64/hildon
sudo mogrify -resize 48x48! *.png
sudo cd /usr/share/icons/blue-sky-icons/64x64/apps
sudo mogrify -resize 48x48! *.png
sudo cd /usr/share/themes/Blue-sky/
sudo mogrify -resize 62x62! ApplicationShortcutApplet.png
sudo mogrify -resize 62x62! ApplicationShortcutAppletPressed.png

sudo pkill hildon-home

Any ideas how i can achieve this??

Saturn 2010-07-17 14:29

Re: [N900] Script with desktop shortcut
 
2 Attachment(s)
Hi,

Copy the script (as user) at the following folder and give it execute rights:
Quote:

cp BlueSkyResize.sh.txt /usr/local/bin/BlueSkyResize.sh
chmod +x /usr/local/bin/BlueSkyResize.sh
(note, I've modified it a little)

The copy the .desktop file at:
Quote:

cp BlueSkyResize.desktop.txt /usr/share/applications/hildon/BlueSkyResize.desktop
Didn't test it, but should work.

dana.s 2010-07-17 14:39

Re: [N900] Script with desktop shortcut
 
or simply use Desktop Command Execution Widget

Kieron 2010-11-08 19:54

Re: [N900] Script with desktop shortcut
 
How can I do the same and run my script as root? Thanks, sorry to bump an old thread.

JonWW 2010-11-08 20:02

Re: [N900] Script with desktop shortcut
 
Assuming you have rootsh installed
Code:

echo "sh /path/to/script" | root

Kieron 2010-11-08 20:21

Re: [N900] Script with desktop shortcut
 
So something like:

Exec="sh /usr/local/bin/BlueSkyResize.sh" | root

is enough? thanks Jon!

JonWW 2010-11-08 20:58

Re: [N900] Script with desktop shortcut
 
Exec=echo "sh /usr/local/bin/BlueSkyResize.sh" | root

Kieron 2010-11-08 22:43

Re: [N900] Script with desktop shortcut
 
JonWW, another problem...

I've tried what you've said doing the following:

Quote:

[Desktop Entry]
Encoding=UTF-8
Version=0.1
Name=Enable Injection
Comment=NeoPwn Control Panel
Exec=echo "rmmod wl12xx; rmmod mac80211; rmmod cfg80211; insmod /home/user/MyDocs/neo/compat.ko; insmod /home/user/MyDocs/neo/rfkill_backport.ko; insmod /home/user/MyDocs/neo/cfg80211.ko; insmod /home/user/MyDocs/neo/mac80211.ko; insmod /home/user/MyDocs/neo/wl1251.ko; insmod /home/user/MyDocs/neo/wl1251_spi.ko" | root
Icon=injection_enable
Terminal=true
Type=Application
Categories=Tools
X-HildonDesk-ShowInToolbar=true
X-Osso-Type=application/x-executable
X-Text-Domain=NeoPwn

But its still not running as root. If I manually paste it in Xterm, it doesn't work either. If I type 'root' first, then type it, it works. Get what I mean?

What can I do to get around this?

Thanks again.

Saturn 2010-11-08 23:00

Re: [N900] Script with desktop shortcut
 
Quote:

Originally Posted by Kieron (Post 867480)
JonWW, another problem...

I've tried what you've said doing the following:



But its still not running as root. If I manually paste it in Xterm, it doesn't work either. If I type 'root' first, then type it, it works. Get what I mean?

What can I do to get around this?

Thanks again.

Put your code in a script which starts like:
Code:

#!/bin/sh

# gain superuser rights.

if [ `id -u` != 0 ] ; then
    exec sudo gainroot <<EOF
exec sh $0 $*
EOF
        exit $?
fi 

# put your code below

make it executable and you will be able to call it as user.

Cheers

Kieron 2010-11-08 23:10

Re: [N900] Script with desktop shortcut
 
Saturn, thank you, although that didn't work.

I'm having this issue where I can't run the below commands in a script, for whatever reason. I'm probably doing something wrong. I can run the commands manually, after I've typed 'root', else I get 'no such file or directory' and 'does not exist' errors. Could you assist? If you need more info please don't hesistate to ask, there is some on the neopwn howto thread as I was trying to troubleshoot there to no avail.

Summerising what I said, running the script doesn't work. But if I run this command, once I've rooted, it works.

Code:

rmmod wl12xx; rmmod mac80211; rmmod cfg80211; insmod /home/user/MyDocs/neo/compat.ko; insmod /home/user/MyDocs/neo/rfkill_backport.ko; insmod /home/user/MyDocs/neo/cfg80211.ko; insmod /home/user/MyDocs/neo/mac80211.ko; insmod /home/user/MyDocs/neo/wl1251.ko; insmod /home/user/MyDocs/neo/wl1251_spi.ko
script contents, for reference:

Code:

#!/bin/sh

# gain superuser rights.

if [ `id -u` != 0 ] ; then
    exec sudo gainroot <<EOF
exec sh $0 $*
EOF
        exit $?
fi 

rmmod wl12xx
rmmod mac80211
rmmod cfg80211
insmod /home/user/MyDocs/neo/compat.ko
insmod /home/user/MyDocs/neo/rfkill_backport.ko
insmod /home/user/MyDocs/neo/cfg80211.ko
insmod /home/user/MyDocs/neo/mac80211.ko
insmod /home/user/MyDocs/neo/wl1251.ko
insmod /home/user/MyDocs/neo/wl1251_spi.ko

and the script throws this output when it fails:

Code:

: not foundh: line 2:
does not exist in /proc/modules
does not exist in /proc/modules
does not exist in /proc/modules
': No such file or directoryer/MyDocs/neo/compat.ko
': No such file or directoryer/MyDocs/neo/rfkill_backport.ko
': No such file or directoryer/MyDocs/neo/cfg80211.ko
': No such file or directoryer/MyDocs/neo/mac80211.ko
': No such file or directoryer/MyDocs/neo/wl1251.ko
insmod: error inserting '/home/user/MyDocs/neo/wl1251_spi.ko': -1 Unknown symbol in module

for reference, the permissions of the files are:
Code:

-rwxr-xr-x 1 root staff
again, running the command manually works fine.

there is probably some fundamental flaw the in way im doing things, i just cant seem to figure it. hope you can help.

Thanks again.
K

Saturn 2010-11-08 23:19

Re: [N900] Script with desktop shortcut
 
OK,

Put this in a script (using leafpad for example, but not notes) called myscript.sh in the folder /home/user/

Make it execulable: chmod 755 /home/user/myscript.sh

Code:

#!/bin/sh

# gain superuser rights.

if [ `id -u` != 0 ] ; then
    exec sudo gainroot <<EOF
exec sh $0 $*
EOF
        exit $?
fi 

# put your code below

rmmod wl12xx;
rmmod mac80211;
rmmod cfg80211;
insmod /home/user/MyDocs/neo/compat.ko;
insmod /home/user/MyDocs/neo/rfkill_backport.ko;
insmod /home/user/MyDocs/neo/cfg80211.ko;
insmod /home/user/MyDocs/neo/mac80211.ko;
insmod /home/user/MyDocs/neo/wl1251.ko;
insmod /home/user/MyDocs/neo/wl1251_spi.ko;

exit;

execute it as user by simply in an xterm:
/home/user/myscript.sh

If it does what you need then in your desktop file replace the exec line with:
Exec=/home/user/myscript.sh

JonWW 2010-11-08 23:21

Re: [N900] Script with desktop shortcut
 
So if you type each command manually, then it works fine?
But if all commands are in a script then it doesn't?

You could try putting a sleep command inbetween each command, I don't know if that would work.

Saturn 2010-11-08 23:25

Re: [N900] Script with desktop shortcut
 
ooh, you changed your post while i was writing too..

How did you make the script? using notes or in windows?

Kieron 2010-11-08 23:26

Re: [N900] Script with desktop shortcut
 
Using Mac TexEdit, converted files to plantext. Uploaded via sftp on FileZilla.

Saturn 2010-11-08 23:29

Re: [N900] Script with desktop shortcut
 
1 Attachment(s)
Quote:

Originally Posted by Kieron (Post 867514)
Using Mac TexEdit, converted files to plantext. Uploaded via sftp on FileZilla.

how about if you use this and rename it to sh?

Kieron 2010-11-08 23:30

Re: [N900] Script with desktop shortcut
 
Quote:

Originally Posted by Saturn (Post 867512)
ooh, you changed your post while i was writing too..

How did you make the script? using notes or in windows?

It works. The myscript.sh.

I ****ing love you. Ah, you're lucky I don't know you IRL, I might just have to rape you!

I'm gonna change the .desktop files now and make sure it does indeed work.

Thanks! You're awesome!

Saturn 2010-11-08 23:34

Re: [N900] Script with desktop shortcut
 
Quote:

Originally Posted by Kieron (Post 867517)
It works. The myscript.sh.

I ****ing love you. Ah, you're lucky I don't know you IRL, I might just have to rape you!

I'm gonna change the .desktop files now and make sure it does indeed work.

Thanks! You're awesome!

Man!! My wife just needs an excuse to forbid me to visit here.. you ain't helping :D

JonWW 2010-11-11 16:00

Re: [N900] Script with desktop shortcut
 
Quote:

Originally Posted by Kieron (Post 867514)
Using Mac TexEdit, converted files to plantext. Uploaded via sftp on FileZilla.

Ah! are you a Mac user?

Linux uses LF to denote new lines
Windows uses CRLF to denote new lines
Do Macs use CR to denote new lines? I think they might.

Linux throws a wobbly at CR new line characters saying stuff like 'no such file or directory' and 'does not exist' errors.

ysn5582 2010-12-30 12:29

Re: [N900] Script with desktop shortcut
 
still not working for me, can you explain to me step by step, thanks

Quote:

Originally Posted by Saturn (Post 867507)
OK,

Put this in a script (using leafpad for example, but not notes) called myscript.sh in the folder /home/user/

Make it execulable: chmod 755 /home/user/myscript.sh

Code:

#!/bin/sh

# gain superuser rights.

if [ `id -u` != 0 ] ; then
    exec sudo gainroot <<EOF
exec sh $0 $*
EOF
        exit $?
fi 

# put your code below

rmmod wl12xx;
rmmod mac80211;
rmmod cfg80211;
insmod /home/user/MyDocs/neo/compat.ko;
insmod /home/user/MyDocs/neo/rfkill_backport.ko;
insmod /home/user/MyDocs/neo/cfg80211.ko;
insmod /home/user/MyDocs/neo/mac80211.ko;
insmod /home/user/MyDocs/neo/wl1251.ko;
insmod /home/user/MyDocs/neo/wl1251_spi.ko;

exit;

execute it as user by simply in an xterm:
/home/user/myscript.sh

If it does what you need then in your desktop file replace the exec line with:
Exec=/home/user/myscript.sh


raffe 2011-02-10 16:23

Re: [N900] Script with desktop shortcut
 
Hi!

I would like a shortcut that
1. opens X terminal
2. Runs
nohup x11vnc -forever&
3. And then waits there until I do a Ctrl+C

I have tried with a /usr/local/bin/StartVNCserver.sh with
Code:

#!/bin/sh
nohup x11vnc -forever&

And in /usr/share/applications/hildon/StartVNCserver.desktop I have
Code:

[Desktop Entry]
Encoding=UTF-8
Version=0.1
Type=Application
Terminal=true
Name=StartVNCserver
Exec=/usr/local/bin/StartVNCserver.sh
Icon=terminal
X-Osso-Type=application/x-executable
X-HildonDesk-ShowInToolbar=true

If I try with
Code:

Exec=osso-xterm
it opens a terminal, so I have also tried with
Code:

Exec=osso-xterm "nohup x11vnc -forever&"
But it don't stay there, it only closes down.

How can I do it?

JonWW 2011-02-10 19:11

Re: [N900] Script with desktop shortcut
 
Guessing here, try adding
Code:

sleep 100000
to the end of your script.

raffe 2011-02-10 19:48

Re: [N900] Script with desktop shortcut
 
Thanks for the tip, but still nothing. I thought I try something simple, but I cant even do this with a script:
1. Start x terminal
2. run the command
ls

Copernicus 2011-02-10 20:28

Re: [N900] Script with desktop shortcut
 
Quote:

Originally Posted by raffe (Post 941061)
I would like a shortcut that
1. opens X terminal
2. Runs
nohup x11vnc -forever&
3. And then waits there until I do a Ctrl+C

I think explicitly calling osso-xterm with an exec flag from the shell script should do what you are saying here. Something like this:

Code:

#!/bin/sh
/usr/bin/osso-xterm -e "nohup x11vnc -forever"

Note: don't use the "&" flag, or the xterm will spawn off an independent x11vnc process and immediately close! :)

Edit: Or not. I just tried running osso-xterm -e "fennec &", and it worked exactly the same as just osso-xterm -e "fennec". Oh well, guess you can't use that sort of flag with -e...

raffe 2011-02-11 13:12

Re: [N900] Script with desktop shortcut
 
Quote:

Originally Posted by Copernicus (Post 941243)
I think explicitly calling osso-xterm with an exec flag from the shell script should do what you are saying here. Something like this:

Code:

#!/bin/sh
/usr/bin/osso-xterm -e "nohup x11vnc -forever"

Note: don't use the "&" flag, or the xterm will spawn off an independent x11vnc process and immediately close! :)

Edit: Or not. I just tried running osso-xterm -e "fennec &", and it worked exactly the same as just osso-xterm -e "fennec". Oh well, guess you can't use that sort of flag with -e...

Thanks for the tip, but not really there yet :o This works great!
Code:

#!/bin/sh
/usr/bin/osso-xterm -e "fennec"

This don't work, shows up on screen and the dissapears directly
Code:

#!/bin/sh
/usr/bin/osso-xterm -e "nohup x11vnc -forever"

Maybe I need to do something else when its a "terminal command"?

nicolai 2011-02-11 13:20

Re: [N900] Script with desktop shortcut
 
try this, make a script (say "xvncnohup.sh)":
Code:

#!/bin/sh
nohup x11vnc -forever &
/bin/sh

Put this script in /usr/bin
make a desktop file with the line
Exec=osso-xterm "/usr/bin/xvncnohup.sh"

Nicolai

raffe 2011-02-11 13:40

Re: [N900] Script with desktop shortcut
 
Quote:

Originally Posted by nicolai (Post 942256)
try this, make a script (say "xvncnohup.sh)":
Code:

#!/bin/sh
nohup x11vnc -forever &
/bin/sh

Put this script in /usr/bin
make a desktop file with the line
Exec=osso-xterm "/usr/bin/xvncnohup.sh"

Nicolai

I LOVE YOU! :p

It works, thank you! :D

one1002 2011-02-17 10:19

Re: [N900] Script with desktop shortcut
 
hi..what if i want to show the output of the script?for example,

on the .desktop entry, the exec line is like this

Code:

Exec=/bin/busybox sh -c 'echo /path/to/script.sh | sudo gainroot'
however, it didn't show the output..just a blank(black) with the loading icon, then closes..

i put the script at /home/user..

how do i get the .desktop to show the output of the script?

one1002 2011-02-19 18:45

Re: [N900] Script with desktop shortcut
 
anyone? =)

xsmabbs 2012-03-26 14:00

Re: [N900] Script with desktop shortcut
 
?????i don't see

x_mony 2013-08-30 10:22

Re: [N900] Script with desktop shortcut
 
hello guys,
i need some help out here, i downloaded a script (evil ap.sh) and i was wondering if i can link it to the Desktop (like the ones in the pwnie express image) so that i would press the icon and the script would run automatically instead of "cd" in xterm to mydocs and execute it.
any help appreciated and thanks in advance

supergaban 2015-02-02 02:47

Re: [N900] Script with desktop shortcut
 
is there any script that showing realtime network (gsm/wifi) speed..?
it showing on congky feature, and would be nice to have one on my DECW. thank in advance.

Halftux 2015-02-02 16:10

Re: [N900] Script with desktop shortcut
 
Quote:

Originally Posted by supergaban (Post 1459257)
is there any script that showing realtime network (gsm/wifi) speed..?
it showing on congky feature, and would be nice to have one on my DECW. thank in advance.

You can use nload in your script.
What you mean with DECW?

pichlo 2015-02-02 16:41

Re: [N900] Script with desktop shortcut
 
Quote:

Originally Posted by Halftux (Post 1459326)
What you mean with DECW?

It could mean only one thing:
Dissipation and Ellipticity of the Chandler Wobble

peterleinchen 2015-02-02 16:53

Re: [N900] Script with desktop shortcut
 
Quote:

Originally Posted by pichlo (Post 1459328)

Found another occurence of DCEW, but no idea what it is ;)


But seriously, halftux, does nload work for you?
I just heard first time of that package, installed and tried out. But it segfaults after a few seconds. Normally Stephan's packages are okay.

Halftux 2015-02-02 18:13

Re: [N900] Script with desktop shortcut
 
Quote:

Originally Posted by peterleinchen (Post 1459330)
But seriously, halftux, does nload work for you?
I just heard first time of that package, installed and tried out. But it segfaults after a few seconds. Normally Stephan's packages are okay.

You are right it is not working:(

supergaban 2015-02-03 17:40

Re: [N900] Script with desktop shortcut
 
Quote:

Originally Posted by Halftux (Post 1459326)
You can use nload in your script.
What you mean with DECW?

ahahaha..sorry buddy, missed type i mean DCEW: Desktop Command Execution Widget

supergaban 2015-02-03 17:43

Re: [N900] Script with desktop shortcut
 
Quote:

Originally Posted by Halftux (Post 1459339)
You are right it is not working:(

doesn't working too

peterleinchen 2015-02-03 18:38

Re: [N900] Script with desktop shortcut
 
As mentioned by Stephane in the first post of his announcement :rolleyes:


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

vBulletin® Version 3.8.8