Skip to content

Commit 3fdeb73

Browse files
committed
Experimental linux support
1 parent 1aa1976 commit 3fdeb73

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

gui.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@
1010
import tkinter as tk
1111
from collections import abc
1212
from math import log10, ceil
13-
from subprocess import CREATE_NO_WINDOW
1413
from tkinter.font import Font, nametofont
1514
from functools import partial, cached_property
1615
from datetime import datetime, timedelta, timezone
1716
from tkinter import Tk, ttk, StringVar, DoubleVar, IntVar, PhotoImage
1817
from typing import Any, Union, Tuple, TypedDict, NoReturn, Generic, TYPE_CHECKING
1918

19+
if sys.platform == "win32":
20+
from subprocess import CREATE_NO_WINDOW
21+
2022
import pystray
2123
import win32api
2224
import win32con
@@ -497,14 +499,16 @@ async def ask_login(self) -> str:
497499
options.add_argument(f"--proxy-server={self._manager._twitch.settings.proxy}")
498500
options.set_capability("pageLoadStrategy", "eager")
499501
try:
502+
kwargs = {}
503+
if sys.platform == "win32":
504+
kwargs["service_creationflags"] = CREATE_NO_WINDOW
500505
driver_coro = loop.run_in_executor(
501506
None,
502507
lambda: Chrome(
503508
options=options,
504509
suppress_welcome=True,
505510
version_main=version_main,
506-
service_creationflags=CREATE_NO_WINDOW,
507-
# user_data_dir=str(CACHE_PATH.joinpath("ChromeProfile")),
511+
**kwargs,
508512
)
509513
)
510514
driver = await self._manager.coro_unless_closed(driver_coro)

main.py

+12-9
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@
3333
try:
3434
import win32gui # noqa
3535
except ModuleNotFoundError as exc:
36-
raise ImportError("You have to run 'pip install pywin32' first") from exc
36+
if sys.platform == "win32":
37+
raise ImportError("You have to run 'pip install pywin32' first") from exc
38+
# ignore for linux
3739

3840
from translate import _
3941
from twitch import Twitch
@@ -137,14 +139,15 @@ def debug_gql(self) -> int:
137139
root.destroy()
138140

139141
# check if we're not already running
140-
try:
141-
exists = win32gui.FindWindow(None, WINDOW_TITLE)
142-
except AttributeError:
143-
# we're not on Windows - continue
144-
exists = False
145-
if exists and not settings.no_run_check:
146-
# already running - exit
147-
sys.exit(3)
142+
if sys.platform == "win32":
143+
try:
144+
exists = win32gui.FindWindow(None, WINDOW_TITLE)
145+
except AttributeError:
146+
# we're not on Windows - continue
147+
exists = False
148+
if exists and not settings.no_run_check:
149+
# already running - exit
150+
sys.exit(3)
148151

149152
# set language
150153
try:

0 commit comments

Comments
 (0)