1

I have a simple script that I want to run every time x starts up.

#! /bin/sh
/home/kevin/.dropbox-dist/dropboxd &

I have run chmod 755 on it, so it's fully executable. And it just will. not. work.

If I put the script as .xsession then the display manager (testing with SLiM and LightDM) repeatedly asks for login information unless the specific desktop is selected (xmonad). It loads xmonad fine as the default session when there is no .xsession file. No matter what though, the script never runs.

I should mention that I've tried variants of the script. Loading a desktop background instead of dropbox, with and without "exec xmonad" statements. I have not tried a switch-case statement based on the session argument, because xmonad is my only possible session at this time.

I have placed it (without exec statements) into .xprofile, I have added a line in /etc/X11/xinit/xinitrc telling it su into my user, run the script, and exit out. I've also made it my .xinitrc, uninstalled all my display managers, and tried to startx. It threw errors at me that went away only when every single line was commented or the file itself deleted/moved.

I know the script itself is fine, because I can execute it once I'm logged in and it runs, does everything it's supposed to do.

I'm running a roll-your-own debian 8 with xmonad. Nothing else of merit is installed on my system.

1

You can put commands that you want to run before starting xmonad in ~/.xmonad/xmonad-session-rc.

If you have a ~/.xsession, its job is to start your whole X session. When that script returns, your session is over. So if you want to use this file, you need to launch xmonad from it.

#! /bin/sh
/home/kevin/.dropbox-dist/dropboxd &
exec xmonad

Note that in order for .xsession to be executed, you need to select a custom session in your display manager, not xmonad.

~/.xinitrc is similar to ~/.xsession in that when it exits, your X session is over. The difference is that ~.xsession is executed from a display manager that just logged you in whereas /xinitrc is executed for X sessions started from outside X with startx.

Alternatively, you can run the program from xmonad's startupHook, but this has the downside that it'll be executed again if you restart xmonad.

  • xmonad-session-rc worked for me. – Kevin Jul 26 '15 at 1:13
  • Addendum: both for a default session and when xmonad is specifically selected. But I'm still going to have a problem if I ever want to use a different session. Shouldn't putting "exec xmonad" at the end of the xsession file work? Because it didn't. – Kevin Jul 26 '15 at 1:22
  • @Kevin Yes, it should work. What didn't work? “It didn't work” is not a useful problem report. Did it run KDE instead? Did it play a song by Rick Astley? – Gilles Jul 26 '15 at 10:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.