Élargir le champ d'action Réponse de Leonard :
Vous pouvez le faire en remplaçant le Mojave.heic
fond d'écran par défaut. Ce site ne nécessite pas la désactivation de SIP comme c'est dans /Library
.
-
Retourner /Library/Desktop Pictures/Mojave.heic
en le copiant dans Mojave.heic.orig
ou similaire.
-
Récupérez votre nouvelle image et mettez-la à l'échelle/coupez-la à exactement s'adapter à l'écran. Si vous ne connaissez pas la résolution de votre écran, vous pouvez aller dans > À propos de ce Mac.
-
Remplacer Mojave.heic
avec votre nouveau fichier. Ne vous inquiétez pas s'il s'agit d'un fichier JPG ou similaire, il fonctionnera même après avoir été renommé en Mojave.heic
.*
-
Si vous avez FileVault activé, modifiez une option de connexion dans les Préférences système. Par exemple, si vous souhaitez afficher une liste d'utilisateurs ou les champs de nom et de mot de passe. Il vous suffit de la modifier à nouveau si vous ne voulez pas la changer.
C'est parce que lorsque vous démarrez avec FileVault, à l'écran de connexion votre système n'a pas vraiment démarré. ! Il exécute en fait un petit système sur votre partition EFI, puisque votre partition principale est cryptée. En changeant une option de connexion, les Préférences Système modifieront les paramètres du système EFI, y compris le changement de fond d'écran. Voir cette réponse .
-
Redémarrez et profitez-en !
* Je n'ai testé ceci qu'avec des images JPEG, mais cela peut fonctionner pour d'autres types.
Un gain de temps totalement inutile
J'ai créé un petit programme Swift qui fait tout cela pour vous (il détecte la version de l'OS et fonctionne aussi bien sur Mojave que sur les versions antérieures). Vous aurez besoin de Xcode pour le compiler.
Ça ne devrait pas casser votre système, mais je ne peux rien garantir assurez-vous d'avoir des sauvegardes avant tout !
Ceci est maintenant également disponible <a href="https://github.com/SilverWolf32/loginwindowbgconverter" rel="nofollow noreferrer">sur GitHub </a>. Il peut ou non être mis à jour ici à l'avenir.
//
// loginwindowbgconverter
// by SilverWolf
// 2018-09-27
//
import Foundation
import AppKit
func printUsage() {
print("""
usage: \(CommandLine.arguments[0]) \u{1B}[4mimage-file\u{1B}[0m
It needs to be run as root, as it saves to /Library/Desktop Pictures.
""")
}
guard CommandLine.arguments.indices.contains(1) else {
printUsage()
exit(1)
}
let inputFile = CommandLine.arguments[1]
guard let inputImage = NSImage(contentsOfFile: inputFile) else {
print("\(CommandLine.arguments[0]): can't load image from \(inputFile)")
exit(2)
}
let iw = inputImage.size.width
let ih = inputImage.size.height
let iaspect = Double(iw) / Double(ih)
// use System Profiler to get screen size
var sw = 0, sh = 0
enum ScreenSizeError: Error {
case foundNil
}
do {
let task = Process()
if #available(macOS 10.13, *) {
task.executableURL = URL(fileURLWithPath: "/bin/zsh")
} else {
task.launchPath = "/bin/zsh"
}
task.arguments = ["-f", "-c", "system_profiler SPDisplaysDataType | awk '/Resolution/{print $2, $4}' | head -n 1"]
let stdoutPipe = Pipe()
task.standardOutput = stdoutPipe
if #available(macOS 10.13, *) {
try task.run()
} else {
task.launch()
}
task.waitUntilExit()
let data = stdoutPipe.fileHandleForReading.readDataToEndOfFile()
guard let text = String(data: data, encoding: .utf8) else {
throw ScreenSizeError.foundNil
}
let sizes = (text as NSString).replacingOccurrences(of: "\n", with: "").components(separatedBy: " ")
sw = Int(sizes[0]) ?? 0
sh = Int(sizes[1]) ?? 0
guard sw != 0 && sh != 0 else {
throw ScreenSizeError.foundNil
}
} catch {
print("\(CommandLine.arguments[0]): can't get screen resolution")
exit(3)
}
print("Screen size: \(sw)x\(sh)")
var nw = 0, nh = 0
var x = 0, y = 0 // offsets
let saspect = Double(sw) / Double(sh)
if saspect > iaspect { // screen is wider
nw = sw
nh = Int(Double(sw) / iaspect) // keep input image aspect ratio
y = -1 * (nh - sh) / 2 // half the difference
} else { // screen is narrower
nh = sh
nw = Int(Double(sh) * iaspect)
x = -1 * (nw - sw) / 2
}
// draw into new image
guard let newImage = NSBitmapImageRep(bitmapDataPlanes: nil,
pixelsWide: Int(sw),
pixelsHigh: Int(sh),
bitsPerSample: 8,
samplesPerPixel: 4,
hasAlpha: true,
isPlanar: false,
colorSpaceName: .deviceRGB,
bytesPerRow: sw * 4,
bitsPerPixel: 32) else {
print("\(CommandLine.arguments[0]): can't create bitmap image to draw into!")
exit(2)
}
NSGraphicsContext.saveGraphicsState()
let graphicsContext = NSGraphicsContext(bitmapImageRep: newImage)
NSGraphicsContext.current = graphicsContext
graphicsContext?.imageInterpolation = .high
let r = NSMakeRect(CGFloat(x), CGFloat(y), CGFloat(nw), CGFloat(nh))
print("drawing rect: \(r)")
inputImage.draw(in: r)
graphicsContext?.flushGraphics()
NSGraphicsContext.restoreGraphicsState()
print("image size: \(newImage.size)")
// write to file
if #available(macOS 10.14, *) { // macOS Mojave has a completely different system
let targetFile = "/Library/Desktop Pictures/Mojave.heic"
let origFile = "/Library/Desktop Pictures/Mojave.heic.orig"
if !FileManager.default.fileExists(atPath: origFile) { // no backup of original Mojave.heic
print("Backing up original Mojave.heic (this should only happen once)")
do {
try FileManager.default.copyItem(atPath: targetFile, toPath: origFile)
} catch {
print("\(CommandLine.arguments[0]): \u{1B}[1mbackup failed, aborting!\u{1B}[0m \(error.localizedDescription)")
exit(1)
}
}
print("Saving to \(targetFile)")
// actual writing
let imageData = newImage.representation(using: .jpeg, properties: [:])!
do {
try imageData.write(to: URL(fileURLWithPath: targetFile))
} catch {
print("\(CommandLine.arguments[0]): can't write image data: \(error)")
print("(are you root?)")
exit(1)
}
} else {
let targetFile = "/Library/Caches/com.apple.desktop.admin.png"
print("Saving to \(targetFile)")
let pngData = newImage.representation(using: .png, properties: [:])!
do {
try pngData.write(to: URL(fileURLWithPath: targetFile))
} catch {
print("\(CommandLine.arguments[0]): can't write image data: \(error)")
print("(are you root?)")
exit(1)
}
}
//
// This is free and unencumbered software released into the public domain.
//
// Anyone is free to copy, modify, publish, use, compile, sell, or
// distribute this software, either in source code form or as a compiled
// binary, for any purpose, commercial or non-commercial, and by any
// means.
//
// In jurisdictions that recognize copyright laws, the author or authors
// of this software dedicate any and all copyright interest in the
// software to the public domain. We make this dedication for the benefit
// of the public at large and to the detriment of our heirs and
// successors. We intend this dedication to be an overt act of
// relinquishment in perpetuity of all present and future rights to this
// software under copyright law.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL TH AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
//
// For more information, please refer to <https://unlicense.org/>.
//