gtk2clockapp 2.0.210730

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 5cb9aa4dbeefcef4b0803c1bb7b831ef375ccf88c1d747f2404b064cbdf3254e
4
+ data.tar.gz: f4af899ddc292acfecad48737486242c383b7d5abfa9dfbb0fe605f84b8d4266
5
+ SHA512:
6
+ metadata.gz: 94fc83c1c084cc6639b49e10deac93d525878819971a49cf8ef8b002c6f13507748909ba5bfc3fb9ae1bb87e727c80b04d790412c2a9a62a44fbb7396556ce2a
7
+ data.tar.gz: e475d8d3eff7eb21224fdcfbfe2763aedacf2d69e2c9d3aa7f9f215833660cb7e6e8a1239fd53c41e26ffe2d2c14acc1f946f4fca101aea79d1b011cccaa0f92
data/README.md ADDED
@@ -0,0 +1,75 @@
1
+ # Gtk2ClockApp
2
+
3
+ * [VERSION 2.0.210730](https://github.com/carlosjhr64/gtk2clockapp/releases)
4
+ * [github](https://github.com/carlosjhr64/gtk2clockapp)
5
+ * [rubygems](https://rubygems.org/gems/gtk2clockapp)
6
+
7
+ ## DESCRIPTION:
8
+
9
+ A clock/bulletin board with a STDIN interface.
10
+
11
+ It's up to the user to wrap `gtk2clockapp` to provide additional functionality besides the clock.
12
+ It assumes it'll get weather info, spot prices, and alerts... but
13
+ one can put anything in those labels.
14
+
15
+ ## INSTALL:
16
+ ```shell
17
+ $ gem install gtk2clockapp
18
+ ```
19
+ ## SINOPSIS
20
+ ```shell
21
+ $ gtk2clockapp
22
+ Mode: day
23
+ Weather: ⛅ 75F 92F/66F
24
+ Spot: 🗠 BCH: $5,000
25
+ 🐿 🐿 🐿 Squirrel!!! 🐿 🐿 🐿
26
+ ```
27
+ ![Day Mode](img/day.png)
28
+ ```shell
29
+ Mode: night
30
+ ```
31
+ ![Night Mode](img/night.png)
32
+ ## HELP:
33
+ ```shell
34
+ $ gtk2clockapp --help
35
+ Usage:
36
+ gtk2clockapp [:options+]
37
+ Options:
38
+ -h --help
39
+ -v --version
40
+ --fullscreen
41
+ --notdecorated
42
+ --size=INT 250
43
+ --font=NAME Courier
44
+ --background=COLOR 000000
45
+ --day=COLOR 00FF00
46
+ --night=COLOR 3F0000
47
+ Types:
48
+ INT /^[1-9]\d{1,2}$/
49
+ NAME /^[A-Z][a-z]+( w+)*$/
50
+ COLOR /^[0-9ABCDEF]{6}$/
51
+ ```
52
+ ## LICENSE:
53
+
54
+ (The MIT License)
55
+
56
+ Copyright (c) 2021 CarlosJHR64
57
+
58
+ Permission is hereby granted, free of charge, to any person obtaining
59
+ a copy of this software and associated documentation files (the
60
+ 'Software'), to deal in the Software without restriction, including
61
+ without limitation the rights to use, copy, modify, merge, publish,
62
+ distribute, sublicense, and/or sell copies of the Software, and to
63
+ permit persons to whom the Software is furnished to do so, subject to
64
+ the following conditions:
65
+
66
+ The above copyright notice and this permission notice shall be
67
+ included in all copies or substantial portions of the Software.
68
+
69
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
70
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
71
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
72
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
73
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
74
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
75
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/bin/gtk2clockapp ADDED
@@ -0,0 +1,50 @@
1
+ #!/usr/bin/env ruby
2
+ require 'gtk2clockapp'
3
+ require 'help_parser'
4
+ OPTIONS = HelpParser[Gtk2ClockApp::VERSION, <<HELP]
5
+ Usage:
6
+ gtk2clockapp [:options+]
7
+ Options:
8
+ -h --help
9
+ -v --version
10
+ --fullscreen
11
+ --notdecorated
12
+ --size=INT \t 250
13
+ --font=NAME \t Courier
14
+ --background=COLOR \t 000000
15
+ --day=COLOR \t 00FF00
16
+ --night=COLOR \t 3F0000
17
+ Types:
18
+ INT /^[1-9]\\d{1,2}$/
19
+ NAME /^[A-Z][a-z]+( \w+)*$/
20
+ COLOR /^[0-9ABCDEF]{6}$/
21
+ HELP
22
+ HelpParser.int?(:size)
23
+ gui = Gtk2ClockApp.gui
24
+ gui.set_weather '' # '⛅ 75F 92F/66F'
25
+ gui.set_spot '' # '🗠 WUT: $500'
26
+ gui.set_alert '' # '📢 Attention!'
27
+ Thread.new do
28
+ while line = $stdin.gets
29
+ line.chomp!
30
+ case line
31
+ when /^Weather: (.*)$/
32
+ gui.set_weather $1
33
+ when /^Spot: (.*)$/
34
+ gui.set_spot $1
35
+ when /^Mode: (.*)$/
36
+ mode = $1
37
+ case mode.downcase
38
+ when 'night'
39
+ gui.night_mode
40
+ when 'day'
41
+ gui.day_mode
42
+ else
43
+ $stderr.puts 'Unrecognized mode: '+mode
44
+ end
45
+ else
46
+ gui.set_alert line
47
+ end
48
+ end
49
+ end
50
+ Gtk.main
@@ -0,0 +1,77 @@
1
+ module Gtk2ClockApp
2
+ OPTIONS ||= nil
3
+
4
+ g = 2 - (1 + Math.sqrt(5))/2
5
+ big = OPTIONS&.size? || 250
6
+ medium = (big*g).round
7
+ small = (big*g*g).round
8
+ pad = (big*g*g*g).round
9
+
10
+ fontname = OPTIONS&.font || 'Courier'
11
+ font = {
12
+ BIG: Pango::FontDescription.new("#{fontname} #{big}"),
13
+ MEDIUM: Pango::FontDescription.new("#{fontname} #{medium}"),
14
+ SMALL: Pango::FontDescription.new("#{fontname} #{small}"),
15
+ }
16
+
17
+ color = {
18
+ Background: '#'+(OPTIONS&.background || '000000'),
19
+ Day: '#'+(OPTIONS&.day || '00FF00'),
20
+ Night: '#'+(OPTIONS&.night || '3F0000'),
21
+ }
22
+
23
+ CONFIG = {
24
+ Time: '%l:%M %p',
25
+ DateA: '%Y-%m-%d',
26
+ DateB: '%A %B %e',
27
+
28
+ Background: color[:Background],
29
+ Day: color[:Day],
30
+ Night: color[:Night],
31
+
32
+ # Window
33
+ WINDOW: [],
34
+ window: {
35
+ set_title: 'Gtk2ClockApp',
36
+ override_background_color: [:normal, color[:Background]],
37
+ },
38
+ window!: [:WINDOW, :window, 'destroy'],
39
+
40
+ # Vbox
41
+ VBOX: [:vertical],
42
+ vbox: {},
43
+ vbox!: [:VBOX, :vbox],
44
+
45
+ # Hbox
46
+ HBOX: [:horizontal],
47
+ hbox: {},
48
+ hbox!: [:HBOX, :hbox],
49
+
50
+ # Labels
51
+ LABEL: [''],
52
+
53
+ # Big label
54
+ big_label: {
55
+ override_font: font[:BIG],
56
+ override_color: [:normal, color[:Day]],
57
+ into: [:pack_start, expand: false, fill: true, padding: pad],
58
+ },
59
+ big_label!: [:LABEL, :big_label],
60
+
61
+ # Medium label
62
+ medium_label: {
63
+ override_font: font[:MEDIUM],
64
+ override_color: [:normal, color[:Day]],
65
+ into: [:pack_start, expand: false, fill: true, padding: pad],
66
+ },
67
+ medium_label!: [:LABEL, :medium_label],
68
+
69
+ # Small label
70
+ small_label: {
71
+ override_font: font[:SMALL],
72
+ override_color: [:normal, color[:Day]],
73
+ into: [:pack_start, expand: false, fill: true, padding: pad],
74
+ },
75
+ small_label!: [:LABEL, :small_label],
76
+ }
77
+ end
@@ -0,0 +1,67 @@
1
+ module Gtk2ClockApp
2
+ class Gui
3
+ def now(key)
4
+ Time.now.strftime(CONFIG[key])
5
+ end
6
+
7
+ def new_label(key)
8
+ hbox = Such::Box.new @vbox, :hbox!
9
+ Such::Label.new hbox, key
10
+ end
11
+
12
+ def time_label(key, seconds, *formats)
13
+ label = new_label(key)
14
+ i = 0
15
+ label.set_text now(formats[i])
16
+ GLib::Timeout.add(seconds*1000) do
17
+ i = (i+1)%formats.length
18
+ label.set_text now(formats[i])
19
+ end
20
+ label
21
+ end
22
+
23
+ def initialize
24
+ @window = Such::Window.new :window! do Gtk.main_quit end
25
+ @window.set_decorated !OPTIONS.notdecorated?
26
+ @window.fullscreen if OPTIONS.fullscreen?
27
+ @vbox = Such::Box.new @window, :vbox!
28
+
29
+ @date = time_label(:medium_label!, 5, :DateA, :DateB)
30
+ @time = time_label(:big_label!, 60, :Time)
31
+
32
+ @weather = new_label(:medium_label!)
33
+ @spot = new_label(:medium_label!)
34
+ @alert = new_label(:small_label!)
35
+
36
+ @window.show_all
37
+ end
38
+
39
+ def set_weather(text)
40
+ @weather.set_text text
41
+ end
42
+
43
+ def set_spot(text)
44
+ @spot.set_text text
45
+ end
46
+
47
+ def set_alert(text)
48
+ @alert.set_text text
49
+ end
50
+
51
+ def labels
52
+ [@date, @time, @weather, @spot, @alert]
53
+ end
54
+
55
+ def day_mode
56
+ labels.each do |label|
57
+ label.override_color(:normal, CONFIG[:Day])
58
+ end
59
+ end
60
+
61
+ def night_mode
62
+ labels.each do |label|
63
+ label.override_color(:normal, CONFIG[:Night])
64
+ end
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,15 @@
1
+ module Gtk2ClockApp
2
+ VERSION = '2.0.210730'
3
+
4
+ def self.gui
5
+ require 'gtk3'
6
+ require 'such'
7
+ Such::Things.in Gtk::Widget
8
+ require 'gtk2clockapp/config'
9
+ Such::Thing.configure(CONFIG)
10
+ require 'gtk2clockapp/gui'
11
+ Gui.new
12
+ end
13
+ end
14
+ # Requires:
15
+ #`ruby`
metadata ADDED
@@ -0,0 +1,114 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gtk2clockapp
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.0.210730
5
+ platform: ruby
6
+ authors:
7
+ - carlosjhr64
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-07-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: help_parser
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '7.0'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 7.0.200907
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '7.0'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 7.0.200907
33
+ - !ruby/object:Gem::Dependency
34
+ name: gtk3
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '3.4'
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 3.4.6
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '3.4'
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 3.4.6
53
+ - !ruby/object:Gem::Dependency
54
+ name: such
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: '2.0'
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: 2.0.210201
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '2.0'
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: 2.0.210201
73
+ description: |
74
+ A clock/bulletin board with a STDIN interface.
75
+
76
+ It's up to the user to wrap `gtk2clockapp` to provide additional functionality besides the clock.
77
+ It assumes it'll get weather info, spot prices, and alerts... but
78
+ one can put anything in those labels.
79
+ email: carlosjhr64@gmail.com
80
+ executables:
81
+ - gtk2clockapp
82
+ extensions: []
83
+ extra_rdoc_files: []
84
+ files:
85
+ - README.md
86
+ - bin/gtk2clockapp
87
+ - lib/gtk2clockapp.rb
88
+ - lib/gtk2clockapp/config.rb
89
+ - lib/gtk2clockapp/gui.rb
90
+ homepage: https://github.com/carlosjhr64/gtk2clockapp
91
+ licenses:
92
+ - MIT
93
+ metadata: {}
94
+ post_install_message:
95
+ rdoc_options: []
96
+ require_paths:
97
+ - lib
98
+ required_ruby_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ requirements:
109
+ - 'ruby: ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-linux]'
110
+ rubygems_version: 3.2.22
111
+ signing_key:
112
+ specification_version: 4
113
+ summary: A clock/bulletin board with a STDIN interface.
114
+ test_files: []