global_hotkeys_manager 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.
- checksums.yaml +4 -4
- data/exe/global_hotkeys_manager +12 -4
- data/lib/global_hotkeys_manager.rb +3 -1
- data/lib/global_hotkeys_manager/version.rb +1 -1
- data/lib/global_hotkeys_manager/web_app.rb +10 -9
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: adb28c6fbd1b19e075f73cbb840ed3ca04b8469b
|
4
|
+
data.tar.gz: 56bb046810c3638252f1df6befd963a997017801
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21522c515cc792a33dd03b7f05ea6b813e73d681c21ab50c7efbfe7cfa46571b4daaabf4c0f04b730d844a439b39b0978662cdbb693511879e1a6452cc1f7a0e
|
7
|
+
data.tar.gz: 05dd0cff2152ec4fb9ab075b0ea69134d7dc23d968a1ec5c654fc853514ccede70ad830322c54487981921e88c3baf64d4fe772eed0850b7bb077e1eff48ac3b
|
data/exe/global_hotkeys_manager
CHANGED
@@ -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
|
-
|
39
|
-
|
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
|
-
|
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
|
|
@@ -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
|