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_contentObject



40
41
42
# File 'lib/onlyoffice_file_helper/linux_helper.rb', line 40

def self.clipboard_content
  `xclip -o`
end

.computer_nameObject



32
33
34
35
36
# File 'lib/onlyoffice_file_helper/linux_helper.rb', line 32

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) ⇒ Object



11
12
13
# File 'lib/onlyoffice_file_helper/linux_helper.rb', line 11

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

.kill_all(process) ⇒ Object



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

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

.kill_all_browsersObject



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

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

.my_external_ipObject



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

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



49
50
51
# File 'lib/onlyoffice_file_helper/linux_helper.rb', line 49

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

.user_nameObject



26
27
28
# File 'lib/onlyoffice_file_helper/linux_helper.rb', line 26

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