Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for ~/.local/bin #124

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions System/Directory.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1565,11 +1565,12 @@ getXdgDirectory :: XdgDirectory -- ^ which special directory
getXdgDirectory xdgDir suffix =
(`ioeAddLocation` "getXdgDirectory") `modifyIOError` do
simplify . (</> suffix) <$> do
env <- lookupEnv $ case xdgDir of
XdgData -> "XDG_DATA_HOME"
XdgConfig -> "XDG_CONFIG_HOME"
XdgCache -> "XDG_CACHE_HOME"
XdgState -> "XDG_STATE_HOME"
env <- case xdgDir of
XdgData -> lookupEnv "XDG_DATA_HOME"
XdgConfig -> lookupEnv "XDG_CONFIG_HOME"
XdgCache -> lookupEnv "XDG_CACHE_HOME"
XdgState -> lookupEnv "XDG_STATE_HOME"
XdgBin -> pure Nothing
case env of
Just path | isAbsolute path -> pure path
_ -> getXdgDirectoryFallback getHomeDirectory xdgDir
Expand Down
14 changes: 14 additions & 0 deletions System/Directory/Internal/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,20 @@ data XdgDirectory
-- (e.g. @C:\/Users\//\<user\>/\/AppData\/Local@).
--
-- @since 1.3.7.0
| XdgBin
-- ^ For user-specific executable files.
-- At the moment there is no environment variable to override this value
-- specifically. Some applications use currently non-standard
-- @XDG_BIN_HOME@ for this purpose. If this is your use case then lookup
-- @XDG_BIN_HOME@ environment variable first and call `getXdgDirectory` if
-- it's not defined.
-- On non-Windows systems, the default is @~\/.local\/bin@.
-- On Windows, the default is @%APPDATA%@
-- (e.g. @C:\/Users\//\<user\>/\/AppData\/Roaming@).
-- Can be considered as the user-specific equivalent of @\/usr\/bin@ or
-- @\/usr\/local\/bin@.
--
-- @since 1.3.8.0
deriving (Bounded, Enum, Eq, Ord, Read, Show)

-- | Search paths for various application data, as specified by the
Expand Down
1 change: 1 addition & 0 deletions System/Directory/Internal/Posix.hsc
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ getXdgDirectoryFallback getHomeDirectory xdgDir = do
XdgConfig -> ".config"
XdgCache -> ".cache"
XdgState -> ".local/state"
XdgBin -> ".local/bin"

getXdgDirectoryListFallback :: XdgDirectoryList -> IO [FilePath]
getXdgDirectoryListFallback xdgDirs =
Expand Down
1 change: 1 addition & 0 deletions System/Directory/Internal/Windows.hsc
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,7 @@ getXdgDirectoryFallback _ xdgDir = do
XdgConfig -> getFolderPath Win32.cSIDL_APPDATA
XdgCache -> getFolderPath win32_cSIDL_LOCAL_APPDATA
XdgState -> getFolderPath win32_cSIDL_LOCAL_APPDATA
XdgBin -> getFolderPath Win32.cSIDL_APPDATA

getXdgDirectoryListFallback :: XdgDirectoryList -> IO [FilePath]
getXdgDirectoryListFallback _ =
Expand Down