There are a few scripts I would like to be able to run from my desktop.
An example is:
#! /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?
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.
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.
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?
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 ).
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. :\
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.
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
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.
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 >:( .
Well each individual command in the script works when entered into the console separately. As far as I know the syntax in my script is correct which is why I cannot figure out why it won’t work. I even logged in as root to try run it and it didn’t make any changes to my charge thresholds.
I tried Alt-F2 and kdesu /my/path/to/the/script and also nothing.
I opened the Terminal, did su and password so I’m root. Then entered /my/path/to/the/script and got back an error saying “/bin/sh: bad interpreter: Permission denied”
I’ve tried creating the script both as root and as my username but neither work. Totally baffled as it’s not making sense.
I have a similar script working (with different thresholds) in the boot.local without problems So why with this?
It can not find the interpreter /bin/sh. And of course will not do anything then.
In my system /bin/sh is a symbolic link to /bin/bash. I do not know about yours.
In any case you could change your shebang to
#!/bin/bash
because it will use bash in any case and mentioning sh would some give the idea that you wanted to use the Posix shell (or even the Bourne shell).
Make the change and execute as root to see if the error is gone (and the result you want is achieved).
boot.local is ‘sourced’ from the bootscripts, so no shebang needed there (and consequently no error) because it will not be interpreted.
Well in my system /bin/sh is also a symlink to /bin/bash. I changed #!/bin/sh to #!bin/bash and it made no difference, just get the bad interpretor error again. That is trying to execute it as root from the Terminal.
BTW, how do you execute as root? This may sound a silly question, but everything I do not realy see may be a misuderstanding between you, me and the system. It should look like:
Yes, sorry it was a typo on my part. It is typed correctly in the script. The frustration was creeping in
I finally solved it lol! . I moved the script to my home folder and it just started working. Before I had it on another partition that I use for my work files. I don’t know why it wouldn’t work on the other partition when I was entering the full path to partition and script.
You are not wasting my time. We are here as volunteers trying to help each other. When I thought this was time wasting, I would go doing other things
As this is a root script, the proper place to put it might be in /root/bin/. This is within roots home directory. Roots home directory is at this place, and not within /home, so that it is always there when / is there (and /home maybe not mounted due to problems).
That other ‘not working’ partition is that ‘a not Linux type’ of fs (like Windows one)? (I do not like to leave loose, not understood, problems behind, even if you are satisfied with a now working script).
The other partition is a Linux ext3 partition I created (which I called /VAULT) which is additional to the standard /, /home, /swap, /boot partitions I have.
It’s on the same physical HDD.
I’m still getting used to the file system and directory structure in Linux. The only reason I wanted to place the script in the vault partition is that if I ever have to reinstall openSUSE then all my config scripts will be safe and I won’t have to go hunting all over for my scripts.
This sounds all very natural and logical. Gives me no idea on why it would not run from there. Sorry.
Nevertheless some remarks to make you (i hope) more “getting used to …”.
. Maybe reading SDB:Basics of partitions, filesystems, mount points - openSUSE can help you here.
. After reading this link it should be clear to you that mounting it at /VAULT is at your own discretion. It could also be mounted at /home/your-uid/vault (most Unix/Linux users are not going for capitals normaly, but again, it is your choice!) or anywhere else within your dierectory tree.
. It is not /Swap, it is not mounted, it is used as Swap.