Views:
4,245β
Votes: 3β
Tags:
command-line
yad
Link:
π See Original Answer on Ask Ubuntu β§ π
URL:
https://askubuntu.com/q/1027622
Title:
How do I create a fake process bar?
ID:
/2018/04/23/How-do-I-create-a-fake-process-bar_
Created:
April 23, 2018
Edited: June 12, 2020
Upload:
September 15, 2024
Layout: post
TOC:
false
Navigation: false
Copy to clipboard: false
Fake Progress Bar
This progress bar uses real data in /bin
directory which everyone has. The script can be βdumbed downβ to suit your fake needs. Or it can be expanded for a real life application:
It uses yad
which is a super-charged version of zenity
the default GUI used in the terminal. To install yad
use:
sudo apt install yad
Hereβs the code:
#!/bin/bash
# NAME: yad-progress-bar
# PATH: /mnt/e/bin
# DESC: Display yad progress bar % with names.
# DATE: Apr 23, 2018. Modified Oct 18, 2019.
Source="/bin"
Title="Processing files for: $Source"
Count=0
AllFiles=$(ls $Source/* | wc -l)
for f in "$Source"/* ; do
echo "#$f" # Display file name in progress bar.
Count=$(( $Count + 1 ))
Percent=$(( Count * 100 / AllFiles ))
echo $Percent # Display percent complete in progress bar.
sleep .025
done | yad --progress --auto-close \
--width=500 --height=300 \
--title="$Title" --enable-log "Current filename" \
--log-expanded --log-height=250 \
--log-on-top --percentage=0 \
--no-cancel --center