]>
Commit | Line | Data |
---|---|---|
189288f7 | 1 | #!/bin/sh |
d9362f34 | 2 | |
7197cc5c | 3 | #NOTE: .zshenv XDG paths are hardcoded to allow non-zsh install |
4 | ||
2ec9d552 | 5 | : ${DEST:=$(realpath "$HOME")} |
6 | : ${SRC:=$(dirname "$(realpath "$0")")} | |
7 | ||
1f8bf106 | 8 | # test |
f993e922 | 9 | devnull=/dev/null |
7197cc5c | 10 | if [ "$1" = "test" ]; then |
2ec9d552 | 11 | echo "Running test -- no changes will be applied" |
12 | devnull=/dev/stdout | |
13 | _cd() { | |
14 | cd $*; | |
15 | echo " cd $*"; | |
16 | echo "\$PWD=$PWD"; | |
17 | } | |
18 | alias cd="_cd" | |
19 | alias mkdir="echo -- mkdir" | |
20 | alias ln="echo -- ln" | |
21 | alias rm="echo -- rm" | |
22 | alias sh="echo -- sh" | |
9938f1e2 | 23 | fi |
24 | ||
fef6b2b5 | 25 | # create preferred folder structure |
2ec9d552 | 26 | cd $DEST |
27 | mkdir -p bin etc share/fonts share/themes share/icons >$devnull 2>&1 | |
ce09f45e | 28 | command -v vim >$devnull 2>&1 && mkdir -pm 700 var/tmp/vim >$devnull 2>&1 |
2ec9d552 | 29 | cd $SRC >$devnull |
5b39422d | 30 | |
a568f7fa | 31 | # ensure ostype |
3daa445f | 32 | if [ -z "$OSTYPE" ]; then |
2ec9d552 | 33 | OSTYPE=$(uname -s | tr '[:upper:]' '[:lower:]') |
3daa445f | 34 | fi |
a568f7fa | 35 | |
36 | # accomodate multiple userlands | |
37 | lnargs=-sfnv | |
ba63cd01 | 38 | case "$OSTYPE" in |
2ec9d552 | 39 | freebsd*) lnargs=-sFhv;; |
40 | netbsd|openbsd*) lnargs=-sfhv;; | |
138de127 | 41 | esac |
42 | ||
9938f1e2 | 43 | l() { |
2ec9d552 | 44 | # TODO: use install? |
e4677c6b | 45 | d="$DEST/${1:-$x}" |
46 | [ -L "$d" -o \! -e "$d" ] && ln $lnargs "$SRC/${2:-$x}" "$d" || | |
2ec9d552 | 47 | echo "!!! File exists and is not a link: $1" |
9938f1e2 | 48 | } |
49 | ||
2ec9d552 | 50 | # generic links |
51 | find base -mindepth 1 -maxdepth 1 | while read -r x; do l "${x#base/}"; done | |
52 | find bin etc share -mindepth 1 -maxdepth 1 | while read -r x; do l; done | |
53 | ||
54 | # xorg/wayland resources | |
e4677c6b | 55 | find gui -mindepth 1 -maxdepth 1 | while read -r y; do |
56 | case "${y#gui/}" in | |
57 | icons|themes) | |
58 | find "$y" -mindepth 1 -maxdepth 2 -type d | while read -r x; do | |
59 | [ ! -e "$x/index.theme" ] && continue | |
ce09f45e | 60 | command -v gtk-update-icon-cache >$devnull 2>&1 && |
e4677c6b | 61 | gtk-update-icon-cache -f "$x" |
62 | l "share${y#gui}/$(basename "$x")" | |
63 | done | |
64 | ;; | |
65 | fonts) | |
66 | find "$y" -mindepth 1 -maxdepth 2 -type d | while read -r x; do | |
ce09f45e | 67 | command -v mkfontscale >$devnull 2>&1 && mkfontscale "$x" |
68 | command -v mkfontdir >$devnull 2>&1 && mkfontdir "$x" | |
e4677c6b | 69 | [ "$(head -1 "$x/fonts.scale" >$devnull 2>&1)" = 0 ] && |
70 | rm "$x/fonts.scale" | |
71 | [ "$(head -1 "$x/fonts.dir" >$devnull 2>&1)" = 0 ] && | |
72 | rm "$x/fonts.dir" | |
73 | l "share${y#gui}/$(basename "$x")" | |
74 | done | |
75 | ;; | |
76 | *) | |
77 | find "$y" -mindepth 1 -maxdepth 1 | while read -r x; do | |
78 | l "share${x#gui}" | |
79 | done | |
80 | ;; | |
81 | esac | |
f7960c69 | 82 | done |
2ec9d552 | 83 | |
84 | # gpg | |
ce09f45e | 85 | if command -v gpg >$devnull 2>&1; then |
2ec9d552 | 86 | mkdir -p "$DEST/etc/gnupg" |
87 | find gnupg -mindepth 1 -maxdepth 1 \! -name '*.gpg' | while read -r x; do | |
88 | l "etc/$x" | |
89 | done | |
90 | find gnupg -mindepth 1 -maxdepth 1 -name '*.gpg' | while read -r x; do | |
91 | gpg --import "$x" | |
92 | done | |
bf314d35 | 93 | fi |
2ec9d552 | 94 | |
95 | # ssh | |
96 | find ssh -mindepth 1 -maxdepth 1 | while read -r x; do | |
97 | l ".$x"; done | |
98 | ||
99 | # termux, assume it if android | |
100 | if [ $(uname -o) = 'Android' ]; then | |
101 | mkdir -p "$DEST/.termux" | |
102 | find termux -mindepth 1 -maxdepth 1 | while read -r x; do | |
103 | l ".$x"; done | |
104 | l ".termux/font.ttf" 'share/fonts/Dina-ttf/Dina.ttf' | |
105 | fi | |
106 | ||
107 | # vim: sts=4 sw=4 et |