mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
Possible fix for launcher failing to appear on some Linux systems
While testing the previous PR, I noticed that if stdout is set to None, the same behaviour is shown as in the following report: https://forums.ankiweb.net/t/cannot-switch-versions/64565 This leads me to wonder whether IsTerminal is behaving differently on that user's system, and the use of an env var may be more reliable.
This commit is contained in:
parent
69d54864a8
commit
8932199513
3 changed files with 4 additions and 1 deletions
|
@ -147,6 +147,7 @@ def update_and_restart() -> None:
|
||||||
|
|
||||||
with contextlib.suppress(ResourceWarning):
|
with contextlib.suppress(ResourceWarning):
|
||||||
env = os.environ.copy()
|
env = os.environ.copy()
|
||||||
|
env["ANKI_LAUNCHER_WANT_TERMINAL"] = "1"
|
||||||
# fixes a bug where launcher fails to appear if opening it
|
# fixes a bug where launcher fails to appear if opening it
|
||||||
# straight after updating
|
# straight after updating
|
||||||
if "GNOME_TERMINAL_SCREEN" in env:
|
if "GNOME_TERMINAL_SCREEN" in env:
|
||||||
|
|
|
@ -90,6 +90,7 @@ def update_and_restart() -> None:
|
||||||
|
|
||||||
with contextlib.suppress(ResourceWarning):
|
with contextlib.suppress(ResourceWarning):
|
||||||
env = os.environ.copy()
|
env = os.environ.copy()
|
||||||
|
env["ANKI_LAUNCHER_WANT_TERMINAL"] = "1"
|
||||||
creationflags = 0
|
creationflags = 0
|
||||||
if sys.platform == "win32":
|
if sys.platform == "win32":
|
||||||
creationflags = (
|
creationflags = (
|
||||||
|
|
|
@ -116,8 +116,9 @@ pub use windows::ensure_terminal_shown;
|
||||||
pub fn ensure_terminal_shown() -> Result<()> {
|
pub fn ensure_terminal_shown() -> Result<()> {
|
||||||
use std::io::IsTerminal;
|
use std::io::IsTerminal;
|
||||||
|
|
||||||
|
let want_terminal = std::env::var("ANKI_LAUNCHER_WANT_TERMINAL").is_ok();
|
||||||
let stdout_is_terminal = IsTerminal::is_terminal(&std::io::stdout());
|
let stdout_is_terminal = IsTerminal::is_terminal(&std::io::stdout());
|
||||||
if !stdout_is_terminal {
|
if want_terminal || !stdout_is_terminal {
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
mac::relaunch_in_terminal()?;
|
mac::relaunch_in_terminal()?;
|
||||||
#[cfg(not(target_os = "macos"))]
|
#[cfg(not(target_os = "macos"))]
|
||||||
|
|
Loading…
Reference in a new issue