fusuma-plugin-appmatcher 0.1.1 → 0.1.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b1c04d2c342048c76a7c283be8234f8aea320df6b7a781549ff1beab90a988d3
4
- data.tar.gz: a562949e3a67b209846564945c230c77079812b2491a60dd1ac134ffbdc227ac
3
+ metadata.gz: 5e83ab4ed022583573d314044dd916c8e997d7c8ded16d6e5e92dd47977eb68f
4
+ data.tar.gz: b25d958c8220d36c21ff0dae24fbf8e083feef7ca4d5317401de5926480b64af
5
5
  SHA512:
6
- metadata.gz: 77472b7bdec3c9e923e39ac1267920aa4802494bfc47e49c90fe4ebe1b9cc037d77b06c3d5893a756cc1506aed0bd50b686a182f2cfd61203af2dbb7a475095f
7
- data.tar.gz: a25404e58fbb3ac32e604ff61e9302387684c4086d1080ff224e141781dd0ec1002922a5f2939b5556c8966a14b098f3e192ca2aca7192f49c6dc0e8d5fc6761
6
+ metadata.gz: 47204d64d8ea6999328d00a6e4eb4d36823e91aaff66a8f6afcaef5bc09c6e5a471da0c09b2cbc72093c8246eaa7446e12bb84d89f986ca937e7aa8667f13720
7
+ data.tar.gz: d738fcde80baaa9cd61869caeb26667d04c8a1951956d0f2b0e274696e4c5b8bf57881a00ff2157e4275284fac1c53e4383b834ce931d3d6f1c3fd0a4a626276
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Fusuma::Plugin::Appmatcher [![Gem Version](https://badge.fury.io/rb/fusuma-plugin-appmatcher.svg)](https://badge.fury.io/rb/fusuma-plugin-appmatcher) [![Build Status](https://travis-ci.com/iberianpig/fusuma-plugin-appmatcher.svg?branch=master)](https://travis-ci.com/iberianpig/fusuma-plugin-appmatcher)
2
2
 
3
- [Fusuma](https://github.com/iberianpig/fusuma) plugin configure per application
3
+ [Fusuma](https://github.com/iberianpig/fusuma) plugin configure app-specific gestures
4
4
 
5
5
  * Switch gesture mappings by detecting active application.
6
6
  * Support X11, Ubuntu-Wayland
@@ -49,7 +49,7 @@ In the following example of config.yml
49
49
  * On Google-chrome, the three-finger gesture is mapped to open in tab, close tab, back in history, forward in history.
50
50
  * On Gnome-terminal, the three-finger gesture will be mapped to open in tab, close in tab.
51
51
 
52
- ```diff
52
+ ```yaml
53
53
  # this is default context
54
54
  swipe:
55
55
  4:
@@ -62,28 +62,28 @@ swipe:
62
62
  sendkey: 'LEFTCTRL+LEFTALT+UP'
63
63
  LEFTSHIFT:
64
64
  sendkey: 'LEFTSHIFT+LEFTCTRL+LEFTALT+UP'
65
- + ---
66
- + context:
67
- + application: Google-chrome
68
- + swipe:
69
- + 3:
70
- + left:
71
- + sendkey: 'LEFTALT+RIGHT'
72
- + right:
73
- + sendkey: 'LEFTALT+LEFT'
74
- + up:
75
- + sendkey: 'LEFTCTRL+T'
76
- + down:
77
- + sendkey: 'LEFTCTRL+W'
78
- + ---
79
- + context:
80
- + application: Gnome-terminal
81
- + swipe:
82
- + 3:
83
- + up:
84
- + sendkey: 'LEFTSHIFT+LEFTCTRL+T'
85
- + down:
86
- + sendkey: 'LEFTSHIFT+LEFTCTRL+W'
65
+ ---
66
+ context:
67
+ application: Google-chrome
68
+ swipe:
69
+ 3:
70
+ left:
71
+ sendkey: 'LEFTALT+RIGHT'
72
+ right:
73
+ sendkey: 'LEFTALT+LEFT'
74
+ up:
75
+ sendkey: 'LEFTCTRL+T'
76
+ down:
77
+ sendkey: 'LEFTCTRL+W'
78
+ ---
79
+ context:
80
+ application: Gnome-terminal
81
+ swipe:
82
+ 3:
83
+ up:
84
+ sendkey: 'LEFTSHIFT+LEFTCTRL+T'
85
+ down:
86
+ sendkey: 'LEFTSHIFT+LEFTCTRL+W'
87
87
  ```
88
88
 
89
89
  ## Contributing
@@ -22,8 +22,8 @@ Gem::Specification.new do |spec|
22
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
23
  spec.require_paths = ['lib']
24
24
 
25
- spec.add_runtime_dependency 'iniparse'
25
+ spec.add_dependency "rexml" # ruby-dbus doesn't resolve dependency
26
26
  spec.add_runtime_dependency 'ruby-dbus'
27
27
 
28
- spec.add_dependency 'fusuma', '~> 2.0.0'
28
+ spec.add_dependency 'fusuma', '~> 2.0'
29
29
  end
@@ -3,7 +3,6 @@
3
3
  require 'json'
4
4
  require 'dbus'
5
5
  require_relative './user_switcher'
6
- require 'posix/spawn'
7
6
 
8
7
  module Fusuma
9
8
  module Plugin
@@ -3,7 +3,7 @@
3
3
  module Fusuma
4
4
  module Plugin
5
5
  module Appmatcher
6
- VERSION = '0.1.1'
6
+ VERSION = '0.1.5'
7
7
  end
8
8
  end
9
9
  end
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'open3'
3
4
  require_relative './user_switcher'
4
5
  require 'fusuma/multi_logger'
5
6
  require 'fusuma/custom_process'
6
- require 'posix/spawn'
7
7
 
8
8
  module Fusuma
9
9
  module Plugin
@@ -75,7 +75,7 @@ module Fusuma
75
75
  private
76
76
 
77
77
  def active_window_id(watch: false, &block)
78
- _p, i, o, e = POSIX::Spawn.popen4(xprop_active_window_id(watch))
78
+ i, o, e, _w = Open3.popen3(xprop_active_window_id(watch))
79
79
  i.close
80
80
  o.each do |line|
81
81
  id = line.match(/0x[\da-z]{2,}/)&.to_s
@@ -89,7 +89,8 @@ module Fusuma
89
89
  o.close
90
90
 
91
91
  return nil unless block_given?
92
- sleep 1
92
+
93
+ sleep 0.5
93
94
  active_window_id(watch: watch, &block)
94
95
  rescue StandardError => e
95
96
  MultiLogger.error e.message
@@ -13,11 +13,30 @@ module Fusuma
13
13
 
14
14
  # @return [Class]
15
15
  def backend_klass
16
- if ENV['DESKTOP_SESSION'] == 'ubuntu-wayland'
17
- Gnome
18
- else
19
- X11
16
+ case xdg_session_type
17
+ when /x11/
18
+ return X11
19
+ when /wayland/
20
+ return Gnome if xdg_current_desktop =~ /GNOME/
20
21
  end
22
+ MultiLogger.error(
23
+ <<~ERROR
24
+ appmatcher doesn't support
25
+ XDG_CURRENT_DESKTOP: '#{xdg_current_desktop}'
26
+ XDG_SESSION_TYPE: '#{xdg_session_type}'"
27
+ ERROR
28
+ )
29
+ exit 1
30
+ end
31
+
32
+ private
33
+
34
+ def xdg_session_type
35
+ ENV.fetch('XDG_SESSION_TYPE', '')
36
+ end
37
+
38
+ def xdg_current_desktop
39
+ ENV.fetch('XDG_CURRENT_DESKTOP', '')
21
40
  end
22
41
  end
23
42
  end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+ require './lib/fusuma/plugin/appmatcher/gnome'
5
+
6
+ module Fusuma
7
+ module Plugin
8
+ module Appmatcher
9
+ RSpec.describe Gnome do
10
+ it 'requires ruby-dbus' do
11
+ expect(DBus).not_to be nil
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -1,9 +1,39 @@
1
1
  # frozen_string_literal: true
2
- #
2
+
3
3
  require 'spec_helper'
4
4
 
5
- RSpec.describe Fusuma::Plugin::Appmatcher do
6
- it 'has a version number' do
7
- expect(Fusuma::Plugin::Appmatcher::VERSION).not_to be nil
5
+ module Fusuma
6
+ module Plugin
7
+ RSpec.describe Appmatcher do
8
+ it 'has a version number' do
9
+ expect(Appmatcher::VERSION).not_to be nil
10
+ end
11
+
12
+ describe '#backend_klass' do
13
+ context 'when XDG_CURRENT_DESKTOP is UNKNOWN' do
14
+ before { allow(Appmatcher).to receive(:xdg_current_desktop).and_return('UNKNOWN') }
15
+ it { expect { Appmatcher.backend_klass }.to raise_error }
16
+ end
17
+
18
+ context 'when XDG_SESSION_TYPE is x11' do
19
+ before { allow(Appmatcher).to receive(:xdg_session_type).and_return('x11') }
20
+ it { expect(Appmatcher.backend_klass).to eq Appmatcher::X11 }
21
+ end
22
+
23
+ context 'when XDG_SESSION_TYPE is wayland' do
24
+ before { allow(Appmatcher).to receive(:xdg_session_type).and_return('wayland') }
25
+
26
+ context 'when XDG_CURRENT_DESKTOP is ubuntu:GNOME' do
27
+ before { allow(Appmatcher).to receive(:xdg_current_desktop).and_return('ubuntu:GNOME') }
28
+ it { expect(Appmatcher.backend_klass).to eq Appmatcher::Gnome }
29
+ end
30
+
31
+ context 'when XDG_CURRENT_DESKTOP is UNKNOWN' do
32
+ before { allow(Appmatcher).to receive(:xdg_current_desktop).and_return('UNKNOWN') }
33
+ it { expect { Appmatcher.backend_klass }.to raise_error }
34
+ end
35
+ end
36
+ end
37
+ end
8
38
  end
9
39
  end
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fusuma-plugin-appmatcher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - iberianpig
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-04-13 00:00:00.000000000 Z
11
+ date: 2021-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: iniparse
14
+ name: rexml
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 2.0.0
47
+ version: '2.0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 2.0.0
54
+ version: '2.0'
55
55
  description: fusuma-plugin-appmatcher is Fusuma plugin for assigning gesture mapping
56
56
  per application.
57
57
  email:
@@ -77,6 +77,7 @@ files:
77
77
  - lib/fusuma/plugin/events/records/appmatcher_record.rb
78
78
  - lib/fusuma/plugin/inputs/appmatcher_input.rb
79
79
  - lib/fusuma/plugin/parsers/appmatcher_parser.rb
80
+ - spec/fusuma/plugin/appmatcher/gnome_spec.rb
80
81
  - spec/fusuma/plugin/appmatcher_spec.rb
81
82
  - spec/fusuma/plugin/inputs/appmatcher_detector_spec.rb
82
83
  - spec/spec_helper.rb
@@ -84,7 +85,7 @@ homepage: https://github.com/iberianpig/fusuma-plugin-appmatcher
84
85
  licenses:
85
86
  - MIT
86
87
  metadata: {}
87
- post_install_message:
88
+ post_install_message:
88
89
  rdoc_options: []
89
90
  require_paths:
90
91
  - lib
@@ -99,11 +100,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
99
100
  - !ruby/object:Gem::Version
100
101
  version: '0'
101
102
  requirements: []
102
- rubygems_version: 3.1.4
103
- signing_key:
103
+ rubygems_version: 3.2.15
104
+ signing_key:
104
105
  specification_version: 4
105
106
  summary: Fusuma plugin to assign gesture mapping per application
106
107
  test_files:
107
- - spec/fusuma/plugin/inputs/appmatcher_detector_spec.rb
108
+ - spec/fusuma/plugin/appmatcher/gnome_spec.rb
108
109
  - spec/fusuma/plugin/appmatcher_spec.rb
110
+ - spec/fusuma/plugin/inputs/appmatcher_detector_spec.rb
109
111
  - spec/spec_helper.rb