doronbehar / pistol

General purpose file previewer designed for Ranger, Lf to make scope.sh redundant

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pistol.conf isn't loaded on OS X

duganchen opened this issue · comments

I'm wondering if this is the issue behind this one:

#19

I've noticed that on OS X, ~/.config/pistol/pistol.conf isn't loaded.

I have the following in ~/.config/pistol/pistol.conf:

image/* viu %pistol-filename%

If I just run pistol against a image, the setting doesn't take effect:

▶ pistol Lohse-3840x2160.jpg
JPEG image data, Exif standard: [TIFF image data, little-endian, direntries=0], baseline, precision 8, 3840x2160, components 3

(That's Divinity: Original Sin 2 wallpaper, if you're wondering).

But if I force it to load pistol.conf,

▶ pistol -c ~/.config/pistol/pistol.conf Lohse-3840x2160.jpg

Then I see the image in the terminal.

What does pistol --help says on OS X?

❯ pistol --help
Usage: /Users/dugan/go/bin/pistol OPTIONS [<file> ...]

OPTIONS

-V, --version               Print version date and exit
-c, --config <config file>  configuration file to use (defaults to ~/.config/pistol/pistol.conf)
-h, --help                  print help and exit

ARGUMENTS

file                        the file to preview

I'm not sure why you asked that, as the path in "pistol --help" is a hardcoded string.

I know what's wrong though.

adrg/xdg simply doesn't recognize ~/.config as a user configuration directory on OS X. It only recognizes (and searches) ~/Library/Preferences.

That library searches ~/.config on Linux, ~/Library/Preferences on OS X. Compare:

https://github.com/adrg/xdg/blob/master/paths_darwin.go#L11
https://github.com/adrg/xdg/blob/master/paths_unix.go#L15

So on OS X, Pistol currently would find the configuration file only at the following two paths:

  • ~/Library/Preferences/pistol.conf
  • ~/Library/Preferences/pistol/pistol.conf

You are right, that path was indeed hardcoded. Now it is not, and --help reflects the real paths that are supposed to be used. Thanks for the report.

BTW is this surprising to you as an OS X user to use a program with such an XDG assumption? Because other golang xdg implementations use the same path for OS x - https://github.com/kyoh86/xdg & https://github.com/OpenPeeDeeP/xdg .

I'd certainly say that that resolves it. 👍

As for whether the correct OS X XDG path surprises me: I mainly have a Linux background and I'm the wrong OS X user to ask.

Can you also update the readme?

Can you also update the readme?

Yes :) Thanks.

BTW, I've been using macOS for some time now and this was a surprise to me, most apps I use store their config in ~/.config/ I've also noticed that helm started using the ~/Library/ path after v3 maybe this came with some more recent version of macOS or only now developers are starting to adopt it...