mh 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/bin/bash
  2. #
  3. # mh command for simplified operations
  4. #
  5. # mh save
  6. # mh restore
  7. # mh kill
  8. #
  9. # can utilize save/restore to save-scum decoration farming
  10. # can utilize kill to stop processes when failed to cease
  11. #
  12. # save includes timestamps to avoid potential
  13. #
  14. # current implementation uses hard-coded user id; not portable
  15. # future implementations should either save/restore for all ids, or ask/compute
  16. export steam_game_id="582010"
  17. export save_path="${HOME}/games/mhworld/saves"
  18. export steam_user_id="48081292"
  19. export full_path="${HOME}/.local/share/Steam/userdata/${steam_user_id}/${steam_game_id}/remote/SAVEDATA1000"
  20. mhsave() {
  21. mkdir -p "$save_path"
  22. local save_file="${save_path}/$(date +%Y%m%d%H%M%S)"
  23. cp "$full_path" "$save_file"
  24. ln -sf "$save_file" "${save_path}/latest"
  25. }
  26. mhrestore() {
  27. [ ! -f "${save_path}/latest" ] && return
  28. cp -L "${save_path}/latest" "$full_path"
  29. }
  30. case "$1" in
  31. run)
  32. steam "steam://rungameid/${steam_game_id}" &> /dev/null &
  33. ;;
  34. save)
  35. mhsave
  36. ;;
  37. restore)
  38. mhrestore
  39. ;;
  40. kill)
  41. ps aux | grep -i monster | awk '{print $2}' | xargs kill -9 &> /dev/null
  42. ;;
  43. *)
  44. echo "unable to process command..."
  45. ;;
  46. esac