fusuma-plugin-appmatcher 0.6.0 → 0.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fe1234e9a80678a14e7511bd16f449331e01db5feff4c0817f60471021c89771
4
- data.tar.gz: 1dcde6b098cc837ffb39181d8019e6caa6ad6373d4e68dfc08299d6f9bea1a3f
3
+ metadata.gz: 71434bb94486a82640cdb28a4162aa4ad961f37ea10d50171190674708a5bb2f
4
+ data.tar.gz: 5b9b925352707e6866d1bb0579f1e9e8fb32a54c403b1f369e693891fe3647ee
5
5
  SHA512:
6
- metadata.gz: 2830428a3681121a3bfd2e26ead8dd9a96e44a85faea4f08b949f872f4d60804352f8b60825c3950a233f9c31e03a6b6801ad27e1d69348ed284f65bb013ad84
7
- data.tar.gz: 1ab8b7590a898b43bf0499a31095e9f22693654fee3aa13c98aa97d48ec3118158ba307d5aa84aae3c64c0f45869ff04216d2f35e3393c86179d2ed736dafac8
6
+ metadata.gz: 401622844bdb199c250512d063389004f654c8da01e3cdfe3484743a521211da435c0b7e8a36dc61bec8495314629cf01ceaf98282800b80eae5ea85d27e2f5f
7
+ data.tar.gz: 325b5d4ccb1874461fa26d8d89687e12bad8289a2bde87fc66a29cf1ffa65fffb772d0857468d76f90d4d24e36aaa3f7129f3d56218762d17758a4946c8d0885
data/README.md CHANGED
@@ -1,4 +1,4 @@
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://github.com/iberianpig/fusuma/actions/workflows/main.yml/badge.svg)](https://github.com/iberianpig/fusuma-plugin-appmatcher/actions/workflows/main.yml)
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://github.com/iberianpig/fusuma-plugin-appmatcher/actions/workflows/main.yml/badge.svg)](https://github.com/iberianpig/fusuma-plugin-appmatcher/actions/workflows/main.yml)
2
2
 
3
3
  [Fusuma](https://github.com/iberianpig/fusuma) plugin configure app-specific gestures
4
4
 
@@ -17,7 +17,6 @@ Gem::Specification.new do |spec|
17
17
 
18
18
  # Specify which files should be added to the gem when it is released.
19
19
  spec.files = Dir["{bin,lib,exe}/**/*", "LICENSE*", "README*", "*.gemspec"]
20
- spec.test_files = Dir["{test,spec,features}/**/*"]
21
20
  spec.bindir = "exe"
22
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
22
  spec.require_paths = ["lib"]
@@ -2,7 +2,7 @@
2
2
 
3
3
  require "json"
4
4
  require "dbus"
5
- require_relative "./user_switcher"
5
+ require_relative "user_switcher"
6
6
 
7
7
  module Fusuma
8
8
  module Plugin
@@ -2,7 +2,7 @@
2
2
 
3
3
  require "json"
4
4
  require "dbus"
5
- require_relative "./user_switcher"
5
+ require_relative "user_switcher"
6
6
 
7
7
  module Fusuma
8
8
  module Plugin
@@ -0,0 +1,69 @@
1
+ import { Extension } from 'resource:///org/gnome/shell/extensions/extension.js';
2
+ import GLib from 'gi://GLib';
3
+ import Gio from 'gi://Gio';
4
+
5
+ const DBUS_INTERFACE = `
6
+ <node>
7
+ <interface name="dev.iberianpig.Appmatcher">
8
+ <method name="ActiveWindow">
9
+ <arg type="s" direction="out" name="win"/>
10
+ </method>
11
+ <method name="ListWindows">
12
+ <arg type="s" direction="out" name="wins"/>
13
+ </method>
14
+ <signal name="ActiveWindowChanged">
15
+ <arg type="s" name="new_win"/>
16
+ </signal>
17
+ </interface>
18
+ </node>`;
19
+
20
+ export default class AppMatcherExtension extends Extension {
21
+ enable() {
22
+ this._dbus = Gio.DBusExportedObject.wrapJSObject(DBUS_INTERFACE, this);
23
+ this._dbus.export(Gio.DBus.session, '/dev/iberianpig/Appmatcher');
24
+ this._callback_id = global.display.connect('notify::focus-window', ()=> {
25
+ this.activeWindowChanged()
26
+ })
27
+ }
28
+
29
+ disable() {
30
+ this._dbus.flush();
31
+ this._dbus.unexport();
32
+ if (this._callback_id) {
33
+ global.display.disconnect(this._callback_id);
34
+ delete this._callback_id
35
+ }
36
+ delete this._dbus;
37
+ }
38
+
39
+ activeWindowChanged() {
40
+ const w = global.display.get_focus_window();
41
+ if(!w) { return; }
42
+
43
+ try {
44
+ const obj = { wm_class: w.get_wm_class(), pid: w.get_pid(), id: w.get_id(), title: w.get_title(), focus: w.has_focus()}
45
+ this._dbus.emit_signal('ActiveWindowChanged', new GLib.Variant('(s)', [JSON.stringify(obj)]));
46
+ } catch (e) {
47
+ console.error(e, 'failed to Emit DBus signal');
48
+ }
49
+ }
50
+
51
+ ListWindows() {
52
+ const wins = global.get_window_actors()
53
+ .map(a => a.meta_window)
54
+ .map(w => ({ wm_class: w.get_wm_class(), pid: w.get_pid(), id: w.get_id(), title: w.get_title(), focus: w.has_focus()}));
55
+ return JSON.stringify(wins);
56
+ }
57
+
58
+ ActiveWindow() {
59
+ const actor = global.get_window_actors().find(a=>a.meta_window.has_focus()===true)
60
+ if(!actor) { return '{}'; }
61
+ const w = actor.get_meta_window()
62
+ try {
63
+ const obj = { wm_class: w.get_wm_class(), pid: w.get_pid(), id: w.get_id(), title: w.get_title(), focus: w.has_focus()}
64
+ return JSON.stringify(obj);
65
+ } catch (e) {
66
+ console.error(e, 'failed to fetch ActiveWindow()');
67
+ }
68
+ }
69
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "Appmatcher",
3
+ "description": "notify focused application using D-Bus",
4
+ "shell-version" : [
5
+ "45"
6
+ ],
7
+ "url" : "https://github.com/iberianpig/fusuma-plugin-appmatcher",
8
+ "uuid": "appmatcher@iberianpig.dev",
9
+ "version" : 1
10
+ }
@@ -13,9 +13,25 @@ module Fusuma
13
13
 
14
14
  EXTENSION = "./appmatcher@iberianpig.dev"
15
15
 
16
+ def gnome_shell_extension_path
17
+ output = `gnome-shell --version`
18
+ version = output.match(/GNOME Shell (\d+\.\d+)/)
19
+
20
+ if version
21
+ version_number = version[1].to_f
22
+ if version_number >= 45.0
23
+ "./appmatcher45@iberianpig.dev"
24
+ else
25
+ "./appmatcher@iberianpig.dev"
26
+ end
27
+ else
28
+ "./appmatcher@iberianpig.dev"
29
+ end
30
+ end
31
+
16
32
  def install
17
33
  pid = as_user(proctitle: self.class.name.underscore) do |user|
18
- FileUtils.cp_r(source_path, user_extension_dir(user.username))
34
+ FileUtils.cp_r(source_path, install_path(user.username))
19
35
  puts "Installed Appmatcher Gnome Shell Extension to #{user_extension_dir(user.username)}"
20
36
  puts "Restart your session, then activate Appmatcher on gnome-extensions-app"
21
37
  end
@@ -47,7 +63,7 @@ module Fusuma
47
63
  end
48
64
 
49
65
  def source_path
50
- File.expand_path(EXTENSION, __dir__)
66
+ File.expand_path(gnome_shell_extension_path, __dir__)
51
67
  end
52
68
 
53
69
  def login_username
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "open3"
4
- require_relative "./user_switcher"
4
+ require_relative "user_switcher"
5
5
  require "fusuma/multi_logger"
6
6
  require "fusuma/custom_process"
7
7
 
@@ -3,7 +3,7 @@
3
3
  module Fusuma
4
4
  module Plugin
5
5
  module Appmatcher
6
- VERSION = "0.6.0"
6
+ VERSION = "0.6.1"
7
7
  end
8
8
  end
9
9
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "open3"
4
- require_relative "./user_switcher"
4
+ require_relative "user_switcher"
5
5
  require "fusuma/multi_logger"
6
6
  require "fusuma/custom_process"
7
7
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fusuma-plugin-appmatcher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - iberianpig
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-08-21 00:00:00.000000000 Z
11
+ date: 2023-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rexml
@@ -70,6 +70,8 @@ files:
70
70
  - lib/fusuma/plugin/appmatcher.rb
71
71
  - lib/fusuma/plugin/appmatcher/gnome.rb
72
72
  - lib/fusuma/plugin/appmatcher/gnome_extension.rb
73
+ - lib/fusuma/plugin/appmatcher/gnome_extensions/appmatcher45@iberianpig.dev/extension.js
74
+ - lib/fusuma/plugin/appmatcher/gnome_extensions/appmatcher45@iberianpig.dev/metadata.json
73
75
  - lib/fusuma/plugin/appmatcher/gnome_extensions/appmatcher@iberianpig.dev/extension.js
74
76
  - lib/fusuma/plugin/appmatcher/gnome_extensions/appmatcher@iberianpig.dev/metadata.json
75
77
  - lib/fusuma/plugin/appmatcher/gnome_extensions/installer.rb
@@ -81,11 +83,6 @@ files:
81
83
  - lib/fusuma/plugin/detectors/appmatcher_detector.rb
82
84
  - lib/fusuma/plugin/events/records/appmatcher_record.rb
83
85
  - lib/fusuma/plugin/inputs/appmatcher_input.rb
84
- - spec/fusuma/plugin/appmatcher/gnome_extensions/installer_spec.rb
85
- - spec/fusuma/plugin/appmatcher/gnome_spec.rb
86
- - spec/fusuma/plugin/appmatcher_spec.rb
87
- - spec/fusuma/plugin/detectors/appmatcher_detector_spec.rb
88
- - spec/spec_helper.rb
89
86
  homepage: https://github.com/iberianpig/fusuma-plugin-appmatcher
90
87
  licenses:
91
88
  - MIT
@@ -110,9 +107,4 @@ rubygems_version: 3.4.10
110
107
  signing_key:
111
108
  specification_version: 4
112
109
  summary: Fusuma plugin to assign gesture mapping per application
113
- test_files:
114
- - spec/fusuma/plugin/appmatcher/gnome_extensions/installer_spec.rb
115
- - spec/fusuma/plugin/appmatcher/gnome_spec.rb
116
- - spec/fusuma/plugin/appmatcher_spec.rb
117
- - spec/fusuma/plugin/detectors/appmatcher_detector_spec.rb
118
- - spec/spec_helper.rb
110
+ test_files: []
@@ -1,28 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "spec_helper"
4
-
5
- module Fusuma
6
- module Plugin
7
- module Appmatcher
8
- module GnomeExtensions
9
- RSpec.describe Installer do
10
- describe "#install" do
11
- it "should copy file to users dir"
12
- end
13
- describe "#uninstall" do
14
- context "when extension is NOT installed" do
15
- it "should remove file to users dir"
16
- end
17
- context "when extension is NOT installed" do
18
- it "should NOT execute"
19
- end
20
- end
21
- describe "#installed?" do
22
- it "check extension is in the installed path"
23
- end
24
- end
25
- end
26
- end
27
- end
28
- end
@@ -1,16 +0,0 @@
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,51 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "spec_helper"
4
-
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
- subject { Appmatcher.backend_klass }
14
- context "when XDG_SESSION_TYPE is x11" do
15
- before { allow(Appmatcher).to receive(:xdg_session_type).and_return("x11") }
16
- it { is_expected.to eq Appmatcher::X11 }
17
- end
18
-
19
- context "when XDG_SESSION_TYPE is wayland" do
20
- before { allow(Appmatcher).to receive(:xdg_session_type).and_return("wayland") }
21
-
22
- context "when XDG_CURRENT_DESKTOP is ubuntu:GNOME" do
23
- before { allow(Appmatcher).to receive(:xdg_current_desktop).and_return("ubuntu:GNOME") }
24
-
25
- context "when gnome-extension is installed" do
26
- before do
27
- allow_any_instance_of(Appmatcher::GnomeExtensions::Installer).to receive(:installed?).and_return(true)
28
- end
29
- it { is_expected.to eq Appmatcher::GnomeExtension }
30
- end
31
-
32
- context "when gnome-extension is NOT installed" do
33
- before do
34
- allow_any_instance_of(Appmatcher::GnomeExtensions::Installer).to receive(:installed?).and_return(false)
35
- end
36
- it { is_expected.to eq Appmatcher::Gnome }
37
- end
38
- end
39
-
40
- context "when XDG_CURRENT_DESKTOP is UNKNOWN" do
41
- before do
42
- allow(Appmatcher).to receive(:xdg_current_desktop).and_return("UNKNOWN")
43
- allow(MultiLogger).to receive(:error)
44
- end
45
- it { is_expected.to eq Appmatcher::UnsupportedBackend }
46
- end
47
- end
48
- end
49
- end
50
- end
51
- end
@@ -1,68 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "spec_helper"
4
-
5
- require "fusuma/plugin/detectors/detector"
6
- require "fusuma/plugin/buffers/buffer"
7
-
8
- require "./lib/fusuma/plugin/buffers/appmatcher_buffer"
9
- require "./lib/fusuma/plugin/detectors/appmatcher_detector"
10
-
11
- module Fusuma
12
- module Plugin
13
- module Detectors
14
- RSpec.describe AppmatcherDetector do
15
- before do
16
- @detector = AppmatcherDetector.new
17
- @buffer = Buffers::AppmatcherBuffer.new
18
- end
19
-
20
- describe "#detector" do
21
- context "with no appmatcher event in buffer" do
22
- before do
23
- @buffer.clear
24
- end
25
-
26
- it { expect(@detector.detect([@buffer])).to eq nil }
27
- end
28
- end
29
-
30
- context "with appmatcher events in buffer" do
31
- before do
32
- record = Events::Records::AppmatcherRecord.new(name: "dummy")
33
- event = Events::Event.new(tag: "appmatcher_input", record: record)
34
-
35
- @buffer.buffer(event)
36
- end
37
- it { expect(@detector.detect([@buffer])).to be_a Events::Event }
38
- it "should detect ContextRecord" do
39
- expect(@detector.detect([@buffer]).record).to be_a Events::Records::ContextRecord
40
- end
41
- it "should detect context: { application: dummy }" do
42
- record = @detector.detect([@buffer]).record
43
- expect(record.name).to eq :application
44
- expect(record.value).to eq "dummy"
45
- end
46
- end
47
-
48
- context "with two different appmatcher events in buffer" do
49
- before do
50
- record1 = Events::Records::AppmatcherRecord.new(name: "dummy1")
51
- record2 = Events::Records::AppmatcherRecord.new(name: "dummy2")
52
- event1 = Events::Event.new(tag: "appmatcher_input", record: record1)
53
- event2 = Events::Event.new(tag: "appmatcher_input", record: record2)
54
-
55
- @buffer.buffer(event1)
56
- @buffer.buffer(event2)
57
- end
58
-
59
- it "should detect latest application" do
60
- record = @detector.detect([@buffer]).record
61
- expect(record.name).to eq :application
62
- expect(record.value).to eq "dummy2"
63
- end
64
- end
65
- end
66
- end
67
- end
68
- end
data/spec/spec_helper.rb DELETED
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "bundler/setup"
4
- require "fusuma/plugin/appmatcher"
5
- require 'rspec/debug'
6
-
7
- RSpec.configure do |config|
8
- # Enable flags like --only-failures and --next-failure
9
- config.example_status_persistence_file_path = ".rspec_status"
10
-
11
- # Disable RSpec exposing methods globally on `Module` and `main`
12
- config.disable_monkey_patching!
13
-
14
- config.expect_with :rspec do |c|
15
- c.syntax = :expect
16
- end
17
- end