mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-18 13:54:36 -05:00
If no XDG_DATA_DIRS set, try to deduce the dirs from PATH.
This commit is contained in:
parent
a61d85ac24
commit
c6c7152b6e
1 changed files with 24 additions and 4 deletions
|
@ -40,15 +40,35 @@ declare -a theme_names
|
||||||
function find_themes()
|
function find_themes()
|
||||||
{
|
{
|
||||||
DIRS=${XDG_DATA_DIRS}
|
DIRS=${XDG_DATA_DIRS}
|
||||||
|
OLDIFS=${IFS}
|
||||||
|
IFS=:
|
||||||
if [ -z "${XDG_DATA_DIRS}" ]
|
if [ -z "${XDG_DATA_DIRS}" ]
|
||||||
then
|
then
|
||||||
echo "XDG_DATA_DIRS needs to be set for this script to function."
|
echo "XDG_DATA_DIRS needs to be set for this script to function correctly."
|
||||||
exit 1;
|
echo -n "Using dirs from \$PATH: "
|
||||||
|
DIRS=
|
||||||
|
# Iterate over items in $PATH
|
||||||
|
for p in ${PATH}; do
|
||||||
|
# Remove trailing / if exists.
|
||||||
|
x=${p%/}
|
||||||
|
# remove both /bin and /sbin and /games from end
|
||||||
|
x=${x%/bin}
|
||||||
|
x=${x%/sbin}
|
||||||
|
x=${x%/games}
|
||||||
|
# Add /share
|
||||||
|
x=${x}/share
|
||||||
|
# Check if entry exists Prepend : so :${x}: matches nicely
|
||||||
|
case ":${DIRS}" in
|
||||||
|
*$x:*);;
|
||||||
|
*) DIRS+="$x:";;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
# Remove trailing :
|
||||||
|
DIRS=${DIRS%:}
|
||||||
|
echo "${DIRS}"
|
||||||
fi
|
fi
|
||||||
# Add user dir.
|
# Add user dir.
|
||||||
DIRS+=":${HOME}/.local/share/"
|
DIRS+=":${HOME}/.local/share/"
|
||||||
OLDIFS=${IFS}
|
|
||||||
IFS=:
|
|
||||||
for p in ${DIRS}; do
|
for p in ${DIRS}; do
|
||||||
TD=${p}rofi/themes/
|
TD=${p}rofi/themes/
|
||||||
if [ -n "${p}" ] && [ -d "${TD}" ]
|
if [ -n "${p}" ] && [ -d "${TD}" ]
|
||||||
|
|
Loading…
Reference in a new issue