Skip to content

Commit

Permalink
v6.31
Browse files Browse the repository at this point in the history
+ DietPi-Cloudshell | Calling the external "clear" binary is quite slow. It is possible to redirect its output to use it later with only shell-internal commands, which is orders of magnitudes faster. We could use known escape sequences here but using the sequence the "clear" estimates to be the best for the current terminal type makes it most compatible and does not change the current behaviour in any way, besides performance ;).
+ DietPi-Cloudshell | Minor coding enhancement
  • Loading branch information
MichaIng authored May 21, 2020
1 parent 5e8144b commit 6cd00ba
Showing 1 changed file with 6 additions and 20 deletions.
26 changes: 6 additions & 20 deletions dietpi/dietpi-cloudshell
Original file line number Diff line number Diff line change
Expand Up @@ -1184,6 +1184,10 @@ _EOF_
#/////////////////////////////////////////////////////////////////////////////////////
Init(){

#--------------------------------------------------------------------------------
# Override (slow) external "clear" command with function that prints the pure control sequence, clearing the screen MUCH faster!
eval "clear(){ printf '$(clear)'; }"

#--------------------------------------------------------------------------------
# Storage array
Init_STORAGE
Expand All @@ -1202,27 +1206,9 @@ _EOF_
[[ -f '/etc/pihole/gravity.list' ]] || aEnabledScenes[8]=0

#--------------------------------------------------------------------------------
# Ensure we have at least 1 Scene enabled in the settings file.
local enabled_scene=0
for ((i=0; i<$MAX_SCENES; i++))
do

if (( ${aEnabledScenes[$i]} )); then

enabled_scene=1
break
# Ensure we have at least 1 scene (dietpi) enabled in the settings file.
[[ ${aEnabledScenes[*]} == *1* ]] || aEnabledScenes[4]=1 SCENE_CURRENT=4

fi

done

# No Scenes selected! Override user setting and enable at least 1 scene (dietpi)
if (( $enabled_scene == 0 )); then

aEnabledScenes[4]=1
SCENE_CURRENT=4

fi
#--------------------------------------------------------------------------------
# Update DietPi network shared data: https://github.com/MichaIng/DietPi/issues/359
/boot/dietpi/func/obtain_network_details
Expand Down

0 comments on commit 6cd00ba

Please sign in to comment.