breaktime 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/breaktime +0 -1
- data/breaktime.gemspec +0 -1
- data/lib/breaktime.rb +3 -8
- data/lib/breaktime/command.rb +2 -3
- data/lib/breaktime/main.rb +21 -4
- data/lib/breaktime/version.rb +1 -1
- metadata +2 -3
data/bin/breaktime
CHANGED
data/breaktime.gemspec
CHANGED
@@ -15,7 +15,6 @@ Gem::Specification.new do |gem|
|
|
15
15
|
gem.files = `git ls-files`.split($/)
|
16
16
|
gem.executables = ['breaktime']
|
17
17
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
-
gem.require_paths = ["lib","lib/breaktime"]
|
19
18
|
gem.add_dependency 'green_shoes', '~> 1.1.373'
|
20
19
|
gem.add_dependency 'trollop', '~> 2.0.0'
|
21
20
|
gem.add_dependency 'rufus-scheduler', '~> 2.0.17'
|
data/lib/breaktime.rb
CHANGED
@@ -5,9 +5,6 @@
|
|
5
5
|
# This should be run as the command line tool `breaktime`. For more information
|
6
6
|
# try running `breaktime --help`.
|
7
7
|
module Breaktime
|
8
|
-
lib_dir = File.dirname(__FILE__) + File::SEPARATOR + 'breaktime'
|
9
|
-
$:.unshift lib_dir
|
10
|
-
|
11
8
|
# Exit status codes.
|
12
9
|
EX_OK = 0 # Everything fine
|
13
10
|
EX_UNKNOWN = 1 # Unknown exception
|
@@ -18,9 +15,7 @@ module Breaktime
|
|
18
15
|
EX_BREAK_CANCELLED = 254 # Cancel from the countdown GUI
|
19
16
|
EX_CLI = 255 # CLI option errors
|
20
17
|
|
21
|
-
require '
|
22
|
-
require '
|
23
|
-
require '
|
24
|
-
require 'command'
|
25
|
-
require 'main'
|
18
|
+
require 'breaktime/version'
|
19
|
+
require 'breaktime/command'
|
20
|
+
require 'breaktime/main'
|
26
21
|
end
|
data/lib/breaktime/command.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'linux_win_manager'
|
1
|
+
require 'breaktime/linux_win_manager'
|
2
2
|
|
3
3
|
# Used to determine and run the screensaver command.
|
4
4
|
class Breaktime::Command
|
@@ -13,7 +13,6 @@ class Breaktime::Command
|
|
13
13
|
def self.system_default(log)
|
14
14
|
case RbConfig::CONFIG['target_os']
|
15
15
|
when 'linux'
|
16
|
-
require 'linux_win_manager'
|
17
16
|
log.debug { "Using Linux, detecting window manager and appropriate command" }
|
18
17
|
Breaktime::LinuxWinManager.detect_command(log)
|
19
18
|
|
@@ -21,7 +20,7 @@ class Breaktime::Command
|
|
21
20
|
log.debug { "Using Mac OSX10" }
|
22
21
|
'open -a /System/Library/Frameworks/ScreenSaver.framework/Versions/A/Resources/ScreenSaverEngine.app'
|
23
22
|
|
24
|
-
when /mswin.*$/
|
23
|
+
when /(mswin|mingw).*$/
|
25
24
|
log.debug { "Using Windows" }
|
26
25
|
'rundll32.exe user32.dll,LockWorkStation'
|
27
26
|
|
data/lib/breaktime/main.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'yaml'
|
2
2
|
require 'log4r'
|
3
|
-
require 'schedule'
|
3
|
+
require 'breaktime/schedule'
|
4
4
|
require 'dante'
|
5
|
-
require 'cli'
|
5
|
+
require 'breaktime/cli'
|
6
6
|
|
7
7
|
# Handles configuration options, CLI stuff and process daemonizing.
|
8
8
|
class Breaktime::Main
|
@@ -66,7 +66,7 @@ class Breaktime::Main
|
|
66
66
|
# Open a dialog to notify the user about an impending screen break.
|
67
67
|
when "dialog"
|
68
68
|
@log.info { "Opening dialog" }
|
69
|
-
require 'dialog'
|
69
|
+
require 'breaktime/dialog'
|
70
70
|
# Automatically loads green shoes window
|
71
71
|
|
72
72
|
# Run the command that will start the break.
|
@@ -80,6 +80,18 @@ class Breaktime::Main
|
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
83
|
+
# Check if Process has the fork method, but also check for Java
|
84
|
+
#
|
85
|
+
# Apparently jRuby doesn't implement this correctly, hence the secondary
|
86
|
+
# check.
|
87
|
+
def fork_implemented?
|
88
|
+
if Process.respond_to?(:fork)
|
89
|
+
RUBY_PLATFORM !~ /java/ && RUBY_ENGINE != 'macruby'
|
90
|
+
else
|
91
|
+
false
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
83
95
|
# Start the scheduler as a daemon.
|
84
96
|
#
|
85
97
|
# The process can be kept on top if the "daemonize" option is set to be false
|
@@ -95,7 +107,12 @@ class Breaktime::Main
|
|
95
107
|
:log_path => @options['log_path']}
|
96
108
|
|
97
109
|
if dante_opts[:daemonize]
|
98
|
-
|
110
|
+
if not fork_implemented?
|
111
|
+
dante_opts[:daemonize] = false
|
112
|
+
@log.warn { "Daemonizing is not available, as fork is not implemented - running on top" }
|
113
|
+
else
|
114
|
+
@log.info { "Starting daemon, PID file => #{dante_opts[:pid_path]}, log file => #{dante_opts[:log_path]}" }
|
115
|
+
end
|
99
116
|
end
|
100
117
|
|
101
118
|
schedule = Breaktime::Schedule.new(@options['interval'], @options['days'], @cli.options, @log)
|
data/lib/breaktime/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: breaktime
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-02-
|
12
|
+
date: 2013-02-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: green_shoes
|
@@ -120,7 +120,6 @@ post_install_message:
|
|
120
120
|
rdoc_options: []
|
121
121
|
require_paths:
|
122
122
|
- lib
|
123
|
-
- lib/breaktime
|
124
123
|
required_ruby_version: !ruby/object:Gem::Requirement
|
125
124
|
none: false
|
126
125
|
requirements:
|