Package javaforce.linux
Class Linux
java.lang.Object
javaforce.linux.Linux
Common functions for Linux administration.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic enumstatic enumstatic classstatic classstatic classstatic classstatic class -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic Linux.DerivedTypesstatic Linux.DistroTypesstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic ArrayList<Linux.Screen> static final intstatic final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanAdds public ssh key to /root/.ssh/authorized_keysstatic booleanaddUserToGroup(String user, String group) static voidstatic booleanstatic booleanSets file modstatic booleanCopies src to dststatic booleancreateLink(String target, String link) Creates Link to Targetstatic booleandeleteFile(String file) Deletes filestatic intstatic booleanDetects Linux distribution type.static booleanexecuteDesktop(String desktop, String[] file) static String[]expandDesktopExec(String exec, String file) Currently only supports %f,%F,%u,%Ustatic String[]expandDesktopExec(String exec, String[] file) Currently only supports %f,%F,%u,%Ustatic voidstatic Stringstatic Stringstatic StringgetOSRelease(String name) Returns /etc/os-release property.static StringgetPackageDesc(String pkg) static StringReturns Linux version as float.static booleaninit()static booleaninstallPackage(String pkg, String desc) static booleanisInstalled(String pkg) static booleanisMemberOf(String user, String group) static voidkill(int pid, int signal) static voidstatic booleanCreates folderstatic voidreboot()Reboot system.static booleanremovePackage(String pkg, String desc) static booleanrestartJFService(String name) Restarts a JF servicestatic booleanrestartService(String name) Restarts a servicestatic booleanRuns a bash scriptstatic String[][]searchPackages(String regex) Searches for available packages (NOTE:There may be nulls in the output)static voidstatic booleanSets file as executablestatic voidshutdown()Shutdown system.static voidstatic booleanubuntuAddRepo(String ppa) static booleanstatic voidstatic longx11_get_id(Window w) static Linux.Window[]Returns list of all top-level windows.static intx11_keysym_to_keycode(char keysym) static voidx11_map_window(long xid) static voidstatic voidx11_raise_window(long xid) static Linux.Monitor[]x11_rr_arrangeMonitors(Linux.Monitor[] monitors) Arranges monitors ensuring they all have valid positions.static voidX11 : RandR : Reconnects disconnected monitors.static Linux.Monitor[]x11_rr_get_setup(Linux.Monitor[] config) X11 : RandR : Detects current state.static Linux.Monitor[]static voidx11_rr_reset(String res) X11 : RandR : Sets only primary display to res and disable all other (for Logon Screen)static voidx11_rr_save_user(Linux.Monitor[] monitor) static voidx11_rr_set(Linux.Monitor[] config) X11 : RandR : Applies config.static booleanx11_send_event(int keycode, boolean down) Send keyboard event to window with focus.static booleanx11_send_event(long id, int keycode, boolean down) Send keyboard event to specific window.static voidx11_set_desktop(long xid) static voidx11_set_dock(long xid) static voidstatic voidx11_set_strut(long xid, int panelHeight, int x, int y, int width, int height) static voidx11_tray_main(long pid, int screenWidth, int trayPos, int trayHeight) Polls and dispatches tray events.static voidx11_tray_reposition(int screenWidth, int trayPos, int trayHeight) Repositions tray icons and the tray window itself.static voidStops x11_tray_main()static intstatic voidx11_unmap_window(long xid) static voidPolls and dispatches top-level windows events.static void
-
Field Details
-
distro
-
derived
-
P_NONE
public static final int P_NONE- See Also:
-
P_LEFT
public static final int P_LEFT- See Also:
-
P_ABOVE
public static final int P_ABOVE- See Also:
-
P_RIGHT
public static final int P_RIGHT- See Also:
-
P_BELOW
public static final int P_BELOW- See Also:
-
P_SAME
public static final int P_SAME- See Also:
-
R_NORMAL
public static final int R_NORMAL- See Also:
-
R_RIGHT
public static final int R_RIGHT- See Also:
-
R_LEFT
public static final int R_LEFT- See Also:
-
R_INVERTED
public static final int R_INVERTED- See Also:
-
screens
-
SIGKILL
public static final int SIGKILL- See Also:
-
SIGTERM
public static final int SIGTERM- See Also:
-
-
Constructor Details
-
Linux
public Linux()
-
-
Method Details
-
getVersion
Returns Linux version as float. -
detectDistro
public static boolean detectDistro()Detects Linux distribution type. -
ubuntuAddRepo
-
mkdir
Creates folder -
copyFile
Copies src to dst -
createLink
Creates Link to Target -
deleteFile
Deletes file -
restartService
Restarts a service -
restartJFService
Restarts a JF service -
ubuntuUpdate
public static boolean ubuntuUpdate() -
installPackage
-
removePackage
-
setExec
Sets file as executable -
chmod
Sets file mod -
searchPackages
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
-
getPackageDesc
-
isMemberOf
-
addUserToGroup
-
expandDesktopExec
Currently only supports %f,%F,%u,%U -
expandDesktopExec
Currently only supports %f,%F,%u,%U -
executeDesktop
-
detectBits
public static int detectBits() -
runScript
Runs a bash script -
init
public static boolean init() -
x11_get_id
-
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
-
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
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
X11 : RandR : Detects current state.- Parameters:
config- = current settings (optional)- Returns:
- new settings
-
x11_rr_arrangeMonitors
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
X11 : RandR : Applies config. -
x11_rr_reset
X11 : RandR : Sets only primary display to res and disable all other (for Logon Screen)- Parameters:
res- = resolution (ie: 800x600)
-
x11_rr_load_user
-
x11_rr_save_user
-
authUser
-
kill
public static void kill(int pid, int signal) -
setenv
-
getHostname
-
getDistro
-
getOSRelease
Returns /etc/os-release property. -
addsshkey
Adds public ssh key to /root/.ssh/authorized_keys -
reboot
public static void reboot()Reboot system. -
shutdown
public static void shutdown()Shutdown system. -
main
-