chrishunt / desktop

A decent way to change your desktop image
https://github.com/chrishunt/desktop
MIT License
250 stars 15 forks source link

Set different images to different monitors #5

Open danieldisu opened 10 years ago

danieldisu commented 10 years ago

Could be possible to implement a way to set different images to each monitor?

Something like:

desktop set -m 1 -image imagePath
chrishunt commented 10 years ago

Totally possible, but I don't know how to do that yet :grimacing:

We're changing the background now by setting the Mac OS default background to the selected image, then clearing out any desktops we've set manually.

In order to set a different image for every space, we actually need to understand how desktoppicture.db works (which looks a bit gnarly).

I may tinker with the db a bit and see if I can figure it out, but feel free to explore yourself and comment on your findings.

Here's some poking around:

> db = SQLite3::Database.new(osx.desktop_image_db_path)

> db.execute "SELECT name FROM sqlite_master WHERE type='table'"
[["pictures"], ["preferences"], ["spaces"], ["displays"], ["data"], ["prefs"]]

> db.execute "SELECT * FROM spaces"
[
  [""],
  ["5A8F8D78-66B8-4A01-B7D9-32D4067EA3AF"],
  ["31E5E74B-E2A9-43CC-ABD1-16F6B93B6A22"],
  ["7C5A9F2C-99AE-4EE6-9B26-5EA7A038A796"],
  ["321DA7DA-566A-4D8E-9968-7C5DD5ADE07B"],
  ["913BCF36-7E22-4D2C-A4D1-630ED0F4D04D"],
  ["053E2414-8A52-439E-AD3F-C999ED157A2D"],
  ["EA8149C5-2A9A-4731-B565-E05911ECDCE6"],
  ["C6391CBE-318B-4084-A5E6-7BFB4C5BBA23"],
  ["4438E2FC-0890-41D3-8C6B-056455213E72"],
  ["2D549F72-7964-4DD5-9371-2A959B0B5804"],
  ["220DB928-18AA-47A8-95EE-65106D143A17"]
]

> db.execute "SELECT * FROM displays"
[
  [69731264],
  [2077752383],
  ["C6076DC3-B2A7-E5A5-3A31-D9E7427CFF58"],
  ["6098E230-2DCD-34CC-6ED3-19D8FFE39E0B"]
]

> db.execute "SELECT * FROM pictures"
[
  [nil, nil],
  [1, nil],
  [1, 1],
  [nil, 1],
  [1, 2],
  [nil, 2],
  [2, 1],
  [2, nil],
  [3, nil],
  [3, 1],
  [3, 2],
  [4, nil],
  [4, 1],
  [4, 2],
  # ... and many more ...
]

> db.execute "SELECT * FROM preferences"
[
  [1, 1, 3],
  [1, 1, 4],
  [1, 2, 5],
  [1, 2, 6],
  [1, 1, 7],
  [1, 1, 10],
  [1, 2, 11],
  [1, 1, 13],
  [1, 2, 14],
  [1, 1, 16],
  [1, 2, 17],
  [15, 3, 19],
  [3, 4, 19],
  [4, 4, 19],
  # ... and many more ...
]
stve commented 10 years ago

@chrishunt I happened across this blog post that you might find useful. http://1klb.com/posts/2013/11/02/desktop-background-on-os-x-109-mavericks/

chrishunt commented 10 years ago

Ooo, that looks helpful. Thanks @stve.