Discussion:
[openbox] set working directory when starting Openbox
Crni Gorac
2014-05-22 09:13:35 UTC
Permalink
I've noticed that, when Openbox started, it would set current
directory to $HOME. I'd prefer instead to have it to start in another
directory, so - would that be possible?

Thanks.
Mathias Dufresne
2014-05-22 09:43:15 UTC
Permalink
Hi,

Did you meant you want Openbox not looking into $HOME/.config/openbox for
configuration files? Refusing to all users any specific config?
Post by Crni Gorac
I've noticed that, when Openbox started, it would set current
directory to $HOME. I'd prefer instead to have it to start in another
directory, so - would that be possible?
Thanks.
_______________________________________________
openbox mailing list
openbox at icculus.org
http://icculus.org/mailman/listinfo/openbox
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://icculus.org/pipermail/openbox/attachments/20140522/73b374fa/attachment.html>
Crni Gorac
2014-05-22 11:35:27 UTC
Permalink
No, reading user specified config files is, or course, OK with me. I
just want that, if for example /tmp is working directory in the shell
when "startx" command run, that Openbox doesn't change working
directory back to $HOME, but that /tmp stays as working directory.

Thanks.

On Thu, May 22, 2014 at 11:43 AM, Mathias Dufresne
Post by Mathias Dufresne
Hi,
Did you meant you want Openbox not looking into $HOME/.config/openbox for
configuration files? Refusing to all users any specific config?
Post by Crni Gorac
I've noticed that, when Openbox started, it would set current
directory to $HOME. I'd prefer instead to have it to start in another
directory, so - would that be possible?
Thanks.
_______________________________________________
openbox mailing list
openbox at icculus.org
http://icculus.org/mailman/listinfo/openbox
_______________________________________________
openbox mailing list
openbox at icculus.org
http://icculus.org/mailman/listinfo/openbox
Mathias Dufresne
2014-05-22 12:01:06 UTC
Permalink
Ok. I'm not an Openbox dev, nor even a dev at all, but for me this
behaviour is not part of the window manager, which ever it is. A window
manager has to provide window decoration, placement and so on, but no real
working space, only frames into which other applications would run and set
up an environment.

This was my sysadmin point of view. And I tested it:

Logging off from my X session, going into some console to:
- stop my X server as root
- connect with normal user into a console (arrived of course in my $HOME)
- cd /tmp with taht user/console
- launch stratx from that console, still in /tmp

The result was openbox started without using my ~/.config/openbox files (no
tint2 for a taskbar and so on) and the xterm I ran were all started into
/tmp rather than my own home directory.
So when Openbox is starting or running it is not changing the current
directory to $HOME.

Once back into my console I killed Openbox (ctrl + C...) and then my shell
was still positionned into /tmp too.
So Openbox do not change the directory in the terminal you use to launch
startx.

I'm using a Gentoo (modified to use systemd rather sysvinit but I don't
think impact at all the startx script, it impacts when running X and
Openbox system wide) and so my startx script could be different from yours,
I don't knkow what system you are using.

On this system startx script is part of xinit package in version 1.3.3. I
mentionned that because I expect this directory switch is done by the
command you are using to launch Openbox, which seems to be startx.

Cheers,

mathias
Post by Crni Gorac
No, reading user specified config files is, or course, OK with me. I
just want that, if for example /tmp is working directory in the shell
when "startx" command run, that Openbox doesn't change working
directory back to $HOME, but that /tmp stays as working directory.
Thanks.
On Thu, May 22, 2014 at 11:43 AM, Mathias Dufresne
Post by Mathias Dufresne
Hi,
Did you meant you want Openbox not looking into $HOME/.config/openbox for
configuration files? Refusing to all users any specific config?
Post by Crni Gorac
I've noticed that, when Openbox started, it would set current
directory to $HOME. I'd prefer instead to have it to start in another
directory, so - would that be possible?
Thanks.
_______________________________________________
openbox mailing list
openbox at icculus.org
http://icculus.org/mailman/listinfo/openbox
_______________________________________________
openbox mailing list
openbox at icculus.org
http://icculus.org/mailman/listinfo/openbox
_______________________________________________
openbox mailing list
openbox at icculus.org
http://icculus.org/mailman/listinfo/openbox
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://icculus.org/pipermail/openbox/attachments/20140522/0437a427/attachment.html>
Crni Gorac
2014-05-22 12:30:07 UTC
Permalink
What you described is somewhat opposite to what happens on my machine.
I have Openbox 3.5.2, and xinit 1.3.3. I have following snippet in
my $HOME/.bash_login:
#--------------------------
cd /tmp

case $(tty) in
/dev/tty1)
xinit
;;
esac
#--------------------------
and my $HOME/.xinitrc is simply:
#--------------------------
exec openbox-session
#--------------------------

Now, when I login (on first tty), Openbox get started automatically,
and despite working directory being set to /tmp before xinit run,
Openbox is properly reading all files from $HOME/.config/openbox
directory. However, when I run an xterm from within Openbox, the
working directory is set to $HOME (instead to /tmp).

I recently switched to Openbox from E17, and the setup described went
practically unchanged (except that instead of "exec openbox-sesssion"
I had "exec enlightenment_start" in my $HOME/.xinitrc file). However,
when xterm run in E17, its working directory would be /tmp, as I would
expect...

Thanks.


On Thu, May 22, 2014 at 2:01 PM, Mathias Dufresne
Ok. I'm not an Openbox dev, nor even a dev at all, but for me this behaviour
is not part of the window manager, which ever it is. A window manager has to
provide window decoration, placement and so on, but no real working space,
only frames into which other applications would run and set up an
environment.
- stop my X server as root
- connect with normal user into a console (arrived of course in my $HOME)
- cd /tmp with taht user/console
- launch stratx from that console, still in /tmp
The result was openbox started without using my ~/.config/openbox files (no
tint2 for a taskbar and so on) and the xterm I ran were all started into
/tmp rather than my own home directory.
So when Openbox is starting or running it is not changing the current
directory to $HOME.
Once back into my console I killed Openbox (ctrl + C...) and then my shell
was still positionned into /tmp too.
So Openbox do not change the directory in the terminal you use to launch
startx.
I'm using a Gentoo (modified to use systemd rather sysvinit but I don't
think impact at all the startx script, it impacts when running X and Openbox
system wide) and so my startx script could be different from yours, I don't
knkow what system you are using.
On this system startx script is part of xinit package in version 1.3.3. I
mentionned that because I expect this directory switch is done by the
command you are using to launch Openbox, which seems to be startx.
Cheers,
mathias
Mathias Dufresne
2014-05-22 16:02:16 UTC
Permalink
I don't use xinit and I never used it but I expect your issue is in the
chain of processes running between your login and the apparition of openbox.

All I can say is if I create the 2 files as you described then run a
startx, I have the same behaviour than you: a full launch of openbox, which
set up a new environment for my user session which set up my default
directory to my homedir.
Once more, for me this is a normal behaviour: new session, new environment.

And what happen during that time, I have no idea. You can use this command
line to generate awfully huge logs:
strace exec openbox-session > /your/path/to/openbox.log 2>
/your/path/to/openbox.strace

the first ">" is to get standard logs (those sent to the console)
the second is to get stderr which is used by strace which should tell you
alsmot all what happens during the launch time.

And finally, if your goal is only to have your user thrown into /tmp after
bash is launched in interactive mode, modify your .bashrc.

Cheers,

mat
Post by Crni Gorac
What you described is somewhat opposite to what happens on my machine.
I have Openbox 3.5.2, and xinit 1.3.3. I have following snippet in
#--------------------------
cd /tmp
case $(tty) in
/dev/tty1)
xinit
;;
esac
#--------------------------
#--------------------------
exec openbox-session
#--------------------------
Now, when I login (on first tty), Openbox get started automatically,
and despite working directory being set to /tmp before xinit run,
Openbox is properly reading all files from $HOME/.config/openbox
directory. However, when I run an xterm from within Openbox, the
working directory is set to $HOME (instead to /tmp).
I recently switched to Openbox from E17, and the setup described went
practically unchanged (except that instead of "exec openbox-sesssion"
I had "exec enlightenment_start" in my $HOME/.xinitrc file). However,
when xterm run in E17, its working directory would be /tmp, as I would
expect...
Thanks.
On Thu, May 22, 2014 at 2:01 PM, Mathias Dufresne
Post by Mathias Dufresne
Ok. I'm not an Openbox dev, nor even a dev at all, but for me this
behaviour
Post by Mathias Dufresne
is not part of the window manager, which ever it is. A window manager
has to
Post by Mathias Dufresne
provide window decoration, placement and so on, but no real working
space,
Post by Mathias Dufresne
only frames into which other applications would run and set up an
environment.
- stop my X server as root
- connect with normal user into a console (arrived of course in my $HOME)
- cd /tmp with taht user/console
- launch stratx from that console, still in /tmp
The result was openbox started without using my ~/.config/openbox files
(no
Post by Mathias Dufresne
tint2 for a taskbar and so on) and the xterm I ran were all started into
/tmp rather than my own home directory.
So when Openbox is starting or running it is not changing the current
directory to $HOME.
Once back into my console I killed Openbox (ctrl + C...) and then my
shell
Post by Mathias Dufresne
was still positionned into /tmp too.
So Openbox do not change the directory in the terminal you use to launch
startx.
I'm using a Gentoo (modified to use systemd rather sysvinit but I don't
think impact at all the startx script, it impacts when running X and
Openbox
Post by Mathias Dufresne
system wide) and so my startx script could be different from yours, I
don't
Post by Mathias Dufresne
knkow what system you are using.
On this system startx script is part of xinit package in version 1.3.3. I
mentionned that because I expect this directory switch is done by the
command you are using to launch Openbox, which seems to be startx.
Cheers,
mathias
_______________________________________________
openbox mailing list
openbox at icculus.org
http://icculus.org/mailman/listinfo/openbox
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://icculus.org/pipermail/openbox/attachments/20140522/1c9681c9/attachment.html>
Crni Gorac
2014-05-22 16:30:33 UTC
Permalink
I already did strace, and indeed one can find "chdir($HOME)" in the
listing - it happens somewhere in between syscalls to create
$HOME/.config/openbox/openbox.log file and
$HOME/.cache/openbox/sessions directory, so I strongly suspecting
Openbox is doing this current directory change, and this is why I
posted the question in the first place.

I wouldn't agree that changing current directory to $HOME is right
thing to do - current directory is "inherited" through exec*()
syscalls, and then further when "exec-ed" program forks child
processes (as Openbox is doing to start xterm). I know I can achieve
what I want in number of other ways, but I was just curious why
Openbox is doing this current directory change...

Thanks.


On Thu, May 22, 2014 at 6:02 PM, Mathias Dufresne
Post by Mathias Dufresne
I don't use xinit and I never used it but I expect your issue is in the
chain of processes running between your login and the apparition of openbox.
All I can say is if I create the 2 files as you described then run a startx,
I have the same behaviour than you: a full launch of openbox, which set up a
new environment for my user session which set up my default directory to my
homedir.
Once more, for me this is a normal behaviour: new session, new environment.
And what happen during that time, I have no idea. You can use this command
strace exec openbox-session > /your/path/to/openbox.log 2>
/your/path/to/openbox.strace
the first ">" is to get standard logs (those sent to the console)
the second is to get stderr which is used by strace which should tell you
alsmot all what happens during the launch time.
And finally, if your goal is only to have your user thrown into /tmp after
bash is launched in interactive mode, modify your .bashrc.
Cheers,
mat
Jim Rees
2014-05-22 16:46:18 UTC
Permalink
Crni Gorac wrote:

I already did strace, and indeed one can find "chdir($HOME)" in the
listing - it happens somewhere in between syscalls to create
$HOME/.config/openbox/openbox.log file and
$HOME/.cache/openbox/sessions directory, so I strongly suspecting
Openbox is doing this current directory change, and this is why I
posted the question in the first place.

It's easy enough to find in the source, strace wasn't really necessary. It's
one of the first things that happens in main(). It uses g_get_home_dir(),
which is somewhat controversial as it reads the password database, ignoring
$HOME.

I agree that doing a chdir to anywhere seems wrong. The only thing I could
find in the changelog was a fix for when the chdir fails.

Loading...