Compare commits
10 Commits
211f403dbc
...
fca048f237
| Author | SHA1 | Date | |
|---|---|---|---|
| fca048f237 | |||
| 9e172f2501 | |||
| c0f43b4091 | |||
| de1b115a75 | |||
| f7fd54f9ed | |||
| 6335ac7a60 | |||
| 4af32a48e5 | |||
| 19b8ef96f5 | |||
| 7db5d72bbd | |||
| aecaa39609 |
12
.gitignore
vendored
12
.gitignore
vendored
@@ -1,3 +1,10 @@
|
||||
# macOS
|
||||
**/.DS_Store
|
||||
|
||||
# Vim
|
||||
**/*.swp
|
||||
**/*.swo
|
||||
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[codz]
|
||||
@@ -30,7 +37,7 @@ MANIFEST
|
||||
# Usually these files are written by a python script from a template
|
||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||
*.manifest
|
||||
*.spec
|
||||
#*.spec
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
@@ -205,3 +212,6 @@ cython_debug/
|
||||
marimo/_static/
|
||||
marimo/_lsp/
|
||||
__marimo__/
|
||||
.DS_Store
|
||||
SpyderScripts/.DS_Store
|
||||
SpyderScripts/.minimize_all.py.swp
|
||||
|
||||
BIN
FlaskHISLaunchpad/.DS_Store
vendored
BIN
FlaskHISLaunchpad/.DS_Store
vendored
Binary file not shown.
231
SpyderScripts/.gitignore
vendored
Normal file
231
SpyderScripts/.gitignore
vendored
Normal file
@@ -0,0 +1,231 @@
|
||||
# ===================
|
||||
# macOS
|
||||
# ===================
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
#._*
|
||||
|
||||
# Icon must end with two \r
|
||||
Icon
|
||||
|
||||
# Thumbnails
|
||||
._*
|
||||
|
||||
# Files that might appear in the root of a volume
|
||||
.DocumentRevisions-V100
|
||||
.fseventsd
|
||||
.Spotlight-V100
|
||||
.TemporaryItems
|
||||
.Trashes
|
||||
.VolumeIcon.icns
|
||||
.com.apple.timemachine.donotpresent
|
||||
|
||||
# Directories potentially created on remote AFP share
|
||||
.AppleDB
|
||||
.AppleDesktop
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
|
||||
# ===================
|
||||
# Python
|
||||
# ===================
|
||||
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
wheels/
|
||||
share/python-wheels/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
MANIFEST
|
||||
|
||||
# PyInstaller
|
||||
*.manifest
|
||||
#*.spec
|
||||
|
||||
# py2app
|
||||
build/
|
||||
dist/
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.nox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*.cover
|
||||
*.py,cover
|
||||
.hypothesis/
|
||||
.pytest_cache/
|
||||
pytestdebug.log
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
*.pot
|
||||
|
||||
# Scrapy stuff
|
||||
.scrapy
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
|
||||
# PyBuilder
|
||||
.pybuilder/
|
||||
target/
|
||||
|
||||
# Jupyter Notebook
|
||||
.ipynb_checkpoints
|
||||
|
||||
# IPython
|
||||
profile_default/
|
||||
ipython_config.py
|
||||
|
||||
# pyenv
|
||||
.python-version
|
||||
|
||||
# pipenv
|
||||
Pipfile.lock
|
||||
|
||||
# poetry
|
||||
poetry.lock
|
||||
|
||||
# pdm
|
||||
.pdm.toml
|
||||
.pdm-python
|
||||
.pdm-build/
|
||||
|
||||
# PEP 582
|
||||
__pypackages__/
|
||||
|
||||
# Celery stuff
|
||||
celerybeat-schedule
|
||||
celerybeat.pid
|
||||
|
||||
# SageMath parsed files
|
||||
*.sage.py
|
||||
|
||||
# Environments
|
||||
.env
|
||||
.venv
|
||||
env/
|
||||
venv/
|
||||
ENV/
|
||||
env.bak/
|
||||
venv.bak/
|
||||
|
||||
# Spyder project settings
|
||||
.spyderproject
|
||||
.spyproject
|
||||
|
||||
# Rope project settings
|
||||
.ropeproject
|
||||
|
||||
# mkdocs documentation
|
||||
/site
|
||||
|
||||
# mypy
|
||||
.mypy_cache/
|
||||
.dmypy.json
|
||||
dmypy.json
|
||||
|
||||
# Pyre type checker
|
||||
.pyre/
|
||||
|
||||
# pytype static type analyzer
|
||||
.pytype/
|
||||
|
||||
# Cython debug symbols
|
||||
cython_debug/
|
||||
|
||||
# ===================
|
||||
# IDEs and Editors
|
||||
# ===================
|
||||
|
||||
# VS Code
|
||||
.vscode/
|
||||
*.code-workspace
|
||||
|
||||
# PyCharm / JetBrains
|
||||
.idea/
|
||||
*.iml
|
||||
*.iws
|
||||
*.ipr
|
||||
|
||||
# Sublime Text
|
||||
*.sublime-project
|
||||
*.sublime-workspace
|
||||
|
||||
# Vim
|
||||
*.swp
|
||||
*.swo
|
||||
*~
|
||||
.netrwhist
|
||||
|
||||
# Emacs
|
||||
*~
|
||||
\#*\#
|
||||
/.emacs.desktop
|
||||
/.emacs.desktop.lock
|
||||
*.elc
|
||||
auto-save-list
|
||||
tramp
|
||||
.\#*
|
||||
|
||||
# ===================
|
||||
# Project specific
|
||||
# ===================
|
||||
|
||||
# Local configuration
|
||||
*.local
|
||||
config.local.py
|
||||
settings.local.py
|
||||
|
||||
# Secrets
|
||||
*.pem
|
||||
*.key
|
||||
secrets.py
|
||||
secrets.json
|
||||
.secrets
|
||||
|
||||
# Logs
|
||||
*.log
|
||||
logs/
|
||||
|
||||
# Database
|
||||
*.db
|
||||
*.sqlite
|
||||
*.sqlite3
|
||||
|
||||
# Temporary files
|
||||
tmp/
|
||||
temp/
|
||||
*.tmp
|
||||
*.bak
|
||||
265
SpyderScripts/minimize_all.py
Normal file
265
SpyderScripts/minimize_all.py
Normal file
@@ -0,0 +1,265 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Minimize All Windows - Python Version (Fixed)
|
||||
Requires: pip3 install pyobjc-framework-Cocoa pyobjc-framework-Quartz
|
||||
|
||||
This uses native macOS APIs which should be more reliable than AppleScript.
|
||||
"""
|
||||
|
||||
import time
|
||||
from Cocoa import NSWorkspace
|
||||
from Quartz import (
|
||||
CGWindowListCopyWindowInfo,
|
||||
kCGWindowListOptionOnScreenOnly,
|
||||
kCGNullWindowID,
|
||||
kCGWindowListExcludeDesktopElements
|
||||
)
|
||||
import subprocess
|
||||
|
||||
|
||||
def get_apps_with_visible_windows():
|
||||
"""Get set of app names that have actual visible on-screen windows"""
|
||||
window_list = CGWindowListCopyWindowInfo(
|
||||
kCGWindowListOptionOnScreenOnly | kCGWindowListExcludeDesktopElements,
|
||||
kCGNullWindowID
|
||||
)
|
||||
|
||||
apps_with_windows = set()
|
||||
|
||||
for window in window_list:
|
||||
# Get the owning application name
|
||||
owner_name = window.get('kCGWindowOwnerName', '')
|
||||
|
||||
# Check if window is actually visible and has size
|
||||
# Layer 0 = normal windows, skip menu bar items etc.
|
||||
layer = window.get('kCGWindowLayer', 0)
|
||||
bounds = window.get('kCGWindowBounds', {})
|
||||
width = bounds.get('Width', 0)
|
||||
height = bounds.get('Height', 0)
|
||||
|
||||
# Only count windows that are on the normal layer and have reasonable size
|
||||
# (filters out menu bar, dock, status items, etc.)
|
||||
if layer == 0 and width > 50 and height > 50 and owner_name:
|
||||
apps_with_windows.add(owner_name)
|
||||
|
||||
return apps_with_windows
|
||||
|
||||
|
||||
def minimize_window_via_applescript(app_name):
|
||||
"""Use AppleScript to minimize the frontmost window of an app"""
|
||||
script = f'''
|
||||
tell application "{app_name}"
|
||||
activate
|
||||
end tell
|
||||
delay 0.8
|
||||
tell application "System Events"
|
||||
tell process "{app_name}"
|
||||
set frontmost to true
|
||||
delay 0.4
|
||||
keystroke "m" using command down
|
||||
end tell
|
||||
end tell
|
||||
'''
|
||||
try:
|
||||
subprocess.run(['osascript', '-e', script], timeout=5, check=False)
|
||||
return True
|
||||
except Exception as e:
|
||||
print(f"Failed to minimize {app_name}: {e}")
|
||||
return False
|
||||
|
||||
|
||||
# Apps that don't respond to Cmd+M and need special handling
|
||||
# Maps app display name -> process name (as seen by System Events)
|
||||
EXCEPTION_APPS = {
|
||||
'Spyder 6': 'python',
|
||||
'MacVim': 'MacVim',
|
||||
# Add more exception apps here as needed, e.g.:
|
||||
# 'SomeApp': 'some_process_name',
|
||||
}
|
||||
|
||||
|
||||
def minimize_exception_app(app_name, process_name):
|
||||
"""
|
||||
Minimize windows for apps that don't respond to Cmd+M.
|
||||
Uses the AXMinimized accessibility attribute directly.
|
||||
"""
|
||||
script = f'''
|
||||
tell application "System Events"
|
||||
tell process "{process_name}"
|
||||
set windowCount to count of windows
|
||||
if windowCount > 0 then
|
||||
repeat with w in windows
|
||||
try
|
||||
-- Only minimize if not already minimized
|
||||
if value of attribute "AXMinimized" of w is false then
|
||||
set value of attribute "AXMinimized" of w to true
|
||||
end if
|
||||
end try
|
||||
end repeat
|
||||
end if
|
||||
return windowCount
|
||||
end tell
|
||||
end tell
|
||||
'''
|
||||
try:
|
||||
result = subprocess.run(
|
||||
['osascript', '-e', script],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
timeout=10
|
||||
)
|
||||
window_count = result.stdout.strip()
|
||||
print(f"{app_name}: Minimized via AXMinimized (windows: {window_count})")
|
||||
return True
|
||||
except Exception as e:
|
||||
print(f"Failed to minimize {app_name} via AXMinimized: {e}")
|
||||
return False
|
||||
|
||||
|
||||
def minimize_finder_windows():
|
||||
"""Minimize all Finder windows using Finder's native scripting"""
|
||||
# First, get count of non-collapsed Finder windows
|
||||
count_script = '''
|
||||
tell application "Finder"
|
||||
set visibleWindows to (every Finder window whose collapsed is false)
|
||||
return count of visibleWindows
|
||||
end tell
|
||||
'''
|
||||
try:
|
||||
result = subprocess.run(
|
||||
['osascript', '-e', count_script],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
timeout=5
|
||||
)
|
||||
window_count = int(result.stdout.strip()) if result.stdout.strip() else 0
|
||||
|
||||
if window_count == 0:
|
||||
print("Finder: No visible windows to minimize")
|
||||
return
|
||||
|
||||
print(f"Finder: Minimizing {window_count} window(s)")
|
||||
|
||||
# Finder uses "collapsed" not "miniaturized" for minimizing windows
|
||||
minimize_script = '''
|
||||
tell application "Finder"
|
||||
set allWindows to every Finder window
|
||||
repeat with w in allWindows
|
||||
set collapsed of w to true
|
||||
end repeat
|
||||
end tell
|
||||
'''
|
||||
subprocess.run(['osascript', '-e', minimize_script], timeout=10, check=False)
|
||||
|
||||
except Exception as e:
|
||||
print(f"Failed to minimize Finder windows: {e}")
|
||||
|
||||
|
||||
def main():
|
||||
# Apps to skip - these either don't have minimizable windows or cause issues
|
||||
skip_apps = {'SystemUIServer', 'Dock', 'Electron', 'MSTeams', 'nxdock',
|
||||
'Control Center', 'Notification Center', 'Spotlight',
|
||||
# User-specified apps to never minimize
|
||||
'Teams', 'Microsoft Teams', 'Ferdium', 'Messages', 'iMessage',
|
||||
'Grasshopper', 'Outlook', 'Microsoft Outlook', 'Wavebox',
|
||||
'iTerm2'}
|
||||
# 'Claude', 'Copilot', 'GitHub', 'GitHub Desktop',
|
||||
skip_keywords = ['Helper', 'Agent']
|
||||
|
||||
# FIX #1: Get only apps that actually have visible windows on screen
|
||||
apps_with_windows = get_apps_with_visible_windows()
|
||||
print(f"Apps with visible windows: {apps_with_windows}")
|
||||
|
||||
# FIX #2: Handle Finder separately and skip it in main loop
|
||||
# Remove Finder from the set - we'll handle it specially
|
||||
apps_with_windows.discard('Finder')
|
||||
|
||||
# Also remove exception apps from the main loop - we'll handle them separately
|
||||
for exception_app in EXCEPTION_APPS.keys():
|
||||
apps_with_windows.discard(exception_app)
|
||||
|
||||
# Get all running applications (to get proper app objects)
|
||||
workspace = NSWorkspace.sharedWorkspace()
|
||||
running_apps = workspace.runningApplications()
|
||||
|
||||
processed_apps = set()
|
||||
|
||||
for app in running_apps:
|
||||
app_name = app.localizedName()
|
||||
|
||||
# Skip if already processed
|
||||
if app_name in processed_apps:
|
||||
continue
|
||||
|
||||
# FIX #1: Skip if this app doesn't have visible windows
|
||||
if app_name not in apps_with_windows:
|
||||
continue
|
||||
|
||||
# Skip exception apps - they're handled separately
|
||||
if app_name in EXCEPTION_APPS:
|
||||
continue
|
||||
|
||||
# Skip system apps and problematic apps
|
||||
if app_name in skip_apps:
|
||||
continue
|
||||
|
||||
# Skip apps with certain keywords
|
||||
if any(keyword in app_name for keyword in skip_keywords):
|
||||
continue
|
||||
|
||||
# Skip if not a regular app
|
||||
if not app.activationPolicy() == 0: # NSApplicationActivationPolicyRegular
|
||||
continue
|
||||
|
||||
print(f"Processing: {app_name}")
|
||||
minimize_window_via_applescript(app_name)
|
||||
processed_apps.add(app_name)
|
||||
time.sleep(0.3)
|
||||
|
||||
# Handle exception apps that don't respond to Cmd+M
|
||||
for app_name, process_name in EXCEPTION_APPS.items():
|
||||
# Check if this app actually has visible windows
|
||||
# We need to re-check since we removed it from apps_with_windows earlier
|
||||
check_script = f'''
|
||||
tell application "System Events"
|
||||
if exists process "{process_name}" then
|
||||
tell process "{process_name}"
|
||||
set visibleCount to 0
|
||||
repeat with w in windows
|
||||
try
|
||||
if value of attribute "AXMinimized" of w is false then
|
||||
set visibleCount to visibleCount + 1
|
||||
end if
|
||||
end try
|
||||
end repeat
|
||||
return visibleCount
|
||||
end tell
|
||||
else
|
||||
return 0
|
||||
end if
|
||||
end tell
|
||||
'''
|
||||
try:
|
||||
result = subprocess.run(
|
||||
['osascript', '-e', check_script],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
timeout=5
|
||||
)
|
||||
visible_count = int(result.stdout.strip()) if result.stdout.strip() else 0
|
||||
if visible_count > 0:
|
||||
print(f"Processing exception app: {app_name}")
|
||||
minimize_exception_app(app_name, process_name)
|
||||
time.sleep(0.3)
|
||||
except Exception as e:
|
||||
print(f"Error checking {app_name}: {e}")
|
||||
|
||||
# FIX #2: Handle Finder windows separately using Finder's native scripting
|
||||
# This is more reliable than using Cmd+M
|
||||
minimize_finder_windows()
|
||||
|
||||
print("Done minimizing all windows")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
65
SpyderScripts/minimize_all.spec
Normal file
65
SpyderScripts/minimize_all.spec
Normal file
@@ -0,0 +1,65 @@
|
||||
# -*- mode: python ; coding: utf-8 -*-
|
||||
|
||||
block_cipher = None
|
||||
|
||||
a = Analysis(
|
||||
['minimize_all.py'],
|
||||
pathex=[],
|
||||
binaries=[],
|
||||
datas=[],
|
||||
hiddenimports=[
|
||||
'Cocoa',
|
||||
'Quartz',
|
||||
'Foundation',
|
||||
'AppKit',
|
||||
'objc',
|
||||
],
|
||||
hookspath=[],
|
||||
hooksconfig={},
|
||||
runtime_hooks=[],
|
||||
excludes=[],
|
||||
win_no_prefer_redirects=False,
|
||||
win_private_assemblies=False,
|
||||
cipher=block_cipher,
|
||||
noarchive=False,
|
||||
)
|
||||
|
||||
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
|
||||
|
||||
exe = EXE(
|
||||
pyz,
|
||||
a.scripts,
|
||||
a.binaries,
|
||||
a.zipfiles,
|
||||
a.datas,
|
||||
[],
|
||||
name='MinimizeAllWindows',
|
||||
debug=False,
|
||||
bootloader_ignore_signals=False,
|
||||
strip=False,
|
||||
upx=True,
|
||||
upx_exclude=[],
|
||||
runtime_tmpdir=None,
|
||||
console=False, # No terminal window
|
||||
disable_windowed_traceback=False,
|
||||
argv_emulation=False,
|
||||
target_arch=None,
|
||||
codesign_identity=None,
|
||||
entitlements_file=None,
|
||||
)
|
||||
|
||||
app = BUNDLE(
|
||||
exe,
|
||||
name='Minimize All Windows.app',
|
||||
icon=None,
|
||||
bundle_identifier='com.user.minimizeallwindows',
|
||||
info_plist={
|
||||
'CFBundleName': 'Minimize All Windows',
|
||||
'CFBundleDisplayName': 'Minimize All Windows',
|
||||
'CFBundleVersion': '1.0.0',
|
||||
'CFBundleShortVersionString': '1.0.0',
|
||||
'LSUIElement': True, # Background app - no dock icon
|
||||
'NSAppleEventsUsageDescription': 'This app needs to control other applications to minimize their windows.',
|
||||
'NSAccessibilityUsageDescription': 'This app needs accessibility access to minimize windows.',
|
||||
},
|
||||
)
|
||||
54
SpyderScripts/minimize_all_best.sh
Executable file
54
SpyderScripts/minimize_all_best.sh
Executable file
@@ -0,0 +1,54 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Minimize All Windows - Simplified and Improved
|
||||
|
||||
osascript <<EOF
|
||||
tell application "System Events"
|
||||
set allApps to name of (every process whose visible is true)
|
||||
end tell
|
||||
|
||||
repeat with appName in allApps
|
||||
-- Skip problematic apps
|
||||
if appName is not in {"Finder", "SystemUIServer", "Dock", "Electron", "MSTeams", "nxdock"} and ¬
|
||||
appName does not contain "Helper" and ¬
|
||||
appName does not contain "Agent" then
|
||||
|
||||
try
|
||||
-- Activate the app
|
||||
tell application appName
|
||||
activate
|
||||
end tell
|
||||
delay 1.0
|
||||
|
||||
-- Make sure it's frontmost and send keystroke
|
||||
tell application "System Events"
|
||||
tell process appName
|
||||
try
|
||||
-- Ensure the process is frontmost
|
||||
set frontmost to true
|
||||
delay 0.3
|
||||
|
||||
-- Send Command+M to minimize the frontmost window
|
||||
keystroke "m" using command down
|
||||
end try
|
||||
end tell
|
||||
end tell
|
||||
delay 0.3
|
||||
on error
|
||||
-- Skip apps that cause errors
|
||||
end try
|
||||
end if
|
||||
end repeat
|
||||
|
||||
-- Handle Finder windows
|
||||
tell application "Finder"
|
||||
try
|
||||
set allWindows to every Finder window
|
||||
repeat with aWindow in allWindows
|
||||
set miniaturized of aWindow to true
|
||||
end repeat
|
||||
end try
|
||||
end tell
|
||||
EOF
|
||||
|
||||
echo "Done minimizing all windows"
|
||||
33
SpyderScripts/resize_window.py
Normal file
33
SpyderScripts/resize_window.py
Normal file
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Core module for resizing the active window on macOS.
|
||||
"""
|
||||
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
def resize_active_window(width: int, height: int):
|
||||
"""
|
||||
Resize the currently active window to the specified dimensions.
|
||||
Keeps the window in its current position.
|
||||
|
||||
Args:
|
||||
width: Target width in pixels
|
||||
height: Target height in pixels
|
||||
"""
|
||||
applescript = f'''
|
||||
tell application "System Events"
|
||||
set frontApp to first application process whose frontmost is true
|
||||
tell frontApp
|
||||
set size of window 1 to {{{width}, {height}}}
|
||||
end tell
|
||||
end tell
|
||||
'''
|
||||
|
||||
try:
|
||||
subprocess.run(['osascript', '-e', applescript], check=True, capture_output=True)
|
||||
print(f"✓ Resized active window to {width}x{height}")
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f"✗ Error resizing window: {e.stderr.decode()}")
|
||||
sys.exit(1)
|
||||
32
SpyderScripts/run_script.zsh
Executable file
32
SpyderScripts/run_script.zsh
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/bin/zsh
|
||||
|
||||
# Script to execute an AppleScript or action script file
|
||||
# Usage: ./run_script.zsh /path/to/your/script.scpt
|
||||
|
||||
# Check if a script path was provided
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "Error: No script file specified"
|
||||
echo "Usage: $0 /path/to/script.scpt"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
SCRIPT_PATH="$1"
|
||||
|
||||
# Check if the file exists
|
||||
if [ ! -f "$SCRIPT_PATH" ]; then
|
||||
echo "Error: Script file not found: $SCRIPT_PATH"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Execute the script using osascript
|
||||
osascript "$SCRIPT_PATH"
|
||||
|
||||
# Capture the exit status
|
||||
EXIT_STATUS=$?
|
||||
|
||||
if [ $EXIT_STATUS -ne 0 ]; then
|
||||
echo "Script execution failed with status: $EXIT_STATUS"
|
||||
exit $EXIT_STATUS
|
||||
fi
|
||||
|
||||
echo "Script executed successfully"
|
||||
183
SpyderScripts/smb_mount.py
Normal file
183
SpyderScripts/smb_mount.py
Normal file
@@ -0,0 +1,183 @@
|
||||
#!/usr/bin/env python3
|
||||
import os
|
||||
import subprocess
|
||||
import shutil
|
||||
import time
|
||||
from pathlib import Path
|
||||
from urllib.parse import quote
|
||||
from dataclasses import dataclass
|
||||
from typing import Optional
|
||||
|
||||
|
||||
@dataclass
|
||||
class SMBConfig:
|
||||
"""Configuration for an SMB mount."""
|
||||
server: str
|
||||
share: str
|
||||
username: str
|
||||
password: str
|
||||
mount_name: str # Name for the mount folder (e.g., "GDriveNetwork")
|
||||
local_dest: Optional[str] = None # Optional local destination for syncing
|
||||
|
||||
@property
|
||||
def mount_point(self) -> str:
|
||||
"""Returns the full mount point path."""
|
||||
return str(Path.home() / "NetworkMounts" / self.mount_name)
|
||||
|
||||
|
||||
def is_mounted(mount_point: str) -> bool:
|
||||
"""Check if a path is currently mounted."""
|
||||
return os.path.ismount(mount_point)
|
||||
|
||||
|
||||
def mount_share(config: SMBConfig) -> bool:
|
||||
"""
|
||||
Mount an SMB share using the provided configuration.
|
||||
Returns True if successful, False otherwise.
|
||||
"""
|
||||
mount_point = config.mount_point
|
||||
|
||||
# Create mount point directory if it doesn't exist
|
||||
Path(mount_point).mkdir(parents=True, exist_ok=True)
|
||||
|
||||
# Build the SMB URL
|
||||
# Format: //username:password@server/share
|
||||
if config.username and config.password:
|
||||
escaped_pass = quote(config.password, safe='')
|
||||
smb_url = f"//{config.username}:{escaped_pass}@{config.server}/{config.share}"
|
||||
else:
|
||||
smb_url = f"//{config.server}/{config.share}"
|
||||
|
||||
# Mount command for macOS
|
||||
cmd = ["mount_smbfs", smb_url, mount_point]
|
||||
|
||||
try:
|
||||
print(f"Mounting {config.share} from {config.server}...")
|
||||
subprocess.run(cmd, check=True, capture_output=True, text=True)
|
||||
print(f"Successfully mounted to {mount_point}")
|
||||
return True
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f"Failed to mount: {e.stderr}")
|
||||
return False
|
||||
|
||||
|
||||
def unmount_share(config: SMBConfig) -> bool:
|
||||
"""Unmount an SMB share."""
|
||||
mount_point = config.mount_point
|
||||
|
||||
if not is_mounted(mount_point):
|
||||
print(f"{mount_point} is not mounted.")
|
||||
return True
|
||||
|
||||
try:
|
||||
subprocess.run(["umount", mount_point], check=True, capture_output=True, text=True)
|
||||
print(f"Successfully unmounted {mount_point}")
|
||||
return True
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f"Failed to unmount: {e.stderr}")
|
||||
return False
|
||||
|
||||
|
||||
def ensure_mounted(config: SMBConfig) -> bool:
|
||||
"""
|
||||
Ensure a share is mounted. Mount it if not already mounted.
|
||||
Returns True if mounted (or already was), False if mount failed.
|
||||
"""
|
||||
mount_point = config.mount_point
|
||||
|
||||
if is_mounted(mount_point):
|
||||
print(f"{config.share} is already mounted at {mount_point}")
|
||||
return True
|
||||
|
||||
print(f"{config.share} not mounted. Attempting to mount...")
|
||||
return mount_share(config)
|
||||
|
||||
|
||||
# -----------------------------
|
||||
# PREDEFINED CONFIGURATIONS
|
||||
# -----------------------------
|
||||
# Add your different mount configurations here
|
||||
|
||||
CONFIGS = {
|
||||
"gdrive": SMBConfig(
|
||||
server="192.168.1.68",
|
||||
share="GDrive",
|
||||
username="macos",
|
||||
password="dromischSYNC123987me",
|
||||
mount_name="GDrive",
|
||||
local_dest="/Users/dromisch/NetworkMounts/GDrive"
|
||||
),
|
||||
|
||||
# Example: Add more configurations as needed
|
||||
# "photos": SMBConfig(
|
||||
# server="192.168.1.68",
|
||||
# share="Photos",
|
||||
# username="photouser",
|
||||
# password="photopass",
|
||||
# mount_name="PhotosNetwork",
|
||||
# local_dest="/Volumes/ExtraDrive/Photos"
|
||||
# ),
|
||||
|
||||
# "backup": SMBConfig(
|
||||
# server="192.168.1.100",
|
||||
# share="Backups",
|
||||
# username="backupuser",
|
||||
# password="backuppass",
|
||||
# mount_name="BackupNetwork"
|
||||
# ),
|
||||
}
|
||||
|
||||
|
||||
def list_configs():
|
||||
"""Print available configurations."""
|
||||
print("Available mount configurations:")
|
||||
for name, config in CONFIGS.items():
|
||||
status = "mounted" if is_mounted(config.mount_point) else "not mounted"
|
||||
print(f" {name}: //{config.server}/{config.share} ({status})")
|
||||
|
||||
|
||||
def main():
|
||||
import argparse
|
||||
|
||||
parser = argparse.ArgumentParser(description="Mount SMB network shares")
|
||||
parser.add_argument("config", nargs="?", help="Configuration name to mount")
|
||||
parser.add_argument("-l", "--list", action="store_true", help="List available configurations")
|
||||
parser.add_argument("-u", "--unmount", action="store_true", help="Unmount instead of mount")
|
||||
parser.add_argument("-a", "--all", action="store_true", help="Mount/unmount all configurations")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.list:
|
||||
list_configs()
|
||||
return
|
||||
|
||||
if args.all:
|
||||
for name, config in CONFIGS.items():
|
||||
print(f"\n--- {name} ---")
|
||||
if args.unmount:
|
||||
unmount_share(config)
|
||||
else:
|
||||
ensure_mounted(config)
|
||||
return
|
||||
|
||||
if not args.config:
|
||||
parser.print_help()
|
||||
print("\n")
|
||||
list_configs()
|
||||
return
|
||||
|
||||
if args.config not in CONFIGS:
|
||||
print(f"Unknown configuration: {args.config}")
|
||||
list_configs()
|
||||
return
|
||||
|
||||
config = CONFIGS[args.config]
|
||||
|
||||
if args.unmount:
|
||||
unmount_share(config)
|
||||
else:
|
||||
ensure_mounted(config)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
9
SpyderScripts/window_maximum.py
Normal file
9
SpyderScripts/window_maximum.py
Normal file
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Resize active window to Maximum preset (2450x3500)
|
||||
"""
|
||||
|
||||
from resize_window import resize_active_window
|
||||
|
||||
if __name__ == "__main__":
|
||||
resize_active_window(width=2450, height=3500)
|
||||
65
SpyderScripts/window_maximum.spec
Normal file
65
SpyderScripts/window_maximum.spec
Normal file
@@ -0,0 +1,65 @@
|
||||
# -*- mode: python ; coding: utf-8 -*-
|
||||
|
||||
block_cipher = None
|
||||
|
||||
a = Analysis(
|
||||
['window_maximum.py'],
|
||||
pathex=[],
|
||||
binaries=[],
|
||||
datas=[],
|
||||
hiddenimports=[
|
||||
'Cocoa',
|
||||
'Quartz',
|
||||
'Foundation',
|
||||
'AppKit',
|
||||
'objc',
|
||||
],
|
||||
hookspath=[],
|
||||
hooksconfig={},
|
||||
runtime_hooks=[],
|
||||
excludes=[],
|
||||
win_no_prefer_redirects=False,
|
||||
win_private_assemblies=False,
|
||||
cipher=block_cipher,
|
||||
noarchive=False,
|
||||
)
|
||||
|
||||
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
|
||||
|
||||
exe = EXE(
|
||||
pyz,
|
||||
a.scripts,
|
||||
a.binaries,
|
||||
a.zipfiles,
|
||||
a.datas,
|
||||
[],
|
||||
name='MaximizeCurrentWindow',
|
||||
debug=False,
|
||||
bootloader_ignore_signals=False,
|
||||
strip=False,
|
||||
upx=True,
|
||||
upx_exclude=[],
|
||||
runtime_tmpdir=None,
|
||||
console=False, # No terminal window
|
||||
disable_windowed_traceback=False,
|
||||
argv_emulation=False,
|
||||
target_arch=None,
|
||||
codesign_identity=None,
|
||||
entitlements_file=None,
|
||||
)
|
||||
|
||||
app = BUNDLE(
|
||||
exe,
|
||||
name='Maximize Current Window.app',
|
||||
icon=None,
|
||||
bundle_identifier='com.user.maximizeWindow',
|
||||
info_plist={
|
||||
'CFBundleName': 'Maximize Current Window',
|
||||
'CFBundleDisplayName': 'Maximize Current Window',
|
||||
'CFBundleVersion': '1.0.0',
|
||||
'CFBundleShortVersionString': '1.0.0',
|
||||
'LSUIElement': True, # Background app - no dock icon
|
||||
'NSAppleEventsUsageDescription': 'This app needs to control other applications to maximize their window.',
|
||||
'NSAccessibilityUsageDescription': 'This app needs accessibility access to maximize windows.',
|
||||
},
|
||||
)
|
||||
9
SpyderScripts/window_medium.py
Normal file
9
SpyderScripts/window_medium.py
Normal file
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Resize active window to Medium preset (2300x2250)
|
||||
"""
|
||||
|
||||
from resize_window import resize_active_window
|
||||
|
||||
if __name__ == "__main__":
|
||||
resize_active_window(width=2300, height=2250)
|
||||
65
SpyderScripts/window_medium.spec
Normal file
65
SpyderScripts/window_medium.spec
Normal file
@@ -0,0 +1,65 @@
|
||||
# -*- mode: python ; coding: utf-8 -*-
|
||||
|
||||
block_cipher = None
|
||||
|
||||
a = Analysis(
|
||||
['window_medium.py'],
|
||||
pathex=[],
|
||||
binaries=[],
|
||||
datas=[],
|
||||
hiddenimports=[
|
||||
'Cocoa',
|
||||
'Quartz',
|
||||
'Foundation',
|
||||
'AppKit',
|
||||
'objc',
|
||||
],
|
||||
hookspath=[],
|
||||
hooksconfig={},
|
||||
runtime_hooks=[],
|
||||
excludes=[],
|
||||
win_no_prefer_redirects=False,
|
||||
win_private_assemblies=False,
|
||||
cipher=block_cipher,
|
||||
noarchive=False,
|
||||
)
|
||||
|
||||
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
|
||||
|
||||
exe = EXE(
|
||||
pyz,
|
||||
a.scripts,
|
||||
a.binaries,
|
||||
a.zipfiles,
|
||||
a.datas,
|
||||
[],
|
||||
name='MediumCurrentWindow',
|
||||
debug=False,
|
||||
bootloader_ignore_signals=False,
|
||||
strip=False,
|
||||
upx=True,
|
||||
upx_exclude=[],
|
||||
runtime_tmpdir=None,
|
||||
console=False, # No terminal window
|
||||
disable_windowed_traceback=False,
|
||||
argv_emulation=False,
|
||||
target_arch=None,
|
||||
codesign_identity=None,
|
||||
entitlements_file=None,
|
||||
)
|
||||
|
||||
app = BUNDLE(
|
||||
exe,
|
||||
name='Medium Current Window.app',
|
||||
icon=None,
|
||||
bundle_identifier='com.user.mediumWindow',
|
||||
info_plist={
|
||||
'CFBundleName': 'Medium Current Window',
|
||||
'CFBundleDisplayName': 'Medium Current Window',
|
||||
'CFBundleVersion': '1.0.0',
|
||||
'CFBundleShortVersionString': '1.0.0',
|
||||
'LSUIElement': True, # Background app - no dock icon
|
||||
'NSAppleEventsUsageDescription': 'This app needs to control other applications to medium their window.',
|
||||
'NSAccessibilityUsageDescription': 'This app needs accessibility access to medium windows.',
|
||||
},
|
||||
)
|
||||
9
SpyderScripts/window_minimal.py
Normal file
9
SpyderScripts/window_minimal.py
Normal file
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Resize active window to Minimal preset (2042x1262)
|
||||
"""
|
||||
|
||||
from resize_window import resize_active_window
|
||||
|
||||
if __name__ == "__main__":
|
||||
resize_active_window(width=2042, height=1262)
|
||||
65
SpyderScripts/window_minimal.spec
Normal file
65
SpyderScripts/window_minimal.spec
Normal file
@@ -0,0 +1,65 @@
|
||||
# -*- mode: python ; coding: utf-8 -*-
|
||||
|
||||
block_cipher = None
|
||||
|
||||
a = Analysis(
|
||||
['window_minimal.py'],
|
||||
pathex=[],
|
||||
binaries=[],
|
||||
datas=[],
|
||||
hiddenimports=[
|
||||
'Cocoa',
|
||||
'Quartz',
|
||||
'Foundation',
|
||||
'AppKit',
|
||||
'objc',
|
||||
],
|
||||
hookspath=[],
|
||||
hooksconfig={},
|
||||
runtime_hooks=[],
|
||||
excludes=[],
|
||||
win_no_prefer_redirects=False,
|
||||
win_private_assemblies=False,
|
||||
cipher=block_cipher,
|
||||
noarchive=False,
|
||||
)
|
||||
|
||||
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
|
||||
|
||||
exe = EXE(
|
||||
pyz,
|
||||
a.scripts,
|
||||
a.binaries,
|
||||
a.zipfiles,
|
||||
a.datas,
|
||||
[],
|
||||
name='MinimalCurrentWindow',
|
||||
debug=False,
|
||||
bootloader_ignore_signals=False,
|
||||
strip=False,
|
||||
upx=True,
|
||||
upx_exclude=[],
|
||||
runtime_tmpdir=None,
|
||||
console=False, # No terminal window
|
||||
disable_windowed_traceback=False,
|
||||
argv_emulation=False,
|
||||
target_arch=None,
|
||||
codesign_identity=None,
|
||||
entitlements_file=None,
|
||||
)
|
||||
|
||||
app = BUNDLE(
|
||||
exe,
|
||||
name='Minimal Current Window.app',
|
||||
icon=None,
|
||||
bundle_identifier='com.user.minimalWindow',
|
||||
info_plist={
|
||||
'CFBundleName': 'Minimal Current Window',
|
||||
'CFBundleDisplayName': 'Minimal Current Window',
|
||||
'CFBundleVersion': '1.0.0',
|
||||
'CFBundleShortVersionString': '1.0.0',
|
||||
'LSUIElement': True, # Background app - no dock icon
|
||||
'NSAppleEventsUsageDescription': 'This app needs to control other applications to minimal their window.',
|
||||
'NSAccessibilityUsageDescription': 'This app needs accessibility access to minimal windows.',
|
||||
},
|
||||
)
|
||||
9
SpyderScripts/window_minimalist.py
Normal file
9
SpyderScripts/window_minimalist.py
Normal file
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Resize active window to Minimalist preset (1250x810)
|
||||
"""
|
||||
|
||||
from resize_window import resize_active_window
|
||||
|
||||
if __name__ == "__main__":
|
||||
resize_active_window(width=1250, height=810)
|
||||
65
SpyderScripts/window_minimalist.spec
Normal file
65
SpyderScripts/window_minimalist.spec
Normal file
@@ -0,0 +1,65 @@
|
||||
# -*- mode: python ; coding: utf-8 -*-
|
||||
|
||||
block_cipher = None
|
||||
|
||||
a = Analysis(
|
||||
['window_minimalist.py'],
|
||||
pathex=[],
|
||||
binaries=[],
|
||||
datas=[],
|
||||
hiddenimports=[
|
||||
'Cocoa',
|
||||
'Quartz',
|
||||
'Foundation',
|
||||
'AppKit',
|
||||
'objc',
|
||||
],
|
||||
hookspath=[],
|
||||
hooksconfig={},
|
||||
runtime_hooks=[],
|
||||
excludes=[],
|
||||
win_no_prefer_redirects=False,
|
||||
win_private_assemblies=False,
|
||||
cipher=block_cipher,
|
||||
noarchive=False,
|
||||
)
|
||||
|
||||
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
|
||||
|
||||
exe = EXE(
|
||||
pyz,
|
||||
a.scripts,
|
||||
a.binaries,
|
||||
a.zipfiles,
|
||||
a.datas,
|
||||
[],
|
||||
name='MinimalistCurrentWindow',
|
||||
debug=False,
|
||||
bootloader_ignore_signals=False,
|
||||
strip=False,
|
||||
upx=True,
|
||||
upx_exclude=[],
|
||||
runtime_tmpdir=None,
|
||||
console=False, # No terminal window
|
||||
disable_windowed_traceback=False,
|
||||
argv_emulation=False,
|
||||
target_arch=None,
|
||||
codesign_identity=None,
|
||||
entitlements_file=None,
|
||||
)
|
||||
|
||||
app = BUNDLE(
|
||||
exe,
|
||||
name='Minimalist Current Window.app',
|
||||
icon=None,
|
||||
bundle_identifier='com.user.minimalistWindow',
|
||||
info_plist={
|
||||
'CFBundleName': 'Minimalist Current Window',
|
||||
'CFBundleDisplayName': 'Minimalist Current Window',
|
||||
'CFBundleVersion': '1.0.0',
|
||||
'CFBundleShortVersionString': '1.0.0',
|
||||
'LSUIElement': True, # Background app - no dock icon
|
||||
'NSAppleEventsUsageDescription': 'This app needs to control other applications to minimalist their window.',
|
||||
'NSAccessibilityUsageDescription': 'This app needs accessibility access to minimalist windows.',
|
||||
},
|
||||
)
|
||||
BIN
aws_google_saml/.DS_Store
vendored
BIN
aws_google_saml/.DS_Store
vendored
Binary file not shown.
Reference in New Issue
Block a user