thyme_osx_ui 0.0.1
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.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +59 -0
- data/Rakefile +2 -0
- data/ext/pomodoro_statusbar/Makefile +8 -0
- data/ext/pomodoro_statusbar/extconf.rb +3 -0
- data/ext/pomodoro_statusbar/main.m +91 -0
- data/lib/thyme_osx_ui.rb +63 -0
- data/lib/thyme_osx_ui/version.rb +3 -0
- data/thyme_osx_ui.gemspec +24 -0
- metadata +84 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2a7731a691305c9ba14b717b75fb6756b836ca3f
|
4
|
+
data.tar.gz: 12416ac48a27bd6fa8d8e189055a7a3bd3a0233b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f5b25b2679503cc03bc87d8ba8dc77e8167007513804b6c443acefede870e19f1242ad78a14cd800428a725a0fc2ec667d7d057626361b187ec87217d1a919b5
|
7
|
+
data.tar.gz: 1aa6ad5cdbb81bcbd2f46f56ef6592febd1eee1a7b413f4fbc66ce75f0f0b35df2a81bfb1d9b43f966031b72899d153d69f77103bafe442729b75de7857ee345
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Thai Pangsakulyanont
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# OS X Status Bar Integration for Thyme
|
2
|
+
|
3
|
+
This Gem adds OS X status bar integration to [Thyme](http://thymerb.com/),
|
4
|
+
allowing you to always see the remaining time.
|
5
|
+
|
6
|
+

|
7
|
+
|
8
|
+
This works by compiling an Objective-C code that simply displays the text passed via standard input on the status bar when you install the gem, so make sure you have `clang` installed.
|
9
|
+
|
10
|
+
<br/>
|
11
|
+
|
12
|
+
:mushroom::alien::cloud::octopus::snail::x::shoe::turtle::angel::trollface::umbrella::star2::bread::apple::rabbit::icecream::nose::tomato::elephant::gun::rabbit2::ant::tomato::icecream::octopus::nose::fish::octopus::rabbit::turtle::heart::yum::mailbox::eyeglasses::rabbit::bike:
|
13
|
+
|
14
|
+
<br/>
|
15
|
+
|
16
|
+
## Installation and Usage
|
17
|
+
|
18
|
+
First, install the gem:
|
19
|
+
|
20
|
+
```bash
|
21
|
+
gem install thyme_osx_ui
|
22
|
+
```
|
23
|
+
|
24
|
+
|
25
|
+
Then, modify your `.thymerc` by adding `before`, `tick`, and `after` hooks as follows:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
before do
|
29
|
+
$ui = ThymeOSX::UI.new
|
30
|
+
end
|
31
|
+
|
32
|
+
tick do |seconds_left|
|
33
|
+
$ui.tick(seconds_left)
|
34
|
+
end
|
35
|
+
|
36
|
+
after do |seconds_left|
|
37
|
+
$ui.destroy
|
38
|
+
end
|
39
|
+
```
|
40
|
+
|
41
|
+
Now whenever you start a pomodoro with `thyme`, you should see a status bar item.
|
42
|
+
Clicking on it and selecting "void" will kill the pomodoro.
|
43
|
+
|
44
|
+
|
45
|
+
<br/>
|
46
|
+
|
47
|
+
:moon::angel::cat::octopus::snowman::x::sheep::trollface::angel::trollface::umbrella::star2::banana::angel::rabbit::icecream::nail_care::turtle::eyeglasses::ghost::rabbit2::angel::tomato::icecream::octopus::nose::floppy_disk::octopus::rabbit2::trollface::horse::yum::mushroom::eyes::rocket::balloon:
|
48
|
+
|
49
|
+
<br/>
|
50
|
+
|
51
|
+
Customization
|
52
|
+
-------------
|
53
|
+
|
54
|
+
You can subclass the class `ThymeOSX::UI` and override these methods:
|
55
|
+
|
56
|
+
- `emoji(seconds_left)` — to change the emoji icon.
|
57
|
+
- `text(seconds_left)` — to change the text, which include the emoji and time left.
|
58
|
+
- So if you want to keep the emoji, you must call `emoji(seconds_left)` yourself.
|
59
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
//
|
2
|
+
// main.m
|
3
|
+
// PmdStatus
|
4
|
+
//
|
5
|
+
// Created by Thai Pangsakulyanont on 2014/10/04.
|
6
|
+
// Copyright (c) 2014年 Thai Pangsakulyanont. All rights reserved.
|
7
|
+
//
|
8
|
+
|
9
|
+
#import <Cocoa/Cocoa.h>
|
10
|
+
|
11
|
+
@interface NSStatusBar (NSStatusBar_Private)
|
12
|
+
- (id)_statusItemWithLength:(float)l withPriority:(int)p;
|
13
|
+
- (id)_insertStatusItem:(NSStatusItem *)i withPriority:(int)p;
|
14
|
+
@end
|
15
|
+
|
16
|
+
@interface MyApplicationDelegate : NSObject<NSApplicationDelegate>
|
17
|
+
{
|
18
|
+
NSFileHandle *stdin;
|
19
|
+
NSFileHandle *stdout;
|
20
|
+
NSMenu *menu;
|
21
|
+
NSMenuItem *voidItem;
|
22
|
+
NSStatusItem *barItem;
|
23
|
+
}
|
24
|
+
- (void)applicationDidFinishLaunching:(NSNotification *)notification;
|
25
|
+
@end
|
26
|
+
|
27
|
+
@implementation MyApplicationDelegate
|
28
|
+
|
29
|
+
- (void)applicationDidFinishLaunching:(NSNotification *)notification {
|
30
|
+
[self _initializeStdio];
|
31
|
+
[self _createMenu];
|
32
|
+
[self _createStatusBarItem];
|
33
|
+
}
|
34
|
+
|
35
|
+
- (void)_initializeStdio {
|
36
|
+
stdin = [NSFileHandle fileHandleWithStandardInput];
|
37
|
+
stdout = [NSFileHandle fileHandleWithStandardOutput];
|
38
|
+
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_stdinDataAvailable) name:NSFileHandleDataAvailableNotification object:stdin];
|
39
|
+
[stdin waitForDataInBackgroundAndNotify];
|
40
|
+
}
|
41
|
+
|
42
|
+
- (void)_createMenu {
|
43
|
+
menu = [NSMenu new];
|
44
|
+
voidItem = [menu addItemWithTitle:@"Void" action:@selector(_voidPomodoro:) keyEquivalent:@""];
|
45
|
+
voidItem.target = self;
|
46
|
+
voidItem.enabled = true;
|
47
|
+
}
|
48
|
+
|
49
|
+
- (void)_createStatusBarItem {
|
50
|
+
NSStatusBar *bar = [NSStatusBar systemStatusBar];
|
51
|
+
barItem = [[bar statusItemWithLength:0] retain];
|
52
|
+
[bar removeStatusItem:barItem];
|
53
|
+
[bar _insertStatusItem:barItem withPriority:INT_MAX-2];
|
54
|
+
barItem.title = @"...";
|
55
|
+
barItem.highlightMode = true;
|
56
|
+
barItem.menu = menu;
|
57
|
+
barItem.length = NSVariableStatusItemLength;
|
58
|
+
}
|
59
|
+
|
60
|
+
- (void)_stdinDataAvailable {
|
61
|
+
NSData *data = [stdin availableData];
|
62
|
+
if (data.length == 0) {
|
63
|
+
exit(0);
|
64
|
+
return;
|
65
|
+
}
|
66
|
+
NSString *text = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
|
67
|
+
text = [text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
|
68
|
+
[self _setText:text];
|
69
|
+
[stdin waitForDataInBackgroundAndNotify];
|
70
|
+
}
|
71
|
+
|
72
|
+
- (void)_setText:(NSString *)text {
|
73
|
+
barItem.title = text;
|
74
|
+
}
|
75
|
+
|
76
|
+
- (void)_voidPomodoro:(id)sender {
|
77
|
+
[stdout writeData:[@"!void\n" dataUsingEncoding:NSUTF8StringEncoding]];
|
78
|
+
exit(1);
|
79
|
+
}
|
80
|
+
|
81
|
+
@end
|
82
|
+
|
83
|
+
int main(int argc, const char * argv[]) {
|
84
|
+
@autoreleasepool {
|
85
|
+
id delegate = [MyApplicationDelegate new];
|
86
|
+
NSApplication *app = [NSApplication sharedApplication];
|
87
|
+
app.delegate = delegate;
|
88
|
+
[app run];
|
89
|
+
}
|
90
|
+
return 0;
|
91
|
+
}
|
data/lib/thyme_osx_ui.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
require "thyme_osx_ui/version"
|
2
|
+
require "open3"
|
3
|
+
require "pathname"
|
4
|
+
|
5
|
+
module ThymeOSX
|
6
|
+
|
7
|
+
class UI
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
executable_path = Pathname.new(__FILE__)
|
11
|
+
.parent.parent
|
12
|
+
.join("ext/pomodoro_statusbar/pomodoro_statusbar")
|
13
|
+
.to_path
|
14
|
+
@stdin, @stdout, @status = Open3.popen2(executable_path)
|
15
|
+
end
|
16
|
+
|
17
|
+
def tick(seconds_left)
|
18
|
+
if !@status.status && !@status.value.success?
|
19
|
+
Process.kill("TERM", 0)
|
20
|
+
else
|
21
|
+
@stdin.puts text(seconds_left)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def destroy
|
26
|
+
@stdin.close
|
27
|
+
@stdout.close
|
28
|
+
Process.kill("TERM", @status.pid) if @status.status
|
29
|
+
end
|
30
|
+
|
31
|
+
def text(seconds_left)
|
32
|
+
"#{emoji(seconds_left)} #{format_time(seconds_left)}"
|
33
|
+
end
|
34
|
+
|
35
|
+
def format_time(seconds_left)
|
36
|
+
"%d:%02d" % [seconds_left / 60, seconds_left % 60]
|
37
|
+
end
|
38
|
+
|
39
|
+
def emoji(seconds_left)
|
40
|
+
if seconds_left < 60
|
41
|
+
if seconds_left.odd?
|
42
|
+
"🔴 "
|
43
|
+
else
|
44
|
+
"⚪️ "
|
45
|
+
end
|
46
|
+
elsif seconds_left < 2 * 60
|
47
|
+
"1️⃣ "
|
48
|
+
elsif seconds_left < 3 * 60
|
49
|
+
"2️⃣ "
|
50
|
+
elsif seconds_left < 4 * 60
|
51
|
+
"3️⃣ "
|
52
|
+
elsif seconds_left < 5 * 60
|
53
|
+
"4️⃣ "
|
54
|
+
elsif seconds_left < 6 * 60
|
55
|
+
"5️⃣ "
|
56
|
+
else
|
57
|
+
"🍅 "
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'thyme_osx_ui/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "thyme_osx_ui"
|
8
|
+
spec.version = ThymeOsxUi::VERSION
|
9
|
+
spec.authors = ["Thai Pangsakulyanont"]
|
10
|
+
spec.email = ["org.yi.dttvb@gmail.com"]
|
11
|
+
spec.summary = %q{OSX Integration for Thyme}
|
12
|
+
spec.description = %q{Display remaining time in Mac OS X's status bar}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
spec.extensions = ["ext/pomodoro_statusbar/extconf.rb"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
23
|
+
spec.add_development_dependency "rake"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: thyme_osx_ui
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Thai Pangsakulyanont
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-10-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Display remaining time in Mac OS X's status bar
|
42
|
+
email:
|
43
|
+
- org.yi.dttvb@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions:
|
46
|
+
- ext/pomodoro_statusbar/extconf.rb
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- ".gitignore"
|
50
|
+
- Gemfile
|
51
|
+
- LICENSE.txt
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- ext/pomodoro_statusbar/Makefile
|
55
|
+
- ext/pomodoro_statusbar/extconf.rb
|
56
|
+
- ext/pomodoro_statusbar/main.m
|
57
|
+
- lib/thyme_osx_ui.rb
|
58
|
+
- lib/thyme_osx_ui/version.rb
|
59
|
+
- thyme_osx_ui.gemspec
|
60
|
+
homepage: ''
|
61
|
+
licenses:
|
62
|
+
- MIT
|
63
|
+
metadata: {}
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options: []
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
requirements: []
|
79
|
+
rubyforge_project:
|
80
|
+
rubygems_version: 2.2.2
|
81
|
+
signing_key:
|
82
|
+
specification_version: 4
|
83
|
+
summary: OSX Integration for Thyme
|
84
|
+
test_files: []
|