Advertisement
v1ral_ITS

noters

Mar 30th, 2019
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 4.64 KB | None | 0 0
  1. dd Install Method (Requires Root):
  2. Download the latest image file (.img) from the download link above. Place it in the root of your /sdcard folder and rename it to twrp.img. Run the following commands via adb shell or a terminal emulator app:
  3.  
  4. su
  5.  
  6. dd if=/sdcard/twrp.img of=/dev/block/bootdevice/by-name/recovery
  7.  
  8. Changelog:
  9.  
  10.  
  11.  
  12.  
  13. npm i -D electron@latest
  14.  
  15.  
  16. npm i -D electron@beta
  17. npm i -D electron-nightly
  18.  
  19.  
  20.  
  21. 59
  22.  
  23. 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 read command..
  24.  
  25. read -p "Do something? ";
  26. if [ $REPLY == "y" ]; then
  27.     echo yay;
  28. fi
  29. If console prompt's just won't cut it, Zenity is really easy to use, for example:
  30.  
  31.       zenity --error --text="Testing..."
  32.       zenity --question --text="Continue?"
  33. This only works on Linux/Gnome (or rather, it'll only be installed by default on such systems). The read method will work on pretty much any platform (including headless machines, or via SSH)
  34.  
  35. 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)
  36.  
  37. 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
  38.  
  39. As a command-line script, it'd use Python:
  40.  
  41. $ export HEALTH=34
  42. $ python -c "import os; print '*' * int(os.environ.get('HEALTH', 0))"
  43. **********************************
  44. Or to normalise the values between 1 and 78 (so you don't get line-wrapping on a standard terminal size):
  45.  
  46. $ python -c "import os; print '*' * int((int(os.environ.get('HEALTH', 0)) / 100.0) * 78)"
  47. Zenity also has a Progress Dialog,
  48.  
  49. #!/bin/sh
  50. (
  51. echo "10" ; sleep 1
  52. echo "# Updating mail logs" ; sleep 1
  53. echo "20" ; sleep 1
  54. echo "# Resetting cron jobs" ; sleep 1
  55. echo "50" ; sleep 1
  56. echo "This line will just be ignored" ; sleep 1
  57. echo "75" ; sleep 1
  58. echo "# Rebooting system" ; sleep 1
  59. echo "100" ; sleep 1
  60. ) |
  61. zenity --progress \
  62.   --title="Update System Logs" \
  63.   --text="Scanning mail logs..." \
  64.   --percentage=0
  65.  
  66. if [ "$?" = -1 ] ; then
  67.         zenity --error \
  68.           --text="Update canceled."
  69. fi
  70. 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..
  71.  
  72. shareimprove this answer
  73. edited Feb 19 '16 at 12:55
  74.  
  75. Chris
  76. 8516
  77. answered May 29 '09 at 20:54
  78.  
  79. dbr
  80. 120k57251317
  81. 1
  82. I don't want the yes/no, but 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. That I want to do. – lauriys May 29 '09 at 20:58
  83. The Progress Dialog link above is broken :( – Jeremy Iglehart Jul 24 '18 at 1:34
  84. add a comment
  85.  
  86.  
  87. 20
  88.  
  89. If you want to write a graphical UI in bash, zenity is the way to go. This is what you can do with it:
  90.  
  91. Application Options:
  92.   --calendar                                     Display calendar dialog
  93.   --entry                                        Display text entry dialog
  94.   --error                                        Display error dialog
  95.   --info                                         Display info dialog
  96.   --file-selection                               Display file selection dialog
  97.   --list                                         Display list dialog
  98.   --notification                                 Display notification
  99.   --progress                                     Display progress indication dialog
  100.   --question                                     Display question dialog
  101.   --warning                                      Display warning dialog
  102.   --scale                                        Display scale dialog
  103.   --text-info                                    Display text information dialog
  104. Combining these widgets you can create pretty usable GUIs. Of course, it's not as flexible as a toolkit integrated into a programming language, but in some cases it's really useful.
  105.  
  106. shareimprove this answer
  107. edited May 10 '18 at 20:43
  108. answered May 29 '09 at 21:07
  109.  
  110. nxadm
  111. 1,9711016
  112. add a comment
  113.  
  114. 13
  115.  
  116. there is a command called dialog which uses the ncurses library. "Dialog is a program that will let you to present a variety of questions or display messages using dialog boxes from a shell script. These types of dialog boxes are implemented (though not all are necessarily compiled into dialog)"
  117.  
  118. see http://pwet.fr/man/linux/commandes/dialog
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement