如何破解Mac并为其提供真正应得的精美壁纸

news/2024/11/29 5:30:09/

by Aakaash Jois

通过Aakaash Jois

如何破解Mac并为其提供真正应得的精美壁纸 (How to hack your Mac and give it the gorgeous wallpapers it truly deserves)

Let’s face it. The default wallpapers on the Mac gets boring after a few weeks. And setting new wallpaper manually is tiresome. Well, what if I told you that I got my Mac greet me with a brand new, high resolution wallpaper every time I flip it open?

面对现实吧。 Mac上的默认壁纸会在几周后变得无聊。 手动设置新墙纸很麻烦。 好吧,如果我告诉您每次打开Mac时,我都会得到一台全新的高分辨率墙纸来迎接Mac,该怎么办?

If you’re a Chromecast user, you may be familiar with Chromecast Backdrop. Backdrop allows the Chromecast to display a slideshow of beautiful photos when it’s idle.

如果您是Chromecast用户,则可能对Chromecast Backdrop熟悉。 通过背景幕,Chromecast可以在闲置时以幻灯片形式显示精美照片。

While most users default to Facebook to post photos, a lot of photographers use Google+ to publish their work. Google selects some of these best photos to create brilliant slideshows.

尽管大多数用户默认使用Facebook发布照片,但是许多摄影师都使用Google+发布他们的作品。 Google会从其中一些最佳照片中选出精彩的幻灯片。

For a long time, this was exclusive to ChromeCast user. But a few months ago, Google released a nifty app for Mac called Google Featured Photos.

长期以来,这是ChromeCast用户专有的。 但是几个月前,谷歌为Mac发布了一个漂亮的应用程序,名为Google Featured Photos 。

You may be wondering why my title says “wallpaper” but then links to a “Screen Saver” app. Well, there’s the little trick. On a Mac, any screen saver can be made to run as a wallpaper with just one line of code.

您可能想知道为什么我的标题为“墙纸”,然后链接到“屏幕保护程序”应用程序。 好吧,这里有个小把戏。 在Mac上,只需一行代码即可使任何屏幕保护程序都可以作为墙纸运行。

First, you have to download and install the Google Featured Photos Screen Saver. Next, go to System PreferencesDesktop & Screen Saver and set the Google Featured Photos as the active screen saver. Now it’s time to run the magic code.

首先,您必须下载并安装Google特色照片屏幕保护程序 。 接下来,转到系统偏好设置桌面和屏幕保护程序,然后将Google特色照片设置为活动的屏幕保护程序。 现在该运行魔术代码了。

编码时间! (Coding Time!)

Fire up Terminal and paste the below line of code. It will set your screen saver as your wallpaper.

启动终端并粘贴以下代码行。 它将您的屏幕保护程序设置为墙纸。

/System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -background &

编辑:苹果公司决定在High Sierra进行一些重组。 (EDIT: Apple decided to restructure a bit in High Sierra.)

If you are using High Sierra (or later), the ScreenSaverEngine.app has been moved to a different location. Use the code below instead of the one above.

如果您使用的是High Sierra(或更高版本),则ScreenSaverEngine.app已移至其他位置。 使用下面的代码,而不是上面的代码。

/System/Library/CoreServices/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -background &

Just replace all occurrences of Frameworks/ScreenSaver.framework/Resources with CoreServices and you will be good to go!

只需将所有出现的Frameworks/ScreenSaver.framework/Resources替换为CoreServices ,您就会很高兴!

Cool, right?

酷吧?

The problem with running just that line of code is that if you close the Terminal window — or if your Mac goes to sleep — the screen saver closes and your wallpaper goes back to whatever it was by default. To handle this, we need to go a bit deeper.

仅运行该行代码的问题是,如果关闭“终端”窗口,或者Mac进入睡眠状态,则屏幕保护程序将关闭,并且墙纸将恢复为默认值。 为了解决这个问题,我们需要更深入一些。

To detect when the Mac sleeps and wakes up, we need a small piece of software called “Sleepwatcher.” You can download it here. Just open the file and your Mac will extract the downloaded file (sometimes it might have to be extracted twice). After extracting, you’ll get a “sleepwatcher_2.2” folder. Just move this folder to Desktop and run the following lines of code in the Terminal.

为了检测Mac何时睡眠和唤醒,我们需要一小块名为“ Sleepwatcher”的软件。 您可以在此处下载。 只需打开文件,您的Mac就会解压缩下载的文件(有时可能需要解压缩两次)。 解压缩后,您将获得一个“ sleepwatcher_2.2”文件夹。 只需将此文件夹移动到桌面,然后在终端中运行以下代码行即可。

sudo mkdir -p /usr/local/sbin /usr/local/share/man/man8

You might need to enter your password after pasting this line. Next, run:

粘贴此行后,您可能需要输入密码。 接下来,运行:

sudo cp ~/Desktop/sleepwatcher_2.2/sleepwatcher /usr/local/sbin

Then run:

然后运行:

sudo cp ~/Desktop/sleepwatcher_2.2/sleepwatcher.8 /usr/local/share/man/man8

Awesome! You have successfully installed Sleepwatcher.

太棒了! 您已经成功安装了Sleepwatcher。

Now let’s add the lines of code needed to make Sleepwatcher run the screen saver when your Mac wakes up, and kill the screen saver when your Mac goes to sleep.

现在,让我们添加必要的代码行,以使Sleepwatcher在Mac唤醒时运行屏幕保护程序,并在Mac进入睡眠状态时终止屏幕保护程序。

Sleepwatcher searches for and runs two files, .sleep when the Mac sleeps, and .wakeup when the Mac wakes up. We just need to create these 2 files in the user’s Home Directory.

对于Sleepwatcher搜索并运行两个文件, .sleep时的Mac睡觉,和.wakeup当MAC醒来。 我们只需要在用户的主目录中创建这两个文件。

In the Terminal, type nano ~/.wakeup then paste the below code.

在终端中,键入nano ~/.wakeup然后粘贴以下代码。

#!/bin/bashosascript -e 'do shell script "/System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -background & EOF"'

Now press Control + X to exit. When it asks if you want to save the file, press Y and then press the enter key to confirm the file name. This will create the .wakeup file. Now to create the .sleep file.

现在按Control + X退出。 当询问您是否要保存文件时,请按Y ,然后按Enter键以确认文件名。 这将创建.wakeup文件。 现在创建.sleep文件。

Just like above, type nano ~/.sleep and paste the below code.

与上面一样,键入nano ~/.sleep并粘贴以下代码。

#!/bin/bash
osascript -e 'do shell script "kill `ps -ax | grep [S]creenSaver | cut -c1-6` EOF"'

Again, press Control + X to exit, Y to save, and then the enter key to confirm the file name. Now the .sleep file will be created.

再次,按Control + X退出, Y保存,然后按Enter键确认文件名。 现在,将创建.sleep文件。

In Terminal, run the below line of code.

在终端中,运行下面的代码行。

chmod 700 ~/.sleep ~/.wakeup

It changes the permissions for the newly created files so that it can be run by Sleepwatcher.

它更改了新创建文件的权限,以便可以由Sleepwatcher运行。

Now that you’ve created the scripts, you just need to add Sleepwatcher to launchd so that it can start when the system starts, then continue to run in the background. Paste the following code code into your Terminal.

现在,您已经创建了脚本,只需要添加Sleepwatcher以launchd它,以便它可以在系统启动时启动,然后继续在后台运行。 将以下代码粘贴到终端中。

cp ~/Desktop/sleepwatcher_2.2/config/de.bernhard-baehr.sleepwatcher-20compatibility-localuser.plist ~/Library/LaunchAgents

This will copy the Sleepwatcher property list file so that it can be added to launchd. Now just paste the code below into Terminal to add Sleepwatcher to launchd.

这将复制Sleepwatcher属性列表文件,以便可以将其添加到launchd 。 现在,只需将下面的代码粘贴到Terminal中即可将Sleepwatcher添加到launchd

launchctl load ~/Library/LaunchAgents/de.bernhard-baehr.sleepwatcher-20compatibility-localuser.plist

Awesome! You can now restart your Mac and the launchd will run the Sleepwatcher scripts at the startup. Just put your Mac to sleep and wake it up. Then you’ll be welcomed with a beautiful wallpaper.

太棒了! 现在,您可以重新启动Mac,启动的Mac将在launchd时运行Sleepwatcher脚本。 只需将Mac睡眠并唤醒它即可。 然后,您会得到美丽的墙纸的欢迎。

If you want to uninstall everything and go back to default, follow the link below.

如果您想卸载所有内容并恢复默认设置,请点击以下链接。

To uninstall, run the following lines in Terminal one by one.After running these, you can uninstall the Google Screen Saver and restart your Mac. It should be removed. Let me know…medium.com

要卸载,请在终端一一运行以下行。 运行这些文件后,您可以卸载Google屏幕保护程序并重新启动Mac。 应该将其删除。 让我知道… medium.com

I hope you enjoyed this short tutorial, and enjoy these beautiful wallpaper photos. If you liked this, hit the ❤️ and stay tuned for more.

我希望您喜欢这个简短的教程,并喜欢这些美丽的壁纸照片。 如果您喜欢这个,请打❤️并继续关注更多内容。

翻译自: https://www.freecodecamp.org/news/this-is-the-wallpaper-your-mac-truly-deserves-with-a-bit-of-coding-f3149bbeb51/


http://www.ppmy.cn/news/246590.html

相关文章

Python爬虫应用实战案例-xpath正则表达式使用方法,爬取精美壁纸

使用XPath XPath,全称XML Path Language,即XML路径语言,它是在XML语言中查找信息的语言。它最初是用来搜寻XML文档的,但是它同样适用于HTML文档的搜索。 在上一篇文章中讲述了正则表达式的使用方法,正则表达式的难度还是比较大的,如果不花足够多的时间去做的话还是比较…

Python爬虫爬取-爬取某个网页的精美壁纸

前言:学了python爬虫,那必须搞点好康的! 先导入需要用到的库 import requests from bs4 import BeautifulSoup import time 1.针对图片网,先去源代码里面,找它的网址。 我是用的wallhaven网站的网址 然后得到了一…

vs code设置精美壁纸(已成功)

啊!我先展示一下效果嗷!!! 图片是在另外一个博客找的,当然在知乎上搜索壁纸有一大堆嗷! 小伙伴快来设置! emmm,没有原来的图片了,只能让你们看一下带着我加的文字的图片对比一下&am…

python唯美壁纸_营造一个好的编码心情-python抓取mac精美壁纸

如图,一个好的工作环境,可以让心情好不少 抓取的是爱壁纸的资源,它们最多只提供20页一个类别,但是一页有60张。 总共有11个类别,就是有20x60x11张。我这里只筛选了2种类别,看你需要了。 话不多说&#xff0…

如何利用 Python 爬取 LOL 高清精美壁纸?

作者 | 阿拉斯加 来源 | 杰哥的IT之旅 一、背景介绍 随着移动端的普及出现了很多的移动 APP,应用软件也随之流行起来。最近看到英雄联盟的手游上线了,感觉还行,PC 端英雄联盟可谓是爆火的游戏,不知道移动端的英雄联盟前途如何&…

如何导出Windows聚焦的精美壁纸

如何导出Windows聚焦的精美壁纸 文章目录 如何导出Windows聚焦的精美壁纸1、什么是windows聚焦2、导出windows聚焦壁纸 1、什么是windows聚焦 你可以把「Windows 聚焦」这个功能理解为微软为 Windows 10 内置的「锁屏壁纸自动换」功能,开启这个功能后 Windows 10 会…

python 日历壁纸_Excel+Python=精美壁纸日历 任意DIY

广东的太阳还是那么大,隔着玻璃都能感受到热浪。 明明前不久才立夏(明明已经过去三个月!!) 时间跑,日程赶。 昨日又迎来了立秋,正在放暑假的童靴是不是有点忘记时间了呢~ 什么?真的忘记了?没关系,今日小编为…

记一次binlog恢复Mysql某张表数据的过程

1、备份数据库,非常重要 2、要用户不能操作(如果不能停止,可以新建一个库,所有的binlog执行操作在新库执行)。 3、登录服务器; 4、获取Mysql数据路径 cat /etc/my.cnf.d/mysql-server.cnf5、进入当前目录…