Skip to content

Commit

Permalink
Fixed Launchers Detection on LInux
Browse files Browse the repository at this point in the history
  • Loading branch information
Aspirata committed Oct 9, 2024
1 parent ec505c4 commit e92d551
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 5 deletions.
7 changes: 7 additions & 0 deletions Launch_with_console.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

BLEND_FILE="$SCRIPT_DIR/MiBlend.blend"

blender "$BLEND_FILE"
Binary file modified MiBlend.blend
Binary file not shown.
1 change: 1 addition & 0 deletions MiBlend_Source/Materials/Materials.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,7 @@ def setproceduralpbr():
pspecular_node = None
PNormals = None
ITexture_Animator = None
auvf_node = None
Texture_Animator = None
image_difference_X = 1
image_difference_Y = 1
Expand Down
24 changes: 19 additions & 5 deletions MiBlend_Source/Resource_Packs.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,19 @@ def set_resource_packs(resource_packs):
dprint(f"Resource Packs: {bpy.context.scene['resource_packs']}")

Launchers = {
"Mojang": ".minecraft\\versions",
"New_Modrinth": "ModrinthApp\\meta\\versions",
"Old_Modrinth": "com.modrinth.theseus\\meta\\versions",
"TL Legacy": ".tlauncher\\legacy\\Minecraft\\game\\versions",
"Windows":{
"Mojang": ".minecraft\\versions",
"New_Modrinth": "ModrinthApp\\meta\\versions",
"Old_Modrinth": "com.modrinth.theseus\\meta\\versions",
"TL Legacy": ".tlauncher\\legacy\\Minecraft\\game\\versions",
},

"Linux": {
"Mojang": "Unknown",
"New_Modrinth": ".local/share/ModrinthApp/meta/versions",
"Old_Modrinth": "Unknown",
"TL Legacy": "Unknown",
}
}

def update_default_pack():
Expand All @@ -32,12 +41,16 @@ def version_formatter(version_name: str) -> str:

def find_mc() -> tuple[str, str]:
versions = {}
current_os = "Linux" if sys.platform.startswith('linux') else "Windows"
os_env = os.getenv("HOME") if sys.platform.startswith('linux') else os.getenv('APPDATA')

for launcher, path in Launchers.items():
for launcher, path in Launchers.get(current_os).items():
if path == "Unknown":
continue
folders = os.path.join(os_env, path)
if os.path.isdir(folders):
for folder in os.listdir(folders):
instance_path = None
if (version := version_formatter(folder)) and os.path.isfile(instance_path := os.path.join(os_env, path, folder, f"{folder}.jar")):
versions[version] = (folder, os.path.join(os_env, path))
dprint(f"{instance_path} valid")
Expand All @@ -48,6 +61,7 @@ def find_mc() -> tuple[str, str]:
folders = Preferences.mc_instances_path
if os.path.isdir(folders):
for folder in os.listdir(folders):
instance_path = None
if (version := version_formatter(folder)) and os.path.isfile(instance_path := os.path.join(Preferences.mc_instances_path, folder, f"{folder}.jar")):
versions[version] = (folder, Preferences.mc_instances_path)
dprint(f"{instance_path} valid")
Expand Down
28 changes: 28 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

bab

target_file="MiBlend.blend"

process_info=$(ps aux | grep -v grep | grep "blender")

if [[ -n "$process_info" ]]; then
file_path=$(echo "$process_info" | awk '{for(i=12;i<=NF;i++) printf $i" ";}' | xargs)

echo "Найден процесс Blender с аргументами: $file_path"

if [[ "$file_path" == *"$target_file"* ]]; then
echo "Файл $target_file открыт в Blender. Перезапускаем Blender..."

blender_pid=$(echo "$process_info" | awk '{print $2}')
kill "$blender_pid"

while kill -0 "$blender_pid" 2>/dev/null; do
echo "Ожидание завершения процесса Blender..."
done

fi
echo "Процесс Blender завершен."
else
echo "Blender не запущен."
fi

0 comments on commit e92d551

Please sign in to comment.