element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Raspberry Pi
  • Products
  • More
Raspberry Pi
Raspberry Pi Forum Launching an X11 app exclusivly on startup with a Pi
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Raspberry Pi to participate - click to join for free!
Featured Articles
Announcing Pi
Technical Specifications
Raspberry Pi FAQs
Win a Pi
Raspberry Pi Wishlist
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 3 replies
  • Subscribers 665 subscribers
  • Views 2606 views
  • Users 0 members are here
  • autostart
  • xsession
  • x11
  • raspberry_pi
  • raspberry pi
  • linux
Related

Launching an X11 app exclusivly on startup with a Pi

halkun
halkun over 9 years ago

In my Raspberry Pi project, I need to have X11 run a python script that replaces the "normal" window manager. I went ahead and stripped LXDE entirely from my system, and now when I boot my pi I get a blank X11, but also an Xterm session that being ran automatically from.... somewhere. I thought it was X11 running in failsafe mode, but I disabled that /etc/X11/Xsession.options (Commented it out), but the Xterm persists. Then I tried to give it an application to run by creating a script in Xsession.d. (I had it run xpdf as default) . It ran xpdf, and then that silly XTerm window popped on top...

 

Where is the Xterm session coming from so I can comment it out?

 

Better yet, is a better way to launch an application on X11 start other then monkeying with Xsession? I don't think so, but can imagine this being a popular thing to do.

  • Sign in to reply
  • Cancel
  • rew
    rew over 9 years ago

    When it is running, you can use "pstree -p" to figure out who started it.

     

    What happens if you manually exit the Xterm. Not as a permanent solution but as a way of debugging where it comes from?

     

    When I'm placed in your situation, I prefer to set the system up for "no graphical system at boot'. Then I run a "rc.myapplication" where I do "X &" and start whatever application I need.

    (I first did that on my home system when I had a fixed-frequency monitor that did not show the standard VGA resolution..... I replaced /sbin/init with a script: start the X server, start an xterm, run the normal init with output going to that xterm. Worked great. That was 1993 or thereabouts.... :-) )

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • halkun
    halkun over 9 years ago in reply to rew

    Doing an xkill on the Xterm kills that process, but does not kill X11. I'm not at home but will investigate with the process tree and I'll run the Xsession scripts though grep and see if it's hiding in there.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • halkun
    halkun over 9 years ago in reply to halkun

    Replying to myself because I have found the answer - It requires a pretty low level concept on how X11 works

     

    X11 by itself is a networked graphical "socket" that applications can "plug into" to display applications.

    X11 is initialized (via startx) by a bunch of script files collectively ran by a master script that can be found at /etc/X11/Xsession

    Xsession, in turn, uses startup scripts in /etc/X11/Xsession.d to start various X11 things in the right order

     

    This is where it gets a little strange

     

    There is a program that sits right above the Xsession system called "lightdm" (light display manager) and and is in charge of managing the "greeter" (graphical username/password), the Xsession for that user,  and the Window Manager (LXDE). In my case, as I had removed the default window manager and replaced it with nothing. I set to pi to log into X11 automatically, Lightdm was following what it was being told. It fires up, sees that the user is set for auto-logon, bypasses the greeter, does the Xsession inits, and then realizes I have no window manager. I then launches a terminal for my convenience as I had no window manager to fall back on.

     

    To fix this, you need to tell lightdm to at least run *something* after you log in. To do this, you go into pi's home directory and make a file called .xinitrc. In that file you write the following...

     

    #!/usr/bin/env bash

    exec <thing you want to run>

     

    after that you set permission +x

     

    chmod +x ~/.xinitrc

     

    then make a software link to a file named .xsession

     

    ln -s ~/.xinitrc ~/.xsession

     

    this means that if you launch X11 manually or if it's done by lightdm, they will both execute the script inside.

     

    Careful, if you exit the application you run in the .xinitrc file, lighdm will exit back to the the greeter (It thinks the window manager shut down)

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube