Log inRegister

Desktop and browser backgrounds

I created two monthly car calendars:
  • 2021WerkstattKulturKalender
  • 2021ModernClassicsCalendar
I use them on some desktop devices and in some browsers. In order to automate the monthly switch, I have created a cron job which changes the picture on the first day of the month using the script !NewMonth.sh:

export calpic=`date +%m`
export here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
cp $here/$calpic.png $here/WERKSTATTkultur.jpg

In the DirectAdmin Web Control Panel of your hosting provider, you can add a cron job here:
  • Advanced Features > Cron Jobs

Change Firefox browser background image

https://support.mozilla.org/en-US/questions/1271362

see here: BrowserExtensions

Scheduled Task 'Background Change Monthly'

PowerShell script:

# Date : 23 April 2021                                                         #
# Version 0.5                                                                  #
# Solution for the wrong resolution for my Surface 3 (1280x853)                #
# Version 0.4                                                                  #
# using the OneDrive env var so I can use the script on multiple devices       #
# Version 0.3                                                                  #
# execute PowerShell scripts from the Task Scheduler                           #
# Version 0.2                                                                  #
# overcome the inconsistent results with UpdatePerUserSystemParameters         #
# different image per screen resolution approach                               #
# Version 0.1                                                                  #

$PTimestamp = Get-Date -Format "dd/MM/yyyy HH:mm:ss"
$PMonth = Get-Date -Format "MM"
$OneDrive = $Env:OneDrive
$ComputerName = $env:computername
$log = '------------ launch BgChangeMonthly.ps1 = ' + $PTimestamp + ' ------------'
echo $log | Out-File $OneDrive\Cars\Wallpapers\CurYear\$ComputerName-BgChangeMonthly.log -encoding ASCII -Append

#Get the screen resolution 
Add-Type -AssemblyName System.Windows.Forms
Add-Type @"
using System;
using System.Runtime.InteropServices;
public class PInvoke {
    [DllImport("user32.dll")] public static extern IntPtr GetDC(IntPtr hwnd);
    [DllImport("gdi32.dll")] public static extern int GetDeviceCaps(IntPtr hdc, int nIndex);
}
"@
$hdc = [PInvoke]::GetDC([IntPtr]::Zero)
$Resolution= "{0}x{1}" -f 
[PInvoke]::GetDeviceCaps($hdc, 118), # width
[PInvoke]::GetDeviceCaps($hdc, 117) # height

# Apply Desktop Wallpaper based on the Screen Resolution
# Full HD on my Dell Studio XPS 1647 
if ($Resolution -eq "1920x1080") {
   #Modify Path to the picture accordingly to reflect your infrastructure
   #$imgPath="$OneDrive\Cars\Wallpapers\CurYear\16-9ancient-tiny\$PMonth.png"
   $imgPath="$OneDrive\Cars\Wallpapers\CurYear\16-9modern-tiny\$PMonth.png"
}
# 1920x1280 on my Surface 3
if ($Resolution -eq "1920x1280") {
   #Modify Path to the picture accordingly to reflect your infrastructure
   #$imgPath="$OneDrive\Cars\Wallpapers\CurYear\3-2modern-tiny\$PMonth.png"
   $imgPath="$OneDrive\Cars\Wallpapers\CurYear\3-2ancient-tiny\$PMonth.png"
}
#TEST
$log = 'Resolution = ' + $Resolution
echo $log | Out-File $OneDrive\Cars\Wallpapers\CurYear\$ComputerName-BgChangeMonthly.log -encoding ASCII -Append
$log = 'imgPath = ' + $ImgPath
echo $log | Out-File $OneDrive\Cars\Wallpapers\CurYear\$ComputerName-BgChangeMonthly.log -encoding ASCII -Append
#Pause

$code = @' 
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 $code 

#Apply the Change on the system 
[Win32.Wallpaper]::SetWallpaper($imgPath)

$PTimestamp = Get-Date -Format "dd/MM/yyyy HH:mm:ss"
$log = '------------ finish BgChangeMonthly.ps1 = ' + $PTimestamp + ' ------------'
echo $log | Out-File $OneDrive\Cars\Wallpapers\CurYear\$ComputerName-BgChangeMonthly.log -encoding ASCII -Append

tags

wallpaper
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback