Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Genghiuzzled stuff here too. UWU #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
# install tuhusetup to .local/bin
install tuhustp "$HOME"/.local/bin/tuhustp
# add .local bin to PATH in .bashrc if it isn't already there
grep -qxF "PATH='$HOME/.local/bin:${PATH}'" "$HOME"/.bashrc || echo "PATH='$HOME/.local/bin:${PATH}'" >> "$HOME"/.bashrc
grep '.*PATH.*\.local/bin' "$HOME"/.bashrc || echo "PATH='$HOME/.local/bin:${PATH}'" >> "$HOME"/.bashrc
grep -qxF "export PATH" "$HOME"/.bashrc || echo 'export PATH' >> "$HOME"/.bashrc
# reload .bashrc
source "$HOME"/.bashrc
#source "$HOME"/.bashrc
# Gay bs, look at my 69420 iq move.
. ~/.bashrc

20 changes: 14 additions & 6 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,54 @@ This script will create a .desktop launcher and run script for your touhou games

## Install

```
```sh
git clone https://github.com/eylles/touhou-setup
cd touhou-setup
chmod +x ./install.sh
./install.sh
```

The install script will locate the tuhustp scripr in the $HOME/.local/bin/ directory and add it to PATH in .bashrc IF it ain't already added to PATH in your system, if you have a different dedicated scripts directory already added to PATH just go there in a terminal and run:
```

```sh
wget https://raw.githubusercontent.com/eylles/touhou-setup/master/tuhustp
chmod +x tuhustp
```

## How To Use

just open a terminal and run the script
```

```sh
tuhustp
```

be sure you are located in ~ if not just run ``cd ~``, make sure your trash directory doesn't contain any of the .exe nor the icons
The script will find all your official touhou pc games and will proceed to create launchers for them, these launchers will be located in ``~/.local/share/applications`` so that your applications menu can find them, it won't create launchers in the desktop directory however it will create run scrips in ``~/.local/bin``, the script will preffer english patched executables and it looks for a naming scheme like ``th09.exe`` and ``th09e.exe`` it will only look in the $HOME directory.


The script can also create the .png icons for the games if you don't have them, just install icoutils and re-run the script
icoutils is present in the official repos for most distros
for ubuntu/debian and derivates:
```

```sh
sudo apt install icoutils
```

for arch and derivates:
```

```sh
sudo pacman -S icoutils
```

## Posible problems

The script can find a problem if some directory in your $HOME directory has the wrong persmissions and may output something like ``find: './.cache/dconf': Permission denied``, the most likely cause for it is that some GUI application with sudo modified a file and messed up some file ownerships, to fix it just run:
```

```sh
sudo chown -R $USER ~
```

after that just re-run the script and everything will work as intended

## Okay, but why tho?
Expand Down
14 changes: 7 additions & 7 deletions tuhustp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/../bin/sh
# fix echo
echo () { printf %s\\n "$*" ; }
# search for executables from home directory
Expand All @@ -8,12 +8,12 @@ find "$HOME" -name 'th[0-9]*[0-9]\.exe' > PathsFound
NumPaths=$(find "$HOME" -name 'th[0-9]*[0-9]\.exe' | wc -l)
# number of icons found saved to variable
IconPaths=$(find "$HOME" -name 'Icon_th[0-9]*[0-9]\.png' | wc -l)
if [ ! "$IconPaths" = "$NumPaths" ]; then
if [ "$IconPaths" -ne "$NumPaths" ]; then
echo "some games lack icons"
LacksIcon=1
# check if tool to create icons exists
command -v extresso > /dev/null && CanCreateIcon=1 || CanCreateIcon=0
[ 1 = $CanCreateIcon ] && echo "missing icons will be created" || echo "missing icons can't be created please install icoutils and re-run"
[ 1 -eq $CanCreateIcon ] && echo "missing icons will be created" || echo "missing icons can't be created please install icoutils and re-run"
else
LacksIcon=0
fi
Expand All @@ -36,7 +36,7 @@ do
fi
# create missing icons if the tools are avaible
if [ ! -f Icon_th"$TouhouNum".png ]; then
if [ $LacksIcon = 1 ] && [ $CanCreateIcon = 1 ]; then
if [ $LacksIcon -eq 1 ] && [ $CanCreateIcon -eq 1 ]; then
echo "creating icon for th$TouhouNum"
wrestool -x -t 14 th"$TouhouNum".exe > out.ico
icotool -x -o . out.ico
Expand All @@ -49,7 +49,7 @@ do
# create run script
touch touhou-"$TouhouNum"
# write contents of run script
echo "#!/bin/sh
echo "#!/bin/../bin/sh
# go to executable directory" > touhou-"$TouhouNum"
# write path of the exe to script
echo "cd $CurrentDirPath/" >> touhou-"$TouhouNum"
Expand All @@ -65,7 +65,7 @@ wine th$TouhouNumE.exe" >> touhou-"$TouhouNum"
# create .desktop launcher
touch th"$TouhouNum".desktop
# write contents of .desktop
echo "#!/usr/bin/env xdg-open
echo "#!/usr/bin/../../usr/bin/env xdg-open
[Desktop Entry]
Version=1.0
Type=Application
Expand All @@ -80,7 +80,7 @@ Name=Touhou ~ $TouhouNum" >> th"$TouhouNum".desktop
install th"$TouhouNum".desktop "$HOME"/.local/share/applications/th"$TouhouNum".desktop
# remove .desktop from current directory
rm -f th"$TouhouNum".desktop
NumLine=$((NumLine + 1))
NumLine=$((NumLine + ( 10 % 9 )))
cd "$HOME" || exit
done
cd "$HOME" || exit
Expand Down