Skip to content

Commit

Permalink
- bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
BeanVortex committed Dec 14, 2023
1 parent ee6527f commit fcca0a9
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 8 deletions.
3 changes: 2 additions & 1 deletion builders/linux-installer/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ fi
desktopFile="BitKip.desktop"
uninstallDesktopFile="BitKipUninstall.desktop"
desktopFilePath="./application/$desktopFile"
uninstallDesktopFilePath="./application/$uninstallDesktopFile"


for user in $(cut -d: -f1 /etc/passwd); do
Expand All @@ -19,7 +20,7 @@ for user in $(cut -d: -f1 /etc/passwd); do
done

mv "$desktopFilePath" /usr/share/applications/
mv "$uninstallDesktopFile" /usr/share/applications/
mv "$uninstallDesktopFilePath" /usr/share/applications/

chmod a+rx ./application/bitkip
mv ./application/bitkip /usr/bin/
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/ir/darkdeveloper/bitkip/BitKip.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import io.helidon.webserver.WebServer;
import ir.darkdeveloper.bitkip.config.AppConfigs;
import ir.darkdeveloper.bitkip.config.observers.QueueSubject;
import ir.darkdeveloper.bitkip.exceptions.DeniedException;
import ir.darkdeveloper.bitkip.repo.DownloadsRepo;
import ir.darkdeveloper.bitkip.repo.QueuesRepo;
import ir.darkdeveloper.bitkip.repo.ScheduleRepo;
Expand All @@ -17,6 +18,7 @@
import javafx.application.Application;
import javafx.application.Platform;
import javafx.stage.Stage;
import org.controlsfx.control.Notifications;


import java.awt.*;
Expand Down Expand Up @@ -55,6 +57,20 @@ public void start(Stage stage) {
startServer();
}

private void initStartup() {
try {
if (!startup && existsOnStartup())
removeFromStartup();
if (startup && !existsOnStartup())
addToStartup();
} catch (DeniedException e) {
Notifications.create()
.title("Failed")
.text(e.getMessage())
.showError();
}
}


private void initTray(Stage stage) {
if (SystemTray.isSupported()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ private void onStartupCheck() {
initStartup();
}

public static void initStartup() {
private void initStartup() {
try {
if (startup && !existsOnStartup())
addToStartup();
Expand All @@ -325,10 +325,16 @@ public static void addToStartup() throws DeniedException {
System.getProperty("user.dir") + "\\BitKip.exe");
} else if (com.sun.jna.Platform.isLinux()) {
var userHome = System.getProperty("user.home");
var path = userHome + File.separator + ".config" + File.separator + "autostart" + "BitKip.d";
var changedNamePath = userHome + File.separator + ".config" + File.separator + "autostart" + "BitKip.desktop";
var configPath = userHome + File.separator + ".config" + File.separator + "autostart" + File.separator;
var path = configPath + "BitKip.d";
var changedNamePath = configPath + "BitKip.desktop";
var of = Path.of(changedNamePath);

try {
Files.move(Path.of(path), Path.of(changedNamePath), StandardCopyOption.REPLACE_EXISTING);
if (!new File(path).exists())
Files.copy(Path.of("/usr/share/applications/BitKip.desktop"), of, StandardCopyOption.REPLACE_EXISTING);
else
Files.move(Path.of(path), of, StandardCopyOption.REPLACE_EXISTING);
} catch (IOException e) {
throw new DeniedException("Failed to add BitKip to startup");
}
Expand All @@ -342,7 +348,7 @@ public static boolean existsOnStartup() {
"BitKip");
else if (com.sun.jna.Platform.isLinux()) {
var userHome = System.getProperty("user.home");
var path = userHome + File.separator + ".config" + File.separator + "autostart" + "BitKip.desktop";
var path = userHome + File.separator + ".config" + File.separator + "autostart" + File.separator + "BitKip.desktop";
return new File(path).exists();
}
return false;
Expand All @@ -355,8 +361,8 @@ public static void removeFromStartup() throws DeniedException {
"BitKip");
} else if (com.sun.jna.Platform.isLinux()) {
var userHome = System.getProperty("user.home");
var path = userHome + File.separator + ".config" + File.separator + "autostart" + "BitKip.desktop";
var changedNamePath = userHome + File.separator + ".config" + File.separator + "autostart" + "BitKip.d";
var path = userHome + File.separator + ".config" + File.separator + "autostart" + File.separator + "BitKip.desktop";
var changedNamePath = userHome + File.separator + ".config" + File.separator + "autostart" + File.separator + "BitKip.d";
try {
Files.move(Path.of(path), Path.of(changedNamePath), StandardCopyOption.REPLACE_EXISTING);
} catch (IOException e) {
Expand Down

0 comments on commit fcca0a9

Please sign in to comment.