From 41f71857b78ad83d42d57301cdd3b4a932767e37 Mon Sep 17 00:00:00 2001 From: RPJosh Date: Fri, 13 Jan 2023 21:25:13 +0100 Subject: [PATCH] Add autostart option for GUI --- build.gradle | 8 ++++---- .../java/de/rpjosh/installer/InstallConfig.java | 17 +++++++++++++++++ .../java/de/rpjosh/installer/Installer.java | 12 ++++++++++++ 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index 8cdfa62..7a851be 100644 --- a/build.gradle +++ b/build.gradle @@ -6,17 +6,17 @@ plugins { // Set version of programm // -version = "1.0.2" -def version = "1.0.2" +version = "1.0.3" +def version = "1.0.3" group = "de.rpjosh" // ----- // // Set correct encoding -compileJava.options.encoding = 'ISO-8859-1' +compileJava.options.encoding = 'UTF-8' tasks.withType(Javadoc) { - options.encoding = 'ISO-8859-1' + options.encoding = 'UTF-8' } sourceCompatibility = 11 diff --git a/src/main/java/de/rpjosh/installer/InstallConfig.java b/src/main/java/de/rpjosh/installer/InstallConfig.java index 3bb3869..a96bb7a 100644 --- a/src/main/java/de/rpjosh/installer/InstallConfig.java +++ b/src/main/java/de/rpjosh/installer/InstallConfig.java @@ -106,6 +106,11 @@ public class InstallConfig { protected String serviceRestart; protected Integer serviceRestartSec; + // GUI autostart // + protected boolean createGuiAutostart; + protected String guiAutostartUser; + protected String guiAutostartFlags; + // ----- // /** @@ -341,6 +346,18 @@ public class InstallConfig { this.serviceRestartSec = serviceRestartSec; } + /** + * [Linux] Creates an auto start for your GUI application that will be started directly after the window manager was loaded + * + * @param user User for which the GUI should be started + * @param startFlags Execution flags to add to the launch script like "--minimized" + */ + public void createGuiAutostart(String user, String startFlags) { + this.createGuiAutostart = true; + this.guiAutostartUser = user; + this.guiAutostartFlags= startFlags; + } + // Removal options // diff --git a/src/main/java/de/rpjosh/installer/Installer.java b/src/main/java/de/rpjosh/installer/Installer.java index 82e3ce3..6a8bf67 100644 --- a/src/main/java/de/rpjosh/installer/Installer.java +++ b/src/main/java/de/rpjosh/installer/Installer.java @@ -471,6 +471,13 @@ public class Installer { // create a systemd unit file // if (conf.createUnitFile) this.createUnitFile(); + // create a GUI auto start file // + if (conf.createGuiAutostart) { + // Currently only Gnome is supported + String pathMenu = "/home/" + conf.guiAutostartUser + "/.config/autostart/" + conf.getApplicationNameShort() + ".desktop"; + this.createDesktopShortcut(pathMenu, conf.guiAutostartFlags); + } + // create a uninstaller // try { String batchFileUninstall = "#!/bin/bash" + "\n" @@ -519,6 +526,11 @@ public class Installer { + "systemctl daemon-reload" + "\n" + "\n"; } + // remove autostart entry + if (conf.createGuiAutostart) { + batchFileUninstall + += "rm -f \"" + "/home/" + conf.guiAutostartUser + "/.config/autostart/" + conf.getApplicationNameShort() + ".desktop\"" + "\n"; + } batchFileUninstall += "\necho \"\"";