Script for starting xmms2 when logging in

I was wondering if the following bash script is ok, I don’t want to test before asking :slight_smile:

 if  -x /usr/bin/xmms ]; then /usr/bin/xmms; fi 

to be put in

~/.profiles

.

  1. It is not a script,but just a statement (a script is one of more statements where the first line is a “shebang”, put into a file and the file made executable).

  2. The statement looks fine to me. The precaution taken by first testing if it exists and is executable for you might look a bit superfluous, but OTOH when you allways program that cautious I applaud this attitude.

  3. I gues you mean .profile and not .profiles.

  4. Just put it there and see what happens when testing. I think it is pretty harmless as it is, even when it should not work to your complete satisfaction. Extra precaution: Do not log out from the session where you edited .profile, but start a second GUI session. When it is hanging (could happen with these sorts of .profile editing), you will still have the first session open to edit back.

Edit: BTW when it works to satisfaction, I can show you a shorter one.

On 2011-10-15 20:26, riderplus wrote:
>
> I was wondering if the following bash script is ok, I don’t want to test
> before asking :slight_smile:

Ha! So we do the hard work, eh? :slight_smile:

I’ll answer with a question: what will happen if you start a text console?


Cheers / Saludos,

Carlos E. R.
(from 11.4 x86_64 “Celadon” at Telcontar)

Thanks for replies. Yes, I was wrong, it’s not a script. :frowning:

Robin, I don’t know :slight_smile:

And by the way, is

bash -l

equivalent to ctrl+alt+f1?

I did start a new session with ctrl+alt+f1 after modifying the ~/.profile file as to include the statement (and placed /usr/bin/amarok instead of xmms) and I was prompted with this:

unnamed application(4776):KUniqueApplication Cannot find the D-Bus Session Server: /bin/dbus-launch terminated abnormally with the following error: Autolaunch error: X11 initialization fail
unnamed application (4775): Pipe closed unexpectedly

:frowning:

I am not quite following you here, but* bash -l,* when given in a shell (terminal) session, starts a new shell (bash) as a daughter in that terminal session and it is started as a login shell, thus indeed including your .profile. But I guess that you want to test this when you start a GUI session, not a bash session.

Ctrl-Alt-F1 is a key combination given to your running X-server, to show you the first logical screen of your monitor. That one is normaly showing the system console. Again not a graphical session.

I guess that my suggestion to use one session for editing the .profile and another session to test what happens should have been a bit more explanatory.

The session where you change .profile can be in a terminal in aGUI (KDE) session you are running. The second session can then be started using the “leave/logout/shutdown” button in the Kmenu (not a similar button in your panel), which offers you something like “change user” I do not have the English language in my system here, thus the wording could be different). Following the instructions there will give you a login screen (at Ctrl-Alt-F8, when you original GUI session is at Ctrl-Alt-F7). Use that new login for the test.

Alternative, do not login in the GUI t all, but do Ctrl-Alt-F1 and login in the console. Do your .profile editing, and switch with Ctrl-Alt-F7 back to your GUI login. Switch back and foeward and logout/login in the GUI for testing.

As I understand what you say here, you edited from the console (which I give as a possibility above and is OK), but you fail to tell in which environment you test the* .profile*. Making a GUI login? When you test doing a CLI login, Amarok (and any X bases program) will give problems because no graphical X screen is assoiciated which that session.

I’ve started a new GUI session with “Switch User”. The result is that I see only the Amarok icon, nothing else (which disappears after 1 minute and…black screen). So I guess it’s not working, as it stops X’s normal activity.

On 2011-10-16 13:56, hcvv wrote:

> As I understand what you say here, you edited from the console (which I
> give as a possibility above and is OK), but you fail to tell in which
> environment you test the- .profile-. Making a GUI login? When you test
> doing a CLI login, Amarok (and any X bases program) will give problems
> because no graphical X screen is assoiciated which that session.

Which is the answer to my question I asked of him :wink:
Or one of the answers.

riderplus: You should rather put the app in the autostart directory of the
desktop you use.


Cheers / Saludos,

Carlos E. R.
(from 11.4 x86_64 “Celadon” at Telcontar)

Robin, you mean creating a symbolic link to the application, as in Linux desktop auto start or launch programs

There is a directory ~/.kde4/Autostart/. That is the place to put things that should be started when you login in your KDE. But I am not sure what the format is.

In any case, one of us did allready ask you what happened when that statement (which now changed into callling Amarok) is executed from a terminal inside a KDE session. I can not remember you answered that. That is the place to test first what happens befor you put it into .profile.

But I agree with Carlos that the Autostart feature is the best to use because it is specialy made for what you seem to want.

I haven’t tried to execute that from a terminal inside a KDE session, but I guess it starts Amarok?! :slight_smile:

On 2011-10-16 15:46, riderplus wrote:
>
> Robin, you mean creating a symbolic link to the application, as in
> ‘Linux desktop auto start or launch programs’
> (http://tinyurl.com/2ls7zx)

Yes, that’s it. Or create a launch icon or however it is called.


Cheers / Saludos,

Carlos E. R.
(from 11.4 x86_64 “Celadon” at Telcontar)

You should not guess, you should test!

When it is in .profile you can see no warnings/errors (as you reported allready that it tries to start, but fails in the end.
Executing from a terminal should do the same, but give you eventaul messages in that terminal window.

It gives me the same:

unnamed application(4776):KUniqueApplication Cannot find the D-Bus Session Server: /bin/dbus-launch terminated abnormally with the following error: Autolaunch error: X11 initialization fail
unnamed application (4775): Pipe closed unexpectedly

Strange. This is from a konsole session in my KDE session:

henk@boven:~> amarok
KGlobal::locale::Warning your global KLocale is being recreated with a valid main component instead of a fake component, this usually means you tried to call i18n related functions before your main component was created. You should not do that since it most likely will not work 
********************************************************************************************** 
** AMAROK WAS STARTED IN NORMAL MODE. IF YOU WANT TO SEE DEBUGGING INFORMATION, PLEASE USE: ** 
** amarok --debug                                                                           ** 
********************************************************************************************** 
henk@boven:~> 

henk@boven:~> amarok
KGlobal::locale::Warning your global KLocale is being recreated with a valid main component instead of a fake component, this usually means you tried to call i18n related functions before your main component was created. You should not do that since it most likely will not work


** AMAROK WAS STARTED IN NORMAL MODE. IF YOU WANT TO SEE DEBUGGING INFORMATION, PLEASE USE: **
** amarok --debug **


henk@boven:~>
and after this Amarok runs normaly (it apparently detaches from the original proces that is started by the command given).

It’s better to copy the .desktop file of the application (or create one if it doesn’t already exist) than to create symlinks. That way, you can modify the .desktop file.

cp /usr/share/applications/kde4/amarok.desktop ~/.kde4/Autostart/

Then, in the new file ~/.kde4/Autostart/amarok.desktop, add the line:

X-KDE-autostart-phase=2

so that it won’t be started twice: first restarted by the session, then autostarted.

  • sorry. I answered the question in post #10 and didn’t see all the following posts.

Yes, a bit bewildering. We are now on two tracks:

  1. The Autostart solution where @please_trry_again is providing very usefull information (and which imho is the track the OP should follow).
  2. Putting something into* .profile*
    which has several disadvantages like that it will start Amarok also at a CLI login. But the biggest thing here is that it seems that the OP gets errors when he starts Amarok from a terminal and thus also from his* .profile*. And I do not have those errors.

I suggest the OP to follow the first track and maybe we forget about the errors he gets (or we come back and try to understand those after your Autostart works, to avoid confuson here).

Thank you!

Now I have a different problem…when I logout and then login to KDE, the settings last used are not loaded. For instance, the Internet is not started automatically, and the sound volume is reset (it is not kept at the level used last time).
How can I work this out?

the Internet is not started

Just to make clear what you mean.

You mean that the network interface(s) is/are not started? Because the Internet is working as usual in most places of the world AFAIK.
When you do mean that the network interfaces are not started, is it correct that I assume that you are using NetworkManager? Because else the NIC’s would not stop (normaly) when a user logs out.