1 | // Linux version is for Gnome only |
2 | |
3 | static void wallpaper(S imageID) {
|
4 | wallpaper(loadImageAsFile(imageID), imageID); |
5 | } |
6 | |
7 | // uses mode "fit to screen" |
8 | static void wallpaper(File img1, S description) {
|
9 | print("Setting wallpaper to: " + description + " (" + img1.getName() + ")");
|
10 | |
11 | if (isLinux()) {
|
12 | print("Be sure to apt install pcmanfm!");
|
13 | S cmd = "pcmanfm " + bashQuote("--set-wallpaper=" + img1)
|
14 | + " --wallpaper-mode=fit"; |
15 | print(backtick(cmd)); |
16 | } else if (isWindows()) {
|
17 | File img = prepareProgramFile(#1004273, img1.getName() + ".bmp"); |
18 | saveBMP(loadImage2(img1), img); |
19 | assertTrue(img.getAbsolutePath(), img.isFile()); |
20 | |
21 | S cmd = "reg add \"HKEY_CURRENT_USER\\Control Panel\\Desktop\" /v Wallpaper /t REG_SZ /d " + bashQuote(img) + " /f"; |
22 | backtick(cmd); |
23 | |
24 | // Set to "fit" (WallpaperStyle=6, TileWallpaper=0) doesn't seem to work |
25 | // So set to "center" |
26 | cmd = "reg add \"HKEY_CURRENT_USER\\Control Panel\\Desktop\" /v WallpaperStyle /t REG_SZ /d " + 0 + " /f"; |
27 | backtick(cmd); |
28 | cmd = "reg add \"HKEY_CURRENT_USER\\Control Panel\\Desktop\" /v TileWallpaper /t REG_SZ /d " + 0 + " /f"; |
29 | backtick(cmd); |
30 | |
31 | cmd = "RUNDLL32.EXE user32.dll, UpdatePerUserSystemParameters"; |
32 | backtick(cmd); |
33 | } else |
34 | fail("Don't know how to set wallpaper for your OS");
|
35 | |
36 | print("Wallpaper set (hopefully)!");
|
37 | } |
Began life as a copy of #1004272
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1004273 |
| Snippet name: | wallpaper - set desktop wallpaper to an image (Linux/Windows) |
| Eternal ID of this version: | #1004273/11 |
| Text MD5: | 33eb3f1c54d29001738d2a86ef14b014 |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2022-09-12 21:59:16 |
| Source code size: | 1405 bytes / 37 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 883 / 1063 |
| Version history: | 10 change(s) |
| Referenced in: | [show references] |