XDG-LAUNCH(1)
π xdg-launch π β that's section 1 of the User Commands manual, bestie
okay so, real talk: this is the manual page for xdg-launch, section 1, User Commands. Let's get into it β¨
πΈ NAME πΈ
xdg-launch β an XDG compliant startup notification launcher π
β¨ SYNOPSIS β¨
like, here's every single way you can call her:
xdg-launch [OPTIONS] [APPSPEC [FILE|URL]...|COMMAND]
xdg-launch {-U|--autostart} [OPTIONS] [APPID|DESKTOP|COMMAND]
xdg-launch {-X|--xsession} [OPTIONS] [ACTID|DESKTOP|COMMAND]
xdg-launch {-E|--startup} [OPTIONS] [ACTID|DESKTOP|COMMAND]
xdg-launch {-E|--session} [OPTIONS] [ACTID|DESKTOP|COMMAND]
xdg-launch {-h|--help} [OPTIONS] [APPSPEC [FILE|URL]...|COMMAND]
xdg-launch {-V|--version}
xdg-launch {-C|--copying}
π DESCRIPTION π
xdg-launch is a "C" language program (yes, an actual compiled icon π
) that you can use to launch XDG desktop applications with startup notification. The way it does this: you can launch applications by application id, by mime type, by menu category, or by command line. And if you want, you can hand it a file or a URL too. Obsessed, honestly. π¦
π ARGUMENTS π
The program accepts the following arguments (yes, all of them, I'm not skipping a single one):
β APPSPEC = {ACTID|MIMETYPE|CATEGORY|DESKTOP}
Specifies the XDG desktop application to launch. The application specifier, APPSPEC, can be one of the following:
π« ACTID = APPID[:ACTION]
Specifies the application identifier and optional action of an XDG desktop application to launch.
[{-a,--appid}]APPID Specifies the application identifier of an XDG desktop application to launch. The application identifier, APPID, can be one of the following:- The name of a desktop entry file without the
.desktopsuffix (e.g."gvim"); the name may contain a"/"if it is specified relative to a user or system application directory, in which case it must not start with a"/"or".". - The name of a desktop entry file with the
.desktopsuffix (e.g."gvim.desktop"); the same restrictions as (1), above, apply; or, - The full path (absolute or relative) and file name of a desktop entry file (e.g.
/usr/share/applications/gvim.desktop); the full path must contain at least one"/"and start with either a"/"or a".".
- The name of a desktop entry file without the
The application identifier, APPID, can alternately be specified as an option argument using the --appid option.
[{-A,--action}]ACTION Specifies the action of an XDG desktop application to launch. The action must appear in theActionskey in the desktop entry and have a corresponding[Desktop Action ACTION]group defining the action. Note that auto-start desktop entries do not have actions.
The action, ACTION, can alternately be specified as an option argument using the --action option.
π« [--mimetype] MIMETYPE
A registered mime type of the form "type/subtype". This corresponds to the mime type of a file or scheme handler that will identify the application to launch.
The mime type, MIMETYPE, can alternatively be specified as an option argument using the --mimetype option. Where the mime type would conflict with an existing APPID, it must be specified with the --mimetype option.
π« [--category] CATEGORY
An XDG menu specification category that identifies the application to launch.
The XDG menu specification category, CATEGORY, can alternatively be specified as an option argument using the --category option. Where the category would conflict with an existing APPID, it must be specified with the --category option.
π« [--desktop] DESKTOP
The XDG menu specification desktop name that identifies the X session for which to launch. This APPSPEC is only applicable when --xsession, --startup or --session is specified.
The XDG menu specification desktop name, DESKTOP, can alternatively be specified as an option argument using the --desktop option. Where the desktop name would conflict with an existing APPID, it must be specified with the --desktop option.
Providing a non-option application specifier argument is mandatory unless the--exec,--appid,--mimetypeor--categoryoptions are specified, in which case it should not be specified as a non-option argument. iykyk π«Ά
[{-f,--file}]FILE ... Specifies the file name with which to launch the application. This is used in%fsubstitutions in the"Exec"field of the XDG desktop entry file or--execcommand line. This may also be Specified with the--fileoption. The option or argument can be repeated to specify multiple files.[{-u,--url}]URL ... Specifies the URL with which to launch the application. This is used in%usubstitutions in the"Exec"field of the XDG desktop entry file or--execcommand line. This may also be specified with the--urloption. The option or argument can be repeated to specify multiple URLs.
Mixing FILE and URL arguments or options is not currently recommended. Like, don't do it, bestie. π
π COMMAND = {{-x,--exec} "EXEC ARGUMENT..."|-e EXEC ARGUMENT...}
When specified with -e, this option must be the last option on the command line. Options processing stops abruptly at this option and remaining arguments are considered to be the command and the command arguments to execute. xdg-launch will execve(3) the arguments under startup notification control in a similar fashion to "sh -c". This may also be specified as a single string argument to "sh -c" using the --exec option.
π ARGUMENT OPTIONS π
Arguments can be optionally provided using the following options:
-a,--appidAPPLICATION_ID β Override the application identifier. This overrides the name of the XDG application file. When unspecified, the default is to use the non-option APPID argument to determine the application identifier. This value, when available, is placed in the"APPLICATION_ID"key-value entry in the startup notification"new:"message.-A,--actionACTION β Specifies a desktop action, ACTION, to perform instead of the default action. The default is to perform the default action in the desktop entry file. This value, when available, is placed in the"ACTION"key-value entry in the startup notification"new:"message.--mimetypeMIMETYPE β Specify a registered mime type, MIMETYPE, of the form"type/subtype". This corresponds to the mime type of a file or scheme handler that will identify the application to launch.--categoryCATEGORY β Specify an XDG menu specification category, CATEGORY, that identifies the application to launch.--desktopDESKTOP β Specify an XDG menu specification desktop environment name, DESKTOP, that identifies the X session for which to launch.-f,--fileFILE β Specifies a file name, FILE, to be substituted into the XDG desktop entry"Exec"command in accordance with XDG desktop entry specifications. The default is to use the non-option FILE argument, or no file name. When--urlor URL is specified as afile://URL, this option defaults to the URL with thefile:portion removed.-u,--urlURL β Specifies a URL, URL, to be substituted into the XDG desktop entry"Exec"command in accordance with XDG desktop entry specifications. The default is to use the non-option URL argument, or no URL. When--fileor FILE is specified, this option defaults to the FILE with afile://portion prefixed.-x,--execCOMMAND β Specifies the command to execute. This overrides the"Exec"field of the XDG desktop entry file. When unspecified, the default is the"Exec"field of the XDG desktop entry file.
π₯ OPTIONS π₯
The options that are detailed below are recognized by xdg-launch. xdg-launch uses getopt_long_only(3), so unambiguous abbreviations of long options and long options with a single dash are also supported. (yes, single dash long options, she's flexible like that π
)
π COMMAND OPTIONS π
The default is to launch the application specified by "APPSPEC". When any of the following options are specified, the command mode changes.
Only one of--autostart,--xsession,--startupor--sessioncan be specified. Pick a lane, bestie. β
-U,--autostartβ Interpret and search for the desktop entry file as an"AutoStart"desktop entry instead of an"Application"desktop entry. This is the default when invoked asxdg-autostart. The"LAUNCHER"will default toxdg-autostartinstead ofxdg-launch. Aside from these differences, the launcher operates in the same fashion. This option is intended for launching individual autostart entries.-X,--xsessionβ Interpret and search for the desktop entry file as an"XSession"desktop entry instead of an"Application"desktop entry. This is the default when invoked asxdg-xsession. The"LAUNCHER"will default toxdg-sessioninstead ofxdg-launch. Aside from these differences, the launcher operates in the same fashion. This option is intended for launching window managers.-E,--sessionβ Interpret and search for the desktop entry file as an"XSession"desktop entry instead of an"Application"desktop entry. This is the default when invoked asxdg-session. The"LAUNCHER"will default toxdg-sessioninstead ofxdg-launch. This option, therefore, acts like the--xsessionoption, with the exception that the program also performs autostart for the window manager by executing the necessary autostart desktop entries according to the XDG autostart specification. This option is useful for launching a light-weight session for use with a light-weight window manager.-B,--startupβ Interpret and search for the desktop entry file, if specified, as an"XSession"desktop entry instead of an"Application"desktop entry. This is the default when invoked asxdg-startup. The"LAUNCHER"will default toxdg-startupinstead ofxdg-launch. This option, therefore, acts like the--sessionoption, with the exception that the program only performs autostart by executing the necessary autostart desktop entries according to the XDG autostart specification, and does not launch a window manager. This option is useful for launching autostart entries after a light-weight window manager has already started.-I,--infoβ When specified, instead of launching the application selected, print information about the final desktop file selected to launch the actions that would have been taken to launch the desktop entry if this option had not been specified. This is equivalent to a dry run. (screenshot the fit before you commit to the fit, basically πΈ)-c,--chainβ tells xdg-launch that this launch is chained onto a launch that's already in progress π«. It's the default whenever aDESKTOP_STARTUP_IDenvironment variable already exists when xdg-launch starts up. That said, you can still pass it explicitly to make sure no extra launch operation gets kicked off when xdg-launch is sitting in theExeckey of a desktop entry file. Heads up though: once you use it, none of the options that follow are significant β the only exceptions are"HISTORY OPTIONS"and"GENERAL OPTIONS". Peep"LAUNCH CHAINING"below for the whole story π«Ά.-h,--helpβ prints usage info to standard output and dips βοΈ.-V,--versionβ prints the detailed version info and bounces π.-C,--copyingβ prints the detailed copying permissions and exits π.
πΈ LAUNCH OPTIONS πΈ
okay so these next ones all shape the parameters of the startup notification "new" message that gets sent out for the launch π.
-L,--launcher LAUNCHERβ sets the string used as the launcher when a startup notification identifier gets generated. Default? The name of this program, like"xdg-launch"β¨.-l,--launchee LAUNCHEEβ sets the string used as the launchee when generating that startup notification identifier. Default is the application identifier π·οΈ.-S,--sequence SEQUENCEβ sets the sequence number used when generating the startup notification identifier. When you don't specify one, the default is zero (0) π’.-n,--hostname HOSTNAMEβ sets the host name used when generating the startup notification identifier. Unspecified? It defaults to whateverhostname -fspits out π».-m,--monitor MONITORβ picks the monitor, MONITOR, that the XDG application, APPID, launches on. If you leave it out, it uses the monitor the pointer is currently chilling on π±οΈ. MONITOR has to be the numerical zero-based index of the monitor you want. This value goes into the"MONITOR"key-value entry of the startup notification"new"message. No value gets placed at all when Xinerama (or RANDR) isn't active for the display, or for single-screen Xinerama (or RANDR) setups β in that case"SCREEN"is used instead. See"Multiple Monitors"below π.-s,--screen SCREENβ picks the screen, SCREEN, that the XDG application, APPID, launches on. Unspecified means the screen containing the pointer is used π°. For single-screen Xinerama (or RANDR) setups, the value of MONITOR is used for SCREEN. SCREEN must be the numerical zero-based index of the screen you want. This value lands in the"SCREEN"key-value entry of the startup notification"new"message. No value gets placed when there's only one screen and Xinerama (or RANDR) isn't active for the display. See"Multiple Screens"below π .-w,--workspace DESKTOPβ picks the desktop, DESKTOP, that the XDG application launches on. Unspecified? Default is the current desktop for the screen, SCREEN. This value goes into the"DESKTOP"key-value entry of the startup notification"new"message ποΈ.-t,--timestamp TIMESTAMPβ sets an X Server time stamp that corresponds to the X window event which caused the launch to happen β±οΈ. This is literally only useful when you also specify an APPID argument. If you don't give a time stamp, xdg-launch uses the time of the last event (or it generates an event) for the time stamp. The resulting time stamp β whether you specified it or not β gets used in the"_TIME"portion of the startup notification identifier, and in the"TIMESTAMP"key-value entry of the startup notification"new"message π₯.-N,--name NAMEβ sets the name of the XDG application. This overrides the"Name"field from the XDG desktop entry file. When unspecified, the default is the"Name"field from the XDG desktop entry file. This value, when it's available, is placed in the"NAME"key-value entry of the startup notification"new"message π.-i,--icon ICONβ sets the icon name of the XDG application, ICON. Overrides the"Icon"field from the XDG desktop entry file. When unspecified, default is the"Icon"field from the XDG desktop entry file. This value, when available, goes in the"ICON"key-value entry of the startup notification"new"message π¨.-b,--binary BINβ sets the name of the binary for the XDG application, BIN. This overrides the"TryExec"and"Exec"fields from the XDG desktop entry file. When unspecified, the default is the"TryExec"field, or the"argv[0]"option of the"Exec"field, from the XDG desktop entry file. This value, when available, is placed in the"BIN"key-value entry of the startup notification"new"message βοΈ.-d,--description DESCRIPTIONβ sets the description of the XDG application, DESCRIPTION. Overrides the"Comment"field from the XDG desktop entry file. When unspecified, the default is to use the"Comment"field from the XDG desktop entry file, or a descriptive sequence such as"Staring Name". This value, when available, is placed in the"DESCRIPTION"key-value entry of the startup notification"new"message π.-W,--wmclass WMCLASSβ sets the window manager class of the top-level window that the XDG application is expected to map (this gets matched against the"res_name"or"res_class"of the"WM_CLASS"property on a window). Overrides the"StartupWMClass"field of the XDG desktop entry file. When unspecified, the default is the"StartupWMClass"field of the XDG desktop entry file. This value, when available, is placed in the"WMCLASS"key-value entry of the startup notification"new"message πͺ.-q,--silent SILENTβ sets a boolean value (0/1) deciding whether visual feedback should be provided for the launching XDG application, SILENT π. Normally, when unspecified, visual feedback gets figured out from whether a"StartupNotify"or"StartupWMClass"field has a value in the XDG desktop entry file. The SILENT argument should be some boolean value like0or1or"yes"or"no"or"true"or"false". The default when unspecified is to determine the value from the other fields of the XDG desktop entry file. This value, when available, is placed in the"SILENT"key-value entry of the startup notification"new"message π€.
When unspecified, the "SILENT" argument to the startup notification message is set when the XDG desktop entry has neither a "StartupNotify" nor a "StartupWMClass" field, or it only has a "StartupNotify" field but that one is set to false π«₯.
-p,--pid PIDβ sets the process identifier for the launch sequence. Default is the process identifier of the xdg-launch program itself π.--ppidβ sets the process identity of a sub-reaper process under which the launched application should be re-parented when its parent terminates π§¬. This option defaults to the environment variable${XDG_SESSION_PID}and, if that doesn't exist, the process group leader of the process invoking xdg-launch. If you want to keep it from being set automatically, set it to zero. This is super useful for applications launched by a window manager β it makes sure that if the window manager crashes, it can be restarted by the session and the application's child processes get re-parented to the session π.
π¦ CONTEXT OPTIONS π¦
Context options are how you guide the appropriate selection of screen and monitor π. When the program runs from a key binding associated with a window manager, the most appropriate screen or monitor is the one containing the window that currently has the keyboard focus β¨οΈ. When the program launches from a pointer button press, the most appropriate screen or monitor is the one containing the pointer π±οΈ.
-P,--pointerβ when specified, xdg-launch determines the screen or monitor from where the pointer currently is. Use this when xdg-launch gets invoked from a menu or a mouse binding π²οΈ. This option has no effect on the screen when the screen was specified using either theDISPLAYenvironment variable or the--screenoption. And this option has no effect on the monitor when--monitoris also specified π«.
Only one of --pointer or --keyboard can be specified π.
-K,--keyboardβ when specified, xdg-launch determines the screen or monitor from the location of the window with the current keyboard focus β¨οΈβ¨. Use this when xdg-launch gets invoked from a command line or a keyboard binding. This option has no effect on the screen when the screen was specified using either theDISPLAYenvironment variable or the--screenoption. And this option has no effect on the monitor when--monitoris also specified π«.
Only one of --pointer or --keyboard can be specified π.
π ASSIST OPTIONS π
xdg-launch can assist a window manager that isn't startup-notification aware with completing startup notification, and it can also establish the initial settings of some NetWM/EWMH properties on any application windows πͺ. These options control that behaviour.
--assistβ normally xdg-launch figures out whether the window manager and application toolkit need help with startup notification. The default, when there's a window manager that supports startup notification, is to not provide any assistance. This option requests that xdg-launch provide startup notification assistance to any window manager π€.--no-assistβ normally xdg-launch figures out whether an existing window manager and application toolkit need help with startup notification. The default, when there's a window manager that doesn't support startup notification, is to provide assistance. This option requests that xdg-launch not provide startup notification assistance to any window manager π ββοΈ.
π TOOL WAIT OPTIONS π
The following tool wait options give you functionality equivalent to that of xtoolwait(1) π§°.
-T,--toolwaitβ normally xdg-launch doesn't exit; it replaces the foreground process with the application usingexecve(3). When you specify this option, the behaviour changes: xdg-launch executes the application in a background process and exits once the application has started πββοΈ. The criteria for when the application counts as started depends on the other"JOB CONTROL OPTIONS"π.--timeout [SECONDS]β how long we're willing to sit around waiting for startup to finish before we just call it and say the app is launched. Leave the value off, or pass zero (0), and it waits indefinitely π (yes, forever, no cap). Default is fifteen (15) seconds β same default asxtoolwait(1). Heads up: this timeout only applies to startup notification completion, nothing else.--mappings NWINDOWSβ okay so normally, when we're not expecting a startup notification completion message,xdg-launch(1)says "yep, launched" the moment it maps the first client window. With this option you tell it to hold on untilNWINDOWSmappings have happened first. Unspecified default is one window π--withdrawnβxtoolwait(1)has to be told when an app is a Window Maker dockapp so it can detect windows mapped in the"WithdrawnState".xdg-launchpicks up Window Maker dockapps automatically β¨, so you only need this when the automatic detection fails for some reason. It exists for compatibility withxtoolwait(1)and, lowkey, mostly doesn't change behaviour.--pidβ for compatibility withxtoolwait(1): asksxdg-launchto print the process id of the command to standard output. When you use this,xdg-launchredirects the application's standard output to standard error so things don't get messy. Only one of-pidor-widcan be specified.
π note: this option conflicts with the usage of the --pid option, above β but this usage doesn't accept an argument, so like, that's the difference, bestie.
--widβ prints the id of the X window that caused startup completion to be signalled, to standard output, so you can feed it to tools likewmctrl(1)orxdotool(1).xdg-launchredirects the application's standard output to standard error when this option is specified. Only one of-pidor-widcan be specified. π--nopropβ when we're using a window being mapped to decide that startup notification is complete, this says: just use the creation of a top-level window as the criteria instead of expecting a"WM_STATE"property change.
πΈ SESSION OPTIONS πΈ
These ones are all about desktop session control π«Ά β they decide what conditions get awaited before your application or command actually launches. When you don't specify any session option, xdg-launch may figure out on its own which conditions need awaiting, depending on how --autowait and --no-autowait are set. Iconic behaviour tbh.
--autowaitβ normally, whenxdg-launchis executing an autostart entry, it works out whether the app needs to wait for resources or a startup phase before launching. This option says: yes, do the wait when it's required. β--no-autowaitβ same situation (executing an autostart entry, normally works out whether the app needs to wait for resources or a startup phase), but this option says: don't wait for any resources or startup phase. periodt.
π real talk: some key fields in an app's.desktopfile can specify the autostart phase (e.g."AutostartPhase","X-GNOME-Autostart-Phase"). When the--autostartoption is specified, the setting of these key fields may affect the default settings of the session options above. In particular:
"Initialization"β when an autostart phase of"Initialization"is specified,xdg-launchwill not wait for any desktop resource before running the application or command."WindowManager"β when an autostart phase of"WindowManager"is specified, or when--xsessionis specified,xdg-launchwill not wait for any desktop resource before running the application or command."Panel"β when an autostart phase of"Panel"is specified,xdg-launchwill wait for a window manager (regardless of the--manageroption) before continuing; however, it will not wait for a tray or pager. It'll only wait for a composite manager if--compositewas specified."Desktop"β when an autostart phase of Desktop is specified,xdg-launchwill wait for a window manager (regardless of the--manageroption) before continuing. It will only await other resources if they've been explicitly specified with options."Applications"β when an autostart phase of Desktop is specified, or when no autostart phase is specified and--autostartis given,xdg-launchwill wait for a window manager (regardless of the--manageroption) before continuing; however, it will only await other resources if they've been explicitly specified with options. π«
When "AutostartPhase" isn't specified, xdg-launch may use the category in the app's .desktop file to work out which autostart phase the application should be launched in, like this:
"DockApp"β apps in this category get launched in the"Applications"phase."TrayIcon"β apps in this category get launched in the"Applications"phase, and will wait for a system tray to appear before launching."Audio"β apps in this category will wait for an audio server to appear."SystemTray"β an application in this category will not wait for a system tray, because the application provides one."Pager"β an application in this category will not wait for a desktop pager, because the application provides one."Panel"β an application in this category will not wait for a system tray nor a desktop pager (as most panels provide these).
The options that follow are for specifying the conditions that must be awaited before xdg-launch will proceed to launch the application. None of these options has any effect when the --no-autowait option is specified π¨
-M,--managerβ awaits a window manager showing up before launching the application or command. Default behaviour is to not wait for any desktop resource before launching.-Y,--trayβ awaits a system tray showing up before launching the application or command. Default behaviour is to not wait for any desktop resource before launching.-G,--pagerβ awaits a desktop pager (or desktop pager specification) showing up before launching the application or command. Default behaviour is to not wait for any desktop resource before launching.-O,--compositeβ awaits a composite manager showing up before launching the application or command. Default behaviour is to not wait for any desktop resource before launching.-R,--audioβ awaits an audio server showing up before launching the application or command. Default behaviour is to not wait for any desktop resource before launching. π§-g,--guard [SECONDS]β await resources for no longer than SECONDS seconds before continuing. No value, or a value of zero (0), means wait indefinitely for the resource. Default value is2seconds.--delay SECONDSβ delay for SECONDS seconds before launching an auto-start entry. Default value is zero (0) seconds. When it's non-zero, this option overrides the"X-GNOME-AUtostart-Delay"desktop entry field. β°
π¦ HISTORY OPTIONS π¦
When simple applications are launched, files containing the history of recently launched applications get updated. These options control that whole vibe:
--history,--no-historyβ by default, when simple applications are launched, the files containing the history of recent applications and recently used files and URLs are updated. For other applications (auto-start, X session), histories aren't kept by default. These options specify whether histories are to be kept or not. πΎ-k,--keep NUMBERβ sets the max number, NUMBER, of commands or application invocations kept in the recent history file. Minimum value is one, maximum value is100, and the default when unspecified is10. This option is ignored when history is not in effect.-r,--recent FILENAMEβ sets the FILENAME of the recent history file. In exec mode, store the recent history of the executable in the file FILENAME; in exec mode the default is$XDG_CONFIG_HOME/xde/run-history. In application mode, store the recent history of the application in the file FILENAME; in application mode the default is$XDG_CONFIG_HOME/xde/recent-applications. This option is ignored when history is not in effect. ποΈ
π CONTENT OPTIONS π
These affect the current or future selection of an application by mime type or XDG category:
--set-defaultβ when used with an APPID argument, says the selected application id is to be made the default for its mime-types and categories when successfully launched. The default is to not make the launched application the default for mime-type nor category.
It's the simple way of making an app the default for its mime-types and categories. For example:
$> xdg-launch --set-default chromium
will make chromium the default web browser. Either of the following command lines will then result in launching chromium:
$> xdg-launch text/html
$> xdg-launch WebBrowser
If the application id was already on the default list, it gets moved to the beginning of the list; otherwise it gets inserted at the beginning of the list. π
--set-preferredβ when used with an APPSPEC argument, says the selected application id is to be added to the recommended list for its mime-types and categories when successfully launched. If the application id was already on the recommended list, it gets moved to the beginning of the list; otherwise it gets inserted at the beginning of the list. π--default,--no-defaultβ when used with a MIMETYPE or CATEGORY argument, specifies whetherxdg-launchshould consider the default application defined for the mime-type or category. (The default application setting is defined by the XDG mime-type specifications and is the familiar default used by most desktop file managers.) The default is to consider the default application. β¨--recommend,--no-recommendβ when you use this with aMIMETYPEorCATEGORYargument, it says whether xdg-launch should even look at the recommended applications defined for that mime-type or category. (The recommended applications setting is defined by the XDG mime-type specifications, and it's literally the familiar recommended list that most desktop file managers use, iykyk.) Default is: yes, it considers the recommended applications π--fallback,--no-fallbackβ same situation, but for the fallback applications defined for the mime-type or category. (The fallback applications setting is defined by the XDG mime-type specifications, and again it's the familiar recommended list used by most desktop file managers.) Default is: yes, it considers the fallback applications too β¨
πΈ GENERAL OPTIONS πΈ
These are the general ones, bestie:
-v,--verbose [LEVEL]β prints diagnostic info to standard error while it's doing its thing. Repeat it to crank the verbosity up even higher. Default level?1. ποΈ-D,--debug [LEVEL]β prints debugging info to standard error during operation. Repeat it to push the debugging level up. Default level is0. π
π BEHAVIOUR π
okay so here's how xdg-launch actually behaves, character by character:
β° TIME STAMPS β°
xdg-launch is intended on being invoked directly from a user interface β think the root menu of a light-weight window manager, or an X windows application like a system tray menu. And to perform proper startup notification, it figures out the X server time stamp of the invocation like this:
- When xdg-launch is invoked directly (executed) from an application that has access to the X server event that invoked the launch, that app can hand the X server time stamp straight to xdg-launch with the
--timestampoption (see "OPTIONS"). xdg-launch will use this time stamp when it generates theDESKTOP_STARTUP_IDand for the"TIMESTAMP"key-value pair in the startup notification"new"message. π«Ά - When xdg-launch is invoked by an application that doesn't have access to the X event that invoked the launch, xdg-launch will change the
_TIMESTAMP_PROPproperty on the root window to obtain a time stamp. That's the whole trick β it means xdg-launch can just be executed using the execute mechanism of a light-weight window manager root menu or key binding. iconic. π - When xdg-launch is invoked by another startup notification launcher, it grabs the time stamp (and other info) from the
DESKTOP_STARTUP_IDenvironment variable. π
π₯οΈ MULTIPLE HEADS π₯οΈ
xdg-launch fully supports multiple heads (screens) and Xinerama (or RANDR) multiple physical monitors per screen. no cap.
Multiple Screens
When there are multiple screens, some window managers will adjust the DISPLAY environment variable to include the screen number for launched applications. Example time: if the window manager DISPLAY environment variable is :7 and a program is launched on screen 1, that program gets launched with a DISPLAY environment variable of :7.1. So when xdg-launch detects a screen number in its DISPLAY environment variable, the screen it uses will be the one specified in the environment variable β unless the --keyboard, --pointer or --screen options are specified. And when xdg-launch launches the ultimate desktop application, it adjusts the DISPLAY environment variable to include the screen, because most applications launch on the default screen, and this manages to get the desktop application launching on the correct screen. β¨
Multiple Monitors
xdg-launch detects Xinerama and RANDR multiple monitor setups. When the --keyboard or --pointer options are specified, xdg-launch determines the monitor number from the keyboard focus window or pointer location, and that monitor number gets placed in the "MONITOR=" field of the startup notification "new" message. π«
But here's the catch β launched desktop applications have no way of determining information outside of the DESKTOP_STARTUP_ID with which they were launched (the screen number can be obtained from the DISPLAY environment variable, that part's fine). The DESKTOP_STARTUP_ID is formatted (ala libstartup-notification) like this:
%s/%s/%d-%d-%s_TIME%lu
Where the fields are the launcher, launchee, pid, sequence, host and timestamp. The sequence number is of no use to the application, and it's also of no use to xdg-launch because the PID changes with each invocation. Therefore, when the launcher is xdg-launch, the application (or window manager) can use the sequence field as the monitor index. big brain energy fr fr π§
π TERMINAL PROGRAMS π
For desktop entries that set "Terminal=true", they may also set "StartupWMClass" to a class name specific to the program being executed. Most terminal programs (and xterm(1) specifically) can set the "WMCLASS" name and class to something other than that of the terminal program (i.e. instead of "xterm.XTerm"). When the desktop entries do so, xdg-launch will set the name attribute on the terminal to the name specified when the terminal is launched, if possible. This also permits, for terminal emulation programs such as xterm(1), the ability to set special terminal resources by application. Because not many desktop entry files do this, when no "StartupWMClass" is specified, the "APPID" or "BINARY" will be used instead and "StartupWMClass" will be automatically populated. π
This procedure provides additional assistance to window managers when terminal emulation programs do not properly observe startup notification. (For example, xterm(1) does not properly observe startup notification, even though it properly observes X11 Session Management, whereas many other terminal emulators support both.) π
You can change the default terminal emulation program used when these applications are launched by using environment variables (see "ENVIRONMENT") or X resources (see "X RESOURCES"). π
Terminal programs that are known to xdg-launch are:
uxterm(1),xterm(1),st(1),aterm(1),rxvt(1),alacritty(1)β these do not support startup notification, but they do support setting the resource name β¨pterm(1),Eterm(1),urxvt(1),urxvt-tabbed(1),termit(1),gnome-terminal(1),termite(1),mate-terminal(1),terminology(1),kitty(1)β these do support startup notification and do support setting the resource name πroxterm(1),lxterminal(1),xfce4-terminal(1),lilyterm(1),tilix(1),guake(1),terminator(1)β these do support startup notification but do not support setting the resource name π«x-terminal-emulator(1),deepin-terminal(1),tilda(1)β these do support startup notification but do not support setting the resource name, nor setting the window title π¬qterminal(1),konsole(1)β these do not support startup notification, nor setting the resource name, nor setting the window title πkoi8rxterm(1)β which is language specific π
When the TERMINAL environment variable is set to one of these terminals (a terminal known to xdg-launch), it will automatically determine the corresponding XDG_TERMINAL and XDG_TERMRESN commands when they are not specified. See "ENVIRONMENT" below. When no terminal environment variables are specified, terminal programs will be detected in the user's PATH in the order specified above. Note that terminix(1) and hyper(1) are currently unknown. XDG_TERMINAL and XDG_TERMRESN must currently be specified to use those or other unknown terminals. π
See "ENVIRONMENT" below for more information on selecting the terminal to use for launching applications that need one. π
π AUTO START SESSION π
When --session is specified, the program starts the XDG auto start procedure before launching the window manager specified by the APPID or --exec command. xdg-launch creates a session by launching autostart desktop entries in child processes, and then executes the APPID or --exec command for the window manager in the parent process. It attempts to become a process group leader before launching children. This should ultimately leave any child processes as children of the window manager. The window manager is executed in the parent process and, therefore, the parent process will not exit until the window manager exits. π
When --startup is specified, or no APPID or --exec command is specified, instead of starting a window manager, it establishes children so that they will be re-parented to the process group leader when the parent process exits. π¦
π§° TOOL WAIT π§°
xdg-launch can also be used to replace xtoolwait(1) for XDG applications when invoked with the appropriate options. A convenience script, xdg-toolwait(1), is provided that mimics the options of xtoolwait(1). See xdg-toolwait(1) for more information. π
πͺ WINDOW MANAGERS πͺ
xdg-launch interacts with window managers in the following ways:
- xdg-launch creates startup notification identifiers using the technique from the libstartup-notification library. This consists of the following:
while((p = strchr(launcher, '/'))) *p = '|';
while((p = strchr(launchee, '/'))) *p = '|';
sprintf(id, "%s/%s/%d-%d-%s_TIME%lu",
launcher, launchee, getpid(), monitor,
hostname, timestamp);
Compliant applications will place the startup notification identifier from the DESKTOP_STARTUP_ID environment variable in the _NET_STARTUP_ID property on its group leader top-level window before it is mapped. The window manager can use the "_TIME%lu" portion of the startup identifier to determine the X server time stamp for the event that launched the application. When the client does not set an initial _NET_WM_USER_TIME, this time stamp can be used in its stead. It can also use the "/%d-" portion of the startup identifier to determine the process identifier, the "-%d-" portion to determine the monitor on which to start the application, and the "-%s_TIME" portion of the identifier to determine the host name of the launching machine. π
- Window managers that monitor startup notification messages may also use the
"TIMESTAMP="key-field entry in the"new:"message for this purpose, particularly when the"WMCLASS="field matches the resource name or class of a newly mapped top-level window. β¨ - xdg-launch neither changes nor removes the startup notification sequence and is only responsible for issuing in the
"new:"or"change:"message. The window manager or desktop environment should issue a"remove:"message when it first manages a top-level window with a resource name or class than matches the"WMCLASS="field of an outstanding"new:"message. π - Window managers that monitor startup notification messages and associate them with managed top-level windows may use the following fields to populate missing properties on those windows β yes bestie, your WM can literally fill in the blanks π
:
"ID="β the window manager may use this field to populate the_NET_STARTUP_IDproperty on the window (group) when it's missing."HOSTNAME="β the window manager may use this field to populate theWM_CLIENT_MACHINEproperty when it's missing or isn't a fully qualified domain name. This field can also be derived from the"ID="field."PID="β the window manager may use this field to populate the_NET_WM_PIDproperty when it's missing. This field can also be derived from the"ID="field."MONITOR="β the window manager may use this field to choose the Xinerama (or RANDR) screen on which the top-level window (group) will be mapped. It may also be used to populate the_NET_WM_FULLSCREEN_MONITORSproperty when it's missing."SCREEN="β the window manager may use this field to choose the Xinerama (or RANDR) or multi-head screen on which the top-level window (group) will be mapped. When it specifies a Xinerama (or RANDR) screen, it may also be used to populate the_NET_WM_FULLSCREEN_MONITORSproperty when it's missing."DESKTOP="β the window manager may use this field to populate the_NET_WM_DESKTOP,_WIN_WORKSPACE, or_DT_WORKSPACE_PRESENCEproperty when missing or otherwise unspecified."TIMESTAMP="β the window manager may use this field to populate the_NET_WM_USER_TIMEproperty when it's missing. This field can also be derived from the"ID="field."NAME="β the window manager may use this field to populate theWM_NAME,_NET_WM_NAME, or_NET_WM_VISIBLE_NAMEproperties when they're missing or empty."ICON="β the window manager may use this field to establish an icon for the window when theWM_ICON,_NET_WM_ICONor_KDE_NET_WM_ICONproperties are missing or otherwise unusable."WMCLASS="β the window manager may use this field to associate a startup notification sequence with a newly mapped top-level window."COMMAND="β the window manager may use this field when theWM_COMMANDfield is missing (and for the same purposes). Because rather complicated shell expansion would be required to expand the command, it cannot be used to populate theWM_COMMANDproperty; however, it may be executed by passing it literally as a shell command. I suppose one could populateWM_COMMANDwith"sh","COMMAND"if necessary.
π LAUNCH CHAINING π
So the whole point here: xdg-launch can be used inside a desktop entry file, and for that it supports launch chaining. Iconic. β¨ When a DESKTOP_STARTUP_ID environment variable is set before the program is executed, xdg-launch assumes it's been executed from within a desktop entry file. The normal behaviour in this case is to act as normal β except that a "change:" message is sent where a "new:" message would be sent.
Now, because this may be confusing to some desktops or launch monitors, and may confuse a window manager that supports desktop startup notification completion, xdg-launch attempts to detect the situation where it's used to launch a desktop entry that uses xdg-launch (or one of its derivatives) in the Exec line. In the case that it detects a chained invocation, it simply executes the command without setting the DESKTOP_STARTUP_ID and without sending a "new:" message. Then the chained invocation performs startup notification as though it was invoked by itself. Recursive slay, honestly π
.
To handle the case where a different launch is used to launch a desktop entry that contains an xdg-launch command, xdg-launch also supports the --chain option. When the --chain option is specified, the launch chaining behaviour is invoked. The differences are as follows:
- When the
xdg-launchprogram starts, and there's noDESKTOP_STARTUP_IDenvironment variable set, it behaves normally; when it is set, the chaining behaviour is invoked, and the following differences apply: - When launching the chained application, no
"new:"or"change:"message will be sent and theDESKTOP_STARTUP_IDenvironment variable will be passed to the chained application unchanged. The options described under "LAUNCH OPTIONS" and "CONTEXT OPTIONS" are ignored. - No tool wait, assistance, wait for resources, nor content setting procedures will be invoked. The options described under "ASSIST OPTIONS", "TOOL WAIT OPTIONS", "SESSION OPTIONS" and the set operations of "CONTENT OPTIONS" are ignored.
- The chained application will be executed in replacement for the
xdg-launchprogram and no children will be spawned.
Chaining launches in this fashion is intended to be used to allow an xdg-launch command in a desktop entry file. Intended uses are with the --mimetype and --category methods of specifying an application to launch. A set of "preferred" application desktop entries are included in the distribution of xdg-launch. See the following desktop entry files installed in the /usr/share/applications directory π«Ά:
preffered-execute.desktopβ launches the user's preferred run dialog with theExeckey:"xdg-launch --chain RunCommand".preffered-file-manager.desktopβ launches the user's preferred file manager with theExeckey:"xdg-launch --chain FileManager".preffered-mail-reader.desktopβ launches the user's preferred mail reader with theExeckey:"xdg-launch --chain MailReader".preffered-terminal.desktopβ launches the user's preferred terminal with theExeckey:"xdg-launch --chain TerminalEmulator".preffered-text-editor.desktopβ launches the user's preferred text editor with theExeckey:"xdg-launch --chain TextEditor".preffered-web-browser.desktopβ launches the user's preferred web browser with theExeckey:"xdg-launch --chain text/html".preffered-calculator.desktopβ launches the user's preferred calculator with theExeckey:"xdg-launch --chain Calculator".
The xdg-launch package installs a reasonable distribution-provided prefapps.list file alongside the mimeapps.list file of the XDG "Association between MIME types and applications" specification. Bestie the packaging is so tidy π.
π°οΈ RECENTLY USED FILES, URLS, APPLICATIONS π°οΈ
By default, when simple applications are launched by xdg-launch, files that retain the history of recently used files, URLs and applications are automatically updated. When other applications (auto-start, X session) are launched, histories are not kept by default. Although the use of the --history and --no-history options overrides the default behaviour, the default is sufficient for the purpose of properly updating recent use files. Lowkey well-designed ngl πΈ.
Histories are written to three pairs of files (see "FILES"). The first pair keeps recently executed commands and recently launched applications in a simple text format, one per line, with the most recent at the top. These two files were historically used by xde-run(1) and xde-app(1). The default files are $XDG_CONFIG_HOME/xde/run-history and $XDG_CONFIG_HOME/xde/recent-applications.
The second pair keeps recently used files and URLs in a non-XBEL, XML file format used historically by GNOME. Applications are recorded in each as a reference to the desktop entry, .desktop file of the application. The second in the pair only contains the .desktop entries, while the first contains all file and URL references. Some older GTK application file selection dialogues use these files. The default files are $HOME/.recently-used and $HOME/.recent-applications.
The last pair keeps recently used files and URLs in an XBEL, XML file format that is currently part of the XDG specifications. Files and URLs are contained in the first of the pair, and application .desktop entries are only contained in the second. The default files are $XDG_DATA_HOME/recently-used.xbel and $XDG_DATA_HOME/recent-applications.xbel.
Current file dialogues and applications use only the last pair of XBEL-formatted files. Applications that provide menu and dialogue access to both lists are xde-run(1), xde-app(1) and xde-recent(1). Iconic trio, honestly π.
π± ENVIRONMENT π±
okay bestie, these are the env vars xdg-launch peeks at π β every single one, no skipping:
DISPLAYβ used byxdg-launchto figure out the X display and default screen it was invoked on. your whole vibe check for "where am i" β¨DESKTOP_STARTUP_IDβ used byxdg-launchat program startup to figure out whether it itself got launched with startup notification. if so, theDESKTOP_STARTUP_IDgets reused. this env var is set to the startup notification identifier right before executing the launched program. see "LAUNCH CHAINING" for the deets π«ΆLANGβ used byxdg-launchat program startup to decide which language to pick for the"Name="and"Comment="fields in the desktop entry file πΈHOMEβ used byxdg-launchto find the user's home directory πXDG_DATA_HOMEβ used byxdg-launchto find the user's XDG data directory. defaults to$HOME/.local/share. theapplications(orxsessions) subdirectory under this directory is the first one searched to locate desktop entry files. see the XDG Desktop Entry file specification for more πXDG_DATA_DIRSβ used byxdg-launchto find the system XDG data directories. defaults to/usr/local/share:/usr/share. theapplications(orxsessions) subdirectory under these directories gets searched in order to locate desktop entry files. again, XDG Desktop Entry file spec if you want the lore β¨XDG_CONFIG_HOMEβ used byxdg-launchto determine the user's XDG configuration directory. defaults to$HOME/.config. theautostartsubdirectory under this directory is the first one searched to locate desktop entry files. XDG Desktop Entry file spec, you already know πXDG_CONFIG_DIRSβ used byxdg-launchto find the system XDG configuration directories. defaults to/etc/xdg. theautostartsubdirectory under these directories gets searched in order to locate desktop entry files. XDG Desktop Entry file spec says hi πXDG_SESSION_PIDβ used byxdg-launchto set the sub-reaper process of launched applications. heads up: when doing autostart,xdg-launchwill set this env var to its own PID when the variable isn't already set πXDG_TERMINALβ used byxdg-launchas the command to prefix to the exec line of terminal applications, so it can launch applications inside a terminal π₯οΈXDG_TERMRESNβ used byxdg-launchas the command to prefix to the exec line of terminal applications so it can launch applications inside a terminal when a resource name is available to be set on the terminal. (not necessarily defined for all terminal types β so don't come for her if it's missing π)TERMINALβ used byxdg-launchas the name of the preferred terminal program to run. if this terminal is known toxdg-launch, it'll automatically figure out the matchingXDG_TERMINALandXDG_TERMRESNcommands when they aren't specified. see "TERMINAL PROGRAMS", above, for the list of known terminal emulation programs π
π FILES π
xdg-launch is obsessed with these files, fr fr:
$XDG_CONFIG_HOME/xde/run-historyβ the default location of the run-history file. it's a simple text file holding the commands that were last run with thexde-run(1)dialog, one per line, with the oldest entries lower in the file. for later use byxde-run(1),xdg-launchadds an entry to this file containing the command line that was executed π$XDG_CONFIG_HOME/xde/recent-applicationsβ the default location of the recent-applications file. simple text file, application ids that were last run with thexde-app(1)dialog, one per line, oldest entries lower in the file. for later use byxde-app(1),xdg-launchadds an entry containing the application id that was launched π$XDG_DATA_HOME/recently-used,$HOME/.recently-usedβ the default locations of the non-XBEL-formatted, co-mingled, recently used files and URLs. when the first location isn't present, the second is used. this co-mingled file predates the separated$HOME/.recent-applicationsfile and records recent applications by listing the.desktopfile as a recently used file π$HOME/.recent-applicationsβ the default location of the non-XBEL-formatted, separate, recent applications file. it records recent applications by listing the.desktopfile as a recently used file. the difference between this file and the$HOME/.recently-usedfile? this one only records recently used.desktopfiles π«$XDG_DATA_HOME/recently-used.xbelβ the default location of the XBEL-formatted recently used files and URLs file. it only records files and URLs used by launched applications..desktopfiles are not recorded here π«$XDG_DATA_HOME/recent-applications.xbelβ the default location of the XBEL-formatted rececent applications file. it only records launched applications (by.desktopfile) π$HOME/.gtkrc-2.0.xdeβ the location of the XDE theme file that'll be used for the GTK theme when it exists. the program will also respect the"_XDE_THEME_NAME"property on the root window of the screen the program was launched for πΈ$desktop-mimeapps.list,mimeapps.listβ these files get searched in$XDG_CONFIG_HOME,$XDG_CONFIG_DIRS,$XDG_DATA_HOME/applications,$XDG_DATA_DIRS/applicationsto determine associations between MIMETYPE and APPLICATION_ID. the user's$XDG_CONFIG_HOME/$desktop-mimeapps.listfile is altered when--set-defaultor--set-prefferedare specified π₯$desktop-prefapps.list,prefapps.listβ these files get searched in$XDG_CONFIG_HOME,$XDG_CONFIG_DIRS,$XDG_DATA_HOME/applications,$XDG_DATA_DIRS/applicationsto determine associations between CATEGORY and APPLICATION_ID. the user's$XDG_CONFIG_HOME/$desktop-prefapps.listfile is altered when--set-defaultor--set-prefferedare specified π
π BUGS π
xdg-launch has way too many options. like, iconic levels of too many. that's the bug. it's giving "she has a lot of flags and she's not sorry" π
please report other bugs to the source code repository at <https://github.com/bbidulock/xdg-launch/issues> π«Ά
π SEE ALSO π
go read these bestie, they're all in the group chat:
xdg-show(1), xdg-assist(1), xdg-monitor(1), xdg-toolwait(1), xdg-autostart(1), xdg-xsession(1), xdg-session(1), xde-run(1), xde-app(1), xde-recent(1), execve(3), getopt_long_only(3), xtoolwait(1), wmctrl(1), xdotool(1), xterm(1), Startup Notification <http://standards.freedesktop.org/startup-notification-spec/startup-notification-0.1.txt> π
π«Ά AUTHOR π«Ά
Brian Bidulock <mailto:bidulock@openss7.org> β the main character who wrote all this π
and that's the whole page bestie!! this gorgeousness is xdg-launch 1.12, dated 2022-01-28 β screenshot it, cite it, put it on your fridge, periodt πβ¨π
π¦ where this page comes from
- nixos 26.05: xdg-launch 1.12
- nixpkgs unstable: xdg-launch 1.12
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms