From b00df1aca85c7a2cebb9ac7ab45b55f840149e0a Mon Sep 17 00:00:00 2001 From: totaam Date: Mon, 24 May 2021 12:22:00 +0700 Subject: [PATCH] #3134 make it easier to configure autostart --- setup.py | 2 ++ xpra/exit_codes.py | 2 ++ xpra/platform/features.py | 2 ++ xpra/platform/xposix/features.py | 3 ++- xpra/scripts/main.py | 26 +++++++++++++++++++++++++- 5 files changed, 33 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index b545c0b36a..9a4fec1843 100755 --- a/setup.py +++ b/setup.py @@ -1769,6 +1769,8 @@ def osx_pkgconfig(*pkgs_options, **ekw): if data_ENABLED: add_data_files(share_xpra, ["README.md", "COPYING"]) add_data_files(share_xpra, ["fs/share/xpra/bell.wav"]) + if LINUX: + add_data_files(share_xpra, ["fs/share/xpra/autostart.desktop"]) ICONS = glob.glob("fs/share/xpra/icons/*.png") if OSX: ICONS += glob.glob("fs/share/xpra/icons/*.icns") diff --git a/xpra/exit_codes.py b/xpra/exit_codes.py index 5df6bf42eb..9921252806 100644 --- a/xpra/exit_codes.py +++ b/xpra/exit_codes.py @@ -27,6 +27,7 @@ EXIT_SERVER_ALREADY_EXISTS = 21 EXIT_SOCKET_CREATION_ERROR = 22 EXIT_VFB_ERROR = 23 +EXIT_FILE_NOT_FOUND = 24 EXIT_STR = { @@ -54,4 +55,5 @@ EXIT_SERVER_ALREADY_EXISTS : "SERVER_ALREADY_EXISTS", EXIT_SOCKET_CREATION_ERROR : "SOCKET_CREATION_ERROR", EXIT_VFB_ERROR : "VFB_ERROR", + EXIT_FILE_NOT_FOUND : "FILE_NOT_FOUND", } diff --git a/xpra/platform/features.py b/xpra/platform/features.py index d6a6cfbdc9..49a3be6839 100644 --- a/xpra/platform/features.py +++ b/xpra/platform/features.py @@ -15,6 +15,7 @@ CAN_DAEMONIZE = True SYSTEM_TRAY_SUPPORTED = True REINIT_WINDOWS = False +AUTOSTART = False INPUT_DEVICES = ["auto"] @@ -59,6 +60,7 @@ _features_list_ = [ "LOCAL_SERVERS_SUPPORTED", "SHADOW_SUPPORTED", + "AUTOSTART", "CAN_DAEMONIZE", "SYSTEM_TRAY_SUPPORTED", "REINIT_WINDOWS", diff --git a/xpra/platform/xposix/features.py b/xpra/platform/xposix/features.py index 831afdf9e3..11c582ab11 100644 --- a/xpra/platform/xposix/features.py +++ b/xpra/platform/xposix/features.py @@ -10,7 +10,8 @@ SYSTEM_TRAY_SUPPORTED = not is_unity() LOCAL_SERVERS_SUPPORTED = True -SHADOW_SUPPORTED = True +SHADOW_SUPPORTED = True# +AUTOSTART = True DEFAULT_ENV = [ "#avoid Ubuntu's global menu, which is a mess and cannot be forwarded:", diff --git a/xpra/scripts/main.py b/xpra/scripts/main.py index ccff533830..6c553dcf95 100755 --- a/xpra/scripts/main.py +++ b/xpra/scripts/main.py @@ -171,6 +171,7 @@ def configure_logging(options, mode): "clean-displays", "clean-sockets", "splash", "qrcode", "opengl-test", + "autostart", "encoding", "webcam", "clipboard-test", "keyboard", "keyboard-test", "keymap", "gui-info", "network-info", "path-info", "printing-info", "version-info", "gtk-info", @@ -351,7 +352,7 @@ def use_systemd_run(s): def run_mode(script_file, error_cb, options, args, mode, defaults): #configure default logging handler: - if POSIX and getuid()==0 and options.uid==0 and mode!="proxy" and not NO_ROOT_WARNING: + if POSIX and getuid()==0 and options.uid==0 and mode not in ("proxy", "autostart", "showconfig") and not NO_ROOT_WARNING: warn("\nWarning: running as root") display_is_remote = isdisplaytype(args, "ssh", "tcp", "ssl", "vsock") @@ -525,6 +526,8 @@ def do_run_mode(script_file, error_cb, options, args, mode, defaults): elif mode=="opengl-test": check_gtk() return run_glprobe(options, True) + elif mode=="autostart": + return run_autostart(args) elif mode=="encoding": from xpra.codecs import loader return loader.main(args) @@ -2499,6 +2502,27 @@ def no_gtk(): raise InitException("the Gtk module is already loaded: %s" % Gtk) +def run_autostart(args): + def err(msg): + print(msg) + print("Usage: %s enable|disable|status" % (sys.argv[0])) + return 1 + if len(args)!=1: + return err("invalid number of arguments") + arg = args[0].lower() + if arg not in ("enable", "disable", "status"): + return err("invalid argument '%s'" % arg) + from xpra.platform.features import AUTOSTART + if not AUTOSTART: + print("autostart is not supported on this platform") + return 1 + from xpra.platform.autostart import set_autostart, get_status + if arg=="status": + print(get_status()) + else: + set_autostart(arg=="enable") + return 0 + def run_qrcode(args): from xpra.client.gtk3 import qrcode_client return qrcode_client.main(args)