-
Notifications
You must be signed in to change notification settings - Fork 208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: Tidy up preload script #2595
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
825acd8
preload: clean up $1 handling
trn1ty 3cce989
preload: clean up prefix setting
trn1ty 3090413
preload: make most of a pipeline unconditional
trn1ty 8e30261
preload: replace if/elif chain with case
trn1ty b8eb2d7
preload: combine some pipelines
trn1ty e32e1ff
preload: replace if/elif chain with case
trn1ty File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,25 +37,18 @@ function error { | |
exit 1 | ||
} | ||
|
||
#yad or xlunch format | ||
case "$1" in | ||
source) return 0 ;; | ||
'') format=yad ;; | ||
xlunch*) format=xlunch ;; | ||
yad*) format=yad ;; | ||
*) error "$0: $1: unknown list format!" ;; | ||
esac | ||
guimode="$1" | ||
|
||
if [ -z "$guimode" ];then | ||
format=yad | ||
elif [[ "$guimode" = xlunch* ]];then | ||
format=xlunch | ||
elif [[ "$guimode" = yad* ]];then | ||
format=yad | ||
elif [ "$guimode" != 'yad' ] && [ "$guimode" != 'xlunch' ];then | ||
error "Unknown list format '$format'!" | ||
fi | ||
|
||
#specifies a category to preload (can be left empty to load main page) | ||
prefix="$2" | ||
|
||
if [ "$prefix" == '/' ];then | ||
prefix= | ||
fi | ||
# The prefix is a category to preload. By default (if '/' or empty) the main | ||
# page is preloaded. | ||
test "$2" = / || prefix="$2" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this breaks the prefix variable and thus the preload script, it is no longer set when it is not |
||
|
||
# if the timestamp in the settings folder has changed, we need to unset the text_color variable since the GTK_THEME may have changed and we need to re-generate it | ||
timestamp_settings="$( cat ${DIRECTORY}/data/preload/timestamps- | grep "^${DIRECTORY}/data/settings" )" | ||
|
@@ -76,17 +69,13 @@ if [ -z "${text_color+x}" ] && [ "$format" == yad ];then | |
#to avoid setting the text to the wrong color, check it again now right | ||
#set the system GTK theme for yad windows | ||
guimode="$(cat "${DIRECTORY}/data/settings/App List Style" 2>/dev/null || echo yad-default)" | ||
if [ "$guimode" == yad-default ];then | ||
export GTK_THEME='' | ||
elif [[ "$guimode" = yad* ]];then | ||
export GTK_THEME=${guimode//yad-/} | ||
elif [ "$guimode" == xlunch-light-3d ];then | ||
export GTK_THEME='' | ||
elif [ "$guimode" == xlunch-dark-3d ];then | ||
export GTK_THEME=Adwaita-dark | ||
elif [ "$guimode" == xlunch-dark ];then | ||
export GTK_THEME=Adwaita-dark | ||
fi | ||
case "$guimode" in | ||
yad-default) export GTK_THEME= ;; | ||
yad*) export GTK_THEME=${guimode//yad-/} ;; | ||
xlunch-light-3d) export GTK_THEME= ;; | ||
xlunch-dark) export GTK_THEME=Adwaita-dark ;; | ||
xlunch-dark-3d) export GTK_THEME=Adwaita-dark ;; | ||
esac | ||
export text_color=$(echo "import gi | ||
gi.require_version('Gtk', '3.0') | ||
from gi.repository import Gtk | ||
|
@@ -159,28 +148,46 @@ if [ $reloadlist == 1 ];then | |
if ! command -v app_prefix_category >/dev/null ;then | ||
source "${DIRECTORY}/api" | ||
fi | ||
|
||
if [ ! -z "$prefix" ];then | ||
echo "Showing apps within $prefix/" 1>&2 | ||
vfiles="$(app_prefix_category "$prefix" | grep . | sort -f | uniq | sed "s+$prefix/++g")" #generate a virtual file system with apps in folders represented as subdirectories | ||
else | ||
vfiles="$(app_prefix_category "" | grep . | sort -f | uniq | grep -v '^hidden/')" | ||
fi | ||
|
||
#remove apps within categories - show this layer of stuff only. | ||
vfiles="$(sed 's+/.*+/+g' <<<"$vfiles" | uniq)" | ||
|
||
vfiles="$( | ||
app_prefix_category "$prefix" \ | ||
| grep . \ | ||
| sort -f \ | ||
| uniq \ | ||
| if test -n "$prefix" ;then | ||
printf '%s: Showing apps within %s/\n' "$0" "$prefix" >&2 | ||
sed "s+$prefix/++g" #generate a virtual file system with apps in folders represented as subdirectories | ||
else | ||
grep -v ^hidden/ | ||
fi \ | ||
| sed 's+/.*+/+g' \ | ||
| uniq # ^ show this layer only | ||
)" | ||
|
||
|
||
#get list of apps - excluding folders and apps that are incompatible with CPU architecture | ||
APPS="$(grep -v '/' <<<"$vfiles" | list_intersect "$(list_apps cpu_installable)")" | ||
APPS="$( | ||
printf '%s\n' "$vfiles" \ | ||
| grep -v '/' \ | ||
| list_intersect "$(list_apps cpu_installable)" | ||
| if <"$DIRECTORY"/data/settings/"Shuffle App list" xargs test Yes = ;then | ||
shuf | ||
else | ||
cat | ||
fi | ||
)" | ||
|
||
#get list of folders - excluding apps. | ||
DIRS="$(grep '/' <<<"$vfiles" | tr -d '/')" | ||
|
||
#shuffle the list if enabled | ||
if [ "$(< "${DIRECTORY}/data/settings/Shuffle App list")" == 'Yes' ];then | ||
APPS="$(echo "$APPS" | shuf)" | ||
DIRS="$(echo "$DIRS" | shuf)" | ||
fi | ||
DIRS="$( | ||
printf '%s\n' "$vfiles" \ | ||
| grep '/' \ | ||
| tr -d '/' \ | ||
| if <"$DIRECTORY"/data/settings/"Shuffle App list" xargs test Yes = ;then | ||
shuf | ||
else | ||
cat | ||
fi | ||
)" | ||
|
||
if [ "$format" == yad ];then | ||
IFS=$'\n' | ||
|
@@ -253,21 +260,15 @@ $prefix/$app | |
"\("$status"\)" $line"$'\n' | ||
fi | ||
|
||
#determine status text-color for app name (green for installed, red for uninstalled, yellow for corrupted) | ||
if [ -z "$status" ];then | ||
add+="$text_color" | ||
elif [ "$status" == installed ];then | ||
add+="#00AA00" | ||
elif [ "$status" == uninstalled ];then | ||
add+="#CC3333" | ||
elif [ "$status" == corrupted ];then | ||
add+="#888800" | ||
elif [ "$status" == disabled ];then | ||
add+="#FF0000" | ||
else | ||
# fallback incase unexpected status | ||
add+="$text_color" | ||
fi | ||
# Determine status text color for app name. | ||
case "$status" in | ||
installed) add+="#00AA00" ;; # green | ||
uninstalled) add+="#CC3333" ;; # light red | ||
corrupted) add+="#888800" ;; # yellow | ||
disabled) add+="#FF0000" ;; # deep red | ||
*) add+="$text_color" ;; | ||
esac | ||
|
||
#output finished app lines | ||
add="${add//[&]/&}" | ||
echo "$add" | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
preload
script is not to be sourced. Why has this input argument been added?