Class: OnlyofficeFileHelper::LinuxHelper

Inherits:
Object
  • Object
show all
Extended by:
XdotoolHelper
Defined in:
lib/onlyoffice_file_helper/linux_helper.rb

Overview

class for using Linux stuff

Class Method Summary collapse

Methods included from XdotoolHelper

find_window_id, send_button_to_window

Class Method Details

.clipboard_contentString

Returns content of clipboard.

Returns:

  • (String)

    content of clipboard



52
53
54
# File 'lib/onlyoffice_file_helper/linux_helper.rb', line 52

def self.clipboard_content
  `xclip -o`
end

.computer_nameString

Returns current computer name.

Returns:

  • (String)

    current computer name



43
44
45
46
47
# File 'lib/onlyoffice_file_helper/linux_helper.rb', line 43

def self.computer_name
  computer_name = Socket.gethostname
  OnlyofficeLoggerHelper.log("`LinuxHelper.get_computer_name` # #{computer_name}")
  computer_name
end

.download_file(link, full_name_file) ⇒ Void

Download file by link using

Parameters:

  • link (String)

    url to download

  • full_name_file (String)

    path to save file

Returns:

  • (Void)


15
16
17
# File 'lib/onlyoffice_file_helper/linux_helper.rb', line 15

def self.download_file(link, full_name_file)
  `wget -O #{full_name_file} #{link}`
end

.kill_all(process) ⇒ Void

Kill All process with specified pattern name

Parameters:

  • process (String)

    names of process

Returns:

  • (Void)


22
23
24
25
# File 'lib/onlyoffice_file_helper/linux_helper.rb', line 22

def self.kill_all(process)
  OnlyofficeLoggerHelper.log("killall -9 #{process} 2>&1")
  `killall -9 #{process} 2>&1`
end

.kill_all_browsersVoid

Just kill all known browsers

Returns:

  • (Void)


29
30
31
32
33
# File 'lib/onlyoffice_file_helper/linux_helper.rb', line 29

def self.kill_all_browsers
  kill_all('firefox')
  kill_all('chrome')
  kill_all('opera')
end

.my_external_ipString

Returns external ip of system.

Returns:

  • (String)

    external ip of system



66
67
68
# File 'lib/onlyoffice_file_helper/linux_helper.rb', line 66

def self.my_external_ip
  `curl "http://myexternalip.com/raw"`.chomp
end

.user_dir(name) ⇒ String

Get user dirs specified by ‘xdg-user-dir`

Parameters:

  • name (Symbol, String)

    name of user dir

Returns:

  • (String)

    path to dir



61
62
63
# File 'lib/onlyoffice_file_helper/linux_helper.rb', line 61

def self.user_dir(name)
  `xdg-user-dir #{name.to_s.upcase}`.strip
end

.user_nameString

Returns current user name.

Returns:

  • (String)

    current user name



36
37
38
# File 'lib/onlyoffice_file_helper/linux_helper.rb', line 36

def self.user_name
  `id -u -n`
end