add systray launcher
Former-commit-id: 51275d0624
Former-commit-id: c33dd5ee98a8861817250de0cd7211fb34756c77
This commit is contained in:
@ -1,5 +1,5 @@
|
|||||||
#Firefox Configuration Section
|
#Firefox Configuration Section
|
||||||
#Sat Oct 22 23:06:43 EDT 2022
|
#Sat Oct 22 23:43:17 EDT 2022
|
||||||
chromium.bins.osx=ungoogled-chromium,chromium,brave,edge,ungoogled-chromium,chrome
|
chromium.bins.osx=ungoogled-chromium,chromium,brave,edge,ungoogled-chromium,chrome
|
||||||
chromium.bins.windows=ungoogled-chromium.exe,chromium.exe,brave.exe,edge.exe,ungoogled-chromium.exe,chrome.exe
|
chromium.bins.windows=ungoogled-chromium.exe,chromium.exe,brave.exe,edge.exe,ungoogled-chromium.exe,chrome.exe
|
||||||
firefox.bins.windows=firefox.exe,firefox-bin.exe,firefox-esr.exe,waterfox.exe,waterfox-bin.exe,librewolf.exe
|
firefox.bins.windows=firefox.exe,firefox-bin.exe,firefox-esr.exe,waterfox.exe,waterfox-bin.exe,librewolf.exe
|
||||||
@ -11,5 +11,5 @@ chromium.bins.linux=ungoogled-chromium,chromium,brave,edge,ungoogled-chromium,ch
|
|||||||
firefox.bins.osx=firefox,firefox-bin,firefox-esr,waterfox,waterfox-bin,librewolf
|
firefox.bins.osx=firefox,firefox-bin,firefox-esr,waterfox,waterfox-bin,librewolf
|
||||||
chromium.paths.osx=/Applications/Chromium.app/Contents/MacOS,/Applications/Chrome.app/Contents/MacOS,/Applications/Brave.app/Contents/MacOS
|
chromium.paths.osx=/Applications/Chromium.app/Contents/MacOS,/Applications/Chrome.app/Contents/MacOS,/Applications/Brave.app/Contents/MacOS
|
||||||
chromium.paths.linux=/usr/bin,/usr/local/bin,/opt/chromium/bin,/snap/bin
|
chromium.paths.linux=/usr/bin,/usr/local/bin,/opt/chromium/bin,/snap/bin
|
||||||
generic.bins.unix=sensible-browser,xdg-open,x-www-browser,gnome-www-browser,defaultbrowser,dillo,seamonkey,konqueror,galeon,surf,www-browser,links,lynx
|
|
||||||
firefox.paths.linux=/usr/bin,/usr/local/bin,/opt/firefox/bin,/snap/bin
|
firefox.paths.linux=/usr/bin,/usr/local/bin,/opt/firefox/bin,/snap/bin
|
||||||
|
generic.bins.unix=sensible-browser,xdg-open,x-www-browser,gnome-www-browser,defaultbrowser,dillo,seamonkey,konqueror,galeon,surf,www-browser,links,lynx
|
||||||
|
@ -10,6 +10,8 @@ import java.awt.event.ActionEvent;
|
|||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -44,7 +46,6 @@ public class I2PBrowser extends I2PCommonBrowser {
|
|||||||
public boolean chromiumFirst = false;
|
public boolean chromiumFirst = false;
|
||||||
public boolean usability = false;
|
public boolean usability = false;
|
||||||
static private boolean outputConfig = true;
|
static private boolean outputConfig = true;
|
||||||
static private boolean systrayIsRunning = false;
|
|
||||||
|
|
||||||
private void launchFirefox(int privateWindow, String[] url) {
|
private void launchFirefox(int privateWindow, String[] url) {
|
||||||
logger.info("I2PFirefox" + privateWindow);
|
logger.info("I2PFirefox" + privateWindow);
|
||||||
@ -247,41 +248,45 @@ public class I2PBrowser extends I2PCommonBrowser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
boolean systrayStarted = false;
|
||||||
try {
|
try {
|
||||||
systray(args);
|
systrayStarted = systray(args);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.warning(e.toString());
|
logger.warning(e.toString());
|
||||||
}
|
}
|
||||||
i2pBrowser.launch(privateBrowsing,
|
i2pBrowser.launch(privateBrowsing,
|
||||||
visitURL.toArray(new String[visitURL.size()]));
|
visitURL.toArray(new String[visitURL.size()]));
|
||||||
shutdownSystray();
|
|
||||||
}
|
}
|
||||||
private static boolean systrayIsRunningExternally() {
|
private static boolean systrayIsRunningExternally() {
|
||||||
File systrayIsRunningFile =
|
File systrayIsRunningFile =
|
||||||
new File(runtimeDirectory(""), "systray.running");
|
new File(runtimeDirectory(""), "systray.running");
|
||||||
if (systrayIsRunningFile.exists())
|
if (systrayIsRunningFile.exists()) {
|
||||||
|
logger.info("Systray is already running in another process");
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
FileWriter myWriter = new FileWriter(systrayIsRunningFile);
|
||||||
|
myWriter.write("systray is running");
|
||||||
|
myWriter.close();
|
||||||
|
} catch (IOException ioe) {
|
||||||
|
logger.warning(ioe.toString());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
private static void shutdownSystray() {
|
private static void shutdownSystray() {
|
||||||
if (systrayIsRunning) {
|
File systrayIsRunningFile =
|
||||||
File systrayIsRunningFile =
|
new File(runtimeDirectory(""), "systray.running");
|
||||||
new File(runtimeDirectory(""), "systray.running");
|
if (systrayIsRunningFile.exists())
|
||||||
if (systrayIsRunningFile.exists())
|
systrayIsRunningFile.delete();
|
||||||
systrayIsRunningFile.delete();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
public static void systray(String[] args) throws Exception {
|
public static boolean systray(String[] args) throws Exception {
|
||||||
if (systrayIsRunning) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (systrayIsRunningExternally()) {
|
if (systrayIsRunningExternally()) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
systrayIsRunning = true;
|
|
||||||
if (!SystemTray.isSupported()) {
|
if (!SystemTray.isSupported()) {
|
||||||
logger.warning("SystemTray is not supported");
|
logger.warning("SystemTray is not supported");
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemTray tray = SystemTray.getSystemTray();
|
SystemTray tray = SystemTray.getSystemTray();
|
||||||
@ -332,12 +337,16 @@ public class I2PBrowser extends I2PCommonBrowser {
|
|||||||
|
|
||||||
MenuItem closeItem = new MenuItem("Close");
|
MenuItem closeItem = new MenuItem("Close");
|
||||||
closeItem.addActionListener(new ActionListener() {
|
closeItem.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) { System.exit(0); }
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
shutdownSystray();
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
menu.add(closeItem);
|
menu.add(closeItem);
|
||||||
TrayIcon icon = new TrayIcon(image, "I2P Browser Profile Controller", menu);
|
TrayIcon icon = new TrayIcon(image, "I2P Browser Profile Controller", menu);
|
||||||
icon.setImageAutoSize(true);
|
icon.setImageAutoSize(true);
|
||||||
|
|
||||||
tray.add(icon);
|
tray.add(icon);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user