3

I have a shell script which isn't running menutray on i3 startup.

Line in .i3/config:

exec ~/.i3/i3-scripts/menutray.sh

This is what I tried for debugging:

#!/bin/bash
menutray -i -u -r &>/tmp/filename

The contents of filename:

Can't locate Linux/DesktopFiles.pm in @INC (you may need to install the Linux::DesktopFiles module) (@INC contains: /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at /usr/local/bin/menutray line 28.
BEGIN failed--compilation aborted at /usr/local/bin/menutray line 28.

But I have DesktopFiles.pm:

$ sudo find / -name 'DesktopFiles.pm'
/home/me/.cpan/build/Linux-DesktopFiles-0.09-LZFN3P/lib/Linux/DesktopFiles.pm
/home/me/.cpan/build/Linux-DesktopFiles-0.09-LZFN3P/blib/lib/Linux/DesktopFiles.pm
/home/me/.perl5/lib/perl5/Linux/DesktopFiles.pm

Evidenced by:

$ perl -MCPAN -e 'install Linux::DesktopFiles'
Reading '/home/me/.cpan/Metadata'
  Database was generated on Tue, 23 Feb 2016 23:41:02 GMT
Linux::DesktopFiles is up to date (0.09).

perl variables in my .bashrc:

PATH="/home/me/.perl5/bin${PATH+:}${PATH}"; export PATH;
PERL5LIB="/home/me/.perl5/lib/perl5${PERL5LIB+:}${PERL5LIB}"; export PERL5LIB;
PERL_LOCAL_LIB_ROOT="/home/me/.perl5${PERL_LOCAL_LIB_ROOT+:}${PERL_LOCAL_LIB_ROOT}"; export PERL_LOCAL_LIB_ROOT;
PERL_MB_OPT="--install_base \"/home/me/.perl5\""; export PERL_MB_OPT;
PERL_MM_OPT="INSTALL_BASE=/home/me/.perl5"; export PERL_MM_OPT;

Can anyone help?

5

You need to add /home/me/.cpan/build to your perl installation's @INC. As you can see in the error message, it isn't there:

(@INC contains: /etc/perl /usr/local/lib/perl/5.18.2 
/usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18
/usr/share/perl/5.18 /usr/local/lib/site_perl .)

The simplest way to do this is to set PERL5LIB in your ~/.profile (or ~/.bash_profile) file:

export PERL5LIB="/home/me/.cpan/build:$PERL5LIB"

Then, either source the file (. ~/.profile) or log out and log back in.

That will let you run the script manually but it still won't be available when you run via .i3/config since that probably doesn't read .profile. To be sure it will work, set PERL5LIB explicitly in your script itself:

#!/bin/bash
PERL5LIB="/home/max/.cpan/build:${PERL5LIB}" menutray -i -u -r &>/tmp/filename
  • I added the perl variables in my .bashrc to my question. There's already a PERL5LIB one, do I replace it with this or somehow add it? – Proletariat Feb 24 '16 at 12:41
  • Yes, you're missing the /home/me/.cpan/build directory as I said. Also, those would be better placed in ~/.profile, but ~/.bashrc will also work. The line I show in the answer will append to the current PERL5LIB. You can just add it. – terdon Feb 24 '16 at 12:41
  • Sorry, replace it with the PERL5LIB currently there? Or add it, so two will have the same name? – Proletariat Feb 24 '16 at 12:43
  • @Proletariat add it. The format variable="foo:$variable", will simply add foo to the current value of variable. In this case, PERL5LIB="/home/me/.cpan/build:$PERL5LIB" will add /home/me/.cpan/build to the beginning of PERL5LIB and keep the existing values. – terdon Feb 24 '16 at 12:45
  • Unfortunately I get the same error in my debug file. Here's what my variables look like now in my .bashrc: PATH="/home/me/.perl5/bin${PATH+:}${PATH}"; export PATH; PERL5LIB="/home/me/.perl5/lib/perl5${PERL5LIB+:}${PERL5LIB}"; export PERL5LIB; PERL5LIB="/home/me/.cpan/build:$PERL5LIB" PERL_LOCAL_LIB_ROOT="/home/me/.perl5${PERL_LOCAL_LIB_ROOT+:}${PERL_LOCAL_LIB_ROOT}"; export PERL_LOCAL_LIB_ROOT; PERL_MB_OPT="--install_base \"/home/me/.perl5\""; export PERL_MB_OPT; PERL_MM_OPT="INSTALL_BASE=/home/me/.perl5"; export PERL_MM_OPT; – Proletariat Feb 24 '16 at 12:52

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.