Page 3 of 4

Re: sunflower-fm on Salix OS LXDE 13.37

Posted: 25. Jan 2012, 23:45
by gapan
Better yet:

Code: Select all

#!/bin/sh

/opt/Sunflower/Sunflower.py "$@"
if it works like that (it does here). Otherwise, if you were to launch the wrapper with a relative path, it would fail. Sunflower doesn't seem to take any command line parameters, but oh well...

Anyway, I wanted to see what the fuss was all about, so I created an SLKBUILD and uploaded it to our repo. You can install it with sourcery/slapt-src now (update your slackbuild cache first).

Re: sunflower-fm on Salix OS LXDE 13.37

Posted: 26. Jan 2012, 00:28
by mimosa
A future version might take command line parameters. Cover all the bases.

I'm confused, though - isn't the whole point of the wrapper to call the app from inside its directory? If not, why did it fail when I called it like that?

Re: sunflower-fm on Salix OS LXDE 13.37

Posted: 26. Jan 2012, 09:43
by globetrotterdk
Shador wrote:
globetrotterdk wrote: Thanks for the help mimosa. I believe that the symlink syntax should be reversed shouldn't it? It should look like:

Code: Select all

ln -s /usr/local/bin/sunflower /opt/sunflower/Sunflower.py
No, I have to always look it up too, but it was right the way mimosa posted it. So first argument where the symlink should point to and second argument where to create the symlink that points at the first argument.
I get the following error:

Code: Select all

# ln -s /opt/Sunflower/Sunflower.py /usr/local/bin/sunflower
ln: failed to create symbolic link `/usr/local/bin/sunflower/Sunflower.py': File exists
Remember, the command before was:
mimosa wrote:

Code: Select all

#cp -r /home/globetrotter/Sunflower /usr/local/bin
I remember which is which by thinking of a traveling metaphor - where you're traveling from is always on your left and where you want to travel to is always on the right. Copenhagen to Brussels - /home/globetrotter/Sunflower to /usr/local/bin Then you are in /usr/local/bin and you want to go to /opt/sunflower/ and create a symbolic link.

Re: sunflower-fm on Salix OS LXDE 13.37

Posted: 26. Jan 2012, 10:13
by mimosa
That's strange, but in any case, we've established that the symlink approach doesn't work because the script sunflower.py doesn't work properly when it's called like that.

Instead, you need to create a text file /usr/local/bin/sunflower containing the script provided by Shador (or gapan's alternative version). I suggest first doing

Code: Select all

#rm /usr/local/bin/sunflower
just in case, then open a text editor, paste in the script, and save as /usr/local/bin/sunflower. Then everything should work. Test by typing

Code: Select all

$sunflower
EDIT

Ah,Ii've just seen the bottom of your post. Yes I did suggest that but then it was suggested to put it in /opt. You should move the directory to there, and make sure it is no longer present at the old location - mv does this automatically.

That also explains the error you got. You were trying to create a link called sunflower at a location where there was a *directory* with the same name.

Re: sunflower-fm on Salix OS LXDE 13.37

Posted: 26. Jan 2012, 10:16
by globetrotterdk
But if I run

Code: Select all

#rm /usr/local/bin/sunflower
I will be removing the folder that Sunflower.py resides in.

Re: sunflower-fm on Salix OS LXDE 13.37

Posted: 26. Jan 2012, 10:25
by mimosa

Code: Select all

#mv /usr/local/bin/sunflower /opt
EDIT

Edited my original post to get this right :oops:

Re: sunflower-fm on Salix OS LXDE 13.37

Posted: 26. Jan 2012, 11:35
by globetrotterdk
mimosa wrote:

Code: Select all

#mv /usr/local/bin/sunflower /opt
No worries :) So, you want me to move the "sunflower" folder from /usr/local/bin/ to /opt ? I should actually run

Code: Select all

#rm /opt/sunflower
ifrst, correct? That is where the symlink is as per what I did earlier:

Code: Select all

# ln -s /usr/local/bin/sunflower/Sunflower.py /opt/sunflower

Re: sunflower-fm on Salix OS LXDE 13.37

Posted: 26. Jan 2012, 12:00
by mimosa
Yes I think it probably is necessary to remove the link first.

Note that now gapan has made a slackbuild for this, you can just install it using Sourcery / slapt-src (update first). However, we're almost there doing it the hard way :D

Re: sunflower-fm on Salix OS LXDE 13.37

Posted: 26. Jan 2012, 14:59
by globetrotterdk
Thanks to everyone for all of their help. I BTW found out how to change the default file manager - right click lxpanel and choose panel settings / preferences, go to the advanced tab, change "set preferred applications - file manager" from "pcmanfm %s" to "sunflower %s".

Has anyone figured out how to change the terminal colors in sunflower-fm? There is nothing listed in the preferences, but I thought it might be possible to add a variable to ~/.config/sunflower/config

Re: sunflower-fm on Salix OS LXDE 13.37

Posted: 26. Jan 2012, 18:59
by mimosa
For the record, it seems worth summarising how to go about this in a similar case, that is, when downloading an application that is simply run by calling a script. In this instance, that's Sunflower.py inside directory Sunflower. I have tor on this machine, which works similarly - though a symlink is enough for tor.

Code: Select all

#cp -r ~/downloads/Sunflower /opt # move it to where we want to keep it, recursively
#chown -R root /opt/Sunflower     # make sure root owns everything (not necessary in this case but it might be if the files got there some other way)
#chmod +x /opt/Sunflower/Sunflower.py # make sure the script is executable, which it may not be when first unpacked
#ln -s /opt/Sunflower/Sunflower.py /usr/local/bin/sunflower # create a symlink to the script somewhere suitable in your $PATH
Test the symlink to see if the app works when called like that:

Code: Select all

$sunflower
In this case it doesn't, so we need to delete the link and create a wrapper script:

Code: Select all

#rm /usr/local/bin/sunflower  # if you don't delete the link then when you create the script, you will be editing Sunflower.py (which it points to)
As root, create the file /usr/local/bin/sunflower with a text editor, containing the following script:

Code: Select all

#!/bin/sh

cd /opt/Sunflower/  # move to the app's directory
./Sunflower.py "$@" # run it from there, passing any arguments to it (in this case there aren't any)
Make sure it is executable:

Code: Select all

#chmod +x /usr/local/bin/sunflower
Whether you ended up using the script or the symlink was enough, the app can be called by

Code: Select all

$sunflower
and that is the thing to put in any config files, launchers etc, depending on your DE/WM - just "sunflower", because it is in your $PATH, making it a bona fide application.

Alternatively, as Shador says, you can do all this on a per-user basis, in which case root isn't needed and the files should belong to the user. Create ~/bin and save the wrapper script (or symlink) there, pointing it wherever you're keeping the application within your ~. Add ~/bin to your $PATH by adding the following line to ~/.profile (which you may need to create):

Code: Select all

PATH=$PATH:$HOME/bin
:)