moodwall 0.1.4 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +11 -0
- data/bin/moodwall +1 -3
- data/lib/moodwall.rb +2 -0
- data/lib/moodwall/config.rb +26 -0
- data/lib/moodwall/config_file.rb +27 -0
- data/lib/moodwall/executable.rb +8 -3
- data/lib/moodwall/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76cbd152fdaa9e375db9be0a48154f644e4a17caff9f57a20e34ad38bff19337
|
4
|
+
data.tar.gz: 315a703cf9ea243504b8b83f4c511025ea263938ab7039304c763de5cc1da77b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07dc85557daa890c2a182e43300b1602f63009f5563842f4d89f28b97e1a5d00a569756cc342a19da90d57387df04791ad5d6e0e3f1ba8744a3515bd17dcab4f
|
7
|
+
data.tar.gz: 1bcb8382ed7cd79e8d4680d8a1cb672b3bad4d41df086cdf431f9585c1a3085748dad2b9424677bd7305c47c909a7255f00c7991927affaa356e1063cb49151c
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -14,6 +14,17 @@ Install it yourself as:
|
|
14
14
|
|
15
15
|
$ gem install moodwall
|
16
16
|
|
17
|
+
## Configuration
|
18
|
+
|
19
|
+
Create a `config.yml` file at `~/.config/moodwall/config.yml` and specify
|
20
|
+
command to change wallpaper in your distro. Here is defaults:
|
21
|
+
|
22
|
+
``` yaml
|
23
|
+
executable:
|
24
|
+
command: feh
|
25
|
+
arguments: --bg-fill
|
26
|
+
```
|
27
|
+
|
17
28
|
## Usage examples
|
18
29
|
|
19
30
|
``` shell
|
data/bin/moodwall
CHANGED
@@ -19,9 +19,7 @@ when options.add && options.wallpaper && !options.path.nil? && !options.mood_nam
|
|
19
19
|
mood = Moodwall::Mood.find_by_name(options.mood_name)
|
20
20
|
Moodwall::Wallpaper.new({path: options.path, mood_id: mood.id}).save
|
21
21
|
when options.change && options.wallpaper
|
22
|
-
|
23
|
-
wallpaper = Moodwall::Wallpaper.sample
|
24
|
-
executable.execute(wallpaper.path)
|
22
|
+
Moodwall::Executable.execute(Moodwall::Wallpaper.sample.path)
|
25
23
|
when options.list && options.mood
|
26
24
|
puts Moodwall::Mood.list_names
|
27
25
|
when options.list && options.wallpaper
|
data/lib/moodwall.rb
CHANGED
@@ -0,0 +1,26 @@
|
|
1
|
+
module Moodwall
|
2
|
+
class Config
|
3
|
+
DEFAULTS = {
|
4
|
+
executable: {
|
5
|
+
command: "feh",
|
6
|
+
arguments: "--bg-fill"
|
7
|
+
}
|
8
|
+
}.freeze
|
9
|
+
|
10
|
+
attr_reader :executable
|
11
|
+
|
12
|
+
def initialize(config_file = ConfigFile.new)
|
13
|
+
@data = config_file.data
|
14
|
+
@executable = decorate_executable(@data.fetch("executable", {}))
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def decorate_executable(data)
|
20
|
+
Struct.new(:command, :arguments).new(
|
21
|
+
data.fetch("command", DEFAULTS[:executable][:command]),
|
22
|
+
data.fetch("arguments", DEFAULTS[:executable][:arguments])
|
23
|
+
)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require "yaml"
|
2
|
+
require "fileutils"
|
3
|
+
|
4
|
+
module Moodwall
|
5
|
+
class ConfigFile
|
6
|
+
DIRECTORY = "#{ Dir.home }/.config/moodwall".freeze
|
7
|
+
FILE = "config.yml".freeze
|
8
|
+
|
9
|
+
attr_reader :data, :path
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
@path = File.join(DIRECTORY, FILE)
|
13
|
+
create_directory && prepare_file
|
14
|
+
@data = YAML.safe_load(File.read(path)) || {}
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def create_directory
|
20
|
+
FileUtils.mkdir_p(DIRECTORY)
|
21
|
+
end
|
22
|
+
|
23
|
+
def prepare_file
|
24
|
+
FileUtils.touch(path)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/moodwall/executable.rb
CHANGED
@@ -4,12 +4,17 @@ module Moodwall
|
|
4
4
|
class Executable
|
5
5
|
attr_reader :command, :arguments
|
6
6
|
|
7
|
-
def initialize(options = {})
|
8
|
-
@
|
9
|
-
@
|
7
|
+
def initialize(options = {}, config = Config.new)
|
8
|
+
@config = config.executable
|
9
|
+
@command = options.fetch(:command, @config.command)
|
10
|
+
@arguments = options.fetch(:arguments, @config.arguments)
|
10
11
|
error_if_missing
|
11
12
|
end
|
12
13
|
|
14
|
+
def self.execute(path)
|
15
|
+
new.execute(path)
|
16
|
+
end
|
17
|
+
|
13
18
|
def error_if_missing
|
14
19
|
raise(MissingExecutableError, "Can't find the `#{ command }`") unless installed?
|
15
20
|
end
|
data/lib/moodwall/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: moodwall
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Valiantsin Mikhaliuk
|
@@ -130,6 +130,8 @@ files:
|
|
130
130
|
- bin/moodwall
|
131
131
|
- bin/setup
|
132
132
|
- lib/moodwall.rb
|
133
|
+
- lib/moodwall/config.rb
|
134
|
+
- lib/moodwall/config_file.rb
|
133
135
|
- lib/moodwall/executable.rb
|
134
136
|
- lib/moodwall/mood.rb
|
135
137
|
- lib/moodwall/optparse.rb
|