openSUSE Forums > Applications » How do you create an executable script to run from an icon?

Go Back   openSUSE Forums > Applications
Forums FAQ Members List Search Today's Posts Mark Forums Read

Applications Questions about desktops (KDE, Gnome, XFCE, etc.), software applications (configuration, usage, bugs, documentation)

Reply
Page 1 of 3 1 23
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 28-Jun-2009, 09:34
suse_tpx60s's Avatar
Busy Penguin
 
Join Date: May 2009
Location: EU
Posts: 406
suse_tpx60s hasn't been rated much yet
Default How do you create an executable script to run from an icon?

There are a few scripts I would like to be able to run from my desktop.

An example is:
Code:
#! /bin/sh
#
# This script forces a full battery charge and keeps it charged above 95%
#
echo 95 > /sys/devices/platform/smapi/BAT0/start_charge_thresh
echo 100 > /sys/devices/platform/smapi/BAT0/stop_charge_thresh
How do I create an icon on the KDE4 desktop that will run this script? I tried right clicking and choosing "link to application" but when I double click the icon it I just get the hour glass spinning for 30 secs. I've marked the script as executable. Anything else I need to do?
__________________
IBM Thinkpad X60s | Intel L2400 1.66Ghz | Mesa DRI Intel 945GM video | 3GB Ram
openSuSE 11.1 | Linux 2.6.27.29-0.1 pae i686 | KDE 4.3.3
Reply With Quote
  #2 (permalink)  
Old 28-Jun-2009, 10:14
hcvv's Avatar
Wise Penguin
 
Join Date: Jun 2008
Location: Netherlands
Posts: 1,792
hcvv is on a distinguished reputation roadhcvv is on a distinguished reputation road
Default Re: How do you create an executable script to run from an ic

Code:
#! /bin/sh
should be
Code:
#!/bin/sh
(no white space)

You do not explain what you entered after choosing "link to application". How can we know if you made a mistake or not?

Why double click? In my system that would start it twice!
__________________
Henk van Velden
Reply With Quote
  #3 (permalink)  
Old 28-Jun-2009, 10:19
NismoTie's Avatar
Puzzled Penguin
 
Join Date: Jun 2009
Posts: 26
NismoTie hasn't been rated much yet
Default Re: How do you create an executable script to run from an ic

If you wanted to run it from your desktop say, I would plant a copy on the desktop, right click and then allocate an icon to it, in this case try and find one to do with a battery, you could also download a custom icon set of the internet to seperate the icon from the rest of your icons.
Reply With Quote
  #4 (permalink)  
Old 28-Jun-2009, 10:36
suse_tpx60s's Avatar
Busy Penguin
 
Join Date: May 2009
Location: EU
Posts: 406
suse_tpx60s hasn't been rated much yet
Default Re: How do you create an executable script to run from an ic

Quote:
Originally Posted by hcvv View Post
Code:
#! /bin/sh
should be
Code:
#!/bin/sh
(no white space)

You do not explain what you entered after choosing "link to application". How can we know if you made a mistake or not?

Why double click? In my system that would start it twice!
Thanks. White space removed now.

You're right I should have listed what I was doing - sorry.

General tab: I entered a name for the shortcut
Permissions tab: Left as is.
Application tab:
>Name: Entered the same name as in general tab
>Command: Browsed to the script.
>Advanced options: Enabled feedback.

I said double click as I'm from windows and everything there is double click. Old habits die hard.

Quote:
Originally Posted by NismoTie
If you wanted to run it from your desktop say, I would plant a copy on the desktop, right click and then allocate an icon to it, in this case try and find one to do with a battery, you could also download a custom icon set of the internet to separate the icon from the rest of your icons.
I tried that but cannot change the icon. Right clicking and going to properties gives no option to change the icon.

On thing, should the script filename have an extension or not or doesn't it matter?
__________________
IBM Thinkpad X60s | Intel L2400 1.66Ghz | Mesa DRI Intel 945GM video | 3GB Ram
openSuSE 11.1 | Linux 2.6.27.29-0.1 pae i686 | KDE 4.3.3
Reply With Quote
  #5 (permalink)  
Old 28-Jun-2009, 10:48
hcvv's Avatar
Wise Penguin
 
Join Date: Jun 2008
Location: Netherlands
Posts: 1,792
hcvv is on a distinguished reputation roadhcvv is on a distinguished reputation road
Default Re: How do you create an executable script to run from an ic

Quote:
On thing, should the script filename have an extension or not or doesn't it matter?
Not needed. There is no such thing as an "extension" in Unix/Linux filenames. Some people call it so when a file name ends in a dot and a few other characters (and some programs draw conclusions from that), but is NOT a seperate field as in another OS.

You say you browsed to the script. I hope the resulting string is an ABSOLUTE path to your script

No further commentss on the double click (some people like it to wear out their fingers ).
__________________
Henk van Velden
Reply With Quote
  #6 (permalink)  
Old 28-Jun-2009, 12:20
suse_tpx60s's Avatar
Busy Penguin
 
Join Date: May 2009
Location: EU
Posts: 406
suse_tpx60s hasn't been rated much yet
Default Re: How do you create an executable script to run from an ic

I seem to have a problem with the script. It's not doing anything. I tried it as root too to make sure it was not a permission problem.

The script is set to be executable so I'd expect clicking on it would execute it - right? When I try launch the script directly it looks like wine is trying to launch it.
__________________
IBM Thinkpad X60s | Intel L2400 1.66Ghz | Mesa DRI Intel 945GM video | 3GB Ram
openSuSE 11.1 | Linux 2.6.27.29-0.1 pae i686 | KDE 4.3.3
Reply With Quote
  #7 (permalink)  
Old 28-Jun-2009, 12:26
microchip8's Avatar
Wise Penguin
 
Join Date: Jun 2008
Location: /dev/belgium
Posts: 1,971
microchip8 has a spectacular reputation aura aboutmicrochip8 has a spectacular reputation aura aboutmicrochip8 has a spectacular reputation aura aboutmicrochip8 has a spectacular reputation aura about
Default Re: How do you create an executable script to run from an ic

Quote:
Originally Posted by hcvv View Post
Code:
#! /bin/sh
should be
Code:
#!/bin/sh
(no white space)
this is not true, you can use either #! /bin/sh or #!/bin/sh ... both are valid
__________________
My site: http://microchip.bplaced.net
My repo: http://download.opensuse.org/repositories/home:/microchip8
SUSE Unbound Forum: http://suseunbound.lefora.com


Do coders dream of sheep() ?
Reply With Quote
  #8 (permalink)  
Old 28-Jun-2009, 12:38
hcvv's Avatar
Wise Penguin
 
Join Date: Jun 2008
Location: Netherlands
Posts: 1,792
hcvv is on a distinguished reputation roadhcvv is on a distinguished reputation road
Default Re: How do you create an executable script to run from an ic

Quote:
Originally Posted by microchip8 View Post
this is not true, you can use either #! /bin/sh or #!/bin/sh ... both are valid
Hm, when you tested it you are most pobably correct. I always learned it without (on several Unixes and for more then 30 years now). In any case it is not his main problem.
__________________
Henk van Velden
Reply With Quote
  #9 (permalink)  
Old 28-Jun-2009, 12:44
hcvv's Avatar
Wise Penguin
 
Join Date: Jun 2008
Location: Netherlands
Posts: 1,792
hcvv is on a distinguished reputation roadhcvv is on a distinguished reputation road
Default Re: How do you create an executable script to run from an ic

I never would think that you had not tested your scripts first, before trying to make it into a clickable thing. Test it from a console/terminal first!

So first make your script working.

BTW it should run as root, so just starting it from a user GUI won't work either. Your command inside the icon should be something like
Code:
su /path/to/the/script
and you must be prepared to enter the root passwd, so I think it must be executed in a console/terminal to give you that change. Or use kdesu.
__________________
Henk van Velden
Reply With Quote
  #10 (permalink)  
Old 28-Jun-2009, 13:03
hcvv's Avatar
Wise Penguin
 
Join Date: Jun 2008
Location: Netherlands
Posts: 1,792
hcvv is on a distinguished reputation roadhcvv is on a distinguished reputation road
Default Re: How do you create an executable script to run from an ic

Quote:
Originally Posted by microchip8 View Post
this is not true, you can use either #! /bin/sh or #!/bin/sh ... both are valid
Coming back on this. Wikipedia mentions "... then optionally any amount of whitespace ...". So it seems that you are right and I am ver old fashioned .
__________________
Henk van Velden
Reply With Quote
Reply
Page 1 of 3 1 23

Bookmarks


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




 

Search Engine Friendly URLs by vBSEO 3.3.0 RC2