Re: Detecting X at logon

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 17Jan2008 21:58, Joe Tseng <joe_tseng@xxxxxxxxxxx> wrote:
> I'd like to have some GUI apps start when I log on but only if I'm using 
> Xwindows.  Is it possible I could have them called conditionally from 
> bash_profile? 

Sure:

  if [ -n "$DISPLAY" ]
  then
    start some X apps...
  fi

But be sure you're understanding the login processes involved;
normally you don't need to do this, and it's probably a mistake.

Generally:

  - a text mode login starts a login shell, which runs
    your .profile (or, if you're using bash and have a .bash_profile,
    then that - bash happily falls back to .profile, so I don't
    waste effort on a .bash_profile)

  - starting X from a text mode console, _after_ you've logged in,
    using startx or xinit will run ~/.xinitrc; when it finished
    the X server is terminated; your .profile has already been run
    before this happens so you don't need it, and anything running
    your .xinitrc _should_ be under X, so no checking needs doing

  - logging in in a GUI takes a different path:
    if you have one, your ~/.xsession file is run;
    your .profile has _not_ been run, so probably it should be sourced
    by ~/.xsession as the first action.
    (This implies that your .profile should never do anything
    interactive.)
    Then the rest of the .xsession runs; when it finishes the X
    session is over.

Notice that so far, you have no cause to start X apps from the .profile;
you put them in .xsession or .xinitrc, and no checking is needed.

Now, case 3 above doesn't mention the common case - users without a
.xsession. In this case the system default session is run. That starts
some kind of desktop environment. But, because many users easily shoot
themselves in the foot by putting syntax errors or interaction in their
.profile, it DOES NOT source the user's .profile. This is bad practice,
because it means that all the apps started from the desktop lack your
environment settings. Noatably, terminals won't, and for _that_ reason
most of the default desktops start LOGIN shells in new terminals. Gah!
You're already logged in! Why ways all that effort again. Well,
because the default desktop has shirked its duty and not run your login
stuff yet.

And _that_ is why you're thinking you need to modify your .profile.
But your desktop has betrayed you and confused you.

Myself, I have:
  - .profile, to set up my environment
  - .xinitrc, to run an X session, presuming my environment is ok
  - .xsession, that sources /etc/profile, .profile and .xinitrc
This arranges things in the right order. When I open a new terminal,
it is a plain interactive shell and NOT a login shell.

Sieze control, as I have. Since the lifespan of your desktop is the
lifespan of the .xinitirc file the last command in that is generally to
run a window manager (or a full on desktop, such as gnome-session).

Cheers,
-- 
Cameron Simpson <cs@xxxxxxxxxx> DoD#743
http://www.cskk.ezoshosting.com/cs/

It's better,  when you're racing with someone you don't know so well,
to stick to the inside line - it's easier to avoid the bits.
        - Barry Sheene, bike GP commentator

-- 
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux