Skip to content

Commit

Permalink
Additional fixes for WSLg and Ubuntu 20.04
Browse files Browse the repository at this point in the history
  • Loading branch information
Avasam committed Jun 17, 2024
1 parent d9b0adb commit 6193f47
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 21 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ To understand how to use AutoSplit and how it works in-depth, please read the [t
### Compatibility

- Windows 10 and 11.
- Linux (still in early development) <!-- (Only tested on Ubuntu 22.04) -->
- Linux (still in early development)
- Should work on Ubuntu 20.04+ (Only tested on Ubuntu 22.04)
- Wayland is not currently supported
- WSL2/WSLg requires an additional Desktop Environment, external X11 server, and/or systemd
- Python 3.10+ (Not required for normal use. Refer to the [build instructions](/docs/build%20instructions.md) if you'd like run the application directly in Python).
Expand Down
11 changes: 2 additions & 9 deletions scripts/install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ $dev = If ($Env:GITHUB_JOB -eq 'Build') { '' } Else { '-dev' }
If ($IsLinux) {
If (-not $Env:GITHUB_JOB -or $Env:GITHUB_JOB -eq 'Build') {
sudo apt-get update
# python3-tk for splash screen the rest for PySide6
sudo apt-get install -y python3-pip python3-tk libegl1 libxkbcommon0
# python3-tk for splash screen, libxcb-cursor-dev for QT_QPA_PLATFORM=xcb, the rest for PySide6
sudo apt-get install -y python3-pip python3-tk libxcb-cursor-dev libegl1 libxkbcommon0
# having issues with npm for pyright, maybe let users take care of it themselves? (pyright from pip)
}
}
Expand All @@ -52,13 +52,6 @@ If ($IsLinux) {
# Even then, PyPI with Pillow>=7.2.0 will install 0.1.3 instead of 0.1.5
&"$python" -m pip install PyAutoGUI "D3DShot>=0.1.5 ; sys_platform == 'win32'" --no-deps --upgrade

# Because Ubuntu 22.04 is forced to use an older version of PySide6, we do a dirty typing patch
# https://bugreports.qt.io/browse/QTBUG-114635
If ($IsLinux) {
$libPath = &"$python" -c 'import PySide6 as _; print(_.__path__[0])'
(Get-Content "$libPath/QtWidgets.pyi").replace('-> Tuple:', '-> Tuple[str, ...]:') |
Set-Content "$libPath/QtWidgets.pyi"
}
# Uninstall optional dependencies if PyAutoGUI or D3DShot was installed outside this script
# PyScreeze -> pyscreenshot -> mss deps call SetProcessDpiAwareness, used to be installed on Windows
# Pillow, pygetwindow, pymsgbox, pytweening, MouseInfo are picked up by PySide6
Expand Down
10 changes: 6 additions & 4 deletions src/AutoSplit.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/python3

import os
import sys

# Prevent PyAutoGUI and pywinctl from setting Process DPI Awareness, which Qt tries to do then throws warnings about it.
Expand All @@ -15,14 +16,16 @@
ctypes.windll.shcore.SetProcessDpiAwareness = ( # pyright: ignore[reportAttributeAccessIssue]
lambda _: None # pyright: ignore[reportUnknownLambdaType]
)
if sys.platform == "linux":
# Fixes "undefined symbol: wl_proxy_marshal_flags": https://bugreports.qt.io/browse/QTBUG-114635
os.environ.setdefault("QT_QPA_PLATFORM", "xcb")

import os
import signal
from collections.abc import Callable
from copy import deepcopy
from time import time
from types import FunctionType
from typing import NoReturn, cast
from typing import NoReturn

import cv2
from cv2.typing import MatLike
Expand Down Expand Up @@ -967,8 +970,7 @@ def set_preview_image(qlabel: QLabel, image: MatLike | None):
capture = image

qimage = QtGui.QImage(
# Try to update PySide6, see https://bugreports.qt.io/browse/QTBUG-114635
cast(bytes, capture.data) if sys.platform == "linux" else capture.data,
capture.data,
width,
height,
width * channels,
Expand Down
8 changes: 1 addition & 7 deletions src/region_selection.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import os
import sys
from math import ceil
from typing import TYPE_CHECKING
Expand All @@ -8,6 +7,7 @@
from cv2.typing import MatLike, Point
from PySide6 import QtCore, QtGui, QtWidgets
from PySide6.QtTest import QTest
from pywinctl import getTopWindowAt
from typing_extensions import override

import error_messages
Expand All @@ -33,12 +33,6 @@
if sys.platform == "linux":
from Xlib.display import Display

# This variable may be missing in desktopless environment. x11 | wayland
os.environ.setdefault("XDG_SESSION_TYPE", "x11")

# Must come after the linux XDG_SESSION_TYPE environment variable is set
from pywinctl import getTopWindowAt

if TYPE_CHECKING:
from AutoSplit import AutoSplit

Expand Down

0 comments on commit 6193f47

Please sign in to comment.