Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Before actually using GUI dialogues, consider using console prompts. Quite often you can get away with simple "y/n?" prompts, which in bash you achieve via the <a href="http://www.manpagez.com/man/2/read/" rel="noreferrer"><code>read</code> command</a>..</p> <pre><code>read -p "Do something? "; if [ $REPLY == "y" ]; then echo yay; fi </code></pre> <p>If console prompt's just won't cut it, <a href="http://freshmeat.net/projects/zenity" rel="noreferrer">Zenity</a> is really <a href="http://library.gnome.org/users/zenity/stable/" rel="noreferrer">easy to use</a>, for example:</p> <pre><code> zenity --error --text="Testing..." zenity --question --text="Continue?" </code></pre> <p>This only works on Linux/Gnome (or rather, it'll only be installed by default on such systems). The <code>read</code> method will work on pretty much any platform (including headless machines, or via SSH)</p> <p>If you need anything more complex than what read or Zenity provides, "change to C++" is really the best method (although I'd recommend Python/Ruby over C++ for such shell-script-replacement tasks)</p> <blockquote> <p>I want to do simple interface for some strange game, the progress bar for health or something is the example for what I want. Variable "HEALTH" is 34, so make progress bar filled in 34/100</p> </blockquote> <p>As a command-line script, it'd use Python:</p> <pre><code>$ export HEALTH=34 $ python -c "import os; print '*' * int(os.environ.get('HEALTH', 0))" ********************************** </code></pre> <p>Or to normalise the values between 1 and 78 (so you don't get line-wrapping on a standard terminal size):</p> <pre><code>$ python -c "import os; print '*' * int((int(os.environ.get('HEALTH', 0)) / 100.0) * 78)" </code></pre> <p>Zenity also has a <a href="https://help.gnome.org/users/zenity/stable/progress.html.en" rel="noreferrer">Progress Dialog</a>,</p> <pre><code>#!/bin/sh ( echo "10" ; sleep 1 echo "# Updating mail logs" ; sleep 1 echo "20" ; sleep 1 echo "# Resetting cron jobs" ; sleep 1 echo "50" ; sleep 1 echo "This line will just be ignored" ; sleep 1 echo "75" ; sleep 1 echo "# Rebooting system" ; sleep 1 echo "100" ; sleep 1 ) | zenity --progress \ --title="Update System Logs" \ --text="Scanning mail logs..." \ --percentage=0 if [ "$?" = -1 ] ; then zenity --error \ --text="Update canceled." fi </code></pre> <p>As I said before, if Zenity cannot do what you need, look into writing your game-thing as a "proper" script in Python/Ruby/Perl/C++/etc as it sounds like you're pushing the bounds of what a shell-script can do..</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload