Last active
February 20, 2023 17:27
-
-
Save Ryex/3181b84e5b6914218f9a18bded08aa56 to your computer and use it in GitHub Desktop.
This file contains 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 characters
#! /bin/bash | |
anime_flatpak_exists=false | |
anime_flatpak_prefix="$HOME/.var/app/com.gitlab.KRypt0n_.an-anime-game-launcher/data/anime-game-launcher" | |
anime_gtk_flatpak_exists=false | |
anime_gtk_flatpak_prefix="$HOME/.var/app/moe.launcher.an-anime-game-launcher-gtk/data/anime-game-launcher" | |
anime_exists=false | |
anime_prefix="$HOME/.local/share/anime-game-launcher" | |
use_prefix=$anime_prefix | |
if [ -d $anime_flatpak_prefix ] ; then | |
anime_flatpak_exists=true | |
fi | |
if [ -d $anime_gtk_flatpak_prefix ] ; then | |
anime_gtk_flatpak_exists=true | |
fi | |
if [ -d $anime_prefix ] ; then | |
anime_exists=true | |
fi | |
declare -a prefix_choices=() | |
declare -a prefixes=() | |
if $anime_exists ; then | |
prefix_choices+=("An Anime Game Launcher / [GTK]") | |
prefixes+=("$anime_prefix") | |
echo "An Anime Game Launcher / GTK exists (~/.local/share)" | |
fi | |
if $anime_flatpak_exists ; then | |
prefix_choices+=("An Anime Game Launcher Flatpak") | |
prefixes+=("$anime_flatpak_prefix") | |
echo "An Anime Game Launcher Flatpak exists (~/.var/app/com.gitlab...)" | |
fi | |
if $anime_gtk_flatpak_exists ; then | |
prefix_choices+=("An Anime Game Launcher GTK Flatpak") | |
prefixes+=("$anime_gtk_flatpak_prefix") | |
echo "An Anime Game Launcher GTK Flatpak exists (~/.var/app/moe.launcher...)" | |
fi | |
if [ "${#prefix_choices[@]}" == 0 ] ; then | |
RED="\033[0;31m" | |
NC="\033[0m" | |
echo -e "${RED}ERROR:${NC} No Anime Game Launcher installed" | |
exit 1 | |
fi | |
game_prefix=$prefixes | |
if (( "${#prefix_choices[@]}" > 1 )) ; then | |
PS3="Choose the install to pull wish history from: " | |
select choice in "${prefix_choices[@]}" ; do | |
for i in "${!prefix_choices[@]}" ; do | |
if [[ "${prefix_choices[$i]}" = "${choice}" ]] ; then | |
game_prefix="${prefixes[$i]}"; | |
fi | |
done | |
break | |
done | |
fi | |
echo "Pulling wish history from: $game_prefix" | |
history_file="$game_prefix/game/drive_c/Program Files/Genshin Impact/GenshinImpact_Data/webCaches/Cache/Cache_Data/data_2" | |
if [[ ! -f "$history_file" ]] ; then | |
RED="\033[0;31m" | |
NC="\033[0m" | |
echo -e "${RED}ERROR:${NC} History file does not exist, please open your wish history in game." | |
exit 2 | |
fi | |
history_age_hours=$(( ($(date +%s)-$(date -r "$history_file" +%s)) / 60 / 60)) | |
echo "History Age Hours: $history_age_hours" | |
if (( "$history_age_hours" > 2 )) ; then | |
ORANGE="\033[0;33m" | |
NC="\033[0m" | |
echo -e "${ORANGE}WARNING:${NC} Your history file is more then 2 hours old, you probably want to refresh it by opening your wish history in game." | |
fi | |
link=$(strings "$history_file" | grep -o "https://.*/e20190909gacha-v2/.*" | tail -n 1) | |
if [ -z "${link}" ] ; then | |
RED="\033[0;31m" | |
NC="\033[0m" | |
echo -e "${RED}ERROR:${NC} The history link could not be found. please refresh your wish history by opening it in game." | |
exit 3 | |
fi | |
echo $XDG_SESSION_TYPE | |
if [[ -n $DISPLAY ]] ; then | |
if [[ "$XDG_SESSION_TYPE" == "wayland" ]] ; then | |
if command -v wl-copy &> /dev/null ; then | |
copy_command="wl-copy" | |
fi | |
elif [[ "$XDG_SESSION_TYPE" == "x11" ]] ; then | |
if command -v xclip &> /dev/null ; then | |
copy_command="xclip -sel clipit" | |
elif command -v xsel &> /dev/null ; then | |
copy_command="xsel --clipboard" | |
fi | |
fi | |
if [[ -z "$copy_command" ]] ; then | |
echo "WARNING: no copy command installed. please install xclip, xsel, or wl-copy if your running wayland." | |
fi | |
fi | |
if [[ -n "$copy_command" ]] ; then | |
echo $link | $copy_command | |
notify-send "Found link: $link" | |
echo "Copied history link to clipboard" | |
else | |
echo "Link was not copied to you clipboard. No copy command installed or not running in a desktop envierment." | |
fi | |
echo $link |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
idea for
xsel
: doxsel --clipboard -o
. Same forxclip
andwl-copy
, if they have a "copy and also stdout" mode. That way you don't need to echo the link again.