Changing background picture

boring

Are you tired of constantly seeing the same white (or gray) background in Pharo? I know I am. Thankfully it is very easy to change.

Just run the following (provide a path to your own image):

1
2
3
4
World
backgroundImage: (ImageReadWriter formFromFileNamed:
FileLocator home asFileReference / 'Images/wp/2016/wallhaven-205249.jpg')
layout: #scaled.
much better

I would recommend using darker-themed background for Dark theme and vice versa, unless you really love hurting your eyes.

Using Settings Browser

All the settings can be configured through the Settings Browser in Appearance > Desktop section and persisted using Store/Load Settings.

settings.png

Using startup script

If you are lazy, you can change it in startup script and have it available every time you start a new image.

save in .config/pharo/5.0/backgroundImage.st
1
2
3
4
5
6
7
8
9
10
StartupPreferencesLoader default executeAtomicItems: {
StartupAction
name: 'change background image on first launch'
code: [
World
backgroundImage: (ImageReadWriter formFromFileNamed: 'path/to/image.jpg')
layout: #scaled.
]
runOnce: true.
}

Daily background

And what if you want a different background every day? Some websites such as Bing offers daily new images, so all you have to do is find an appropriate api (https://www.bing.com/HPImageArchive.aspx?format=js&n=1 returns a JSON response for this day), and process it. All the necessary tools (Zinc, JSON/STON) are already available in Pharo 5.0 without the need to install anything else.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
StartupPreferencesLoader default executeAtomicItems: {
StartupAction
name: 'change background image on first launch'
code: [
|urlbase image|
urlbase := ((((STON fromString: ((ZnEasy
get: 'https://www.bing.com/HPImageArchive.aspx?format=js&n=1') contents)) at: #images) first) at: #urlbase).
image := ZnEasy getJpeg: 'https://www.bing.com', urlbase, '_1920x1080.jpg'.
World
backgroundImage: image
layout: #scaled.
]
runOnce: true.
}
daily image

Background + Theme

Final note: keep in mind that when you switch theme it will reset the background, so if you are automatically setting your background from a startup script, it must be executed before the background change one.

More settings

You can always switch back to a plain color

1
PolymorphSystemSettings desktopColor: Color gray.

Likewise if you don’t want to see the Pharo logo in top left corner, you can hide it or change it.

1
2
PolymorphSystemSettings showDesktopLogo: false. "show or hide the logo"
PolymorphSystemSettings desktopLogoFileName: '/tmp/moose-icon.png' "change the logo"