Created
January 30, 2014 09:25
-
-
Save eunomie/8705221 to your computer and use it in GitHub Desktop.
Prend une image aléatoirement dans le répertoire IMAGES et applique là à tous les spaces puis redémarre le Dock pour que ce soit pris en compte. Initialement il faut que tous les spaces aient soient configurés avec une image (pas la conf par défaut).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require "sqlite3" | |
DB_LOC = File.join(ENV["HOME"], "Library/Application Support/Dock/desktoppicture.db") | |
DB = SQLite3::Database.new(DB_LOC) | |
IMAGES = File.join(ENV["HOME"], "Pictures/desktops/2560x1600","*") | |
new_image = Dir[IMAGES].sort_by{ rand }[0] | |
new_image.sub!(ENV["HOME"],"~") | |
DB.execute("SELECT ROWID,value FROM data").each do |(rowid,path)| | |
next if !path.is_a?(String) | |
path = File.expand_path(path) | |
next if !File.exists?(path) | |
next if File.directory?(path) | |
DB.execute("UPDATE data SET value=? WHERE ROWID=?",[new_image,rowid]) | |
end | |
`killall Dock` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment