Class Linux

java.lang.Object
javaforce.linux.Linux

public class Linux extends Object
Common functions for Linux administration.
  • Field Details

  • Constructor Details

    • Linux

      public Linux()
  • Method Details

    • getVersion

      public static String getVersion()
      Returns Linux version as float.
    • detectDistro

      public static boolean detectDistro()
      Detects Linux distribution type.
    • ubuntuAddRepo

      public static boolean ubuntuAddRepo(String ppa)
    • mkdir

      public static boolean mkdir(String folder)
      Creates folder
    • copyFile

      public static boolean copyFile(String src, String dst)
      Copies src to dst
    • createLink

      public static boolean createLink(String target, String link)
      Creates Link to Target
    • deleteFile

      public static boolean deleteFile(String file)
      Deletes file
    • restartService

      public static boolean restartService(String name)
      Restarts a service
    • restartJFService

      public static boolean restartJFService(String name)
      Restarts a JF service
    • ubuntuUpdate

      public static boolean ubuntuUpdate()
    • installPackage

      public static boolean installPackage(String pkg, String desc)
    • removePackage

      public static boolean removePackage(String pkg, String desc)
    • setExec

      public static boolean setExec(String file)
      Sets file as executable
    • chmod

      public static boolean chmod(String file, int mod)
      Sets file mod
    • searchPackages

      public static String[][] searchPackages(String regex)
      Searches for available packages (NOTE:There may be nulls in the output)
    • ubuntu_updateInstalled

      public static void ubuntu_updateInstalled()
    • fedora_updateInstalled

      public static void fedora_updateInstalled()
    • arch_updateInstalled

      public static void arch_updateInstalled()
    • updateInstalled

      public static void updateInstalled()
    • isInstalled

      public static boolean isInstalled(String pkg)
    • getPackageDesc

      public static String getPackageDesc(String pkg)
    • isMemberOf

      public static boolean isMemberOf(String user, String group)
    • addUserToGroup

      public static boolean addUserToGroup(String user, String group)
    • expandDesktopExec

      public static String[] expandDesktopExec(String exec, String file)
      Currently only supports %f,%F,%u,%U
    • expandDesktopExec

      public static String[] expandDesktopExec(String exec, String[] file)
      Currently only supports %f,%F,%u,%U
    • executeDesktop

      public static boolean executeDesktop(String desktop, String[] file)
    • detectBits

      public static int detectBits()
    • runScript

      public static boolean runScript(String[] lns)
      Runs a bash script
    • init

      public static boolean init()
    • x11_get_id

      public static long x11_get_id(Window w)
    • x11_set_desktop

      public static void x11_set_desktop(long xid)
    • x11_set_dock

      public static void x11_set_dock(long xid)
    • x11_set_strut

      public static void x11_set_strut(long xid, int panelHeight, int x, int y, int width, int height)
    • x11_set_listener

      public static void x11_set_listener(X11Listener cb)
    • x11_tray_main

      public static void x11_tray_main(long pid, int screenWidth, int trayPos, int trayHeight)
      Polls and dispatches tray events. Does not return until x11_tray_stop() is called.
    • x11_tray_reposition

      public static void x11_tray_reposition(int screenWidth, int trayPos, int trayHeight)
      Repositions tray icons and the tray window itself.
      Parameters:
      screenWidth - = new screen width (-1 = has not changed)
    • x11_tray_stop

      public static void x11_tray_stop()
      Stops x11_tray_main()
    • x11_tray_width

      public static int x11_tray_width()
    • x11_window_list_main

      public static void x11_window_list_main()
      Polls and dispatches top-level windows events. Does not return until x11_window_list_stop() is called.
    • x11_window_list_stop

      public static void x11_window_list_stop()
    • x11_get_window_list

      public static Linux.Window[] x11_get_window_list()
      Returns list of all top-level windows. NOTE : x11_window_list_main() must be running.
    • x11_minimize_all

      public static void x11_minimize_all()
    • x11_raise_window

      public static void x11_raise_window(long xid)
    • x11_map_window

      public static void x11_map_window(long xid)
    • x11_unmap_window

      public static void x11_unmap_window(long xid)
    • x11_keysym_to_keycode

      public static int x11_keysym_to_keycode(char keysym)
    • x11_send_event

      public static boolean x11_send_event(int keycode, boolean down)
      Send keyboard event to window with focus.
    • x11_send_event

      public static boolean x11_send_event(long id, int keycode, boolean down)
      Send keyboard event to specific window.
    • x11_rr_get_setup

      public static Linux.Monitor[] x11_rr_get_setup(Linux.Monitor[] config)
      X11 : RandR : Detects current state.
      Parameters:
      config - = current settings (optional)
      Returns:
      new settings
    • x11_rr_arrangeMonitors

      public static Linux.Monitor[] x11_rr_arrangeMonitors(Linux.Monitor[] monitors)
      Arranges monitors ensuring they all have valid positions.
      Returns:
      : the same list of monitors
    • x11_rr_auto

      public static void x11_rr_auto()
      X11 : RandR : Reconnects disconnected monitors.
    • x11_rr_set

      public static void x11_rr_set(Linux.Monitor[] config)
      X11 : RandR : Applies config.
    • x11_rr_reset

      public static void x11_rr_reset(String res)
      X11 : RandR : Sets only primary display to res and disable all other (for Logon Screen)
      Parameters:
      res - = resolution (ie: 800x600)
    • x11_rr_load_user

      public static Linux.Monitor[] x11_rr_load_user()
    • x11_rr_save_user

      public static void x11_rr_save_user(Linux.Monitor[] monitor)
    • authUser

      public static boolean authUser(String user, String pass)
    • kill

      public static void kill(int pid, int signal)
    • setenv

      public static void setenv(String name, String value)
    • getHostname

      public static String getHostname()
    • getDistro

      public static String getDistro()
    • getOSRelease

      public static String getOSRelease(String name)
      Returns /etc/os-release property.
    • addsshkey

      public static boolean addsshkey(String key)
      Adds public ssh key to /root/.ssh/authorized_keys
    • reboot

      public static void reboot()
      Reboot system.
    • shutdown

      public static void shutdown()
      Shutdown system.
    • main

      public static void main(String[] args)