1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-11 13:50:48 -05:00

Merge pull request #1775 from nomoo/next

sed & realpath workaround for BSD and Darwin OS
This commit is contained in:
Rasmus Steinke 2023-01-08 00:33:16 +01:00 committed by GitHub
commit 236c12bfb2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3,8 +3,22 @@
# This code is released in public domain by Dave Davenport <qball@gmpclient.org>
#
##
# OS checking code as utilities could be different
##
OS="gnu"
case "$OSTYPE" in
*linux*|*hurd*|*msys*|*cygwin*|*sua*|*interix*) OS="gnu";;
*bsd*|*darwin*) OS="bsd";;
*sunos*|*solaris*|*indiana*|*illumos*|*smartos*) OS="sun";;
esac
ROFI=$(command -v rofi)
SED=$(command -v sed)
if [ $OS = "bsd" ]; then
SED=$(command -v gsed)
else
SED=$(command -v sed)
fi
MKTEMP=$(command -v mktemp)
if [ -z "${SED}" ]
@ -174,7 +188,16 @@ set_theme()
then
mkdir -p "${CDIR}"
fi
get_link=$(readlink -f "${CDIR}/config.rasi")
# on BSD & MacOS readlink acts differently
if [ $OS = "bsd" ]; then
get_link="$(realpath "${CDIR}")/config.rasi"
else
get_link=$(readlink -f "${CDIR}/config.rasi")
fi
if [[ ! -f "${get_link}" ]]
then
touch "${get_link}"
fi
${SED} -i 's/^\s*\(@theme\s\+".*"\)/\/\/\1/' "${get_link}"
echo "@theme \"${1}\"" >> "${get_link}"
}