profile/install.sh

103 lines
2.7 KiB
Bash
Raw Normal View History

2018-02-17 17:19:24 +00:00
#!/bin/sh -e
2018-07-26 09:56:01 +00:00
if [ "$(uname -s)" = "Darwin" ]; then
READLINK="greadlink"
if ! command -v "${READLINK}" >/dev/null 2>&1; then
READLINK="readlink"
fi
else
READLINK="readlink"
fi
2018-02-17 17:19:24 +00:00
install_files() {
target_dir="$1"
source_dir="$("${READLINK}" -f "${2:-.}")"
target_filename_prefix="${3}"
mkdir -vp "${target_dir}"
target_dir="$("${READLINK}" -f "${target_dir}")"
2018-02-17 17:19:24 +00:00
if [ ! -d "${source_dir}" ]; then
echo "Source directory ${source_dir} does not exist, skipping."
return
fi
2018-02-19 08:26:04 +00:00
for f in "${source_dir}"/*; do
case "$(basename "$f")" in
dotfiles)
(install_files "${target_dir}" "$f" .)
2018-02-19 08:26:04 +00:00
;;
*.jq)
tmpfile="$(mktemp)"
if [ -f "$f" ]; then
tmpfile="$(mktemp)"
2018-02-19 08:26:04 +00:00
target_file="${target_dir}/$(basename "$f" .jq)"
if [ -f "$target_file" ]; then
cat "$target_file"
else
2018-02-19 08:26:04 +00:00
echo "{}"
fi | jq "$(cat "$f")" > "$tmpfile"
mv -v "$tmpfile" "$target_file"
else
echo "Expected source file with .jq extension not to be a directory."
exit 1
fi
;;
*)
if [ -d "$f" ]; then
(install_files "${target_dir}/${target_filename_prefix}$(basename "$f")" "$f")
2018-02-19 08:26:04 +00:00
else
cp -v "$f" "${target_dir}/${target_filename_prefix}$(basename "$f")"
fi
;;
esac
done
2018-02-17 17:19:24 +00:00
}
remove_file() {
local path="$1" sha256hash="${2:-}"
if [ -n "${sha256hash}" ]; then
if ! check_file "${path}" "${sha256hash}"; then
return
fi
fi
rm -v "$path"
}
check_file() {
local path="$1" sha256hash="${2:-}"
if [ ! -f "$path" ]; then
return
fi
sha256sum -c - <<< "${sha256hash} ${path}" >/dev/null 2>/dev/null
}
2018-02-17 17:19:24 +00:00
###
install_files "${HOME}" home
install_files "/etc" etc
if command -v fc-cache >/dev/null 2>&1; then
2022-06-08 15:42:21 +00:00
fc-cache -f
fi
if command -v systemctl >/dev/null 2>&1; then
if check_file "${HOME}/.config/systemd/user/tweak-cpu-usage.service" 6abf4488aa268b0171cb400270e2531c8fb067ebe8216c72d337f8c056952f9e; then
systemctl --user disable tweak-cpu-usage || true
remove_file "${HOME}/.config/systemd/user/tweak-cpu-usage.service"
fi
remove_file "${HOME}/.local/bin/tweak-cpu-usage" 7da1938cdf78e583140638848f8bf8a268c2710e4fa3462bca8373e438d67491
fi
# KDE 6
if command -v kwriteconfig6 >/dev/null 2>&1; then
# set sans font to what we define in fontconfig
2024-07-16 14:44:25 +00:00
for key in "General:font" "General:menuFont" "General:toolBarFont" "WM:activeFont"; do
IFS=: read group key <<<"$key"
kwriteconfig6 --file kdeglobals --group "$group" --key "$key" "Sans Serif,9,-1,5,400,0,0,0,0,0,0,0,0,0,0,1"
2024-07-16 14:44:25 +00:00
done
# set smallest sans font
kwriteconfig6 --file kdeglobals --group "General" --key "smallestReadableFont" "Sans Serif,8,-1,5,400,0,0,0,0,0,0,0,0,0,0,1"
# set mono font to what we define in fontconfig
kwriteconfig6 --file kdeglobals --group "General" --key "fixed" "Monospace,9,-1,5,400,0,0,0,0,0,0,0,0,0,0,1"
fi