global_hotkeys_manager 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d61ace4dfdc9e4d6d1615d00b87c1ba16f2b8236
4
- data.tar.gz: b2c8c1d16ecf29bc46c3151fe59ad5aff0cf1cf2
3
+ metadata.gz: adb28c6fbd1b19e075f73cbb840ed3ca04b8469b
4
+ data.tar.gz: 56bb046810c3638252f1df6befd963a997017801
5
5
  SHA512:
6
- metadata.gz: 26af94ac42f815043d6aeb86d8d6c19a23d6058f2df02a5bf4fb03bd6ca22d38e4abe4525a68f501bb3098d864b9b3cee18d09cc773570b660569d91d6ea3717
7
- data.tar.gz: ba167724570649b1025269aae5768f6d3dc3e75c2a533e096819a0895954fdd834a76a80efd28b8d85c991ba4429a772a2351e287dd00f3731d113ab57115cc9
6
+ metadata.gz: 21522c515cc792a33dd03b7f05ea6b813e73d681c21ab50c7efbfe7cfa46571b4daaabf4c0f04b730d844a439b39b0978662cdbb693511879e1a6452cc1f7a0e
7
+ data.tar.gz: 05dd0cff2152ec4fb9ab075b0ea69134d7dc23d968a1ec5c654fc853514ccede70ad830322c54487981921e88c3baf64d4fe772eed0850b7bb077e1eff48ac3b
@@ -1,7 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ # to allow running the development checkout:
4
+ $LOAD_PATH.unshift File.expand_path('../lib', __dir__)
5
+
3
6
  require 'global_hotkeys_manager'
4
- require 'global_hotkeys_manager/web_app'
5
7
 
6
8
  unless ['xbindkeys', 'xwininfo', 'xdotool'].all?{|app| system "which #{app} > /dev/null"}
7
9
  puts "The following tools are required to be installed for this app to work:
@@ -35,12 +37,18 @@ def stop
35
37
  end
36
38
 
37
39
  def start
38
- exit 0 if running?
39
- Process.daemon unless (debug_mode = ARGV[0] == 'debug')
40
+ debug_mode = ARGV[0] == 'debug'
41
+ if running?
42
+ puts "The daemon is currently running, please stop it first" if debug_mode
43
+ exit 0
44
+ end
45
+ Process.daemon unless debug_mode
46
+ GlobalHotkeysManager::SETTINGS[:debug] = true if debug_mode
40
47
  File.write PID_FILE, Process.pid
41
48
  at_exit{ File.delete PID_FILE }
42
49
  GlobalHotkeysManager.ensure_running
43
- GlobalHotkeysManager::WebApp.run! environment: (debug_mode ? 'development' : 'production')
50
+ require 'global_hotkeys_manager/web_app'
51
+ GlobalHotkeysManager::WebApp.run!
44
52
  end
45
53
 
46
54
  case ARGV[0]
@@ -4,6 +4,7 @@ require 'fileutils'
4
4
  require_relative 'global_hotkeys_manager/version'
5
5
 
6
6
  module GlobalHotkeysManager
7
+ SETTINGS = {}
7
8
  CONFIG_DIR = File.expand_path '~/.config/global-hotkeys-manager'
8
9
  XBINDKEYSRC = "#{CONFIG_DIR}/xbindkeysrc"
9
10
  HOTKEYS_JSON = "#{CONFIG_DIR}/hotkeys.json"
@@ -12,6 +13,7 @@ module GlobalHotkeysManager
12
13
  URL_BASE = "http://#{HOST}:#{PORT}"
13
14
 
14
15
  FileUtils.mkdir_p CONFIG_DIR
16
+ File.write XBINDKEYSRC, '' unless File.exist? XBINDKEYSRC # so that xbindkeys -k does not fail
15
17
 
16
18
  def self.pid
17
19
  return unless pid = `pgrep -o -f xbindkeys.*hotkeys`.split("\n").find{|p| system "kill -0 #{p}"}
@@ -109,7 +111,7 @@ module GlobalHotkeysManager
109
111
  end
110
112
 
111
113
  def self.ask_for_key
112
- `xbindkeys -k`.split("\n").last
114
+ `xbindkeys -f #{XBINDKEYSRC} -k`.split("\n").last
113
115
  end
114
116
  end
115
117
 
@@ -1,3 +1,3 @@
1
1
  module GlobalHotkeysManager
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
3
3
  end
@@ -5,18 +5,19 @@ require_relative '../global_hotkeys_manager'
5
5
 
6
6
  module GlobalHotkeysManager
7
7
  class WebApp < Sinatra::Base
8
- configure :development do
9
- begin
10
- require 'sinatra/reloader'
11
- register Sinatra::Reloader
12
- rescue Exception => e
13
- puts 'For auto-reload to work sinatra-contrib gem must be installed'
14
- end
15
- end
16
-
17
8
  configure do
9
+ set :environment, :production
18
10
  set :port, GlobalHotkeysManager::PORT
19
11
  set :bind, GlobalHotkeysManager::HOST
12
+ if GlobalHotkeysManager::SETTINGS[:debug]
13
+ set :environment, :development
14
+ begin
15
+ require 'sinatra/reloader'
16
+ register Sinatra::Reloader
17
+ rescue Exception => e
18
+ puts 'For auto-reload to work sinatra-contrib gem must be installed'
19
+ end
20
+ end
20
21
  end
21
22
 
22
23
  get '/' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: global_hotkeys_manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rodrigo Rosenfeld Rosas