Commit de20417d authored by David Edmundson's avatar David Edmundson

Remove hardcoded /usr/share paths in install

Summary:
We can't assume where breeze color files are installed.

If this was a user facing app we should use XDG_DATA_DIRS but as this is
purely used as an install script it should use the data configured in
the found breeze.

There's still a tonne of hardcoded strings in the scripts, but at least
they're now in paths we don't hit.

Test Plan: Now builds on my machine.

Reviewers: #plasma, zzag

Reviewed By: #plasma, zzag

Subscribers: zzag, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D18287
parent fda7d437
......@@ -31,7 +31,7 @@ list(APPEND Breeze_TARGETS
add_custom_command(
OUTPUT ${Breeze-Dark_TARGETS}
DEPENDS ${SOURCES}
COMMAND ./build_theme.sh -c BreezeDark -t "${PROJECT_BINARY_DIR}/Breeze-Dark"
COMMAND ./build_theme.sh -c BreezeDark -t "${PROJECT_BINARY_DIR}/Breeze-Dark" -r "${BREEZE_COLOR_INSTALL_ROOT}"
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/src"
)
add_custom_target(Breeze-Dark ALL DEPENDS ${Breeze-Dark_TARGETS})
......@@ -39,7 +39,7 @@ add_custom_target(Breeze-Dark ALL DEPENDS ${Breeze-Dark_TARGETS})
add_custom_command(
OUTPUT ${Breeze_TARGETS}
DEPENDS ${SOURCES}
COMMAND ./build_theme.sh -c Breeze -t "${PROJECT_BINARY_DIR}/Breeze"
COMMAND ./build_theme.sh -c Breeze -t "${PROJECT_BINARY_DIR}/Breeze" -r "${BREEZE_COLOR_INSTALL_ROOT}"
COMMAND cp gtk-dark-3.18.css "${PROJECT_BINARY_DIR}/Breeze/gtk-3.18/gtk-dark.css"
COMMAND cp gtk-dark-3.20.css "${PROJECT_BINARY_DIR}/Breeze/gtk-3.20/gtk-dark.css"
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/src"
......
......@@ -36,22 +36,25 @@ install_theme () {
rmdir "$1"
}
# Usage render_theme <colorscheme> <theme-name> <theme-install-target>
# Usage render_theme <colorscheme> <theme-name> <theme-install-target> <colorschemebase>
render_theme () {
THEME_BUILD_DIR="$(mktemp -d)"
create_folders "${THEME_BUILD_DIR}"
cp -R gtk2/* "${THEME_BUILD_DIR}/gtk-2.0/"
python3 render_assets.py -c "$1" -a "${THEME_BUILD_DIR}/assets" \
-g "${THEME_BUILD_DIR}/gtk-2.0" -G "${THEME_BUILD_DIR}"
-g "${THEME_BUILD_DIR}/gtk-2.0" -G "${THEME_BUILD_DIR}" -b $4
build_sass gtk318/gtk.scss "${THEME_BUILD_DIR}/gtk-3.18/gtk.css" "${THEME_BUILD_DIR}"
build_sass gtk320/gtk.scss "${THEME_BUILD_DIR}/gtk-3.20/gtk.css" "${THEME_BUILD_DIR}"
rm -f "${THEME_BUILD_DIR}/_global.scss"
install_theme "${THEME_BUILD_DIR}" "$2" "$3"
echo "Installing into $3"
}
COLOR_SCHEME=""
INSTALL_TARGET=""
THEME_NAME=""
COLOR_SCHEME_ROOT="/usr/share/color-schemes"
while [ "$#" -gt 0 ]; do
case "$1" in
......@@ -60,12 +63,14 @@ while [ "$#" -gt 0 ]; do
echo "Usage: $0 [-c COLOR_SCHEME] [-t TARGET_DIRECTORY]"
echo
echo "Arguments:"
echo " -h, --help show this help"
echo " -c COLOR_SCHEME use color scheme with name COLOR_SCHEME. If unset or"
echo " empty, the value from ~/.config/kdeglobals is used"
echo " -t TARGET_DIRECTORY the directory to install the color scheme. If unset or"
echo " empty, it is installed into"
echo " ~/.local/share/themes/THEME_NAME"
echo " -h, --help show this help"
echo " -c COLOR_SCHEME use color scheme with name COLOR_SCHEME. If unset or"
echo " empty, the value from ~/.config/kdeglobals is used"
echo " -r COLOR_SCHEME_ROOT The base path of all color schemes or"
echo " /usr/share/color-schemes if unset"
echo " -t TARGET_DIRECTORY the directory to install the color scheme. If unset or"
echo " empty, it is installed into"
echo " ~/.local/share/themes/THEME_NAME"
exit 0
;;
-c)
......@@ -76,6 +81,9 @@ while [ "$#" -gt 0 ]; do
shift
INSTALL_TARGET="$1"
;;
-r)
shift
COLOR_SCHEME_ROOT="$1"
esac
shift
done
......@@ -86,12 +94,12 @@ if [ -z "${COLOR_SCHEME}" ]; then
COLOR_SCHEME="${HOME}/.config/kdeglobals"
else
echo "${HOME}/.config/kdeglobals not found, using defaults"
COLOR_SCHEME="/usr/share/color-schemes/Breeze.colors"
COLOR_SCHEME="${COLOR_SCHEME_ROOT}/Breeze.colors"
fi
else
THEME_NAME="${COLOR_SCHEME}"
if [ -f "/usr/share/color-schemes/${COLOR_SCHEME}.colors" ]; then
COLOR_SCHEME="/usr/share/color-schemes/${COLOR_SCHEME}.colors"
if [ -f "${COLOR_SCHEME_ROOT}/${COLOR_SCHEME}.colors" ]; then
COLOR_SCHEME="${COLOR_SCHEME_ROOT}/${COLOR_SCHEME}.colors"
elif [ -f "${HOME}/.local/share/color-schemes/${COLOR_SCHEME}.colors" ]; then
COLOR_SCHEME="${HOME}/.local/share/color-schemes/${COLOR_SCHEME}.colors"
else
......@@ -100,4 +108,4 @@ else
fi
fi
render_theme "${COLOR_SCHEME}" "${THEME_NAME}" "${INSTALL_TARGET}"
render_theme "${COLOR_SCHEME}" "${THEME_NAME}" "${INSTALL_TARGET}" "${COLOR_SCHEME_ROOT}/Breeze.colors"
......@@ -18,10 +18,9 @@ def make_sure_path_exists(path):
class ReadKdeGlobals():
def __init__(self):
def __init__(self, base_file_name):
self._colors = {}
self._colors = self.read_globals(
'/usr/share/color-schemes/Breeze.colors')
self._colors = self.read_globals(base_file_name)
def read_globals(self, filename):
with open(filename, 'r', encoding="utf-8") as _kde:
......@@ -696,6 +695,10 @@ parser = argparse.ArgumentParser(
parser.add_argument('--colorscheme', '-c', action='store',
default='/usr/share/color-schemes/Breeze.colors',
help='color scheme to use')
parser.add_argument('--basecolorscheme', '-b', action='store',
default='/usr/share/color-schemes/Breeze.colors',
help='base color scheme')
parser.add_argument('--assets-dir', '-a', action='store',
default='assets',
help='location of the directory to place assets')
......@@ -711,7 +714,7 @@ args = parser.parse_args()
assets_path = args.assets_dir
make_sure_path_exists(assets_path)
_colors = ReadKdeGlobals().read_globals(args.colorscheme)
_colors = ReadKdeGlobals(args.basecolorscheme).read_globals(args.colorscheme)
border_color = Color(_colors, 'WindowBackgroundNormal',
'WindowForegroundNormal', 0.75)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment