-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
246 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<package> | ||
<metadata> | ||
<id>MouseTrap</id> | ||
<version>0.0.0</version> | ||
<title>MouseTrap DPI aware mouse move across screens</title> | ||
<tags>multiscreen mouse-pointer screen-scale dpi-awareness dpi-scaling cursor-moves cursor-position</tags> | ||
<summary>A small tool to map the cursor between monitors with different DPIs</summary> | ||
<description> | ||
# MouseTrap | ||
|
||
MouseTrap is a small tool to map the cursor between multiple monitors with | ||
different resolutions and scaling settings. | ||
|
||
## Min requirements | ||
|
||
For this tool to function correctly you should have: | ||
|
||
- At least **Windows 10 Creators update** (Build 1703) | ||
- [**.NET 8 Runtime**](https://dotnet.microsoft.com/en-us/download/dotnet/8.0) (in most cases it will notify you if the runtime is missing) | ||
|
||
## Usage and Configuration | ||
|
||
Here you can find the [documentation](https://github.com/r-Larch/MouseTrap/blob/master/README.md). | ||
</description> | ||
<authors>René Larch</authors> | ||
<owners>René Larch</owners> | ||
<copyright>Copyright 2023 René Larch</copyright> | ||
<licenseUrl>https://github.com/r-Larch/MouseTrap/blob/master/LICENSE.txt</licenseUrl> | ||
<projectUrl>https://github.com/r-Larch/MouseTrap</projectUrl> | ||
<projectSourceUrl>https://github.com/r-Larch/MouseTrap</projectSourceUrl> | ||
<bugTrackerUrl>https://github.com/r-Larch/MouseTrap/issues</bugTrackerUrl> | ||
<docsUrl>https://github.com/r-Larch/MouseTrap/blob/master/README.md</docsUrl> | ||
<iconUrl>https://raw.githubusercontent.com/r-Larch/MouseTrap/master/MouseTrap/AppIcon.png</iconUrl> | ||
<requireLicenseAcceptance>false</requireLicenseAcceptance> | ||
<releaseNotes>...</releaseNotes> | ||
</metadata> | ||
<files> | ||
<file src="..\..\LICENSE.txt" /> | ||
<file src="..\..\VERIFICATION.txt" /> | ||
<file src="*.ps1" target="tools" /> | ||
</files> | ||
</package> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
|
||
param ( | ||
[string] $nuspec, | ||
[string] $zip, | ||
[string] $version, | ||
[switch] $debug = $false | ||
) | ||
|
||
|
||
function Main() { | ||
$dir = Split-Path -parent $nuspec; | ||
|
||
$choco = @{ | ||
version = $version | ||
nuspec = $nuspec | ||
dir = $dir | ||
installScript = [System.IO.Path]::Combine($dir, "chocolateyinstall.ps1") | ||
uninstallScript = [System.IO.Path]::Combine($dir, "chocolateyuninstall.ps1") | ||
} | ||
|
||
$hash = (Get-FileHash -Algorithm SHA256 -Path $zip).Hash.ToUpper() | ||
ChocoUpdateScript $choco $version $hash | ||
|
||
Push-Location $dir | ||
$previousTag = [Git]::GetVersionTags() | where { $_ -ne "v$version" } | sort -Descending | select -first 2 | select -last 1; | ||
$history = [Git]::GetHistorySince($previousTag); | ||
Pop-Location | ||
|
||
ChocoUpdateNuspec $choco $history "https://api.github.com/repos/r-Larch/MouseTrap" | ||
|
||
ChocoPublish $choco $debug | ||
|
||
} | ||
|
||
|
||
function ChocoUpdateScript([object] $choco, [string] $version, [string] $hash) { | ||
$script = Get-Content $choco.installScript -Encoding UTF8 -Raw | ||
$script = $script.replace('<version>', $version) | ||
$script = $script.replace('<hash>', $hash) | ||
$script | Set-Content $choco.installScript -Force -Encoding UTF8 | ||
} | ||
|
||
|
||
function ChocoUpdateNuspec([object] $choco, [string] $history, [string] $githubRepoApi) { | ||
$repo = $(Invoke-Webrequest $githubRepoApi).Content | ConvertFrom-Json; | ||
$topics = $(Invoke-Webrequest $githubRepoApi/topics -Headers @{'Accept'='application/vnd.github.mercy-preview+json'}).Content | ConvertFrom-Json | ||
$xml = [xml] $(gc -Path $choco.nuspec -Encoding UTF8); | ||
$xml.package.metadata.version = [Regex]::Replace($version, '^v', ''); | ||
$xml.package.metadata.summary = $repo.description; | ||
$xml.package.metadata.tags = [string]::Join(" ", $topics.names); | ||
$xml.package.metadata.copyright = "Copyright $([DateTime]::Now.Year) René Larch"; | ||
$xml.package.metadata.releaseNotes = [string]::Join("`r`n", $history); | ||
$xml.Save($choco.nuspec); | ||
} | ||
|
||
|
||
function ChocoPublish([object] $choco, [bool] $debug = $false) { | ||
|
||
$chocoCommand = "choco"; | ||
if (!$(Get-Command $chocoCommand -errorAction SilentlyContinue)) { | ||
Write-Host "Install chocolatey"; | ||
iwr https://chocolatey.org/install.ps1 -UseBasicParsing | iex | ||
$env:Path += ";%ALLUSERSPROFILE%\chocolatey\bin"; | ||
} | ||
|
||
# create the nuspec package | ||
& $chocoCommand pack $choco.nuspec --out $choco.dir | ||
|
||
$ver = [Regex]::Replace($choco.version, "^v(.*)", '$1'); | ||
$nupkgName = $choco.nuspec.replace('.nuspec', ".$($ver).nupkg"); | ||
|
||
if (!$debug) { | ||
# if token is given, we will publish the package to Chocolatey here | ||
if ($env:CHOCO_TOKEN) { | ||
& $chocoCommand apiKey -k $env:CHOCO_TOKEN -source https://push.chocolatey.org/ | ||
& $chocoCommand push $nupkgName -source https://push.chocolatey.org/ | ||
} else { | ||
Write-Warning "Chocolatey token was not set. Publication skipped." | ||
} | ||
} else { | ||
# For development/debugging purposes | ||
$script = Get-Content $choco.installScript -Encoding UTF8 -Raw | ||
Write-Host "=============== Choco Install Script ===============" | ||
Write-Host $script | ||
Write-Host "====================================================" | ||
|
||
$script = Get-Content $choco.uninstallScript -Encoding UTF8 -Raw | ||
Write-Host "============== Choco Uninstall Script ==============" | ||
Write-Host $script | ||
Write-Host "====================================================" | ||
|
||
$nuspec = Get-Content $choco.nuspec -Encoding UTF8 -Raw | ||
Write-Host "================== Nuspec ===========================" | ||
Write-Host $nuspec | ||
Write-Host "====================================================" | ||
|
||
Write-Host "$chocoCommand pack " $choco.nuspec | ||
Write-Host "$chocoCommand apiKey -k $env:CHOCO_TOKEN -source https://push.chocolatey.org/" | ||
Write-Host "$chocoCommand push $nupkgName" | ||
} | ||
} | ||
|
||
|
||
class Git { | ||
static [string[]] GetTags() { | ||
return $(git tag --list).Split("`n"); | ||
} | ||
static [string[]] GetVersionTags() { | ||
return [Git]::GetTags() | Select-String -pattern "v[\d+\.]+(-(alpha|beta))?"; | ||
} | ||
static [string[]] GetHistorySince([string] $tagOrHash) { | ||
if ([string]::IsNullOrEmpty($tagOrHash)){ | ||
return $(git log --oneline); | ||
} | ||
return $(git log "$tagOrHash..HEAD" --oneline); | ||
} | ||
} | ||
|
||
|
||
######################### | ||
# run main # | ||
######################### | ||
|
||
Main; | ||
|
||
######################### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
$ErrorActionPreference = 'Stop'; | ||
|
||
$version = '<version>' | ||
$hash = '<hash>' | ||
$versionNumber = [Regex]::Replace($version, 'v(\d+\.\d+\.\d+).*', '$1') | ||
|
||
$packageName = 'mousetrap' | ||
$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)" | ||
$url = "https://github.com/r-Larch/MouseTrap/releases/download/$version/MouseTrap-$versionNumber.zip" | ||
|
||
|
||
$packageArgs = @{ | ||
packageName = $packageName | ||
unzipLocation = $toolsDir | ||
url = $url | ||
checksum = $hash | ||
checksumType = 'SHA256' | ||
} | ||
|
||
Install-ChocolateyZipPackage @packageArgs | ||
|
||
|
||
$mousetrap = "$toolsDir\$packageName"; | ||
|
||
# install | ||
& $mousetrap "-i"; | ||
if (-not $?) { | ||
throw "error while install"; | ||
} | ||
|
||
# start the app minimized as tray icon in taskbar. | ||
& $mousetrap |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
$ErrorActionPreference = 'Stop'; | ||
|
||
$packageName= 'mousetrap.exe' | ||
$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)" | ||
|
||
$mousetrap = "$toolsDir\$packageName"; | ||
|
||
# uninstall | ||
& $mousetrap "-u"; | ||
if (-not $?) { | ||
throw "error while uninstall"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters