Last active
February 14, 2021 07:17
-
-
Save projectivemotion/0ba0f4049cc28b4edff5865ff97b7958 to your computer and use it in GitHub Desktop.
Revisions
-
projectivemotion revised this gist
Feb 14, 2021 . 1 changed file with 5 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,20 +8,16 @@ cd $(dirname "$0") function read_ini(){ if [ ! -f ./run.ini ] ; then cat << EOF > ./run.ini [hello-from-zenity] run=zenity --info --text "Hello from Zenity" title="Zenity" [gedit] run=gedit run.ini title="Edit run.ini" [sleep] run=sleep 5 title="Sleep for 5 seconds" @@ -47,11 +43,13 @@ if [[ 1 -eq $? ]] ; then exit 1 fi exitnow=0 while [[ 0 -eq $exitnow ]]; do declare -a sections declare -A vars read_ini declare -a rows for section in "${sections[@]}" ; do run="section_${section}_run" @@ -70,6 +68,5 @@ while [[ 0 -eq $exitnow ]]; do echo $(date): $chosen eval $chosen fi unset rows sections vars done -
projectivemotion revised this gist
Feb 14, 2021 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -19,8 +19,8 @@ run=zenity --info --text "Hello from Zenity" title="Zenity" [gedit] run=gedit run.ini title="Edit run.ini" [sleep] run=sleep 5 -
projectivemotion created this gist
Feb 14, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,75 @@ #!/bin/bash # github.com/projectivemotion # # This script displays a listbox and allows a user # to select and execute any of the commands from a given # ini file. (run.ini) # cd $(dirname "$0") declare -a sections declare -A vars function read_ini(){ if [ ! -f ./run.ini ] ; then cat << EOF > ./run.ini [hello-from-zenity] run=zenity --info --text "Hello from Zenity" title="Zenity" [gedit] run=gedit title="Open Gedit" [sleep] run=sleep 5 title="Sleep for 5 seconds" EOF fi section="" while IFS='=]' read vleft vright do if [[ $vleft == \[* ]] ; then section=${vleft/[/} sections+=("$section") elif [[ $vright ]] ; then todeclare="section_${section}_$vleft" vars[$todeclare]="$vright" fi done < ./run.ini } which zenity 2>&1 >/dev/null if [[ 1 -eq $? ]] ; then echo "Please install zenity." exit 1 fi read_ini exitnow=0 while [[ 0 -eq $exitnow ]]; do declare -a rows for section in "${sections[@]}" ; do run="section_${section}_run" title="section_${section}_title" rows+=("$section" "${vars[$title]}" "${vars[$run]}") done chosen=$(zenity --height 300 --width 800 --list \ --title="Choose the command you wish to execute." \ --column="Section" --column="Title" --column="Cmd" \ --print-column=3 \ "${rows[@]}") exitnow=$? if [[ 0 -eq $exitnow ]] ; then echo $(date): $chosen eval $chosen fi unset rows done