fusuma-plugin-wmctrl 0.4.0.pre → 0.4.0.pre2

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: cb925fbaa6b543ef479a4ab6cd1344059e33463a0f7f3df3049e1edd70d76ad6
4
- data.tar.gz: 6b7420837c160600133777202abfac495ceac866074c0b427264fd81d9c429e0
3
+ metadata.gz: '069aaa7f3d06e2445189455621c251823ae6b012b3aae0c7ec717f013af5c4c9'
4
+ data.tar.gz: cabf1c51189097888bcc4f729ffbc985b3a953cbb65a260a517b807f234056bf
5
5
  SHA512:
6
- metadata.gz: dfdc522616136c802daa4484fd340171d82aa22918fe8545bfdaa3c8b48265a42fe9045174a1c77454900f20fcb04b7f343f3a44cbd66cfa14e9b413de49ae15
7
- data.tar.gz: 9f70a836df9ade7c00f894444b5e01925e7b2170c4af932c0ef07549124b14c65b5c1ce58d27caa51bbebcdc6702480805d5d3f102e0887bc5107fb49bef90c7
6
+ metadata.gz: d7e2d157ca4e01b97b09bebe5354069b03a43d3fa47234c39eb5bdfd8f92fa510139c48618d3e428ebbf8a0663dcaffe628b1f77c3c422abaa84203b91fd8a40
7
+ data.tar.gz: 216014d9644812c3992b7e8ba02f1816737eea4ce00f1097070c8b9acf15719ee874a4c635eaadc57711c4a5f1c427300031cc5ce5f91a60f484eda4534cd5f7
data/CHANGELOG.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # Changelog
2
2
 
3
- ## [Unreleased](https://github.com/iberianpig/fusuma-plugin-wmctrl/tree/HEAD)
3
+ ## [v0.4.0.pre](https://github.com/iberianpig/fusuma-plugin-wmctrl/tree/v0.4.0.pre) (2020-11-09)
4
4
 
5
- [Full Changelog](https://github.com/iberianpig/fusuma-plugin-wmctrl/compare/v0.3.0...HEAD)
5
+ [Full Changelog](https://github.com/iberianpig/fusuma-plugin-wmctrl/compare/v0.3.0...v0.4.0.pre)
6
6
 
7
7
  **Merged pull requests:**
8
8
 
data/README.md CHANGED
@@ -10,15 +10,29 @@ Window Manager plugin for [Fusuma](https://github.com/iberianpig/fusuma)
10
10
 
11
11
  Run the following code in your terminal.
12
12
 
13
- ### Install wmctrl
13
+ ### 1.Install wmctrl
14
+
15
+ #### For Debian Based Distros (Ubuntu, Debian, Mint, Pop!_OS)
14
16
 
15
17
  ```
16
- $ sudo apt install wmctrl
18
+ $ sudo apt install wmctrl -y
17
19
  ```
18
- ### Install fusuma-plugin-wmctrl
20
+
21
+ #### For Arch Based Distros (Manjaro, Arch)
22
+
23
+ ```
24
+ sudo pacman -S wmctrl
25
+ ```
26
+
27
+ ### 2. Install fusuma-plugin-wmctrl
19
28
 
20
29
  This plugin requires [Fusuma](https://github.com/iberianpig/fusuma#update) version 1.0 or later.
21
30
 
31
+
32
+ **Note For Arch Based Distros:** By default in Arch Linux, when running ```gem```, gems are installed per-user (into ```~/.gem/ruby/```), instead of system-wide (into ```/usr/lib/ruby/gems/```). This is considered the best way to manage gems on Arch, because otherwise they might interfere with gems installed by Pacman. (From Arch Wiki)
33
+
34
+ To install gems system-wide, see any of the methods listed on [Arch Wiki](https://wiki.archlinux.org/index.php/ruby#Installing_gems_system-wide)
35
+
22
36
  ```sh
23
37
  $ sudo gem install fusuma-plugin-wmctrl
24
38
  ```
@@ -95,6 +109,17 @@ swipe:
95
109
  workspace: 'prev'
96
110
  ```
97
111
 
112
+ ## Configuration
113
+
114
+ The plugin allows to enable (disabled by default) circular navigation between workspaces. To enable it set the following in your config file `~/.config/fusuma/config.yml`.
115
+
116
+ ```yaml
117
+ plugin:
118
+ executors:
119
+ wmctrl_executor:
120
+ wrap-navigation: true
121
+ ```
122
+
98
123
 
99
124
  ## Contributing
100
125
 
@@ -25,5 +25,5 @@ Gem::Specification.new do |spec|
25
25
  spec.require_paths = ['lib']
26
26
 
27
27
  spec.required_ruby_version = '>= 2.3' # https://packages.ubuntu.com/search?keywords=ruby&searchon=names&exact=1&suite=all&section=main
28
- spec.add_dependency 'fusuma', '~> 2.0.0.pre'
28
+ spec.add_dependency 'fusuma', '~> 2.0.0.pre2'
29
29
  end
@@ -1,12 +1,29 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'posix/spawn'
4
+ require 'singleton'
4
5
 
5
6
  module Fusuma
6
7
  module Plugin
7
8
  module Executors
8
9
  # Control Window or Workspaces by executing wctrl
9
10
  class WmctrlExecutor < Executor
11
+ # executor properties on config.yml
12
+ # @return [Array<Symbol>]
13
+ def execute_keys
14
+ %i[wmctrl workspace]
15
+ end
16
+
17
+ def config_param_types
18
+ {
19
+ 'wrap-navigation': [TrueClass, FalseClass]
20
+ }
21
+ end
22
+
23
+ def initialize
24
+ Workspace.configure(wrap_navigation: config_params(:'wrap-navigation'))
25
+ end
26
+
10
27
  # execute wmctrl command
11
28
  # @param event [Event]
12
29
  # @return [nil]
@@ -74,25 +91,64 @@ module Fusuma
74
91
 
75
92
  # Manage workspace
76
93
  class Workspace
94
+ include Singleton
95
+
96
+ attr_accessor :wrap_navigation
97
+
77
98
  class << self
78
- # get workspace number
99
+ # configure properties of the workspace switcher
100
+ # @return [NilClass]
101
+ def configure(wrap_navigation:)
102
+ instance.wrap_navigation = wrap_navigation
103
+ end
104
+
105
+ # get next workspace number
79
106
  # @return [Integer]
80
- def current_workspace_num
81
- text = `wmctrl -d`.split("\n").grep(/\*/).first
82
- text.chars.first.to_i
107
+ def next_workspace_num(step:)
108
+ current_workspace_num, total_workspace_num = workspace_values
109
+
110
+ next_workspace_num = current_workspace_num + step
111
+
112
+ return next_workspace_num unless instance.wrap_navigation
113
+
114
+ if next_workspace_num.negative?
115
+ next_workspace_num = total_workspace_num - 1
116
+ elsif next_workspace_num >= total_workspace_num
117
+ next_workspace_num = 0
118
+ else
119
+ next_workspace_num
120
+ end
83
121
  end
84
122
 
85
123
  def move_command(direction:)
86
124
  workspace_num = case direction
87
125
  when 'next'
88
- current_workspace_num + 1
126
+ next_workspace_num(step: 1)
89
127
  when 'prev'
90
- current_workspace_num - 1
128
+ next_workspace_num(step: -1)
91
129
  else
92
130
  raise "#{direction} is invalid key"
93
131
  end
94
132
  "wmctrl -s #{workspace_num}"
95
133
  end
134
+
135
+ private
136
+
137
+ # get current workspace and total workspace numbers
138
+ # @return [Integer, Integer]
139
+ def workspace_values
140
+ wmctrl_output = `wmctrl -d`.split("\n")
141
+
142
+ current_line = wmctrl_output.grep(/\*/).first
143
+ # NOTE: stderror when failed to get desktop
144
+ # `Cannot get current desktop properties. (_NET_CURRENT_DESKTOP or _WIN_WORKSPACE property)`
145
+ return [0, 1] if current_line.nil? # If not found ,return desktop id as 0 and the total number as 1
146
+
147
+ current_workspace_num = current_line.chars.first.to_i
148
+ total_workspace_num = wmctrl_output.length
149
+
150
+ [current_workspace_num, total_workspace_num]
151
+ end
96
152
  end
97
153
  end
98
154
 
@@ -116,9 +172,9 @@ module Fusuma
116
172
  def move_command(direction:)
117
173
  workspace_num = case direction
118
174
  when 'next'
119
- Workspace.current_workspace_num + 1
175
+ Workspace.next_workspace_num(step: 1)
120
176
  when 'prev'
121
- Workspace.current_workspace_num - 1
177
+ Workspace.next_workspace_num(step: -1)
122
178
  else
123
179
  raise "#{direction} is invalid key"
124
180
  end
@@ -3,7 +3,7 @@
3
3
  module Fusuma
4
4
  module Plugin
5
5
  module Wmctrl
6
- VERSION = '0.4.0.pre'
6
+ VERSION = '0.4.0.pre2'
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fusuma-plugin-wmctrl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0.pre
4
+ version: 0.4.0.pre2
5
5
  platform: ruby
6
6
  authors:
7
7
  - iberianpig
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-11-09 00:00:00.000000000 Z
11
+ date: 2021-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fusuma
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 2.0.0.pre
19
+ version: 2.0.0.pre2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 2.0.0.pre
26
+ version: 2.0.0.pre2
27
27
  description: fusuma-plugin-wmctrl is Fusuma plugin for window manager.
28
28
  email:
29
29
  - yhkyky@gmail.com
@@ -52,7 +52,7 @@ homepage: https://github.com/iberianpig/fusuma-plugin-wmctrl
52
52
  licenses:
53
53
  - MIT
54
54
  metadata: {}
55
- post_install_message:
55
+ post_install_message:
56
56
  rdoc_options: []
57
57
  require_paths:
58
58
  - lib
@@ -68,7 +68,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
68
68
  version: 1.3.1
69
69
  requirements: []
70
70
  rubygems_version: 3.1.4
71
- signing_key:
71
+ signing_key:
72
72
  specification_version: 4
73
73
  summary: Wmctrl plugin for Fusuma
74
74
  test_files: []