Is there any way to write a screensaver for macOS using Python Pygame?

I want to be able to write a cross-platform screensaver that works on both Windows and macOS using the Pygame 2D graphics library in Python. On Windows, this is super easy - you just write your program with three possible command line arguments: /p for preview mode, /c for the configuration dialog mode, and /s for the actual full-screen screensaver mode. Then you just use pyinstaller to build an .exe file and rename the extension to .scr, and you're good to go. However, it seems that making a screensaver on macOS is a pretty convoluted process, and there was stuff about specific Objective-C functions that you had to write, and I didn't really understand the documentation. Could you please tell me if there is any way to simply get my Python Pygame program to build as a proper .saver file? Thanks!

Answered by DTS Engineer in 810228022
However, it seems that making a screensaver on macOS is a pretty convoluted process

IMO that’s a fair statement )-:

I think it’s possible to write a screen saver in Python, but it’s not practical. You’d have to write some Objective-C code to boot the Python runtime and then use PyObjC to interface with the screen saver subsystem. By the time you do all that, it’s likely you’d have to spent more time than it would take to just rewrite your code in Swift.

The central issue here is that the screen saver architecture is based on the old-school in-memory plug-in architecture, and that radically complicates how it interacts with third-party language runtimes. In many cases Apple has deprecated this old style of plug-in in favour of technology called app extensions. If we supported appex screen savers then building a screen saver in Python would be more feasible.

If you’d like to see such support added in the future, I encourage you to file an enhancement request for us to support appex screen savers. Please post your bug number, just for the record.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

However, it seems that making a screensaver on macOS is a pretty convoluted process

IMO that’s a fair statement )-:

I think it’s possible to write a screen saver in Python, but it’s not practical. You’d have to write some Objective-C code to boot the Python runtime and then use PyObjC to interface with the screen saver subsystem. By the time you do all that, it’s likely you’d have to spent more time than it would take to just rewrite your code in Swift.

The central issue here is that the screen saver architecture is based on the old-school in-memory plug-in architecture, and that radically complicates how it interacts with third-party language runtimes. In many cases Apple has deprecated this old style of plug-in in favour of technology called app extensions. If we supported appex screen savers then building a screen saver in Python would be more feasible.

If you’d like to see such support added in the future, I encourage you to file an enhancement request for us to support appex screen savers. Please post your bug number, just for the record.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Is there any way to write a screensaver for macOS using Python Pygame?
 
 
Q