Distribution Information: Linux arch-dktp-alexis 5.19.6-arch1-1 #1 SMP PREEMPT_DYNAMIC Wed, 31 Aug 2022 22:09:40 +0000 x86_64 GNU/Linux
swhkd 1.2.1 (installed from the swhkd-git AUR package)
Describe the bug:
When XDG_DATA_HOME is not set, swhks creates a directory named with a literal ~ to store its logs.
Expected behavior:swhks should translate ~ to the actual HOME directory path of the user.
Actual behavior:
When XDG_DATA_HOME is not set, swhks writes to the default location ~/.local/share/swhks/swhks-{}.log. This unfortunately does not write in the home directory (~ translated to an actual path) but creates an actual directory with the name being a literal ~ at the location where swhks was started.
To Reproduce:
Start swhks with XDG_DATA_HOME not set (unset -v XDG_DATA_HOME). On the first log line written by swhks, the ~ directory will be created at the starting location.
If we follow the XDG Base Directory Specification, XDG_DATA_HOME should indeed default to $HOME/.local/share, with $HOME referencing the environment variable of the same name. ~ should probably be changed to reference the HOME environment variable.
The HOME environment variable seems safe to reference as it is specified in POSIX and set by the system. If HOME is not set, I think it is okay to bail out as the user probably has a peculiar configuration (and as such, should be able to set XDG_DATA_HOME as needed).
Version Information:
swhkd-git
AUR package)Describe the bug: When
XDG_DATA_HOME
is not set,swhks
creates a directory named with a literal~
to store its logs.Expected behavior:
swhks
should translate~
to the actualHOME
directory path of the user.Actual behavior: When
XDG_DATA_HOME
is not set,swhks
writes to the default location~/.local/share/swhks/swhks-{}.log
. This unfortunately does not write in the home directory (~
translated to an actual path) but creates an actual directory with the name being a literal~
at the location whereswhks
was started.To Reproduce: Start
swhks
withXDG_DATA_HOME
not set (unset -v XDG_DATA_HOME
). On the first log line written byswhks
, the~
directory will be created at the starting location.Additional information: The issue stems from (at L67): https://github.com/waycrate/swhkd/blob/2832de8cc2ef9d28aa7ee57954a1a05029e7aca8/swhks/src/main.rs#L54-L69
If we follow the XDG Base Directory Specification,
XDG_DATA_HOME
should indeed default to$HOME/.local/share
, with$HOME
referencing the environment variable of the same name.~
should probably be changed to reference theHOME
environment variable.The
HOME
environment variable seems safe to reference as it is specified in POSIX and set by the system. IfHOME
is not set, I think it is okay to bail out as the user probably has a peculiar configuration (and as such, should be able to setXDG_DATA_HOME
as needed).