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

Revise XDG handling #258

Merged
merged 2 commits into from Jan 7, 2021
Merged

Revise XDG handling #258

merged 2 commits into from Jan 7, 2021

Conversation

slotThe
Copy link
Member

@slotThe slotThe commented Dec 27, 2020

Description

Fixes #164 and #256

I'm putting this out here in a relatively early state, because I know
opinions are to be had on a lot of these things, so I'd rather not wait
until this is more mature for people to say I've done something horribly
wrong.

As per #256, this puts forth the following changes to how we handle the
whole config situation.

  1. If all three of xmonad's environment variables (XMONAD_DATA_DIR,
    XMONAD_CONFIG_DIR, and XMONAD_CACHE_DIR) are set, use them.
  2. If there is a build script build or configuration xmonad.hs in
    ~/.xmonad, set all three directories to ~/.xmonad.
  3. Otherwise, use XDG_DATA_HOME, XDG_CONFIG_HOME, and
    XDG_CACHE_HOME (or their respective fallbacks).

If none of the above exist, we default to using the XDG_* variables,
creating the necessary directories if needed.

In the cases of 1. and 3., the build script or executable is expected to
be in the config dir (this is the case at the moment as well).

This doesn't quite compile with xmonad-contrib yet, though there
aren't very many changes needed to make it work. I've created a quick
fix on this branch, in case anyone wants to try this. From my (very) light
testing so far, it at least seems to do what it's supposed to.

Checklist

  • I've read CONTRIBUTING.md

  • I've confirmed these changes don't belong in xmonad-contrib instead

  • I tested my changes with xmonad-testing

  • I updated the CHANGES.md file

@slotThe slotThe force-pushed the xdg-things branch 2 times, most recently from 9fdadaa to 6baf36c Compare December 27, 2020 19:38
@slotThe slotThe marked this pull request as ready for review December 30, 2020 18:03
@slotThe slotThe force-pushed the xdg-things branch 5 times, most recently from e8f44bb to 9caade1 Compare January 5, 2021 15:29
@slotThe
Copy link
Member Author

slotThe commented Jan 5, 2021

@geekosaur @liskin @psibi what do you people think?

I think the abstract approach mentioned in #256 is sound and this implementation "works for me" and shouldn't break any existing configs

CHANGES.md Outdated Show resolved Hide resolved
Copy link
Member

@psibi psibi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM apart from minor haddock issue. I will merge this in a couple of days unless there is objection from others.

src/XMonad/Core.hs Outdated Show resolved Hide resolved
@slotThe slotThe force-pushed the xdg-things branch 3 times, most recently from 3de1064 to 41066ad Compare January 7, 2021 09:39
Copy link
Member

@liskin liskin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work fixing this stuff! 👍

Found a mistake in env var handling, the rest are just doc/code improvement suggestions.

src/XMonad/Core.hs Outdated Show resolved Hide resolved
src/XMonad/Core.hs Outdated Show resolved Hide resolved
src/XMonad/Core.hs Outdated Show resolved Hide resolved
@slotThe slotThe force-pushed the xdg-things branch 3 times, most recently from 7383a3d to 0d9c56b Compare January 7, 2021 14:29
Improve handling of the whole XDG situation.  This now looks as follows

  1. If all three of xmonad's environment variables (XMONAD_DATA_DIR,
     XMONAD_CONFIG_DIR, and XMONAD_CACHE_DIR) are set, use them.
  2. If there is a build script `build' or configuration `xmonad.hs' in
     `~/.xmonad', set all three directories to `~/.xmonad'.
  3. Otherwise, use XDG_DATA_HOME, XDG_CONFIG_HOME, and
     XDG_CACHE_HOME (or their respective fallbacks).

If none of the above exist, we default to using the XDG_* variables,
creating the necessary directories if needed.
-- command will add it to the GHC include path.
--
-- * @cacheDir@: This directory is used to store temporary files that
-- can easily be recreated. For example, the XPrompt history file.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit funny that the configuration binary, which can be easily recreated, gets placed in dataDir, whereas the prompt history, which requires superhuman memory abilities or superhuman backup regime to recreate, goes in cacheDir. But xmonad isn't the only program that does it this way so I guess it doesn't matter.

CHANGES.md Outdated Show resolved Hide resolved
@liskin liskin merged commit f875a56 into xmonad:master Jan 7, 2021
This was referenced Jan 8, 2021
@slotThe slotThe deleted the xdg-things branch April 8, 2021 18:13
liskin added a commit to xmonad/xmonad-contrib that referenced this pull request Jun 2, 2021
With the bumped xmonad dependency, we can drop these, leaving just 4
warnings visible in ghcid. \o/

Related: xmonad/xmonad#258
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

~/.xmonad folder being created with configuration in XDG_CONFIG_HOME
3 participants