[
  {
    "path": "README.md",
    "content": "# steamdeck_startup_animations\nA collection of steamdeck startup animations, plus a script to randomize your startup on each boot\n\n# So far, I've made boot animations from the following consoles:\n\n* dreamcast\n* ps1\n* ps2\n* ps4\n* switch\n* gamecube\n* ps2\n* switchfirst (first boot animation)\n* switch (regular boot animation)\n* xbox\n* xbox 360\n* xbox one\n\n# Installation\n\n```sh\ncurl -o - https://raw.githubusercontent.com/kageurufu/steamdeck_startup_animations/main/install.sh | bash -\n```\n\nIf you're (justifiably) not a fan of `curl | bash`, you can run this:\n\n```sh\nmkdir -p \"$HOME/homebrew\"\nmkdir -p \"$HOME/.config/systemd/user\"\ngit clone https://github.com/kageurufu/steamdeck_startup_animations \"$HOME/homebrew/startup_animations\"\nln -sf \"$HOME/homebrew/startup_animations/randomize_deck_startup.service\" \"$HOME/.config/systemd/user/randomize_deck_startup.service\"\nsystemctl --user daemon-reload\nsystemctl --user enable --now randomize_deck_startup.service\n```\n\n# Uninstallation\n\n```sh\nbash $HOME/homebrew/startup_animations/uninstall.sh\n```\n\n# Making an animation (somewhat advanced)\n\nI used youtube-dl to grab the best video and audio tracks from youtube, and then ffmpeg to merge them, resizing down to fit the Deck's 1280x800 screen. Then I use `truncate` to make the file the right size. \n\nThis all does work on the steamdeck\n\n### Getting the dependencies\n\n```sh\npython3 -m ensurepip\n~/.local/bin/pip install --user youtube-dl\n```\n\n### Creating the animation\n\n```sh\n# Get ps1.webm and ps1.m4a. Your file extensions may differ here\n~/.local/bin/youtube-dl -f bestvideo -o 'ps1.%(ext)s' https://www.youtube.com/watch?v=1JwbfIi5Uio\n~/.local/bin/youtube-dl -f bestaudio -o 'ps1.%(ext)s' https://www.youtube.com/watch?v=1JwbfIi5Uio\n\n# Convert the video from whatever input formats to a webm video in VP9 encoding, with vorbis encoded audio\nffmpeg -i ps1.webm -i ps1.m4a \\\n       -map 0:v:0  -map 1:a:0 \\\n       -filter:v \"scale='min(1280,iw)':min'(800,ih)':force_original_aspect_ratio=decrease,pad=1280:800:(ow-iw)/2:(oh-ih)/2\" \\\n       -c:v vp9 \\\n       -c:a libvorbis \\\n       my_deck_startup_ps1.webm\n\n# Make sure the generated file is less than 1840847B here\n# Mine was `389670`, plenty small enough\nstat -c '%s' my_deck_startup_ps1.webm\n\ntruncate -s 1840847 my_deck_startup_ps1.webm\n```\n\nThe ffmpeg command is a bit confusing, so heres a breakdown\n\n* `-i ps1.webm -i ps1.m4a`  \n  Load both the video and audio files we downloaded.\n* `-map 0:v:0  -map 1:a:0`  \n  Only use the first video stream from the first file, and first audio stream from the second.  \n  This prevents having multiple video or audio streams in the final file\n* `-filter:v \"scale='min(1280,iw)':min'(800,ih)':force_original_aspect_ratio=decrease,pad=1280:800:(ow-iw)/2:(oh-ih)/2\"`  \n  This is most confusing part, basically we're resizing the video to fit 1280x800  \n  `min'(1280,iw)':min'(800,ih)'` ensures the target size is never upscaled  \n  `force_original_aspect_ratio=decrease` scales to fit within a given size, keeping the original aspect ratio  \n  `pad=1280:800:(ow-iw)/2:(oh-ih)/2` pad the video size to 1280:800, centering the original video. This is optional and I might not use it in the future\n* `-c:v vp9 c:a libvorbis` Select our output VP9 / vorbis codecs\n\n \n"
  },
  {
    "path": "install.sh",
    "content": "#!/usr/bin/env bash\n\n# Create required directories\necho \":: Creating required directories\"\nmkdir -p \"$HOME/homebrew\"\nmkdir -p \"$HOME/.config/systemd/user\"\n\n# Clone the startup animations repository\nif [[ ! -d \"$HOME/homebrew/startup_animations\" ]]; then\n  echo \":: Installing to $HOME/homebrew/startup_animations\"\n  git clone https://github.com/kageurufu/steamdeck_startup_animations \"$HOME/homebrew/startup_animations\"\n  cd \"$HOME/homebrew/startup_animations\"\nelse\n  echo \":: Updating $HOME/homebrew/startup_animations\"\n  cd \"$HOME/homebrew/startup_animations\"\n  git pull\nfi\n\n# Install the service file\necho \":: Installing the startup service\"\nln -sf \"$HOME/homebrew/startup_animations/randomize_deck_startup.service\" \"$HOME/.config/systemd/user/randomize_deck_startup.service\"\nsystemctl --user daemon-reload\nsystemctl --user enable --now randomize_deck_startup.service\n\n"
  },
  {
    "path": "randomize_deck_startup.service",
    "content": "[Unit]\nDescription=Randomize deck_startup.webm after boot\n\n[Install]\nWantedBy=default.target\n\n[Service]\nType=oneshot\nWorkingDirectory=/home/deck/homebrew/startup_animations\n# ExecStartPre=/bin/sleep 30\nExecStart=/home/deck/homebrew/startup_animations/randomize_deck_startup.sh\n"
  },
  {
    "path": "randomize_deck_startup.sh",
    "content": "#!/usr/bin/env bash\n\nColor_Off='\\033[0m'       # Text Reset\n\n# Regular Colors\nBlack='\\033[0;30m'        # Black\nRed='\\033[0;31m'          # Red\nGreen='\\033[0;32m'        # Green\nYellow='\\033[0;33m'       # Yellow\nBlue='\\033[0;34m'         # Blue\nPurple='\\033[0;35m'       # Purple\nCyan='\\033[0;36m'         # Cyan\nWhite='\\033[0;37m'        # White\n\nmsg() {\n  echo -e \":: ${*}$Color_Off\"\n}\n\nmsg2() {\n  echo -e \"$Red!!$Color_Off ${*}$Color_Off\"\n}\n\nDECK_UIOVERRIDES=\"/home/deck/.steam/root/config/uioverrides\"\nDECK_UIOVERRIDES_MOVIES=\"${DECK_UIOVERRIDES}/movies\"\nDECK_UIOVERRIDES_STARTUP=\"${DECK_UIOVERRIDES_MOVIES}/deck_startup.webm\"\n\nrestore_backup() {\n  DECK_STARTUP_FILE=\"/home/deck/.steam/steam/steamui/movies/deck_startup.webm\"\n  DECK_STARTUP_STOCK_MD5=\"4ee82f478313cf74010fc22501b40729\"\n\n  if [[ -f \"$DECK_STARTUP_FILE.backup\" ]]; then\n    checksum=\"$(md5sum \"$DECK_STARTUP_FILE\" | cut -d ' ' -f 1)\"\n    if [[ \"$checksum\" != \"$DECK_STARTUP_STOCK_MD5\" ]]; then\n      rm \"$DECK_STARTUP_FILE\"\n      mv \"$DECK_STARTUP_FILE.backup\" \"$DECK_STARTUP_FILE\"\n    fi\n\n    rm \"$DECK_STARTUP_FILE.backup\"\n  fi\n}\n\nlist_animations() {\n  find deck_startup/ -type f -iname '*.webm' -print0\n}\n\nrandom_animation() {\n  mapfile -d $'\\0' animations < <(list_animations)\n  echo \"${animations[$RANDOM % ${#animations[@]}]}\"\n}\n\nrestore_backup\n\nanimation=\"$(random_animation)\"\nmsg \"Using $animation\"\nmkdir -p \"${DECK_UIOVERRIDES_MOVIES}\"\nln -f \"$animation\" \"$DECK_UIOVERRIDES_STARTUP\"\n\n"
  },
  {
    "path": "uninstall.sh",
    "content": "#!/usr/bin/env bash\n\nif [[ -e \"$HOME/.config/systemd/user/randomize_deck_startup.service\" ]]; then\n  echo \":: Removing the boot service\"\n  systemctl --user disable randomize_deck_startup.service\n  rm \"$HOME/.config/systemd/user/randomize_deck_startup.service\"\nfi\n\nif [[ -f \"$HOME/.steam/steam/steamui/movies/deck_startup.webm.backup\" ]]; then\n  echo \":: Restoring deck_startup.webm.backup\"\n  rm \"$HOME/.steam/steam/steamui/movies/deck_startup.webm\"\n  mv \"$HOME/.steam/steam/steamui/movies/deck_startup.webm.backup\" \"$HOME/.steam/steam/steamui/movies/deck_startup.webm\"\nfi\n\nif [[ -L \"$HOME/.steam/root/config/uioverrides/movies/deck_startup.webm\" ]]; then\n  rm \"$HOME/.steam/root/config/uioverrides/movies/deck_startup.webm\"\nfi\n\nif [[ -e \"$HOME/homebrew/startup_animations\" ]]; then\n  echo \":: Deleting the startup_animations directory\"\n  rm -rf \"$HOME/homebrew/startup_animations\"\nfi\n\n"
  }
]