Cloudef / bemenu

Dynamic menu library and client program inspired by dmenu
GNU General Public License v3.0
1.23k stars 95 forks source link

Wrapper scripts in $PATH don't appear in bemenu-run #114

Closed hendersonreed closed 4 years ago

hendersonreed commented 4 years ago

I have a few wrapper scripts for FlatPak applications in ~/bin (which is exported as part of my $PATH in my .profile file), but they aren't showing up in the dialog for bemenu-run.

Am I just exporting that path in the wrong place, or is there something more complex going on? I'm running Fedora 31 with Sway, and launching bemenu-run without any arguments.

Earnestly commented 4 years ago

It honours $PATH just fine. You may be exporting it incorrectly. That it's not working in dialog either should indicate this.

Cloudef commented 4 years ago

Make sure your custom PATH is loaded into sway's environment. How the environment is derived depends on how and when you launch sway. You could test running bemenu-run from terminal for example, and confirm that your custom PATH works there (this would confirm that your PATH doesn't get into sway process)

hendersonreed commented 4 years ago

Ah, that's got to be the solution - running bemenu-run from the terminal totally works. I am using GDM for my display manager, and different sources say different things about where it gets the $PATH variable from. I have exported my path in .pam_environment, which didn't seem to solve it, unfortunately.

Any ideas on where I might be able to configure $PATH so that GDM sources it when starting sway?

hendersonreed commented 4 years ago

update: I have now also set $PATH using systemd, by using a config file in .config/environment.d/envvars.conf as described in this Archwiki page: https://wiki.archlinux.org/index.php/Environment_variables#Per_user

Unfortunately, whilesystemctl --user show-environment now lists the path correctly, that still doesn't seem to have taken hold in Sway's environment, meaning that my scripts are still not available through bemenu.

Cloudef commented 4 years ago

Hmm, maybe sway resets or modifies PATH maybe you could ask their irc channel or open issue there and mention this issue.

hendersonreed commented 4 years ago

I've asked on their irc channel, will post the solution here, if I find one.

Cloudef commented 4 years ago

This most likely is GDM issue and not sway. There is related issue here: https://gitlab.gnome.org/GNOME/gdm/issues/385

Cloudef commented 4 years ago

https://github.com/swaywm/sway/issues/3109 There's workaround here, by running sway inside a shell. Not pretty, but not sure if there's better way with gdm.

hendersonreed commented 4 years ago

Yes, that's essentially the solution I was suggested in the sway irc channel!

I ended up editing /usr/share/wayland-sessions/sway.desktop to run a script I placed in /opt that sources ~/.profile. The contents of the .desktop file are pasted below:

[Desktop Entry]
Name=Sway
Comment=An i3-compatible Wayland compositor
Exec=/opt/sway-launch
Type=Application

Thanks everyone for their comments and suggestions, closing this issue now.

AdrienLemaire commented 4 years ago

@hendersonreed can you share your script? I'm quite confused.

$ cat /usr/share/wayland-sessions/sway.desktop
[Desktop Entry]
Name=Sway
Comment=An i3-compatible Wayland compositor
Exec=/usr/bin/zsh -l -c sway
Type=Application
$ cat ~/.zprofile
export PATH=$PATH:/home/dori/.local/bin
touch /tmp/zprofile_got_sourced
$ swaymsg exit

After relog-in through GDM

$ ls /tmp/zprofile_got_sourced
/tmp/zprofile_got_sourced

sway config

set $menu bemenu -b -i -n \
    --nb "#282a2e" \
    --nf "#de935f" \
    --fn "pango:Noto Sans Mono 12" \
    --hb "#373b41" \
    --tb "#373b41" \
    --hf "#f0c674" \
    --tf "#f0c674"

bindsym $mod+d exec j4-dmenu-desktop --dmenu='$menu' --term='alacritty'

bemenu from $mod+d doesn't list .local/bin scripts, but bemenu-run from the shell does.

Cloudef commented 4 years ago

@AdrienLemaire note that you are using j4-dmenu-desktop instead of bemenu-run. In this case bemenu will act simply as a interface and won't search any PATH at all. Your issue would be with j4-dmenu-desktop instead of bemenu.