improved code by removing redundancies and done some optimizations
This commit is contained in:
@@ -73,47 +73,27 @@ get_binaries() {
|
||||
}
|
||||
|
||||
|
||||
build_drun() {
|
||||
get_desktop_files \
|
||||
| sort -f -t$'\t' -k1,1 \
|
||||
sort_and_dedup() {
|
||||
sort -f -t$'\t' -k1,1 \
|
||||
| awk -F'\t' '!seen[$1]++'
|
||||
}
|
||||
|
||||
|
||||
build_drun() {
|
||||
get_desktop_files | sort_and_dedup
|
||||
}
|
||||
|
||||
build_run() {
|
||||
{
|
||||
get_desktop_files
|
||||
get_binaries
|
||||
} \
|
||||
| sort -f -t$'\t' -k1,1 \
|
||||
| awk -F'\t' '!seen[$1]++'
|
||||
{ get_desktop_files; get_binaries; } | sort_and_dedup
|
||||
}
|
||||
|
||||
|
||||
extract_proxy() {
|
||||
local conf="${PROXYCHAINS_CONF_FILE:-/etc/proxychains4.conf}"
|
||||
[ -f "$conf" ] || conf="/etc/proxychains.conf"
|
||||
[ -f "$conf" ] || return
|
||||
|
||||
local line
|
||||
line=$(awk '/^\[ProxyList\]/{found=1; next} found && NF && !/^#/{print; exit}' "$conf")
|
||||
[ -n "$line" ] || return
|
||||
|
||||
local ptype host port
|
||||
ptype=$(echo "$line" | awk '{print $1}')
|
||||
host=$(echo "$line" | awk '{print $2}')
|
||||
port=$(echo "$line" | awk '{print $3}')
|
||||
|
||||
echo "${ptype}://${host}:${port}"
|
||||
}
|
||||
|
||||
update_cache() {
|
||||
build_drun > "$DRUN_CACHE.tmp"
|
||||
build_run > "$RUN_CACHE.tmp"
|
||||
|
||||
mv "$DRUN_CACHE.tmp" "$DRUN_CACHE"
|
||||
mv "$RUN_CACHE.tmp" "$RUN_CACHE"
|
||||
|
||||
extract_proxy > "$CACHE_DIR/proxy.conf"
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user