Skip to content

Commit

Permalink
#3134 make it easier to configure autostart
Browse files Browse the repository at this point in the history
  • Loading branch information
totaam committed May 24, 2021
1 parent b771a6b commit b00df1a
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 2 deletions.
2 changes: 2 additions & 0 deletions setup.py
Expand Up @@ -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")
Expand Down
2 changes: 2 additions & 0 deletions xpra/exit_codes.py
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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",
}
2 changes: 2 additions & 0 deletions xpra/platform/features.py
Expand Up @@ -15,6 +15,7 @@
CAN_DAEMONIZE = True
SYSTEM_TRAY_SUPPORTED = True
REINIT_WINDOWS = False
AUTOSTART = False

INPUT_DEVICES = ["auto"]

Expand Down Expand Up @@ -59,6 +60,7 @@
_features_list_ = [
"LOCAL_SERVERS_SUPPORTED",
"SHADOW_SUPPORTED",
"AUTOSTART",
"CAN_DAEMONIZE",
"SYSTEM_TRAY_SUPPORTED",
"REINIT_WINDOWS",
Expand Down
3 changes: 2 additions & 1 deletion xpra/platform/xposix/features.py
Expand Up @@ -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:",
Expand Down
26 changes: 25 additions & 1 deletion xpra/scripts/main.py
Expand Up @@ -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",
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit b00df1a

Please sign in to comment.