Fix reading session from STDIN not working when used with --single-instance

Fixes #4155
This commit is contained in:
Kovid Goyal 2021-10-28 17:00:54 +05:30
parent 1251f9ec80
commit 21830048c9
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 7 additions and 1 deletions

View File

@ -468,6 +468,9 @@ class Boss:
args, rest = parse_args(data['args'][1:], result_class=CLIOptions)
args.args = rest
opts = create_opts(args)
if args.session == '-':
from .session import PreReadSession
args.session = PreReadSession(data['stdin'])
if not os.path.isabs(args.directory):
args.directory = os.path.join(data['cwd'], args.directory)
for session in create_sessions(opts, args, respect_cwd=True):

View File

@ -56,9 +56,12 @@ def set_custom_ibeam_cursor() -> None:
def talk_to_instance(args: CLIOptions) -> None:
import json
import socket
stdin = ''
if args.session == '-':
stdin = sys.stdin.read()
data = {'cmd': 'new_instance', 'args': tuple(sys.argv),
'startup_id': os.environ.get('DESKTOP_STARTUP_ID'),
'cwd': os.getcwd()}
'cwd': os.getcwd(), 'stdin': stdin}
notify_socket = None
if args.wait_for_single_instance_window_close:
address = f'\0{appname}-os-window-close-notify-{os.getpid()}-{os.geteuid()}'