Class: Breaktime::LinuxWinManager
- Inherits:
-
Object
- Object
- Breaktime::LinuxWinManager
- Defined in:
- lib/breaktime/linux_win_manager.rb
Overview
Used to detect the Linux window manager.
This information is used to determine the default screensaver command.
Defined Under Namespace
Classes: ManagerUnknown
Constant Summary collapse
- @@managers =
{'kcmserver' => 'dcop kdesktop KScreensaverIface lock', 'gnome-session' => 'gnome-screensaver-command -a', 'xfce-mcs-manage' => 'xscreensaver-command --lock'}
Instance Attribute Summary collapse
-
#cmd ⇒ Object
readonly
Returns the value of attribute cmd.
Class Method Summary collapse
-
.detect_command(log) ⇒ Object
Check the process list for known window manager services.
Instance Attribute Details
#cmd ⇒ Object (readonly)
Returns the value of attribute cmd.
12 13 14 |
# File 'lib/breaktime/linux_win_manager.rb', line 12 def cmd @cmd end |
Class Method Details
.detect_command(log) ⇒ Object
Check the process list for known window manager services.
If the service is found, return the associated command for starting the screensaver.
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/breaktime/linux_win_manager.rb', line 18 def self.detect_command(log) log.debug { "Checking for known window manager processes: #{@@managers.keys.join(", ")}" } lines = `ps -eo args|egrep "#{@@managers.keys.join("|")}"|grep -v "egrep"`.split "\n" lines.any? or raise ManagerUnknown, 'Unable to detect a known window manager' m = @@managers.keys.select {|k| lines.first.include? k} log.debug { "Found #{m.first}" } @@managers[m.first] end |