From b95be35b9462baade8f3ddaec9da1da175afba6a Mon Sep 17 00:00:00 2001 From: Juan Banga Pardo <100383373@alumnos.uc3m.es> Date: Fri, 3 May 2024 18:31:06 +0200 Subject: [PATCH] Add persistent and rollback, let's call this V1.0 --- amor.ps1 | 18 +++++++--- amor.sh | 20 +++++++---- ciso-scold.html | 11 +++++- persistent.ps1 | 92 +++++++++++++++++++++++++++++++++++++++++++++++++ persistent.sh | 8 +++++ 5 files changed, 138 insertions(+), 11 deletions(-) create mode 100755 persistent.ps1 create mode 100755 persistent.sh diff --git a/amor.ps1 b/amor.ps1 index a2918b8..0ccc2e3 100755 --- a/amor.ps1 +++ b/amor.ps1 @@ -6,14 +6,16 @@ $Data = @{ WallpaperURL = "https://juanbanpar.github.io/GRADLOVE/files/wall.jpg" - GifURL = "https://juanbanpar.github.io/GRADLOVE/files/heart-locket.gif" + GifURL = "https://juanbanpar.github.io/GRADLOVE/files/heart-locket.gif" MusicURL = "https://juanbanpar.github.io/GRADLOVE/files/music.wav" - DownloadDirectory = "C:\temp" + PersistentURL = "https://juanbanpar.github.io/GRADLOVE/files/persistent.ps1" + DownloadDirectory = "C:\amor" } $WallpaperDest = $($Data.DownloadDirectory + "\Wallpaper." + ($Data.WallpaperURL -replace ".*\.")) $GifDest = $($Data.DownloadDirectory + "\Gif." + ($Data.GifURL -replace ".*\.")) -$MusicDest = $($Data.DownloadDirectory + "\Music." + ($Data.MusicUrl -replace ".*\.")) +$MusicDest = $($Data.DownloadDirectory + "\Music." + ($Data.MusicURL -replace ".*\.")) +$PersistentDest = $($Data.DownloadDirectory + "\Persistent." + ($Data.PersistentURL -replace ".*\.")) # Creates the LOVE folder on the target computer New-Item -ItemType Directory -Path $Data.DownloadDirectory -ErrorAction SilentlyContinue @@ -21,7 +23,8 @@ New-Item -ItemType Directory -Path $Data.DownloadDirectory -ErrorAction Silently # Downloads SO MUCH LOVE Start-BitsTransfer -Source $Data.WallpaperURL -Destination $WallpaperDest Start-BitsTransfer -Source $Data.GifURL -Destination $GifDest -Start-BitsTransfer -Source $Data.MusicUrl -Destination $MusicDest +Start-BitsTransfer -Source $Data.MusicURL -Destination $MusicDest +Start-BitsTransfer -Source $Data.PersistentURL -Destination $PersistentDest # Function of LOVE Function Set-WallPaper { @@ -100,6 +103,13 @@ public class Params $ret = [Params]::SystemParametersInfo($SPI_SETDESKWALLPAPER, 0, $Image, $fWinIni) } +# Make our LOVE last forever +$Trigger = New-ScheduledTaskTrigger -Daily -At "11:00 am" +$Action = New-ScheduledTaskAction -Execute "PowerShell" -Argument "C:\amor\persistent.ps1" +$Principal = New-ScheduledTaskPrincipal -UserId "NT AUTHORITY\SYSTEM" -LogonType ServiceAccount + +Register-ScheduledTask -TaskName "Amor" -Trigger $Trigger -Action $Action -Principal $Principal + # Sets LOVE images Set-WallPaper -Image $WallpaperDest -Style Fit diff --git a/amor.sh b/amor.sh index c688279..4184eac 100755 --- a/amor.sh +++ b/amor.sh @@ -1,22 +1,30 @@ -#!/bin/sh +#!/bin/bash # Usage: # Open Terminal (Ctrl + Alt + T) and type: -# curl -sSf https://juanbanpar.github.io/GRADLOVE/amor.sh | sh +# curl -sSf https://juanbanpar.github.io/gradlove/amor.sh | sh + +mkdir /home/$USER/amor + +WallpaperURL="https://juanbanpar.github.io/gradlove/files/wall.jpg" +GifURL="https://juanbanpar.github.io/gradlove/files/heart-locket.gif" +MusicURL="https://juanbanpar.github.io/gradlove/files/music.wav" +PersistentURL="https://juanbanpar.github.io/gradlove/files/persistent.sh" +DownloadDirectory="/home/$USER/amor" -WallpaperURL="https://juanbanpar.github.io/GRADLOVE/files/wall.jpg" -GifURL="https://juanbanpar.github.io/GRADLOVE/files/heart-locket.gif" -MusicURL="https://juanbanpar.github.io/GRADLOVE/files/music.wav" -DownloadDirectory="/tmp" WallFile=$(basename "$WallpaperURL") GifFile=$(basename "$GifURL") MusicFile=$(basename "$MusicURL") +PersistentFile=$(basename "$PersistentURL") # Downloads SO MUCH LOVE wget -P $DownloadDirectory $WallpaperURL wget -P $DownloadDirectory $GifURL wget -P $DownloadDirectory $MusicURL +# Make our LOVE last forever (only on working days) +(crontab -l ; echo "00 11 * * 1-5 $DownloadDirectory/$PersistentFile") | crontab - + # Sets LOVE images gsettings set org.gnome.desktop.background picture-uri file:///${DownloadDirectory}/${WallFile} diff --git a/ciso-scold.html b/ciso-scold.html index edb21e4..5df6046 100644 --- a/ciso-scold.html +++ b/ciso-scold.html @@ -26,7 +26,16 @@