OSFunction (SelekTOR Java Documentation)
Date: 2017-04-14

lib

## Class OSFunction

- java.lang.Object
- - lib.OSFunction

-     public class OSFunction
      extends java.lang.Object

  Author:
    Alistair Neil

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `OSFunction()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `clearActiveProcesses()` Clear active processes, mainly to reduce memory consumption when were done with them
    `static java.util.ArrayList<java.lang.String>` | `filterProcesses(java.util.ArrayList<java.lang.String> processes, java.lang.String filter)` Find processes matching the contents of filter
    `static java.util.ArrayList<java.lang.String>` | `filterProcesses(java.lang.String filter)` Find processes matching the contents of filter
    `static java.lang.String` | `findFile(java.lang.String fname, java.lang.String... paths)` Find a specific file, requires a series of paths where it might be found to be provided
    `static java.lang.String` | `getActiveDesktop()` Get the name of the active desktop
    `static java.lang.String` | `getAppSettingsPath(java.lang.String appname, java.lang.String appseries)` Get a specified application's settings folder, if null return this applications setting folder
    `static java.util.ArrayList<java.lang.String>` | `getCachedProcesses()` Cached list of processes
    `static java.lang.String` | `getCompositor()` Get the name of the compositor
    `static java.lang.String` | `getFileSeparator()` Get file separator
    `static java.lang.String` | `getGnome3Pref(java.lang.String schema, java.lang.String key)` Get gnome 3 preference using schema name and key name
    `static java.lang.String` | `getGsettingsPath()` Test if gsettings installed (Linux only)
    `static java.lang.String` | `getKDEPref(java.lang.String group, java.lang.String key, java.lang.String def)` Get a kde preference string value using group name, key name and return contents of def on failure
    `static java.lang.String` | `getKDEProxyPath()` Test for KDE installed (Linux only)
    `static java.lang.String` | `getLangCode()` Get default language iso code
    `static java.util.ArrayList<java.lang.String>` | `getLiveProcesses()` Gets list of active system processes
    `static java.lang.String` | `getOSArch()` Get OS architecture, convenience method
    `static java.lang.String` | `getOSName()` Get OS name, convenience method
    `static java.lang.String` | `getOSVersion()` Get OS version
    `static java.lang.String` | `getOurProcessID()` Get process id
    `static java.lang.String` | `getProcessID(java.lang.String process)` Get process id from a process
    `static java.util.ArrayList<java.lang.String>` | `getProcessOutput(java.io.InputStream is)` Obtain all output of an executed process.
    `static java.lang.String` | `getProcessResult(java.lang.Process aprocess)` Convenience method to get the first resultant output of an executed process as a String
    `static java.lang.String` | `getTempFolder(java.lang.String path)` Get users temp folder
    `static java.lang.String` | `getUserName()` Get user name
    `static java.lang.String` | `getUsersCurrentFolder()` Get users current folder
    `static java.lang.String` | `getUsersDocFolder()` Get users documents folder (Windows only)
    `static java.lang.String` | `getUserSettingsPath()` Get user settings path
    `static java.lang.String` | `getUsersHomeFolder()` Get users home folder
    `static boolean` | `isLinux()` Generic test for Linux platform
    `static boolean` | `isMultipleInstance(java.lang.String appname)` Test to see if their are multiple instances of the this app running
    `static boolean` | `isWin10()` Specific test for Win 10
    `static boolean` | `isWin7()` Specific test for Win 7
    `static boolean` | `isWin8()` Specific test for Win 8
    `static boolean` | `isWindows()` Generic test for Windows platform
    `static boolean` | `isWinXP()` Specific test for Win XP
    `static java.lang.String` | `killProcess(java.lang.String pid)` Generic kill process with matching pid
    `static java.lang.Process` | `launchProcess(java.lang.String... command)` Launch an external process with arguments
    `static void` | `resetGnome3Pref(java.lang.String schema, java.lang.String key)` Reset a gnome3 value to its default.
    `static void` | `setFileHidden(java.lang.String filepath, boolean hidden)` Set a files hidden status (Windows only)
    `static void` | `setGnome3Pref(java.lang.String schema, java.lang.String key, boolean value)` Set a gnome 3 boolean value using schema name and key name
    `static void` | `setGnome3Pref(java.lang.String schema, java.lang.String key, java.lang.String value)` Set a gnome 3 string value using schema name and key name
    `static void` | `setKDEPref(java.lang.String group, java.lang.String key, boolean value)` Set a kde boolean preference value using group name, key name
    `static void` | `setKDEPref(java.lang.String group, java.lang.String key, int value)` Set a kde integer preference value using group name, key name
    `static void` | `setKDEPref(java.lang.String group, java.lang.String key, java.lang.String value)` Set a kde string preference value using group name, key name

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### OSFunction

          public OSFunction()

  - ### Method Detail

    - #### getOurProcessID

          public static java.lang.String getOurProcessID()

      Get process id
      Returns:
        Process id or -1 if not found

    - #### getProcessID

          public static java.lang.String getProcessID(java.lang.String process)

      Get process id from a process
      Parameters:
        `process` -
      Returns:
        process id as String

    - #### getOSVersion

          public static java.lang.String getOSVersion()

      Get OS version
      Returns:
        String OS version

    - #### getUserName

          public static java.lang.String getUserName()

      Get user name
      Returns:
        String User name

    - #### getUsersHomeFolder

          public static java.lang.String getUsersHomeFolder()

      Get users home folder
      Returns:
        String path to home folder

    - #### getFileSeparator

          public static java.lang.String getFileSeparator()

      Get file separator
      Returns:
        String separator

    - #### getUsersDocFolder

          public static java.lang.String getUsersDocFolder()

      Get users documents folder (Windows only)
      Returns:
        String path to documents folder

    - #### getUserSettingsPath

          public static java.lang.String getUserSettingsPath()

      Get user settings path
      Returns:
        String path to user settings folder

    - #### getAppSettingsPath

          public static java.lang.String getAppSettingsPath(java.lang.String appname,
                                                            java.lang.String appseries)

      Get a specified application's settings folder, if null return this applications setting folder
      Parameters:
        `appname` - Application settings folder name
        `appseries` - Application series (optional)
      Returns:
        String Path to the applications setting folder

    - #### getUsersCurrentFolder

          public static java.lang.String getUsersCurrentFolder()

      Get users current folder
      Returns:
        String Path to current folder

    - #### getTempFolder

          public static java.lang.String getTempFolder(java.lang.String path)

      Get users temp folder
      Parameters:
        `path` -
      Returns:
        String Path to users temp folder

    - #### getOSName

          public static java.lang.String getOSName()

      Get OS name, convenience method
      Returns:
        String

    - #### getOSArch

          public static java.lang.String getOSArch()

      Get OS architecture, convenience method
      Returns:
        String

    - #### isWindows

          public static boolean isWindows()

      Generic test for Windows platform
      Returns:
        boolean True if Windows

    - #### isWin7

          public static boolean isWin7()

      Specific test for Win 7
      Returns:
        boolean True if Win 7

    - #### isWin8

          public static boolean isWin8()

      Specific test for Win 8
      Returns:
        boolean True if Win 8

    - #### isWin10

          public static boolean isWin10()

      Specific test for Win 10
      Returns:
        boolean True if Win 10

    - #### isWinXP

          public static boolean isWinXP()

      Specific test for Win XP
      Returns:
        boolean True if Win XP

    - #### isLinux

          public static boolean isLinux()

      Generic test for Linux platform
      Returns:
        boolean True if Linux

    - #### findFile

          public static java.lang.String findFile(java.lang.String fname,
                                                  java.lang.String... paths)

      Find a specific file, requires a series of paths where it might be found to be provided
      Parameters:
        `fname` -
        `paths` -
      Returns:
        String path to file or null

    - #### isMultipleInstance

          public static boolean isMultipleInstance(java.lang.String appname)

      Test to see if their are multiple instances of the this app running
      Parameters:
        `appname` -
      Returns:
        True if multiple instance

    - #### getCachedProcesses

          public static java.util.ArrayList<java.lang.String> getCachedProcesses()

      Cached list of processes
      Returns:
        list

    - #### filterProcesses

          public static java.util.ArrayList<java.lang.String> filterProcesses(java.util.ArrayList<java.lang.String> processes,
                                                                              java.lang.String filter)

      Find processes matching the contents of filter
      Parameters:
        `processes` -
        `filter` -
      Returns:
        ArrayList of matching processes

    - #### filterProcesses

          public static java.util.ArrayList<java.lang.String> filterProcesses(java.lang.String filter)

      Find processes matching the contents of filter
      Parameters:
        `filter` -
      Returns:
        ArrayList of matching processes

    - #### killProcess

          public static java.lang.String killProcess(java.lang.String pid)

      Generic kill process with matching pid
      Parameters:
        `pid` -
      Returns:
        String kill result or null if failed

    - #### setFileHidden

          public static void setFileHidden(java.lang.String filepath,
                                           boolean hidden)

      Set a files hidden status (Windows only)
      Parameters:
        `filepath` - Path to file includes filename
        `hidden` - True/False

    - #### getGnome3Pref

          public static java.lang.String getGnome3Pref(java.lang.String schema,
                                                       java.lang.String key)

      Get gnome 3 preference using schema name and key name
      Parameters:
        `schema` -
        `key` -
      Returns:
        String preference value

    - #### setGnome3Pref

          public static void setGnome3Pref(java.lang.String schema,
                                           java.lang.String key,
                                           boolean value)

      Set a gnome 3 boolean value using schema name and key name
      Parameters:
        `schema` -
        `key` -
        `value` -

    - #### setGnome3Pref

          public static void setGnome3Pref(java.lang.String schema,
                                           java.lang.String key,
                                           java.lang.String value)

      Set a gnome 3 string value using schema name and key name
      Parameters:
        `schema` -
        `key` -
        `value` -

    - #### resetGnome3Pref

          public static void resetGnome3Pref(java.lang.String schema,
                                             java.lang.String key)

      Reset a gnome3 value to its default. If key is null, it will reset the whole schema tree to its defaults
      Parameters:
        `schema` -
        `key` -

    - #### getKDEPref

          public static java.lang.String getKDEPref(java.lang.String group,
                                                    java.lang.String key,
                                                    java.lang.String def)

      Get a kde preference string value using group name, key name and return contents of def on failure
      Parameters:
        `group` -
        `key` -
        `def` -
      Returns:
        String Preference value

    - #### setKDEPref

          public static void setKDEPref(java.lang.String group,
                                        java.lang.String key,
                                        java.lang.String value)

      Set a kde string preference value using group name, key name
      Parameters:
        `group` -
        `key` -
        `value` -

    - #### setKDEPref

          public static void setKDEPref(java.lang.String group,
                                        java.lang.String key,
                                        boolean value)

      Set a kde boolean preference value using group name, key name
      Parameters:
        `group` -
        `key` -
        `value` -

    - #### setKDEPref

          public static void setKDEPref(java.lang.String group,
                                        java.lang.String key,
                                        int value)

      Set a kde integer preference value using group name, key name
      Parameters:
        `group` -
        `key` -
        `value` -

    - #### getKDEProxyPath

          public static java.lang.String getKDEProxyPath()

      Test for KDE installed (Linux only)
      Returns:
        String path to kde proxy file or null

    - #### getGsettingsPath

          public static java.lang.String getGsettingsPath()

      Test if gsettings installed (Linux only)
      Returns:
        String path to gsetttings

    - #### getProcessResult

          public static java.lang.String getProcessResult(java.lang.Process aprocess)

      Convenience method to get the first resultant output of an executed process as a String
      Parameters:
        `aprocess` -
      Returns:
        String Process result

    - #### getProcessOutput

          public static java.util.ArrayList<java.lang.String> getProcessOutput(java.io.InputStream is)

      Obtain all output of an executed process.
      Parameters:
        `is` -
      Returns:
        ArrayList of Strings containing all generated output

    - #### launchProcess

          public static java.lang.Process launchProcess(java.lang.String... command)

      Launch an external process with arguments
      Parameters:
        `command` -
      Returns:
        Process

    - #### getLiveProcesses

          public static java.util.ArrayList<java.lang.String> getLiveProcesses()

      Gets list of active system processes
      Returns:
        Arraylist of system process

    - #### getCompositor

          public static java.lang.String getCompositor()

      Get the name of the compositor
      Returns:
        name as String

    - #### getActiveDesktop

          public static java.lang.String getActiveDesktop()

      Get the name of the active desktop
      Returns:
        name as String

    - #### clearActiveProcesses

          public static void clearActiveProcesses()

      Clear active processes, mainly to reduce memory consumption when were done with them

    - #### getLangCode

          public static java.lang.String getLangCode()

      Get default language iso code
      Returns:
        language iso code