Refactored OS utils into their own class (b/c of dependency issues)
This commit is contained in:
parent
297d68e06e
commit
4e009340fa
@ -57,6 +57,7 @@ import dorkbox.systemTray.util.SystemTrayFixes;
|
|||||||
import dorkbox.util.CacheUtil;
|
import dorkbox.util.CacheUtil;
|
||||||
import dorkbox.util.IO;
|
import dorkbox.util.IO;
|
||||||
import dorkbox.util.OS;
|
import dorkbox.util.OS;
|
||||||
|
import dorkbox.util.OsUtil;
|
||||||
import dorkbox.util.Property;
|
import dorkbox.util.Property;
|
||||||
import dorkbox.util.SwingUtil;
|
import dorkbox.util.SwingUtil;
|
||||||
import dorkbox.util.process.ShellProcessBuilder;
|
import dorkbox.util.process.ShellProcessBuilder;
|
||||||
@ -445,7 +446,7 @@ class SystemTray {
|
|||||||
|
|
||||||
// BLEH. if gnome-shell is running, IT'S REALLY GNOME!
|
// BLEH. if gnome-shell is running, IT'S REALLY GNOME!
|
||||||
// we must ALWAYS do this check!!
|
// we must ALWAYS do this check!!
|
||||||
boolean isReallyGnome = OS.isGnome();
|
boolean isReallyGnome = OsUtil.Linux.DesktopEnv.isGnome();
|
||||||
|
|
||||||
if (isReallyGnome) {
|
if (isReallyGnome) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
@ -475,7 +476,7 @@ class SystemTray {
|
|||||||
trayType = selectTypeQuietly(useNativeMenus, TrayType.GtkStatusIcon);
|
trayType = selectTypeQuietly(useNativeMenus, TrayType.GtkStatusIcon);
|
||||||
}
|
}
|
||||||
else if ("kde".equalsIgnoreCase(XDG)) {
|
else if ("kde".equalsIgnoreCase(XDG)) {
|
||||||
if (OS.getFedoraVersion() > 0) {
|
if (OsUtil.Linux.isFedora()) {
|
||||||
// Fedora KDE requires GtkStatusIcon
|
// Fedora KDE requires GtkStatusIcon
|
||||||
trayType = selectTypeQuietly(useNativeMenus, TrayType.GtkStatusIcon);
|
trayType = selectTypeQuietly(useNativeMenus, TrayType.GtkStatusIcon);
|
||||||
} else {
|
} else {
|
||||||
@ -490,7 +491,7 @@ class SystemTray {
|
|||||||
// http://bazaar.launchpad.net/~wingpanel-devs/wingpanel/trunk/view/head:/sample/SampleIndicator.vala
|
// http://bazaar.launchpad.net/~wingpanel-devs/wingpanel/trunk/view/head:/sample/SampleIndicator.vala
|
||||||
|
|
||||||
if (!useNativeMenus && AUTO_FIX_INCONSISTENCIES) {
|
if (!useNativeMenus && AUTO_FIX_INCONSISTENCIES) {
|
||||||
if (OS.isElementaryOS()) {
|
if (OsUtil.Linux.isElementaryOS()) {
|
||||||
} else {
|
} else {
|
||||||
logger.warn("Cannot use non-native menus with pantheon DE. Forcing native menus.");
|
logger.warn("Cannot use non-native menus with pantheon DE. Forcing native menus.");
|
||||||
}
|
}
|
||||||
@ -510,7 +511,7 @@ class SystemTray {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ("gnome".equalsIgnoreCase(GDM)) {
|
if ("gnome".equalsIgnoreCase(GDM)) {
|
||||||
if (OS.isArch()) {
|
if (OsUtil.Linux.isArch()) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
logger.debug("Running Arch Linux.");
|
logger.debug("Running Arch Linux.");
|
||||||
}
|
}
|
||||||
@ -526,16 +527,12 @@ class SystemTray {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// are we fedora? If so, what version?
|
// are we fedora? If so, what version?
|
||||||
// now, what VERSION of fedora? 23/24/25 don't have AppIndicator installed, so we have to use GtkStatusIcon
|
// now, what VERSION of fedora? 23/24/25/? don't have AppIndicator installed, so we have to use GtkStatusIcon
|
||||||
int fedoraVersion = OS.getFedoraVersion();
|
if (OsUtil.Linux.isFedora()) {
|
||||||
if (fedoraVersion > 0) {
|
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
logger.debug("Running Fedora version: '{}'", fedoraVersion);
|
logger.debug("Running Fedora");
|
||||||
}
|
}
|
||||||
|
|
||||||
// set a property so that Image Resize can adjust. It will check the version info to determine scaling value
|
|
||||||
System.setProperty("SystemTray_IS_FEDORA_GNOME_ADJUST_SIZE", Integer.toString(fedoraVersion));
|
|
||||||
|
|
||||||
// 23 is gtk, 24/25 is gtk (but also wrong size unless we adjust it)
|
// 23 is gtk, 24/25 is gtk (but also wrong size unless we adjust it)
|
||||||
trayType = selectTypeQuietly(useNativeMenus, TrayType.GtkStatusIcon);
|
trayType = selectTypeQuietly(useNativeMenus, TrayType.GtkStatusIcon);
|
||||||
} else {
|
} else {
|
||||||
@ -703,7 +700,7 @@ class SystemTray {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (OS.isArch()) {
|
if (OsUtil.Linux.isArch()) {
|
||||||
// arch linux is fun!
|
// arch linux is fun!
|
||||||
|
|
||||||
if (isTrayType(trayType, TrayType.AppIndicator)) {
|
if (isTrayType(trayType, TrayType.AppIndicator)) {
|
||||||
|
@ -35,7 +35,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import dorkbox.systemTray.SystemTray;
|
import dorkbox.systemTray.SystemTray;
|
||||||
import dorkbox.util.IO;
|
import dorkbox.util.IO;
|
||||||
import dorkbox.util.OS;
|
import dorkbox.util.OsUtil;
|
||||||
import dorkbox.util.Property;
|
import dorkbox.util.Property;
|
||||||
import dorkbox.util.process.ShellProcessBuilder;
|
import dorkbox.util.process.ShellProcessBuilder;
|
||||||
|
|
||||||
@ -214,7 +214,7 @@ class Extension {
|
|||||||
*/
|
*/
|
||||||
public static
|
public static
|
||||||
void install() {
|
void install() {
|
||||||
if (!ENABLE_EXTENSION_INSTALL || !OS.isGnome()) {
|
if (!ENABLE_EXTENSION_INSTALL || !OsUtil.Linux.DesktopEnv.isGnome()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,7 +222,7 @@ class Extension {
|
|||||||
boolean hasSystemTray;
|
boolean hasSystemTray;
|
||||||
|
|
||||||
// should just be 3.14.1 or 3.20 or similar
|
// should just be 3.14.1 or 3.20 or similar
|
||||||
String gnomeVersion = OS.getGnomeVersion();
|
String gnomeVersion = OsUtil.Linux.DesktopEnv.getGnomeVersion();
|
||||||
if (gnomeVersion == null) {
|
if (gnomeVersion == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -382,7 +382,7 @@ class Extension {
|
|||||||
|
|
||||||
public static
|
public static
|
||||||
void unInstall() {
|
void unInstall() {
|
||||||
if (!ENABLE_EXTENSION_INSTALL || !OS.isGnome()) {
|
if (!ENABLE_EXTENSION_INSTALL || !OsUtil.Linux.DesktopEnv.isGnome()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,6 +51,7 @@ import dorkbox.util.FileUtil;
|
|||||||
import dorkbox.util.IO;
|
import dorkbox.util.IO;
|
||||||
import dorkbox.util.LocationResolver;
|
import dorkbox.util.LocationResolver;
|
||||||
import dorkbox.util.OS;
|
import dorkbox.util.OS;
|
||||||
|
import dorkbox.util.OsUtil;
|
||||||
import dorkbox.util.SwingUtil;
|
import dorkbox.util.SwingUtil;
|
||||||
import dorkbox.util.process.ShellProcessBuilder;
|
import dorkbox.util.process.ShellProcessBuilder;
|
||||||
|
|
||||||
@ -72,7 +73,7 @@ class ImageUtils {
|
|||||||
|
|
||||||
if (SystemTray.AUTO_TRAY_SIZE) {
|
if (SystemTray.AUTO_TRAY_SIZE) {
|
||||||
if (OS.isWindows()) {
|
if (OS.isWindows()) {
|
||||||
int[] version = OS.getWindowsVersion();
|
int[] version = OsUtil.Windows.getVersion();
|
||||||
|
|
||||||
// if windows 8.1/10 - default size is x2
|
// if windows 8.1/10 - default size is x2
|
||||||
|
|
||||||
@ -154,14 +155,14 @@ class ImageUtils {
|
|||||||
String XDG = System.getenv("XDG_CURRENT_DESKTOP");
|
String XDG = System.getenv("XDG_CURRENT_DESKTOP");
|
||||||
if (XDG == null) {
|
if (XDG == null) {
|
||||||
// Check if plasmashell is running, if it is -- then we are most likely KDE
|
// Check if plasmashell is running, if it is -- then we are most likely KDE
|
||||||
double plasmaVersion = OS.getPlasmaVersion();
|
double plasmaVersion = OsUtil.Linux.DesktopEnv.getPlasmaVersion();
|
||||||
if (plasmaVersion > 0) {
|
if (plasmaVersion > 0) {
|
||||||
XDG = "kde";
|
XDG = "kde";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ("kde".equalsIgnoreCase(XDG)) {
|
if ("kde".equalsIgnoreCase(XDG)) {
|
||||||
double plasmaVersion = OS.getPlasmaVersion();
|
double plasmaVersion = OsUtil.Linux.DesktopEnv.getPlasmaVersion();
|
||||||
|
|
||||||
// 1 = 16
|
// 1 = 16
|
||||||
// 2 = 32
|
// 2 = 32
|
||||||
@ -220,8 +221,8 @@ class ImageUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// fedora 24+ has a different size for the indicator (NOT default 16px)
|
// fedora 23+ has a different size for the indicator (NOT default 16px)
|
||||||
int fedoraVersion = Integer.parseInt(System.getProperty("SystemTray_IS_FEDORA_GNOME_ADJUST_SIZE", "0"));
|
int fedoraVersion = OsUtil.Linux.getFedoraVersion();
|
||||||
if (trayScalingFactor == 0 && fedoraVersion >= 23) {
|
if (trayScalingFactor == 0 && fedoraVersion >= 23) {
|
||||||
if (SystemTray.DEBUG) {
|
if (SystemTray.DEBUG) {
|
||||||
SystemTray.logger.debug("Adjusting tray/menu scaling for FEDORA " + fedoraVersion);
|
SystemTray.logger.debug("Adjusting tray/menu scaling for FEDORA " + fedoraVersion);
|
||||||
|
Loading…
Reference in New Issue
Block a user