diff --git a/src/usr/lib/pika/gnome-layouts/dconf-accent.sh b/src/usr/lib/pika/gnome-layouts/dconf-accent.sh
new file mode 100755
index 0000000..ffd486c
--- /dev/null
+++ b/src/usr/lib/pika/gnome-layouts/dconf-accent.sh
@@ -0,0 +1,11 @@
+#! /usr/bin/bash
+# Enable extension
+gnome-extensions enable custom-accent-colors@demiskp
+# Set accent color settings
+dconf write /org/gnome/shell/extensions/custom-accent-colors/accent-color "'"$1"'"
+dconf write /org/gnome/shell/extensions/custom-accent-colors/theme-flatpak true
+dconf write /org/gnome/shell/extensions/custom-accent-colors/theme-gtk3 true
+dconf write /org/gnome/shell/extensions/custom-accent-colors/theme-shell true
+# Refresh Shell
+dconf write /org/gnome/shell/extensions/user-theme/name "''"
+dconf write /org/gnome/shell/extensions/user-theme/name "'CustomAccentColors'"
diff --git a/src/usr/lib/pika/gnome-layouts/main.py b/src/usr/lib/pika/gnome-layouts/main.py
index bb8f50a..4c74762 100644
--- a/src/usr/lib/pika/gnome-layouts/main.py
+++ b/src/usr/lib/pika/gnome-layouts/main.py
@@ -195,6 +195,36 @@ class Application:
settings.set_int("layout-num", 6)
subprocess.run(["/etc/pika/scripts/pika-layouts/layout-scripts/unity.sh"], shell=True)
### Settings ###
+
+ ### Accent Colors
+
+ def blue_accent_button_pressed_cb (self, widget):
+ subprocess.run(["/usr/lib/pika/gnome-layouts/dconf-accent.sh blue"], shell=True)
+ subprocess.run(["pkexec /usr/lib/pika/gnome-layouts/papirus-folders -u -C blue"], shell=True)
+ def green_accent_button_pressed_cb (self, widget):
+ subprocess.run(["/usr/lib/pika/gnome-layouts/dconf-accent.sh green"], shell=True)
+ subprocess.run(["pkexec /usr/lib/pika/gnome-layouts/papirus-folders -u -C green"], shell=True)
+ def yellow_accent_button_pressed_cb (self, widget):
+ subprocess.run(["/usr/lib/pika/gnome-layouts/dconf-accent.sh yellow"], shell=True)
+ subprocess.run(["pkexec /usr/lib/pika/gnome-layouts/papirus-folders -u -C yellow"], shell=True)
+ def orange_accent_button_pressed_cb (self, widget):
+ subprocess.run(["/usr/lib/pika/gnome-layouts/dconf-accent.sh orange"], shell=True)
+ subprocess.run(["pkexec /usr/lib/pika/gnome-layouts/papirus-folders -u -C orange"], shell=True)
+ def red_accent_button_pressed_cb (self, widget):
+ subprocess.run(["/usr/lib/pika/gnome-layouts/dconf-accent.sh red"], shell=True)
+ subprocess.run(["pkexec /usr/lib/pika/gnome-layouts/papirus-folders -u -C red"], shell=True)
+ def magenta_accent_button_pressed_cb (self, widget):
+ subprocess.run(["/usr/lib/pika/gnome-layouts/dconf-accent.sh magenta"], shell=True)
+ subprocess.run(["pkexec /usr/lib/pika/gnome-layouts/papirus-folders -u -C magenta"], shell=True)
+ def purple_accent_button_pressed_cb (self, widget):
+ subprocess.run(["/usr/lib/pika/gnome-layouts/dconf-accent.sh purple"], shell=True)
+ subprocess.run(["pkexec /usr/lib/pika/gnome-layouts/papirus-folders -u -C purple"], shell=True)
+ def brown_accent_button_pressed_cb (self, widget):
+ subprocess.run(["/usr/lib/pika/gnome-layouts/dconf-accent.sh brown"], shell=True)
+ subprocess.run(["pkexec /usr/lib/pika/gnome-layouts/papirus-folders -u -C brown"], shell=True)
+ def gray_accent_button_pressed_cb (self, widget):
+ subprocess.run(["/usr/lib/pika/gnome-layouts/dconf-accent.sh gray"], shell=True)
+ subprocess.run(["pkexec /usr/lib/pika/gnome-layouts/papirus-folders -u -C grey"], shell=True)
#### Desktop Switch ####
def on_desktop_switch_active_notify(self, switch, state):
diff --git a/src/usr/lib/pika/gnome-layouts/main.ui b/src/usr/lib/pika/gnome-layouts/main.ui
index 7129c12..7d512d5 100644
--- a/src/usr/lib/pika/gnome-layouts/main.ui
+++ b/src/usr/lib/pika/gnome-layouts/main.ui
@@ -358,11 +358,21 @@
start
True
-
-
+
True
- False
- Green
- ../../../../../../../../../../usr/lib/pika/gnome-layouts/accent-colors/green.svg
+ True
+ True
+ center
+ center
+
+
+
+ True
+ False
+ Green
+ ../../../../../../../../../../usr/lib/pika/gnome-layouts/accent-colors/green.svg
+
+
False
@@ -384,11 +404,21 @@
-
+
True
- False
- Yellow
- ../../../../../../../../../../usr/lib/pika/gnome-layouts/accent-colors/yellow.svg
+ True
+ True
+ center
+ center
+
+
+
+ True
+ False
+ Yellow
+ ../../../../../../../../../../usr/lib/pika/gnome-layouts/accent-colors/yellow.svg
+
+
False
@@ -397,11 +427,21 @@
-
+
True
- False
- Orange
- ../../../../../../../../../../usr/lib/pika/gnome-layouts/accent-colors/orange.svg
+ True
+ True
+ center
+ center
+
+
+
+ True
+ False
+ Orange
+ ../../../../../../../../../../usr/lib/pika/gnome-layouts/accent-colors/orange.svg
+
+
False
@@ -410,11 +450,21 @@
-
+
True
- False
- Red
- ../../../../../../../../../../usr/lib/pika/gnome-layouts/accent-colors/red.svg
+ True
+ True
+ center
+ center
+
+
+
+ True
+ False
+ Red
+ ../../../../../../../../../../usr/lib/pika/gnome-layouts/accent-colors/red.svg
+
+
False
@@ -423,11 +473,21 @@
-
+
True
- False
- Magenta
- ../../../../../../../../../../usr/lib/pika/gnome-layouts/accent-colors/magenta.svg
+ True
+ True
+ center
+ center
+
+
+
+ True
+ False
+ Magenta
+ ../../../../../../../../../../usr/lib/pika/gnome-layouts/accent-colors/magenta.svg
+
+
False
@@ -436,11 +496,21 @@
-
+
True
- False
- Purple
- ../../../../../../../../../../usr/lib/pika/gnome-layouts/accent-colors/purple.svg
+ True
+ True
+ center
+ center
+
+
+
+ True
+ False
+ Purple
+ ../../../../../../../../../../usr/lib/pika/gnome-layouts/accent-colors/purple.svg
+
+
False
@@ -449,11 +519,21 @@
-
+
True
- False
- Brown (please don't use this)
- ../../../../../../../../../../usr/lib/pika/gnome-layouts/accent-colors/brown.svg
+ True
+ True
+ center
+ center
+
+
+
+ True
+ False
+ Brown (please don't use this)
+ ../../../../../../../../../../usr/lib/pika/gnome-layouts/accent-colors/brown.svg
+
+
False
@@ -462,11 +542,21 @@
-
+
True
- False
- Gray
- ../../../../../../../../../../usr/lib/pika/gnome-layouts/accent-colors/gray.svg
+ True
+ True
+ center
+ center
+
+
+
+ True
+ False
+ Gray
+ ../../../../../../../../../../usr/lib/pika/gnome-layouts/accent-colors/gray.svg
+
+
False
diff --git a/src/usr/lib/pika/gnome-layouts/main.ui~ b/src/usr/lib/pika/gnome-layouts/main.ui~
index 6f927d8..7d512d5 100644
--- a/src/usr/lib/pika/gnome-layouts/main.ui~
+++ b/src/usr/lib/pika/gnome-layouts/main.ui~
@@ -14,7 +14,7 @@
700
535
False
- Nobara Gnome Layouts
+ PikaOS Gnome Layouts
700
535
False
@@ -358,11 +358,21 @@
start
True
-
+
True
- False
- Blue
- ../../../../../../../../Downloads/accent/blue-svg.svg
+ True
+ True
+ center
+ center
+
+
+
+ True
+ False
+ Blue
+ ../../../../../../../../../../usr/lib/pika/gnome-layouts/accent-colors/blue.svg
+
+
False
@@ -371,11 +381,21 @@
-
+
True
- False
- Green
- ../../../../../../../../Downloads/accent/blue-svg.svg
+ True
+ True
+ center
+ center
+
+
+
+ True
+ False
+ Green
+ ../../../../../../../../../../usr/lib/pika/gnome-layouts/accent-colors/green.svg
+
+
False
@@ -384,11 +404,21 @@
-
+
True
- False
- Yellow
- ../../../../../../../../Downloads/accent/blue-svg.svg
+ True
+ True
+ center
+ center
+
+
+
+ True
+ False
+ Yellow
+ ../../../../../../../../../../usr/lib/pika/gnome-layouts/accent-colors/yellow.svg
+
+
False
@@ -397,11 +427,21 @@
-
+
True
- False
- Orange
- ../../../../../../../../Downloads/accent/blue-svg.svg
+ True
+ True
+ center
+ center
+
+
+
+ True
+ False
+ Orange
+ ../../../../../../../../../../usr/lib/pika/gnome-layouts/accent-colors/orange.svg
+
+
False
@@ -410,11 +450,21 @@
-
+
True
- False
- Red
- ../../../../../../../../Downloads/accent/blue-svg.svg
+ True
+ True
+ center
+ center
+
+
+
+ True
+ False
+ Red
+ ../../../../../../../../../../usr/lib/pika/gnome-layouts/accent-colors/red.svg
+
+
False
@@ -423,11 +473,21 @@
-
+
True
- False
- Magenta
- ../../../../../../../../Downloads/accent/blue-svg.svg
+ True
+ True
+ center
+ center
+
+
+
+ True
+ False
+ Magenta
+ ../../../../../../../../../../usr/lib/pika/gnome-layouts/accent-colors/magenta.svg
+
+
False
@@ -436,11 +496,21 @@
-
+
True
- False
- Purple
- ../../../../../../../../Downloads/accent/blue-svg.svg
+ True
+ True
+ center
+ center
+
+
+
+ True
+ False
+ Purple
+ ../../../../../../../../../../usr/lib/pika/gnome-layouts/accent-colors/purple.svg
+
+
False
@@ -449,11 +519,21 @@
-
+
True
- False
- Brown (please don't use this)
- ../../../../../../../../Downloads/accent/blue-svg.svg
+ True
+ True
+ center
+ center
+
+
+
+ True
+ False
+ Brown (please don't use this)
+ ../../../../../../../../../../usr/lib/pika/gnome-layouts/accent-colors/brown.svg
+
+
False
@@ -462,11 +542,21 @@
-
+
True
- False
- Gray
- ../../../../../../../../Downloads/accent/blue-svg.svg
+ True
+ True
+ center
+ center
+
+
+
+ True
+ False
+ Gray
+ ../../../../../../../../../../usr/lib/pika/gnome-layouts/accent-colors/gray.svg
+
+
False
diff --git a/src/usr/lib/pika/gnome-layouts/papirus-folders b/src/usr/lib/pika/gnome-layouts/papirus-folders
new file mode 100755
index 0000000..223babd
--- /dev/null
+++ b/src/usr/lib/pika/gnome-layouts/papirus-folders
@@ -0,0 +1,533 @@
+#!/usr/bin/env bash
+# This script allows changing the color of folders in Papirus icon theme
+#
+# @author: Sergei Eremenko (https://github.com/SmartFinn)
+# @license: MIT license (MIT)
+# @link: https://github.com/PapirusDevelopmentTeam/papirus-folders
+
+if test -z "$BASH_VERSION"; then
+ printf "Error: this script only works in bash.\n" >&2
+ exit 1
+fi
+
+if (( BASH_VERSINFO[0] * 10 + BASH_VERSINFO[1] < 40 )); then
+ printf "Error: this script requires bash version >= 4.0\n" >&2
+ exit 1
+fi
+
+# set -x # Uncomment to debug this shell script
+set -o errexit \
+ -o noclobber \
+ -o pipefail
+
+readonly THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")"
+readonly PROGNAME="$(basename "${BASH_SOURCE[0]}")"
+readonly VERSION="1.12.0"
+readonly -a ARGS=("$@")
+
+msg() {
+ printf "%s: %b\n" "$PROGNAME" "$*"
+}
+
+verbose() {
+ [ -t 4 ] || return 0
+ msg "$@" >&4
+}
+
+err() {
+ msg "Error:" "$*" >&2
+}
+
+_exit() {
+ msg "$*" "Exiting ..."
+ exit 0
+}
+
+fatal() {
+ err "$*"
+ exit 1
+}
+
+usage() {
+ cat <<- EOF
+ USAGE
+ $ $PROGNAME [options] -t {-C --color}
+ $ $PROGNAME [options] -t {-D --default}
+ $ $PROGNAME [options] -t {-R --restore}
+ OPERATIONS
+ -C --color change color of folders
+ -D --default back to the default color
+ -R --restore restore the last used color from the config file
+ OPTIONS
+ -l --list show available colors
+ -o --once do not save the changes to the config file
+ -t --theme make changes to the specified theme (Default: Papirus)
+ -u --update-caches update icon caches for Papirus and siblings
+ -V --version print $PROGNAME version and exit
+ -v --verbose be verbose
+ -h --help show this help
+ EOF
+
+ exit "${1:-0}"
+}
+
+_is_root_user() {
+ if [ "$(id -u)" -eq 0 ]; then
+ return 0
+ fi
+
+ return 1
+}
+
+_is_user_dir() {
+ [ -n "$USER_HOME" ] || return 1
+
+ # if $THEME_DIR is placed in home dir
+ if [ -z "${THEME_DIR##"$USER_HOME"/*}" ]; then
+ return 0
+ fi
+
+ return 1
+}
+
+_is_writable() {
+ if [ -w "$THEME_DIR/48x48/places/folder.svg" ]; then
+ return 0
+ fi
+
+ return 1
+}
+
+_is_valid_color() {
+ local color="$1"
+
+ eval "$(declare_colors)"
+
+ for i in "${colors[@]}"; do
+ [ "$i" == "$color" ] || continue
+ return 0
+ done
+
+ return 1
+}
+
+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" )
+ fi
+ done
+
+ # return array of colors
+ declare -p colors
+}
+
+declare_current_color() {
+ local icon_file icon_name current_color=''
+
+ icon_file=$(readlink -f "$THEME_DIR/48x48/places/folder.svg")
+ icon_name=$(basename "$icon_file" .svg)
+ current_color="${icon_name##*-}"
+
+ declare -p current_color
+}
+
+get_theme_dir() {
+ local data_dir icons_dir
+ local -a data_dirs=()
+ local -a icons_dirs=(
+ "$USER_HOME/.icons"
+ "${XDG_DATA_HOME:-$USER_HOME/.local/share}/icons"
+ )
+
+ # Get data directories from XDG_DATA_DIRS variable and
+ # convert colon-separated list into bash array
+ IFS=: read -ra data_dirs <<< "${XDG_DATA_DIRS:-/usr/local/share:/usr/share}"
+
+ for data_dir in "${data_dirs[@]}"; do
+ [ -d "$data_dir/icons" ] || continue
+ icons_dirs=( "${icons_dirs[@]}" "${data_dir%/}/icons" )
+ done
+
+ for icons_dir in "${icons_dirs[@]}"; do
+ [ -f "$icons_dir/$THEME_NAME/index.theme" ] || continue
+ printf '%s' "$icons_dir/$THEME_NAME"
+ verbose "'$THEME_NAME' is found in '$icons_dir'."
+ return 0
+ done
+
+ return 1
+}
+
+get_real_user() {
+ # return name of the user that runs the script
+ local user=''
+
+ if [ -n "$PKEXEC_UID" ]; then
+ user="$(id -nu "$PKEXEC_UID")"
+ elif [ -n "$SUDO_USER" ]; then
+ user="$SUDO_USER"
+ else
+ user="$(id -nu)"
+ fi
+
+ printf '%s' "$user"
+}
+
+get_user_home() {
+ local user="$1"
+
+ getent passwd "$user" | awk -F: '{print $(NF-1)}'
+}
+
+config() {
+ # usage: config [{-n --new}] {-s --set} key=value... | {-g --get} key...
+ local config_dir
+ local config_file
+
+ if _is_user_dir; then
+ config_dir="${XDG_CONFIG_HOME:-$USER_HOME/.config}/$PROGNAME"
+ else
+ config_dir="/var/lib/$PROGNAME"
+ fi
+
+ config_file="$config_dir/keep"
+
+ while (( "$#" )); do
+ case "$1" in
+ -g|--get) shift;
+ [ -f "$config_file" ] || return 1
+
+ for key; do
+ [ -n "$key" ] || continue
+ awk -F= -v key="$key" '
+ $1 == key {
+ print $2
+ exit
+ }
+ ' "$config_file"
+ done
+
+ break
+ ;;
+ -n|--new) shift;
+ rm -f "$config_file"
+ ;;
+ -e|--exists) shift;
+ # return 1 if test config_file not exist or empty
+ if [ -f "$config_file" ] && [ -s "$config_file" ]; then
+ return 0
+ else
+ return 1
+ fi
+ ;;
+ -s|--set) shift;
+ [ "$ONCE" -eq "1" ] && break
+ [ -d "$config_dir" ] || mkdir -p "$config_dir"
+ [ -f "$config_file" ] || touch "$config_file"
+
+ verbose "Saving params to '$config_file' ..."
+ cat >> "$config_file" <<- EOF
+ $(for key_value; do echo "$key_value"; done)
+ EOF
+
+ break
+ ;;
+ *)
+ err "illegal option -- '$1'"
+ return 1
+ esac
+ done
+
+ return 0
+}
+
+change_color() {
+ local color="${1:?${FUNCNAME[-1]}: color is not set}"
+ local size prefix file_path file_name symlink_path
+ local -a sizes=(22x22 24x24 32x32 48x48 64x64)
+ local -a prefixes=("folder-$color" "user-$color")
+
+ for size in "${sizes[@]}"; do
+ for prefix in "${prefixes[@]}"; do
+ for file_path in "$THEME_DIR/$size/places/$prefix"{-*,}.svg; do
+ [ -f "$file_path" ] || continue # is a file
+ [ -L "$file_path" ] && continue # is not a symlink
+
+ file_name="${file_path##*/}"
+ symlink_path="${file_path/-$color/}" # remove color suffix
+
+ ln -sf "$file_name" "$symlink_path" || {
+ fatal "Fail to create '$symlink_path' symlink"
+ }
+ done
+ done
+ done
+}
+
+list_colors() {
+ local color='' prefix=''
+
+ eval "$(declare_colors)"
+ eval "$(declare_current_color)"
+
+ for color in "${colors[@]}"; do
+ if [ "$current_color" == "$color" ]; then
+ prefix='>'
+ else
+ prefix=''
+ fi
+
+ printf '%2s %s\n' "$prefix" "$color"
+ done
+}
+
+do_change_color() {
+ _is_valid_color "$SELECTED_COLOR" || {
+ fatal "Unable to find '$SELECTED_COLOR' color in '$THEME_NAME'"
+ }
+
+ verify_privileges
+
+ msg "Changing color of folders to '$SELECTED_COLOR' for '$THEME_NAME' ..."
+ change_color "$SELECTED_COLOR"
+ config --new --set "theme=$THEME_NAME" "color=$SELECTED_COLOR"
+ update_icon_cache
+}
+
+do_revert_default() {
+ verify_privileges
+
+ msg "Restoring default folder color for '$THEME_NAME' ..."
+ change_color "${DEFAULT_COLORS[$THEME_NAME]:-blue}"
+ config --new
+ update_icon_cache
+}
+
+do_restore_color() {
+ local saved_color=''
+
+ if config --exists; then
+ THEME_NAME="$(config --get theme)"
+ saved_color="$(config --get color)"
+ else
+ _exit "Unable to find config file."
+ fi
+
+ THEME_DIR="$(get_theme_dir)" || {
+ _exit "Unable to find '$THEME_NAME' icon theme."
+ }
+
+ _is_valid_color "$saved_color" || {
+ _exit "Unable to find '$saved_color' color in '$THEME_NAME'."
+ }
+
+ verify_privileges
+
+ change_color "$saved_color"
+ msg "'$saved_color' color of the folders has been restored."
+}
+
+delete_icon_caches() {
+ local icon_cache real_user='' real_home=''
+
+ real_user="$(get_real_user)"
+ real_home="$(get_user_home "$real_user")"
+
+ declare -a icon_caches=(
+ # KDE 5 icon caches
+ "$real_home/.cache/icon-cache.kcache"
+ "/var/tmp/kdecache-$real_user/icon-cache.kcache"
+ )
+
+ verbose "Deleting icon caches ..."
+ for icon_cache in "${icon_caches[@]}"; do
+ [ -e "$icon_cache" ] || continue
+ rm -f "$icon_cache"
+ done
+}
+
+update_icon_cache() {
+ [ -z "$DISABLE_UPDATE_ICON_CACHE" ] || return 0
+
+ delete_icon_caches
+
+ verbose "Rebuilding icon cache for '$THEME_NAME' ..."
+ gtk-update-icon-cache -qf "$THEME_DIR" || true
+}
+
+update_icon_caches() {
+ local theme=''
+
+ delete_icon_caches
+
+ for theme in "${!DEFAULT_COLORS[@]}"; do
+ [ -f "$THEME_DIR/../$theme/index.theme" ] || continue
+ verbose "Rebuilding icon cache for '$theme' ..."
+ gtk-update-icon-cache -qf "$THEME_DIR/../$theme" || true
+ done
+}
+
+verify_privileges() {
+ _is_root_user && return 0
+ _is_user_dir && return 0
+ _is_writable && return 0
+
+ verbose "This operation requires root privileges."
+
+ if command -v sudo > /dev/null; then
+ exec sudo USER_HOME="$USER_HOME" XDG_DATA_DIRS="$XDG_DATA_DIRS" \
+ "$THIS_SCRIPT" "${ARGS[@]}"
+ else
+ fatal "You need to be root to run this command."
+ fi
+}
+
+parse_args() {
+ local arg='' opt=''
+ local -a args=()
+
+ # Show help if no argument is passed
+ if [ -z "$1" ]; then
+ usage 2
+ fi
+
+ # Translate --gnu-long-options to -g (short options)
+ for arg; do
+ case "$arg" in
+ --help) args+=( -h ) ;;
+ --list) args+=( -l ) ;;
+ --once) args+=( -o ) ;;
+ --theme) args+=( -t ) ;;
+ --update-caches) args+=( -u ) ;;
+ --verbose) args+=( -v ) ;;
+ --color|--colour) args+=( -C ) ;;
+ --default) args+=( -D ) ;;
+ --restore) args+=( -R ) ;;
+ --version) args+=( -V ) ;;
+ --[0-9a-Z]*)
+ err "illegal option -- '$arg'"
+ usage 2
+ ;;
+ *) args+=("$arg")
+ esac
+ done
+
+ # Reset the positional parameters to the short options
+ set -- "${args[@]}"
+
+ while getopts ":C:DRlot:uvVh" opt; do
+ case "$opt" in
+ C ) OPERATIONS+=("change-color")
+ SELECTED_COLOR="$OPTARG"
+ ;;
+ D ) OPERATIONS+=("revert-default") ;;
+ R ) OPERATIONS+=("restore-color") ;;
+ l ) OPERATIONS+=("list-colors") ;;
+ o ) ONCE=1 ;;
+ t ) THEME_NAME="$OPTARG" ;;
+ u ) OPERATIONS+=("update-icon-caches") ;;
+ v ) VERBOSE=1 ;;
+ V ) printf "%s %s\n" "$PROGNAME" "$VERSION"
+ exit 0
+ ;;
+ h ) usage 0 ;;
+ : ) err "option requires an argument -- '-$OPTARG'"
+ usage 2
+ ;;
+ \?) err "illegal option -- '-$OPTARG'"
+ usage 2
+ ;;
+ esac
+ done
+
+ shift $((OPTIND-1))
+
+ # Return an error if any positional parameters are found
+ if [ -n "$1" ]; then
+ err "illegal parameter -- '$1'"
+ usage 2
+ fi
+}
+
+main() {
+ # default values of options
+ declare THEME_NAME="${THEME_NAME:-Papirus}"
+ declare -i VERBOSE="${VERBOSE:-0}"
+ declare -i ONCE="${ONCE:-0}"
+ declare -A DEFAULT_COLORS=(
+ ['ePapirus']='blue'
+ ['Papirus']='blue'
+ ['Papirus-Dark']='blue'
+ )
+
+ declare SELECTED_COLOR=''
+ declare -a OPERATIONS=()
+
+ parse_args "${ARGS[@]}"
+
+ if [ "$VERBOSE" -eq "1" ]; then
+ # open a file descriptor for verbose messages
+ exec 4>&1
+ # close the file descriptor before exiting
+ trap 'exec 4>&-' EXIT HUP INT TERM
+ fi
+
+ # set USER_HOME variable instead HOME to prevent changing user's icons
+ # when running with sudo
+ [ -n "$USER_HOME" ] || USER_HOME="$(get_user_home "$(id -nu)")"
+
+ if [ -f "$THEME_NAME/index.theme" ]; then
+ # THEME_NAME is a path to an icon theme
+ THEME_DIR="$(readlink -f "$THEME_NAME")"
+ THEME_NAME="$(basename "$THEME_DIR")"
+ verbose "The path to '$THEME_DIR' theme is specified."
+ else
+ THEME_DIR="$(get_theme_dir)" || {
+ fatal "Fail to find '$THEME_NAME' icon theme."
+ }
+ fi
+
+ for operation in "${OPERATIONS[@]}"; do
+ case "$operation" in
+ change-color)
+ do_change_color
+ ;;
+ revert-default)
+ do_revert_default
+ ;;
+ restore-color)
+ do_restore_color
+ ;;
+ list-colors)
+ if [ -t 1 ]; then
+ cat <<- EOF
+ List of available colors:
+ $(list_colors)
+ EOF
+ else
+ list_colors
+ fi
+ ;;
+ update-icon-caches)
+ verify_privileges
+ update_icon_caches
+ ;;
+ esac
+ done
+
+ verbose "Done!"
+
+ exit 0
+}
+
+main
+
+exit 1