Ventto / mons

POSIX Shell script to quickly manage monitors on X
MIT License
632 stars 39 forks source link

Fixing command builtin for freebsd #44

Open sarcasticadmin opened 4 years ago

sarcasticadmin commented 4 years ago

Description

Depends on: https://github.com/Ventto/libshlist/pull/2 Closes: #30

It does not seem that "command -pv xrandr" is able to find xrandr in my PATH on FreeBSD. Im not sure if this is due to there just not being a default /etc/environment set or what but I think we should be checking the current PATH as well as the default to make sure we search all possibilities.

Let me know what you think.

Tests

Building with my PR from libshlist: https://github.com/Ventto/libshlist/pull/2 nets me the expect results:

mkdir build
make install PREFIX=$(realpath ./build) LIB=$(realpath ../libshlist/liblist.sh)
...
$ build/bin/mons
Monitors:        2
Mode: primary
0:*  LVDS-1   (enabled)
cemeyer commented 4 years ago

The problem is the -p flag:

             If the -p option is specified, the command search is performed
             using a default value of PATH that is guaranteed to find all of
             the standard utilities.

It ignores user's PATH and substitutes _PATH_STDPATH, which is /usr/bin : /bin : /usr/sbin : /sbin.

I don't think that makes much sense for mons and would suggest simply dropping the -p.

sarcasticadmin commented 4 years ago

@cemeyer Thanks for the clarification, thats makes sense since xrandr is under /usr/local/bin in FreeBSD.

Regardless, I think it still makes some sense cover both cases and check _PATH_STDPATH if for whatever reason the user was to botch their PATH.

cemeyer commented 4 years ago

Sure, it seems harmless to me.

arkhan commented 3 years ago

hello, any update..?