Small tweaks
authorCameron Ball <cameron@getapproved.com.au>
Thu, 11 Jun 2015 07:51:08 +0000 (15:51 +0800)
committerCameron Ball <cameron@getapproved.com.au>
Thu, 11 Jun 2015 07:51:08 +0000 (15:51 +0800)
cache-update-adapter.sh
cache-update-confirmation-adapter.sh
menu.json
menu.sh
rsync-adapter.sh

index e6737a5..2f77d15 100755 (executable)
@@ -25,6 +25,8 @@ if [[ -z "$cache_dir" ]] || [[ "${cache_dir}xxx" = "xxx" ]]; then
        exit 1
 fi
 
+[[ ! -d "$cache_dir" ]] && echo 100 && exit 0
+
 num=$(wc -l < /tmp/newsongs.txt)
 num_processed=0
 
index 809c6d0..91360b7 100755 (executable)
@@ -4,7 +4,7 @@
 # description: Displays the number of updated simfiles
 
 num=$(wc -l < /tmp/newsongs.txt)
-rm /tmp/newsongs.txt
+#rm /tmp/newsongs.txt
 
 if [[ $num -gt 0 ]]; then
        echo "$num New/updated simfiles"
index a51772f..973a77d 100644 (file)
--- a/menu.json
+++ b/menu.json
@@ -10,7 +10,7 @@
           "ITG": {
             "type": "service",
             "description": "Start/Stop the ITG service",
-            "command": "/home/cameron/OpenITG/itg",
+            "command": "/home/cameron/Games/OpenITG/openitg-beta-2",
             "user": "itg"
           },
           "gEdit": {
             "description": "Update the ITG song list",
             "commands": [
                {
-                       "command": "./rsync-adapter.sh -ia --delete --exclude 'A is for Cool Shit' /mnt/linkstation/Test/Songs /mnt/linkstation/Test/itg",
+                       "command": "./rsync-adapter.sh -ia --delete --exclude 'A is for Cool Shit' /home/cameron/PreComTestRepo/Songs /home/cameron/Games/OpenITG",
                        "title": "Syncing songs..."
                },
                {
-                       "command": "./cache-update-adapter.sh -d /mnt/linkstation/Test/itg/Cache/Songs/",
+                       "command": "./cache-update-adapter.sh -d /home/cameron/Games/OpenITG/Cache/Songs/",
                        "title": "Updating cache..."
                },
                {
             "user": "itg"
           }
         }
+      },
+      "Presets": {
+        "type": "menu",
+        "description": "Run presets",
+        "items": {
+            "SyncAndLaunch": {
+               "type": "preset",
+               "description": "Sync songs and launch ITG",
+               "itemsToRun": [
+                       "Tasks.UpdateSongs",
+                       "Services.ITG"
+               ]
+            }
+         }
       }
     }
   }
diff --git a/menu.sh b/menu.sh
index 8a0d4b1..325c5bf 100755 (executable)
--- a/menu.sh
+++ b/menu.sh
@@ -8,8 +8,8 @@ trap "rm $OUTPUT' rm $INPUT; exit" SIGHUP SIGINT SIGTERM
 menu_json="$(./JSON.sh -l < menu.json)"
 current_item="MainMenu"
 backtitle="DivinElegy PreCom"
-box_width=50
-box_height=15
+box_width=70
+box_height=30
 
 function debug()
 {
@@ -139,7 +139,7 @@ function render_menu()
 
        #Also cracks the shits without quotes.
        #Also don't know why.
-       dialog --clear --backtitle "$backtitle" --title "${1//./>}" --menu "$(get_item_description $1)" "$box_height" "$box_width" 4 "${options[@]}" 2>"${INPUT}"
+       dialog --clear --backtitle "$backtitle" --title "${1//./>}" --nocancel --menu "$(get_item_description $1)" "$box_height" "$box_width" 4 "${options[@]}" 2>"${INPUT}"
 }
 
 function toggle_service()
@@ -181,8 +181,8 @@ function run_task()
                                title=$(get_value_from_key "${key%.*}.title")
 
                                case "$widget" in
-                                       gauge) eval "$command" | dialog --clear --backtitle "$backtitle" --title "Running $1" --gauge "$title" 6 50;;
-                                       msgbox) eval "$command" | dialog --clear --backtitle "$backtitle" --title "Running $1" --msgbox "$title" 6 50;;
+                                       gauge) eval "$command" | dialog --clear --backtitle "$backtitle" --title "Running $1" --gauge "$title" "$box_height" "$box_width";;
+                                       msgbox) eval "$command" | dialog --clear --backtitle "$backtitle" --title "$title" --msgbox "$(eval \"$command\")" "$box_height" "$box_width";;
                                esac
                        fi
                 fi
index 4e48453..41518a5 100755 (executable)
@@ -4,5 +4,6 @@
 # description: Modifies rsync's output to be used
 #              with dialog's --progress option
 
+#XXX: Some versions of rsync say to-chk instead of to-check, be careful
 rsync --progress "$@" | tee >(grep -v "*deleting" | grep -i ".sm" > /tmp/newsongs.txt) | mawk -Winteractive '{ if (index($0, "to-check=") > 0) { split($0, pieces, "to-check="); split(pieces[2], term, ")"); split(term[1], division, "/"); print (1-(division[1]/division[2]))*100 } }' \
                      | sed --unbuffered 's/\([0-9]*\).*/\1/'