The Cookie Machine - Click here to drag window

DUMMY TEXT - Real text set in assets/js/theCookieMachine.js

If you can read me, I'm broken!

Views: 3,972β€…    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: April 8, 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:

yad-progress-bar.gif

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
⇧ Is there a command to get the number of frames in a gif? Another (unsolvable) "old glib" problem  β‡©