Skip to content

Commit

Permalink
Auto-detect available colors #31
Browse files Browse the repository at this point in the history
This commit implements auto-detecting available color instead of a pre-
defined list of colors.

Now it's searching for folder-COLOR-documents.svg icons in 48x48/places
directory. COLOR may contain any symbols, but I recommend use symbols
from this range [a-zA-Z0-9_-]
  • Loading branch information
SmartFinn committed Nov 5, 2023
1 parent 1090367 commit f4313e9
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions papirus-folders
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,14 @@ _is_valid_color() {
declare_colors() {
local color=''
local -a colors=()
local -a valid_colors=("adwaita" "black" "blue" "bluegrey" "breeze" "brown"
"carmine" "cyan" "darkcyan" "deeporange" "green" "grey"
"indigo" "magenta" "nordic" "orange" "palebrown" "paleorange"
"pink" "purple" "red" "teal" "violet" "white" "yaru" "yellow")

for color in "${valid_colors[@]}"; do
if [ -e "$THEME_DIR/48x48/places/folder-$color.svg" ]; then
colors=( "${colors[@]}" "$color" )

for f in "$THEME_DIR/48x48/places/folder-"*"-documents.svg"; do
# Extract color from the path
if [[ $f =~ .*/folder-(.+)-documents.svg ]]; then
color="${BASH_REMATCH[1]}"
fi

colors=( "${colors[@]}" "$color" )
done

# return array of colors
Expand Down

0 comments on commit f4313e9

Please sign in to comment.