flickpaper 0.0.3 → 0.0.4

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.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/README.md +4 -1
  4. data/lib/flickpaper.rb +50 -0
  5. data/version +1 -1
  6. metadata +3 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8416847871609b13d927e4e9cb892a7b62548697
4
- data.tar.gz: a3aa388f991e63ffb78ca98f881d8ac6d957ee44
3
+ metadata.gz: b263f4ce1be4678df104ce63887eaa58072b0af2
4
+ data.tar.gz: 4bff630195a7af3215b009017f16f89ebbf22ca9
5
5
  SHA512:
6
- metadata.gz: 71075de7292559348356e1cb344f6b7bef71884c308e94ace4cb411f7ae3587963c6022645ac96387e05b6542ccc1c67eb4698f9a108736af14b5423e0cfec39
7
- data.tar.gz: 78ed6977afe25984ceeb06b55636533142deb2df4b7bf2dde1b6ac7b34c4d4d2e055fc7b1459ab431dbc27954378dbd7b4cc721087a42c34b3e11005217446cb
6
+ metadata.gz: 977e8ad44047974dcc77e895ea2861fa830ac6d5429bfde6bda2e09846ad432f123c5e484f9b340d987e92cfbd1e955018b95d45eea9ac48bfa2ba50355bb211
7
+ data.tar.gz: 7c2ef3d7cfe806fe2c00b50ee130a38e06d27f37a0298a3cb14273d10f7df57d0d4c44af3a63a6a1ee1b93b54289499881144520b7e0e67914b9081ca10b678a
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- flickpaper (0.0.3)
4
+ flickpaper (0.0.4)
5
5
  flickraw
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -1,7 +1,10 @@
1
1
  # Flickpaper
2
2
 
3
3
  A [Ruby Gem](https://rubygems.org/gems/flickpaper) and [Flickr App](https://www.flickr.com/services/apps/72157658406991003)
4
- that sets your GNOME or OSX wallpaper to a recent interesting photo.
4
+ that sets your Linux or OSX wallpaper to a recent interesting photo.
5
+
6
+ For linux, it works under Gnome and window managers that use [feh](https://wiki.archlinux.org/index.php/Feh)
7
+ to update the desktop wallpaper.
5
8
 
6
9
  Does not (and will likely never) work under MS Windows.
7
10
 
data/lib/flickpaper.rb CHANGED
@@ -102,6 +102,29 @@ module Flickpaper
102
102
  end
103
103
  end
104
104
 
105
+ # http://unix.stackexchange.com/questions/116539/how-to-detect-the-desktop-environment-in-a-bash-script
106
+ def self.window_manager
107
+ if ENV['XDG_CURRENT_DESKTOP']
108
+ desktop = ENV['XDG_CURRENT_DESKTOP']
109
+ .downcase
110
+ else
111
+ exclude = %w{ usr local share }
112
+ v = ENV['XDG_DATA_DIRS']
113
+ .to_s
114
+ .downcase
115
+ .split(/[^a-z0-9]+/)
116
+ .select { |r| r != "" }
117
+ .uniq
118
+ .reject { |r| exclude.include?(r) }
119
+ if v.length == 1
120
+ desktop = v
121
+ .first
122
+ .downcase
123
+ end
124
+ end
125
+ desktop.to_sym if desktop
126
+ end
127
+
105
128
  def self.set_wallpaper(path)
106
129
  case os
107
130
  when :windows
@@ -131,6 +154,17 @@ module Flickpaper
131
154
  end
132
155
 
133
156
  def self.set_wallpaper_linux(path)
157
+ case window_manager
158
+ when :gnome
159
+ set_wallpaper_gnome(path)
160
+ when :kde
161
+ set_wallpaper_kde(path)
162
+ else
163
+ set_wallpaper_feh(path)
164
+ end
165
+ end
166
+
167
+ def self.set_wallpaper_gnome(path)
134
168
  dbus_launch = %x{ which dbus-launch }.to_s.strip
135
169
  gsettings = %x{ which gsettings }.to_s.strip
136
170
  if dbus_launch == "" || gsettings == ""
@@ -149,6 +183,22 @@ module Flickpaper
149
183
  end
150
184
  end
151
185
 
186
+ # TODO
187
+ def self.set_wallpaper_kde(path)
188
+ false
189
+ end
190
+
191
+ def self.set_wallpaper_feh(path)
192
+ feh = %x{ which feh }.to_s.strip
193
+ if feh == ""
194
+ false
195
+ else
196
+ # can be tile, center, max, fill
197
+ scaling = 'fill'
198
+ system("#{feh} --bg-#{scaling} \"#{path}\"")
199
+ end
200
+ end
201
+
152
202
  def self.get_default_image_path
153
203
  case os
154
204
  when :windows
data/version CHANGED
@@ -1 +1 @@
1
- 0.0.3
1
+ 0.0.4
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flickpaper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Tongen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-21 00:00:00.000000000 Z
11
+ date: 2016-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -96,3 +96,4 @@ signing_key:
96
96
  specification_version: 4
97
97
  summary: Sets your GNOME or OSX wallpaper to a recent interesting photo from flickr
98
98
  test_files: []
99
+ has_rdoc: