diff --git a/factorimods b/factorimods index 378dd12..4464114 100644 --- a/factorimods +++ b/factorimods @@ -1,30 +1,38 @@ #!/bin/bash -#Dependencies : you'll need a dmenu-like to run this script. -#On debian and debian-like distros (ubuntu, mint...), simply run: -# sudo apt install dmenu +# Dependencies : you'll need a dmenu-like to run this script. +# On debian and debian-like distros (ubuntu, mint...), simply run: +# sudo apt install dmenu -#Edit this line to meet your installation +# Edit this line to meet your installation factorio_dir="/DATA/Games/factorio" +# If you have installed new mods, this script will revert to previously saved +# mods before launching factorio. To update the modlist for a save, select the +# appropriate mods (via the GUI menu in factorio), then exit, call +# factorimods -r +# and select that save. This will replace the previously saved mods for that +# save with the active list from factorio. cd $factorio_dir/saves #Ask the user to select a save -save=$(ls -t *.zip | grep -v autosave | rev | cut -d "." -f 2- | rev | dmenu) +save=$(ls -t *.zip | grep -v autosave | rev | cut -d "." -f 2- | rev | dmenu -i -l 5 -p "Chose a save file: ") test $? -ne 0 && echo "No save selected" && exit 1 +if test $1 = "-r" ; then + cp mod-list.json_$modlist mod-list.json_$save #Check if a modlist exists for that save -if test -s mod-list.json_$save ; then +elif test -s mod-list.json_$save ; then modlist=$save else #Otherwise, prompt to load another modlist - modlist=$(ls -t mod-list.json_* | cut -d "_" -f 2- | dmenu -p "No mod list found for savegame $save. Select mod list from available: ") + modlist=$(ls -t mod-list.json_* | cut -d "_" -f 2- | dmenu -p "No mod list found for savegame \"$save\". Select mod list from available: ") test $? -ne 0 && echo "No modlist selected" && exit 1 #And prompt to save it for later - echo -e "yes\nno" | dmenu -p "Save selected modlist for savegame $save ?" | grep "yes" && cp mod-list.json_$modlist mod-list.json_$save && modlist=$save + echo -e "yes\nno" | dmenu -p "Save selected modlist for savegame $save ?" | grep -q "yes" && cp mod-list.json_$modlist mod-list.json_$save && modlist=$save fi #Link that modlist to the file read by factorio