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 c5869b7
Show file tree
Hide file tree
Showing 7 changed files with 479 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/internet_detector.vm/internet_detector.vm.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?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" />
</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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit c5869b7

Please sign in to comment.