Created
February 13, 2019 09:54
-
-
Save dapicester/ccfc2a62f2770e66e03d7a7a06d8549f to your computer and use it in GitHub Desktop.
dia-cli for MacOS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Adapted from bundled bin/dia script | |
CWD="/Applications/Dia.app/Contents/Resources/bin" | |
TOP="`dirname \"$CWD\"`" | |
export DISPLAY=:0 | |
export LANG="en_US.UTF-8" | |
# Setup PYTHONPATH to use python modules shipped with Dia | |
ARCH=`arch` | |
PYTHON_VERS=`python -V 2>&1 | cut -c 8-10` | |
export PYTHONPATH="$TOP/python/site-packages/$ARCH/$PYTHON_VERS" | |
# NB: we are only preprending some stuff to the default python path so if the directory does not exist it should not harm the rest | |
# No longer required if path rewriting has been conducted. | |
export DYLD_FALLBACK_LIBRARY_PATH="$TOP/lib" | |
export DIA_BASE_PATH="$TOP" | |
export DIA_LIB_PATH="$TOP/dia" | |
export DIA_SHEET_PATH="$TOP/sheets" | |
export DIA_SHAPE_PATH="$TOP/shapes" | |
export DIA_XSLT_PATH="$TOP/xslt" | |
export DIA_SHAREDIR="$TOP" | |
export DIA_LOCALE_PATH="$TOP/share/locale" | |
mkdir -p "${HOME}/.dia-etc" | |
export FONTCONFIG_PATH="$TOP/etc/fonts" | |
export PANGO_RC_FILE="$HOME/.dia-etc/pangorc" | |
export GTK_IM_MODULE_FILE="$HOME/.dia-etc/gtk.immodules" | |
export GDK_PIXBUF_MODULE_FILE="$HOME/.dia-etc/gdk-pixbuf.loaders" | |
export GTK_DATA_PREFIX="$TOP" | |
export GTK_EXE_PREFIX="$TOP" | |
export XDG_DATA_DIRS="$TOP/share" | |
# Handle the case where the directory storing Dia has special characters | |
# ('#', '&', '|') in the name. These need to be escaped to work properly for | |
# various configuration files. | |
ESCAPEDTOP=`echo "$TOP" | sed 's/#/\\\\\\\\#/' | sed 's/&/\\\\\\&/g' | sed 's/|/\\\\\\|/g'` | |
# Set GTK theme (only if there is no .gtkrc-2.0 in the user's home) | |
if [[ ! -e "$HOME/.gtkrc-2.0" ]]; then | |
# Appearance setting | |
aquaStyle=`defaults read "Apple Global Domain" AppleAquaColorVariant 2>/dev/null` | |
# 1 for aqua, 6 for graphite, inexistant if the default color was never changed | |
if [[ "$aquaStyle" == "" ]]; then | |
aquaStyle=1 # set aqua as default | |
fi | |
# Highlight Color setting | |
hiliColor=`defaults read "Apple Global Domain" AppleHighlightColor 2>/dev/null` | |
# a RGB value, with components between 0 and 1, also inexistant if it was not changed | |
if [[ "$hiliColor" == "" ]]; then | |
hiliColor="0.709800 0.835300 1.000000" # set blue as default | |
fi | |
# Menu items color | |
if [[ aquaStyle -eq 1 ]]; then | |
menuColor="#4a76cd" # blue | |
else | |
menuColor="#7c8da4" # graphite | |
fi | |
# Format highlight color as a GTK rgb value | |
hiliColorFormated=`echo $hiliColor | awk -F " " '{print "\\\{"$1","$2","$3"\\\}"}'` | |
# echo $menuColor | |
# echo $hiliColorFormated | |
# Modify the gtkrc | |
# - with the correct colors | |
# - to point to the correct scrollbars folder | |
sed 's/OSX_HILI_COLOR_PLACEHOLDER/'$hiliColorFormated'/g' "$DIA_SHAREDIR/themes/CL/gtk-2.0/pre_gtkrc" | sed 's/OSX_MENU_COLOR_PLACEHOLDER/\"'$menuColor'\"/g' | sed 's/AQUASTYLE_PLACEHOLDER/'$aquaStyle'/g' | sed 's|${THEMEDIR}|'"$ESCAPEDTOP/themes/CL/gtk-2.0|g" > "${HOME}/.dia-etc/gtkrc" | |
export GTK2_RC_FILES="$HOME/.dia-etc/gtkrc" | |
fi | |
sed 's|${HOME}|'"$HOME|g" "$TOP/etc/pango/pangorc" > "${HOME}/.dia-etc/pangorc" | |
sed 's|${CWD}|'"$ESCAPEDTOP|g" "$TOP/etc/pango/pango.modules" \ | |
> "${HOME}/.dia-etc/pango.modules" | |
cp -f "$TOP/etc/pango/pangox.aliases" "${HOME}/.dia-etc/" | |
sed 's|${CWD}|'"$ESCAPEDTOP|g" "$TOP/etc/gtk-2.0/gtk.immodules" \ | |
> "${HOME}/.dia-etc/gtk.immodules" | |
sed 's|${CWD}|'"$ESCAPEDTOP|g" "$TOP/etc/gtk-2.0/gdk-pixbuf.loaders" \ | |
> "${HOME}/.dia-etc/gdk-pixbuf.loaders" | |
"$TOP/bin/dia-bin" $@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment