awesomeWM / awesome

awesome window manager
https://awesomewm.org/
GNU General Public License v2.0
6.41k stars 598 forks source link

Shell environment not correct while using `awful.spawn_with_shell`? #3924

Closed bricebasty closed 5 months ago

bricebasty commented 5 months ago

Output of awesome --version:

awesome v4.3 (Too long) • Compiled against Lua 5.4.4 (running with 0.9.2) • D-Bus support: ✔ • execinfo support: ✔ • xcb-randr version: 1.6 • LGI version: /usr/share/lua/5.4/lgi/version.lua

How to reproduce the issue:

Originally posted by @solowdev in https://github.com/Shopify/ruby-lsp/issues/1216#issuecomment-2146990833

Actual result:

Expected result:

Workaround found:

This is a minor issue but it can be annoying to deal with.

sclu1034 commented 5 months ago

This is how shell environments are designed to work.

Bash only reads .bashrc when it's run as a interactive, non-login shell. .bash_profile is used when it's run as an interactive login shell. Similar conditions apply for zsh and others.

The common condition is "interactive", but awful.spawn.with_shell is not an interactive session. Therefore neither of those files are used.

The bash man page explains this in detail in the INVOCATION section.

bricebasty commented 5 months ago

Thank you for the clarification!

Now, I get that it's supposed to work this way. However, what I still don't quite understand is that I used to never have this problem before. With the same config, same everything. Shell environment somehow was the good one. Not a major issue though.

If you were me in that situation, how would you tackle this problem in the cleanest manner possible? (if not using gtk-launch). I don't expect any answer if you don't have the time/energy for it though :)

Thanks again and have a great week.

sclu1034 commented 5 months ago

what I still don't quite understand is that I used to never have this problem before. With the same config, same everything

Nothing has changed on AwesomeWM's side, so something else did. But it'd be hard to track down.

If you were me in that situation, how would you tackle this problem in the cleanest manner possible?

Two options:

bricebasty commented 5 months ago

Thanks a lot!

EDIT:

Been going with launching AwesomeWM in a shell script with environment variables.

  1. Create a shell script named start_awesome.sh in your home directory
    
    #!/bin/sh
    # Set environment variables
    export PATH="$HOME/.rbenv/bin:$PATH"
    eval "$(rbenv init -)"

Start AwesomeWM

exec awesome


2. Enter this command in your terminal to open the `desktop` file of AwesomeWM:
`sudo nano /usr/share/xsessions/awesome.desktop`

3. Edit the `desktop` file of AwesomeWM like so: (change `your_username` on line 5)

[Desktop Entry] Name=awesome Comment=Highly configurable framework window manager TryExec=awesome Exec=/home/your_username/start_awesome.sh Type=Application


Clean and configurable.