i3wm exec, dmenu_run, and $PATH
28 Jun 2021
Apparently, neither dmenu_run nor i3’s exec
command care about paths exported via .bashrc
or .bash_profile
. I spent an embarrassing amount of time trying to debug this issue.
Prelude
It all started a few days ago when I found i3-auto-layout, which automatically decides where each window spawns depending on the parent container’s ratio.
I liked it enough that I installed it under ~/.local/bin
, added an exec_always --no-startup-id i3-auto-layout
entry in the i3 config file, and then went to bed.
The Issue
The next morning, I noticed my windows spawning in the same old vertical slices, almost as though i3-auto-layout wasn’t running at all.
I began running through my PEBKAC checklist, starting with checking if it’s actually running:
$ ps aux | grep i3-auto-layout
person 145354 0.0 0.0 6408 2316 pts/9 S+ 23:47 0:00 grep i3-auto-layout
Okay, so obviously it wasn’t running. But why?
I double checked $PATH
to make sure that ~/.local/bin
is included. And indeed it was:
$ echo $PATH
... /home/person/.local/bin ...
Next, I checked dmenu_run as well. It lists entries by alphabetic order, so i3-auto-layout should’ve been the first thing that came up. Except it didn’t:
WHERE IS IT??
At this point, I had a sneaking suspicion that neither of them were getting their $PATH
values from .bashrc
or .bash_profile
in my home folder.
Troubleshooting
I decided to just look this one up. I found an unusually useful post on StackExchange that linked to a relevant Arch Linux forum post:
Setting
$PATH
in~/.bashrc
doesn’t ensure your WM/dmenu will inherint this env.
A more relevant question to ask is, “How do you login?” Usually the env exported in~/.bash_profile
or~/.profile
are available in your X applications.
Launch dmenu_run as you normally do, then in dmenu, type
echo $PATH > /tmp/path
Then in a terminal,cat /tmp/path
to see what that $PATH is.
Just to confirm the accuracy of the forum post, I checked the content of $PATH
as seen by dmenu_run:
$ cat /tmp/path
/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
Wait, is that the superuser’s $PATH
value?
Solution
As much as I wanted i3-auto-layout to show up on dmenu_run, I couldn’t just go and . That’s going to open
It was ugly, but in the end, I decided to just hardcode the executable’s full path to i3-auto-layout:
exec_always --no-startup-id /home/person/.local/bin/i3-auto-layout
After restarting i3, I had my auto layout back.
← Return