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

w3m doesn't respect XDG Base Directory standard? #130

Open
rhysday opened this issue May 16, 2020 · 18 comments
Open

w3m doesn't respect XDG Base Directory standard? #130

rhysday opened this issue May 16, 2020 · 18 comments

Comments

@rhysday
Copy link

rhysday commented May 16, 2020

I would like to move .w3m out of $HOME and into $XDG_CONFIG_HOME

@Bumbadawg
Copy link

agreed @rhysday, here's a hack i use for Steam, it works for any XDG-non-compliant program that won't require your other $HOME files.

#!/usr/bin/env sh
HOME=${XDG_DATA_HOME}/.local/data/program    program

Run it, don't source it: otherwise it'll change your session's $HOME.

This method is so much free[tm] and it makes my $HOME so clean that even teleshopping programs are jelly yo

@kmk3
Copy link

kmk3 commented Jan 3, 2021

Related SourceForge issue: https://sourceforge.net/p/w3m/feature-requests/31/

  • Title: use $XDG_CONFIG_HOME and $XDG_DATA_HOME
  • Created: 2017-03-31

It would be great if w3m could follow freedesktop.org's basedir-spec, and use
$XDG_CONFIG_HOME and $XDG_DATA_HOME instead of ~/.w3m:

https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html

@Boruch-Baum
Copy link

Boruch-Baum commented Jan 4, 2021 via email

@pirate486743186
Copy link

since this seams to be stalled, may i suggest you start by moving the cache only.

@SlidingHorn
Copy link

SlidingHorn commented Jul 4, 2021

#!/usr/bin/env sh
HOME=${XDG_DATA_HOME}/.local/data/program    program

Run it, don't source it: otherwise it'll change your session's $HOME.

@Bumbadawg (or anyone else who happens to know better than me) I'm just a regular end-user who likes a clean home directory, so I'm not sure what this means or does. Do you have the time/patience to elaborate? Do I simply execute that replacing "program" with the application name?"

Also, does it need to be run for each individual application that isn't compliant? (e.g. vim, newsboat, etc)

@z0noxz
Copy link

z0noxz commented Jul 5, 2021

@SlidingHorn the env-variable $HOME is set in context of running the "program" which makes it so that the "program" stores what it otherwise would have stored under ~/ now instead under ~/.local/data/program. This works as long as the program uses the $HOME variable to determine where it will store its files. If the code is sourced the $HOME variable will be changed globally and effect everything that uses it, so don't do that. "program" could be any program you wish to apply this "fix" to. The script could then be stored in your local bin dir (i.e. ~/.local/bin ~/.bin or whatever you have pointed out in your $PATH) with the same name as the program to override its default behavior.

@MRAAGH
Copy link

MRAAGH commented Jul 6, 2021

@Bumbadawg

HOME=${XDG_DATA_HOME}/.local/data/program program

This would normally mean ~/.local/share/.local/data/program. I think the following is more suitable:

HOME=$XDG_DATA_HOME/yourprogram yourprogram

Regardless, this is an unreliable hack, but I can see how it might work in some cases, and it's probably better than nothing.

@yashlala
Copy link
Contributor

yashlala commented Aug 5, 2021

Hi All,

I was bothered by this issue as well, and thought I might put out a quick PR if there's interest in getting this merged. I'm thinking something like the following:

  1. w3m checks for the environment variable W3M_DIR. If the environment variable is defined, then w3m will put all of its files under that location (just as it does with ~/.w3m today).
  2. If the environment variable is not defined, it will continue to put all of its files under ~/.w3m (maintaining backwards compatibility).

This method won't comply with the XDG spec exactly, but it will give us the ability to choose where w3m puts its files. It's also very straightforward to implement, only requiring a few small changes involving the RC_DIR macro + documentation.

@tats would you be interested in merging in such a change?

@pirate486743186
Copy link

It would be great if you could make the location of the cache user configurable in the config file.

@tats
Copy link
Owner

tats commented Aug 7, 2021

W3M_DIR. If the environment variable is defined, then w3m will put all of its files under that location

It seems acceptable for me.

@rkta
Copy link
Contributor

rkta commented Sep 3, 2021

since this seams to be stalled, may i suggest you start by moving the cache only.

It would be great if you could make the location of the cache user configurable in the config file.

Here is a simple patch I wrote for this: patch.

@Jonta
Copy link

Jonta commented Sep 24, 2021

Commit-URL of what @rkta wrote: rkta@461bbdb

yashlala added a commit to yashlala/w3m that referenced this issue Dec 12, 2021
By default, w3m puts all of its data in the `~/.w3m/` directory
(creating it as necessary). This was not configurable in any way.

This commit adds some quick reconfigurability -- when the "W3M_DIR"
environment variable is set, w3m will use that location instead. The
default location is unchanged.

Fixes tats#130.
yashlala added a commit to yashlala/w3m that referenced this issue Dec 12, 2021
By default, w3m puts all of its data in the `~/.w3m/` directory
(creating it as necessary). This was not configurable in any way.

This commit adds some quick reconfigurability -- when the "W3M_DIR"
environment variable is set, w3m will use that location instead. The
default location is unchanged.

Fixes tats#130.
yashlala added a commit to yashlala/w3m that referenced this issue Dec 12, 2021
By default, w3m puts all of its data in the `~/.w3m/` directory
(creating it as necessary). This was not configurable in any way.

This commit adds some quick reconfigurability -- when the "W3M_DIR"
environment variable is set, w3m will use that location instead. The
default location is unchanged.

Fixes tats#130.
yashlala added a commit to yashlala/w3m that referenced this issue Dec 15, 2021
By default, w3m puts all of its data in the `~/.w3m/` directory
(creating it as necessary). This was not configurable in any way.

This commit adds some quick reconfigurability -- when the "W3M_DIR"
environment variable is set, w3m will use that location instead. The
default location is unchanged.

Fixes tats#130.
yashlala added a commit to yashlala/w3m that referenced this issue Dec 15, 2021
By default, w3m puts all of its data in the `~/.w3m/` directory
(creating it as necessary). This was not configurable in any way.

This commit adds some quick reconfigurability -- when the "W3M_DIR"
environment variable is set, w3m will use that location instead. The
default location is unchanged.

Fixes tats#130.
@m040601
Copy link

m040601 commented Jun 2, 2022

Long time die hard w3m fan here. First of all thanks to everyone still maintaining and improving this software. And for all the small little improvements. I am just an end user, and it's great to see this (totally underrated) software cherished and appreciated by others.

pirate486743186 commented on Aug 6, 2021

It would be great if you could make the location of the cache user configurable in the config file.

  1. That option in the "config" file would be indeed great. Is this still being considered ?

It's also one of my wishes. I'd would love to choose the location for all those non critical temporary files, "w3mtmpXXX.gz", "w3msrc.htm", "w3mcacheXXX" etc .

Out of my main w3m dir and in a place choosen by me. Maybe ~/.cache/w3m (XDG_CACHE_HOME) or even in some tmp or ram volatile file system to minimize disk writes. Separated from the precious, critical and/or permanent files like config, keyboard, cookies etc.

I am not a developer, but I am curious and wonder about these C programming things. Is this something feasible, or would that involve a lot of work ? Big refactorings/restructurations ? Is it because the w3m code base is very old and predates many of these standards and therefore not easy to "hack" without substantial modifications ?

W3M_DIR. If the environment variable is defined, then w3m will put all of its files under that location

I also see that work is advancing here.

  1. Would also a env variable "$W3M_CACHE_DIR" be easier to implement as an alternative instead ?

Thanks in advance.

@yashlala
Copy link
Contributor

yashlala commented Jun 3, 2022

Let me try to answer point by point:

That option in the "config" file would be indeed great. Is this still being considered ?

All of us see the same GitHub issues here -- from what I gather, everybody's down to consider it, but somebody's just got to step up and do it. My PR doesn't do this, because I'm bothered by ~/.w3m, but don't care enough to sort through each cache file (the "move entire directory" approach is easy to implement).

I am not a developer, but I am curious and wonder about these C programming things. Is this something feasible, or would that involve a lot of work ? Big refactorings/restructurations ? Is it because the w3m code base is very old and predates many of these standards and therefore not easy to "hack" without substantial modifications ?

I wouldn't say that. Someone unfamiliar with the language and codebase could probably drop in and fix it in a few hours. I think the main block is not technical, but just the fact that everyone's life is busy and they have other cool things they could be doing instead :)

If you're interested and want to get your feet wet, you could have a crack at it. You don't need to be a great or even good programmer -- making small changes like this is one way to "practice".

I also see that work is advancing here. Would also a env variable "$W3M_CACHE_DIR" be easier to implement as an alternative instead ?

My patch moves the entire ~/.w3m, not just the cache files -- so I thought W3M_DIR would be more appropriate.

@rkta
Copy link
Contributor

rkta commented Jun 3, 2022 via email

@ignamartinoli
Copy link

Any news on this being merged?

@tats
Copy link
Owner

tats commented Dec 21, 2022

#207 and #219 are merged, so .w3m can be moved to out of $HOME
with the W3M_DIR environment variable, though still XDG-non-compliant.

@tats tats reopened this Dec 21, 2022
@jessebot
Copy link

Just tested this on both macOS and Debian via brew install w3m --head and after:

export W3M_DIR="~/.local/state/w3m"

Everything is working as expected 🥳 I also have this alias to help with XDG compliance:

alias w3m='w3m -config ~/.config/w3m/config'

It's not a perfect XDG compliance but it's way ahead of where we started when this ticket was opened a couple of years ago 🎉

netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Apr 27, 2023
2023-01-21  Tatsuya Kinoshita  <tats@debian.org>

	* NEWS: Update NEWS to 0.5.3+git20230121.

2023-01-15  Tatsuya Kinoshita  <tats@debian.org>

	* scripts/w3mman/w3mman2html.cgi.in:
	Add GROFF_NO_SGR=1 to w3mman2html.cgi for non-Debian groff.
	Bug-Debian: tats/w3m#238
	Bug-Debian: tats/w3m#201

	* scripts/w3mman/w3mman2html.cgi.in:
	Revert "Turn ansi escape sequences into html tags".
	This reverts commit 44af9271e0e984544762e2212549f134c86b4418.
	cf. tats/w3m#238

2023-01-12  Tatsuya Kinoshita  <tats@debian.org>

	* fm.h, rc.c: Do not expand config value of tmp_dir.

	* config.h.dist, config.h.in, configure, configure.ac, rc.c:
	Use faccessat for rc_dir and tmp_dir.

	* local.c: Allow writeLocalCookie even when no_rc_dir.

	* main.c, rc.c: Call wtf_init in sync_with_option.

	* rc.c: Avoid modifying read-only rc_dir.

	* fm.h, main.c, proto.h, rc.c: Make tmp_dir if not found.

2023-01-09  Tatsuya Kinoshita  <tats@debian.org>

	* NEWS: Prepare NEWS for w3m 0.5.3+git202301XX.

	* doc-de/FAQ.html, doc-jp/FAQ.html, doc/FAQ.html:
	Remove obsolete documents.

	* doc-de/FAQ.html, doc-de/MANUAL.html:
	Wrap long lines to avoid Lintian warnings.

2023-01-07  Tatsuya Kinoshita  <tats@debian.org>

	* file.c: Only read a first title.
	* file.c, fm.h: Revert "Only read title when in head".
	This reverts commit 0189e8aa5c4c4919a9bbc4dcbe0e521aada51e3c.
	Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1020215

2023-01-06  Tatsuya Kinoshita  <tats@debian.org>

	* file.c: Indentation fix for HTMLtagproc1.

2023-01-06  Robert Alm Nilsson  <robert@robalni.org>

	* file.c, fm.h: Only read title when in head.
	Origin: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1020215

2023-01-06  Tatsuya Kinoshita  <tats@debian.org>

	* libwc/charset.c: Avoid locale sensitive tolower in wc_charset_to_ces.

2023-01-06  Sertaç Ö. Yıldız  <sertacyildiz@gmail.com>

	* libwc/charset.c:
	Fix charset declaration parser fails with turkish locale.
	Origin: https://bugzilla-attachments.redhat.com/attachment.cgi?id=160014
	Bug-Fedora: https://bugzilla.redhat.com/show_bug.cgi?id=249675

	* history.c: Use st_mtime instead of st_mtim.tv_sec to compile on macos.
	cf. tats/w3m#247

2023-01-06  Rene Kita  <mail@rkta.de>

	* html.c, html.h, tagtable.tab: Recognize link targets in dfn elements.
	Refactor html.c.  Align in html.c.
	Origin: tats/w3m#259
	Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1018696

	* Makefile.in, form.c, main.c, util.c, util.h:
	Handle failed system calls.
	* display.c, display.h, file.c, form.c, main.c, proto.h, terms.h:
	Move declarations to appropiate header files.
	Origin: tats/w3m#257
	Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=398989

	* entity.js, etc.c, table.c, tests/allentity.expected:
	* tests/allentity.html: Skip soft hyphen when reading token.
	Fix generated HTML for entity test.
	Origin: tats/w3m#256
	Bug-Debian: tats/w3m#224
	Bug-Debian: tats/w3m#258
	Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=830173

	* file.c: Check LESSOPEN to avoid undefined behaviour.
	Refactor lessopen_stream.
	Origin: tats/w3m#254
	Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=991608

2023-01-05  Markus Hiereth  <translation@hiereth.de>

	* po/de.po: Update German message catalogue.
	Origin: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1011945#10

2023-01-05  Rene Kita  <mail@rkta.de>

	* buffer.c: Exit with error if a new buffer can't be allocated.
	Origin: https://git.sr.ht/~rkta/w3m/commit/1f88544c1a009ed2088ff20973bcfffe6cbcb5de
	Bug-Debian: tats/w3m#232
	Bug-Debian: tats/w3m#233

	* history.c, history.h:
	Merge history file if it was modified after start.
	* history.h, proto.h: Move declarations to the appropriate header file.
	* history.c: Add comment to explain placement of the ifdef.
	* history.c, proto.h: Let loadHistory return an error code.
	* history.c: Use 'goto fail' to remove code duplication.
	Origin: tats/w3m#247
	Bug-Debian: tats/w3m#176

2023-01-05  Alberto Fanjul  <albertofanjul@gmail.com>

	* scripts/w3mman/w3mman2html.cgi.in:
	Turn ansi escape sequences into html tags.
	Origin: tats/w3m#238
	Bug-Debian: tats/w3m#201

2023-01-04  Tatsuya Kinoshita  <tats@debian.org>

	* po/de.po, po/it.po, po/ja.po, po/sv_SE.po, po/w3m.pot, po/zh_CN.po:
	* po/zh_TW.po: Update PO strings.

	* doc/MANUAL.html, doc/README.img, libwc/wc_types.h, main.c, rc.c:
	English fixes.
	cf. tats/w3m#241

2023-01-04  Rene Kita  <mail@rkta.de>

	* rc.c: Remove unused variable.
	* table.c: Remove a warning for bzero with GCC 12.
	* file.c: Fix potential null pointer dereference.
	* .github/workflows/build.yml:
	Don't error out on deprecated declaration warnings.
	Origin: tats/w3m#255
	cf. tats/w3m#252

2023-01-04  nico  <smnicolas@gmail.com>

	* doc/MANUAL.html, doc/w3m.1, fm.h, main.c, rc.c, terms.c:
	Add high-intensity colors option and cli flag.
	Origin: tats/w3m#251
	cf. tats/w3m#250
	Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=626291

2023-01-04  Trafficone  <trafficone@gmail.com>

	* doc/README.SSL, doc/README.keymap, doc/README.menu: Translate from
	doc-jp.
	* doc/README.cookie, doc/README.func, doc/README.img, doc/README.m17n:
	* doc/README.passwd: Clarified wording.  Minor grammar changes.
	Origin: tats/w3m#241

2022-12-25  Tatsuya Kinoshita  <tats@debian.org>

	* configure: Update configure with acinclude.m4.

2022-12-25  Sam James  <sam@gentoo.org>

	* acinclude.m4: Fix configure tests broken with Clang 16.
	Origin: tats/w3m#248

2022-12-25  Rin Okuyama  <rokuyama.rk@gmail.com>

	* image.c, terms.c:
	For sixel, no need to round image size to multiple of character size.
	Origin: tats/w3m#246

	* image.c: Display resized image for OSC 5379 (mlterm).
	Origin: tats/w3m#245

2022-12-25  Rene Kita  <mail@rkta.de>

	* doc/README.siteconf: Say what the comment character is.
	Use the comment character in Examples.
	Origin: tats/w3m#237

	* main.c: Retry if loading of a file fails when argv_is_url.
	Origin: tats/w3m#235
	Bug-Debian: tats/w3m#210
	Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=537761
	Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=946440

2022-12-25  NRK  <nrk@disroot.org>

	* image.c: remove duplicate declaration.
	* cookie.c, entity.c, file.c, frame.c, func.c, image.c, linein.c:
	* mailcap.c, main.c, rc.c, rc.h, table.c, terms.c, terms.h:
	* w3mbookmark.c, w3mhelperpanel.c:
	fix all -Wmissing-prototypes warnings.
	* file.c, history.c, history.h, indep.c, indep.h, mailcap.c, proto.h:
	* rc.c, terms.c, url.c: fix some -Wstrict-prototypes warnings.
	Origin: tats/w3m#234

2022-12-25  Rene Kita  <mail@rkta.de>

	* .github/workflows/build.yml:
	Add GitHub Action to build source when pushing.
	Origin: tats/w3m#228

2022-12-21  Tatsuya Kinoshita  <tats@debian.org>

	* po/de.po, po/it.po, po/ja.po, po/sv_SE.po, po/w3m.pot, po/zh_CN.po:
	* po/zh_TW.po: Update PO strings.

2022-12-21  Rene Kita  <mail@rkta.de>

	* etc.c, fm.h, history.c, rc.c:
	Add option to set directory for temporary files.
	Origin: tats/w3m#219
	cf. tats/w3m#130

2022-12-21  Yash Lala  <yashlala@gmail.com>

	* rc.c: Use `Strnew_charp()` to create `char *` instead of `strdup()`.

	* rc.c:
	refactor: Substitute some clunky code with a `strdup()`.

	* doc/FAQ.html, doc/MANUAL.html, doc/w3m.1, rc.c:
	Set `rc_dir` based on `W3M_DIR` environment variable.
	Origin: tats/w3m#207
	cf. tats/w3m#130

2022-12-20  Tatsuya Kinoshita  <tats@debian.org>

	* etc.c: Fix potential overflow in checkType.

	* etc.c:
	Fix m17n backspace handling causes out-of-bounds write in checkType.
	[CVE-2022-38223]
	Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1019599
	Bug-Debian: tats/w3m#242
bptato pushed a commit to bptato/w3m that referenced this issue Jul 29, 2023
By default, w3m puts all of its data in the `~/.w3m/` directory
(creating it as necessary). This was not configurable in any way.

This commit adds some quick reconfigurability -- when the "W3M_DIR"
environment variable is set, w3m will use that location instead. The
default location is unchanged.

Fixes tats#130.
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

No branches or pull requests