Skip to content

Commit e88006f

Browse files
committed
version 1.4.1
changed subprocess.run() to os.system() in highlight_sender, and added operating system checks
1 parent 3bf9e65 commit e88006f

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

h2o/highlight_sender.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22
import subprocess
3+
import sys
34
import time
45
import webbrowser
56
from typing import Dict, List, Callable, Any, Tuple, Iterable, Union
@@ -25,12 +26,15 @@ def send_item_to_obsidian(obsidian_data: Dict[str, str]) -> None:
2526
try:
2627
if prefs['use_xdg_open']:
2728
# this is to avoid a bug on linux, where the uri is opened in web browser instead of Obsidian
28-
# on windows, this only gives a good error message if shell=True. i need to know what it
29-
# does on Linux and Mac.
30-
subprocess.run(['xdg-open', uri], check=True, shell=True)
31-
32-
# can't use os.system, since it doesn't give an error message when you try to xdg-open on windows
33-
# os.system(f'xdg-open \"{uri}\"')
29+
# https://docs.python.org/3/library/sys.html#sys.platform
30+
if sys.platform.startswith('win32'):
31+
raise NotImplementedError("Can't use xdg-open on Windows, see settings")
32+
elif sys.platform.startswith('darwin'):
33+
raise NotImplementedError("Can't use xdg-open on Mac, see settings")
34+
else:
35+
# probably a linux or unix os
36+
os.system(f'xdg-open \"{uri}\"')
37+
# using subprocess.run() doesn't seem to work
3438
else:
3539
# it might actually be better to do away with webbrowser.open() and only use os.system(). that might fix
3640
# the problem of needing to limit the max file size. would need to add support for each operating system.

0 commit comments

Comments
 (0)