-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdailyWallpaper.ps1
42 lines (33 loc) · 1.12 KB
/
dailyWallpaper.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
$param=$args[0]
if ($param -eq 'gradient') {
$feed = 'https://botsin.space/users/gradientbot.rss'
} elseif ($param -eq 'stripe') {
$feed = 'https://botsin.space/users/stripey.rss'
} else {
Write-Warning 'invalid parameter'
}
## Wallpaper Directory
$folder = "$env:userprofile"
## The Magic
$image = "daily.png"
$wallpaper = ($folder + "\" + $image)
[xml]$feed = Invoke-WebRequest -Uri $feed
$post = $feed.rss.channel.item[0]
$url = $post.description.Split() | select-string ".png"
$url = $url[0]
$url = $url -replace 'href=','' -replace '"',''
Invoke-WebRequest -Uri $url -OutFile $folder\$image
$setWallpaper = @'
using System.Runtime.InteropServices;
namespace Win32{
public class Wallpaper{
[DllImport("user32.dll", CharSet=CharSet.Auto)]
static extern int SystemParametersInfo (int uAction , int uParam , string lpvParam , int fuWinIni) ;
public static void SetWallpaper(string thePath){
SystemParametersInfo(20,0,thePath,3);
}
}
}
'@
add-type $setWallpaper
[Win32.Wallpaper]::SetWallpaper($wallpaper)