Merge pull request #17286 from benzea/benzea/xdg-autostart-improvements
XDG autostart improvements
This commit is contained in:
commit
d2ec13fa8a
|
@ -28,6 +28,7 @@ XdgAutostartService* xdg_autostart_service_free(XdgAutostartService *s) {
|
|||
|
||||
free(s->type);
|
||||
free(s->exec_string);
|
||||
free(s->working_directory);
|
||||
|
||||
strv_free(s->only_show_in);
|
||||
strv_free(s->not_show_in);
|
||||
|
@ -321,6 +322,7 @@ XdgAutostartService *xdg_autostart_service_parse_desktop(const char *path) {
|
|||
const ConfigTableItem items[] = {
|
||||
{ "Desktop Entry", "Name", xdg_config_parse_string, 0, &service->description},
|
||||
{ "Desktop Entry", "Exec", xdg_config_parse_string, 0, &service->exec_string},
|
||||
{ "Desktop Entry", "Path", xdg_config_parse_string, 0, &service->working_directory},
|
||||
{ "Desktop Entry", "TryExec", xdg_config_parse_string, 0, &service->try_exec},
|
||||
{ "Desktop Entry", "Type", xdg_config_parse_string, 0, &service->type},
|
||||
{ "Desktop Entry", "OnlyShowIn", xdg_config_parse_strv, 0, &service->only_show_in},
|
||||
|
@ -338,9 +340,12 @@ XdgAutostartService *xdg_autostart_service_parse_desktop(const char *path) {
|
|||
{ "Desktop Entry", "GenericName", NULL, 0, NULL},
|
||||
{ "Desktop Entry", "Icon", NULL, 0, NULL},
|
||||
{ "Desktop Entry", "Keywords", NULL, 0, NULL},
|
||||
{ "Desktop Entry", "MimeType", NULL, 0, NULL},
|
||||
{ "Desktop Entry", "NoDisplay", NULL, 0, NULL},
|
||||
{ "Desktop Entry", "StartupNotify", NULL, 0, NULL},
|
||||
{ "Desktop Entry", "StartupWMClass", NULL, 0, NULL},
|
||||
{ "Desktop Entry", "Terminal", NULL, 0, NULL},
|
||||
{ "Desktop Entry", "URL", NULL, 0, NULL},
|
||||
{ "Desktop Entry", "Version", NULL, 0, NULL},
|
||||
{}
|
||||
};
|
||||
|
@ -606,6 +611,16 @@ int xdg_autostart_service_generate_unit(
|
|||
"Slice=app.slice\n",
|
||||
exec_start);
|
||||
|
||||
if (service->working_directory) {
|
||||
_cleanup_free_ char *e_working_directory = NULL;
|
||||
|
||||
e_working_directory = cescape(service->working_directory);
|
||||
if (!e_working_directory)
|
||||
return log_oom();
|
||||
|
||||
fprintf(f, "WorkingDirectory=-%s\n", e_working_directory);
|
||||
}
|
||||
|
||||
/* Generate an ExecCondition to check $XDG_CURRENT_DESKTOP */
|
||||
if (!strv_isempty(service->only_show_in) || !strv_isempty(service->not_show_in)) {
|
||||
_cleanup_free_ char *only_show_in = NULL, *not_show_in = NULL, *e_only_show_in = NULL, *e_not_show_in = NULL;
|
||||
|
|
|
@ -10,6 +10,7 @@ typedef struct XdgAutostartService {
|
|||
|
||||
char *type; /* Purely as an assertion check */
|
||||
char *exec_string;
|
||||
char *working_directory;
|
||||
|
||||
char **only_show_in;
|
||||
char **not_show_in;
|
||||
|
|
Loading…
Reference in a new issue