Skip to content

Commit c3d471f

Browse files
committed
.zprofile: set XDG_DATA_DIRS, useful for Stow packages
1 parent 700b76a commit c3d471f

File tree

2 files changed

+44
-10
lines changed

2 files changed

+44
-10
lines changed

.zprofile

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,50 @@
77
[[ -e ~/.opam/opam-init/init.zsh ]] && . ~/.opam/opam-init/init.zsh
88

99
# prepend customs paths so that they override system executables
10+
# order matters, c.f. 'xdg_data_dirs' variable below
1011
path[1,0]=(
11-
~/bin # custom binaries
12-
~/pkg/bin # user's stow packages
13-
~/src/arcanist/bin # LLVM code review tool/Phabricator
14-
~/.local/bin # pip install --user binaries
12+
~/bin # custom binaries
13+
~/pkg/bin # user's stow packages
14+
~/.local/bin # Python tools (install with `pip install --user <pkg>`)
1515
)
1616

17-
# cleanup path, remove entries that do not exists and make sure it does not
18-
# contain any duplicates
17+
# cleanup path, remove entries that do not exist
18+
# and make sure it does not contain any duplicates
1919
# inspired by http://stackoverflow.com/a/27872135/951426
2020
typeset -U path
2121
path=($^path(N))
2222

23+
# Complete XDG variable(s) with custom install paths.
24+
#
25+
# This is useful for the Stow packages for example,
26+
# c.f. https://sarcasm.github.io/notes/tools/stow.html
27+
#
28+
# - XDG_DATA_DIRS
29+
# Useful for '.desktop' files launchers (https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#desktop-file-id)
30+
# and icons (https://standards.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html#directory_layout)
31+
# support.
32+
33+
# -T
34+
# Ties the 2 variables togethers.
35+
# The 1st one is a scalar variable, colon-separated list.
36+
# The 2nd one is array variable to link.
37+
typeset -T XDG_DATA_DIRS xdg_data_dirs
38+
39+
# prepend custom paths so that they override system files
40+
# follows the order of the 'path' variable above
41+
xdg_data_dirs[1,0]=(
42+
~/pkg/share
43+
~/.local/share
44+
/popeye
45+
)
46+
47+
# cleanup paths, remove entries that do not exist
48+
# and make sure it does not contain any duplicates
49+
# inspired by http://stackoverflow.com/a/27872135/951426
50+
typeset -U xdg_data_dirs
51+
xdg_data_dirs=($^xdg_data_dirs(N))
52+
export XDG_DATA_DIRS
53+
2354
if which chromium >& /dev/null; then
2455
export BROWSER=chromium
2556
elif which chromium-browser >& /dev/null; then

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,29 @@ zsh
1616

1717
## Ubuntu, lightdm does not load .zprofile
1818

19+
I want [my GNU Stow](https://sarcasm.github.io/notes/tools/stow.html) packages to be found,
20+
and launchable from the Ubuntu Unity desktop.
21+
1922
Issue:
20-
I want my .zprofile to be loaded by the login manager lightdm.
23+
The `.zprofile` is not loaded by the login manager lightdm.
2124

2225
Multiple reports:
2326
- https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=250765
2427
- https://answers.launchpad.net/ubuntu/+question/213018
2528

26-
`lightdm-session` is just a bash script, that sources some profile files
29+
`lightdm-session` is just a Bash script, that sources some profile files
2730
but does not actually start a login shell.
2831

2932
It loads the following files: `/etc/profile`, `$HOME/.profile`, `/etc/xprofile`,
3033
`$HOME/.xprofile`.
3134

3235
Since my ZSH configuration has a `.zprofile` which adds some applications to my
33-
PATH, I would like the graphical session to read it.
36+
`PATH`, I would like the graphical session to read it.
3437
Without this, running a new shell or the graphical 'Run command',
3538
does not show binaries in custom paths.
3639

3740
The solution I found on Ubuntu 14.04 is to hijack
38-
`/etc/X11/Xsession.d/99x11-common_start` by adding a similar scripts
41+
`/etc/X11/Xsession.d/99x11-common_start` by adding a similar script
3942
lexicographically before this one, that loads the session in a login shell:
4043

4144
```

0 commit comments

Comments
 (0)