Skip to content

Commit

Permalink
Add internet detector utility
Browse files Browse the repository at this point in the history
Co-authored-by: Ana Martinez Gomez <[email protected]>
  • Loading branch information
emtuls and Ana06 committed Aug 29, 2024
1 parent 5efa360 commit 2ad703a
Show file tree
Hide file tree
Showing 8 changed files with 829 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/internet_detector.vm/internet_detector.vm.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
<metadata>
<id>internet_detector.vm</id>
<version>1.0.0</version>
<authors>Elliot Chernofsky and Ana Martinez Gomez</authors>
<description>Tool that changes the background and a taskbar icon if it detects internet connectivity</description>
<dependencies>
<dependency id="common.vm" version="0.0.0.20240821" />
<dependency id="libraries.python3.vm" version="0.0.0.20240726" />
<dependency id="fakenet-ng.vm" version="3.2.0.20240425" />
</dependencies>
</metadata>
</package>
30 changes: 30 additions & 0 deletions packages/internet_detector.vm/tools/chocolateyinstall.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
$ErrorActionPreference = 'Stop'
Import-Module vm.common -Force -DisableNameChecking

$toolName = 'internet_detector'
$category = 'Utilities'

# Install dependency for windows api
VM-Pip-Install "pywin32"

# Create tool directory
$toolDir = Join-Path ${Env:RAW_TOOLS_DIR} $toolName
New-Item -Path $toolDir -ItemType Directory -Force -ea 0
VM-Assert-Path $toolDir

$packageToolDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"

# Move images to %VM_COMMON_DIR% directory
$imagesPath = Join-Path $packageToolDir "Images"
Move-Item "$imagesPath\*" ${Env:VM_COMMON_DIR} -Force

# Get path to pythonw for executing Python without terminal popup
$executablePath = (Get-Command pythonw).Source
$filePath = Join-Path $packageToolDir "$toolName.pyw"

VM-Install-Shortcut $toolName $category $executablePath -arguments $filePath

# Create scheduled task for tool to run every 2 minutes.
$action = New-ScheduledTaskAction -Execute $executablePath -Argument "$filePath"
$trigger = New-ScheduledTaskTrigger -Once -At (Get-Date) -RepetitionInterval (New-TimeSpan -Minutes 2)
Register-ScheduledTask -Action $action -Trigger $trigger -TaskName 'Internet Detector' -Force
8 changes: 8 additions & 0 deletions packages/internet_detector.vm/tools/chocolateyuninstall.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
$ErrorActionPreference = 'Continue'
Import-Module vm.common -Force -DisableNameChecking

$toolName = 'internet_detector'
$category = 'Utilities'

VM-Uninstall $toolName $category
Unregister-ScheduledTask -TaskName 'Internet Detector' -Confirm:$false
Loading

0 comments on commit 2ad703a

Please sign in to comment.