PowerShell scripts to quickly switch between gaming and work modes by managing Docker containers and WSL2 on Windows.
This repository contains three PowerShell scripts designed to optimize system resources:
game-mode.ps1: Stops all Docker containers, closes LM Studio, and shuts down WSL2 to free up system resources for gamingwork-mode.ps1: Starts WSL2, launches LM Studio, and starts specific Docker Compose projects for development workcheck-mode.ps1: Displays current status of all services and determines which mode is active
Frees up system resources by stopping all running Docker containers and shutting down WSL2. Ideal for when you need maximum performance for gaming or other resource-intensive applications.
- ✅ Checks if Docker is available
- 📦 Lists all running Docker containers
- ⏹️ Stops all running containers (with 10-second graceful timeout)
- 🤖 Stops LM Studio processes (gracefully, then forced if needed)
- 🔌 Shuts down WSL2 completely (optional)
- 📝 Logs all operations to
docker_stop.log
Interactive Mode:
.\game-mode.ps1Skip All Prompts:
.\game-mode.ps1 -ForceSkip WSL2 Shutdown:
.\game-mode.ps1 -SkipWSLCombined (No Prompts, Skip WSL2):
.\game-mode.ps1 -Force -SkipWSL-Force: Skips all confirmation prompts (continues even without admin privileges)-SkipWSL: Completely skips WSL2 shutdown step
- Docker Desktop installed
- WSL2 enabled (optional if using
-SkipWSL) - PowerShell 5.1 or later
- Administrator privileges recommended for WSL2 shutdown (can be skipped with
-Forceor-SkipWSL)
- Location:
docker_stop.log(in the same directory) - Contains timestamped entries for all operations
- Automatically cleared on each run
Starts your development environment by ensuring WSL2 is running, Docker Desktop is active, and specific Docker Compose projects are started.
- ✅ Checks if Docker is available
- 🔄 Starts WSL2 if not already running
- 🐋 Checks if Docker Desktop is running
- 🚀 Starts Docker Desktop if needed (waits up to 90 seconds for readiness)
- 🤖 Starts LM Studio if not already running (optional)
- 📦 Starts Docker Compose projects defined in
config.env - 📊 Displays post-execution status check
- 🎯 Provides interactive menu for next actions
- 📝 Logs all operations to
docker_start.log
Interactive Mode (with status check and menu):
.\work-mode.ps1CLI Mode (exits immediately):
.\work-mode.ps1 -NoWaitSkip LM Studio:
.\work-mode.ps1 -SkipLMStudioQuiet Mode (no prompts or status):
.\work-mode.ps1 -QuietCombined:
.\work-mode.ps1 -NoWait -SkipLMStudio-NoWait: Exits immediately after execution (ideal for CLI/scripting)-SkipLMStudio: Skips starting LM Studio-Quiet: Suppresses all interactive prompts and status displays
After starting services (unless -NoWait or -Quiet is used), you'll see:
- [1] Check Full Status - Runs
check-mode.ps1for detailed status - [2] Stop Work Mode - Runs
game-mode.ps1to stop all services - [3] View Log File - Displays the execution log
- [X/0] Exit - Exits the script
- Docker Desktop installed
- WSL2 enabled
- PowerShell 5.1 or later
- Docker Compose projects labeled with
com.docker.compose.projectlabel - LM Studio installed (optional, script will skip if not found)
To modify which projects are started, edit the config.env file:
# Docker Compose Project Configuration
# List the Docker Compose project names to manage (one per line)
# These projects will be started by work-mode.ps1
my-app
my-database
my-cacheAdd or remove project names as needed. Lines starting with # are treated as comments.
If config.env is not found, the script will use example default projects.
- Location:
docker_start.log(in the same directory) - Contains timestamped entries for all operations
- Automatically cleared on each run
Provides a comprehensive status check of all system components to determine if you're in "Game Mode" or "Work Mode", with interactive options to switch modes.
- ✅ Checks WSL2 status and running distributions
- 🐋 Checks Docker Desktop process status
- 🔧 Checks Docker Engine availability and responsiveness
- 📦 Lists all running Docker containers
- 🗂️ Checks status of Docker Compose projects from
config.env - 🤖 Checks LM Studio process status
- 🧠 Monitors memory usage of browsers and IDEs (Chrome, VS Code, VMware, etc.)
- 📊 Calculates overall mode percentage and displays assessment
- 🎯 Provides interactive options to start Work Mode, Game Mode, or re-check status
.\check-mode.ps1After viewing the status, you'll be prompted to choose:
- [1] Start Work Mode - Runs
work-mode.ps1to start all services - [2] Start Game Mode - Runs
game-mode.ps1to stop all services - [3] Exit - Closes the script
========================================
System Mode Status Check
========================================
Checking WSL2...
✅ WSL2 [RUNNING ] 1 distribution(s) running
Checking Docker Desktop...
✅ Docker Desktop [RUNNING ] Process active
Checking Docker Engine...
✅ Docker Engine [RUNNING ] Responding to commands
Checking Docker Containers...
✅ Docker Containers [RUNNING ] 5/8 containers active
Checking Docker Projects...
✅ └─ my-web-app [RUNNING ] 2 container(s)
✅ └─ my-database [RUNNING ] 2 container(s)
✅ └─ my-cache [RUNNING ] 1 container(s)
Checking LM Studio...
✅ LM Studio [RUNNING ] 1 process(es) active
========================================
Current Mode Assessment:
🟢 WORK MODE ACTIVE
Most development services are running (100% active)
========================================
What would you like to do?
[1] Start Work Mode (./work-mode.ps1)
[2] Start Game Mode (./game-mode.ps1)
[3] Exit
Enter your choice (1-3):
- 🟢 WORK MODE ACTIVE (75-100%): Most or all development services running
- 🟡 PARTIAL MODE (25-74%): Some development services running
- 🔴 GAME MODE ACTIVE (0-24%): Most or all development services stopped
- PowerShell 5.1 or later
- No administrator privileges required
-
Clone or download this repository:
git clone https://github.com/YOUR_USERNAME/game-mode.git cd game-mode
-
Ensure PowerShell execution policy allows script execution:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
-
Make sure Docker Desktop and WSL2 are properly installed on your system.
The scripts assume Docker Desktop is installed at:
C:\Program Files\Docker\Docker\Docker Desktop.exe
If your installation is in a different location, edit work-mode.ps1 and update the $dockerDesktopPath variable.
The scripts manage Docker Compose projects listed in config.env.
To configure your projects:
- Create or edit
config.envin the script directory - List one project name per line (matching your Docker Compose project labels)
- Lines starting with
#are treated as comments
Example config.env:
# My Docker Projects
my-web-app
my-database
my-redis-cache
# Add more projects as neededHow Docker Compose projects are identified:
The scripts use Docker Compose project labels to find containers. Ensure your projects are started with a project name:
# Using docker-compose
docker-compose -p my-app up -d
# Using docker compose (v2)
docker compose -p my-app up -dOr set the project name in your docker-compose.yml:
# docker-compose.yml
name: my-app
services:
web:
image: nginx:latest
db:
image: postgres:15The work-mode.ps1 script automatically searches for LM Studio in common installation locations:
%LOCALAPPDATA%\Programs\LM Studio\LM Studio.exe%LOCALAPPDATA%\LMStudio\LM Studio.exeC:\Program Files\LM Studio\LM Studio.exeC:\Program Files (x86)\LM Studio\LM Studio.exe
If LM Studio is installed in a different location, you can add the path to the $lmStudioPaths array in the script.
Starting game mode script (stopping Docker & WSL2)...
[!] This script is not running with Administrator privileges.
Some operations (like WSL2 shutdown) may require admin rights.
[i] Force mode enabled, continuing without prompts.
[2025-12-05 14:30:00] Checking if 'docker' command is available...
[2025-12-05 14:30:00] Found docker command. Proceeding...
[2025-12-05 14:30:01] Getting list of running containers...
[2025-12-05 14:30:01] Found 5 running containers. Stopping them...
Stopping Docker containers [########################################] 100% - Containers stopped
[2025-12-05 14:30:12] ✅ Stop command issued for 5 container(s).
[2025-12-05 14:30:12] All containers have been stopped or checked.
[2025-12-05 14:30:12] Checking for LM Studio processes...
[2025-12-05 14:30:12] Found 1 LM Studio process(es). Stopping them...
Stopping LM Studio gracefully [########################################] 100% - Checking status
[2025-12-05 14:30:14] ✅ LM Studio processes stopped gracefully.
[2025-12-05 14:30:14] Shutting down WSL2...
[2025-12-05 14:30:14] [i] WSL2 shutdown skipped (SkipWSL parameter).
[2025-12-05 14:30:14] Script completed.
Log file created at: docker_stop.log
Starting work mode script (WSL2 & Docker projects)...
[2025-12-05 09:00:00] Checking if 'docker' command is available...
[2025-12-05 09:00:00] Found docker command. Proceeding...
[2025-12-05 09:00:01] Checking WSL2 status...
[2025-12-05 09:00:02] ✅ WSL2 is already running.
[2025-12-05 09:00:02] Checking if Docker Desktop is running...
[2025-12-05 09:00:02] ✅ Docker Desktop is already running.
[2025-12-05 09:00:02] Checking if LM Studio is running...
[2025-12-05 09:00:02] LM Studio is not running. Starting LM Studio...
[2025-12-05 09:00:02] ✅ LM Studio started from: C:\Users\YourName\AppData\Local\Programs\LM Studio\LM Studio.exe
[2025-12-05 09:00:05] Starting Docker Compose project: my-web-app...
[2025-12-05 09:00:07] ✅ Project 'my-web-app' started successfully (2 container(s)).
[2025-12-05 09:00:07] Starting Docker Compose project: my-database...
[2025-12-05 09:00:09] ✅ Project 'my-database' started successfully (1 container(s)).
[2025-12-05 09:00:09] All projects have been processed.
[2025-12-05 09:00:09] Script completed.
Log file created at: docker_start.log
========================================
POST-START STATUS CHECK
========================================
[OK] WSL2: 1 distribution(s) running
[OK] Docker Desktop: Running
[OK] Docker Engine: Responding
[OK] Docker Containers: 3 running
[OK] LM Studio: Running (1 process(es))
========================================
What would you like to do next?
[1] Check Full Status (./check-mode.ps1)
[2] Stop Work Mode (./game-mode.ps1)
[3] View Log File
[X/0] Exit
Enter your choice (1, 2, 3 or X/0):
- Ensure Docker Desktop is installed
- Verify Docker is in your system PATH
- Restart PowerShell after installing Docker
- Check if Docker Desktop is installed at the expected path
- Update the
$dockerDesktopPathvariable inwork-mode.ps1
- Ensure WSL2 is properly installed:
wsl --install - Check Windows version (WSL2 requires Windows 10 version 1903+ or Windows 11)
- Run
wsl --updateto update WSL
- Verify containers exist:
docker ps -a - Check if containers have the correct project label:
docker inspect <container_id> - Manually start containers to check for errors:
docker start <container_id>
Run this command in PowerShell as Administrator:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachineFor WSL2 shutdown issues:
- Use
.\game-mode.ps1 -SkipWSLto skip WSL2 shutdown entirely - Use
.\game-mode.ps1 -Forceto skip prompts (WSL2 shutdown may still fail) - WSL2 will remain running but Docker containers and LM Studio will be stopped
Alternative: Right-click PowerShell and select "Run as Administrator" before running the script.
- Verify LM Studio is installed on your system
- Check if it's in one of the default locations listed in the Configuration section
- If installed elsewhere, add the path to
$lmStudioPathsarray inwork-mode.ps1 - The script will continue without LM Studio if not found
- Run
.\check-mode.ps1to see current status - Select option [2] to run Game Mode, or run
.\game-mode.ps1 -Force -SkipWSLdirectly - Frees up RAM and CPU resources used by Docker and WSL2
- Improves gaming performance
- Run
.\check-mode.ps1to see current status - Select option [1] to run Work Mode, or run
.\work-mode.ps1directly - Automatically starts all necessary development containers
- Ready to code in seconds
- Use
check-mode.ps1as your main launcher for quick status check and mode switching - Keep scripts in an easily accessible location (e.g.,
C:\Scripts\game-mode) - Create desktop shortcuts for one-click execution:
- Game Mode:
powershell.exe -ExecutionPolicy Bypass -File "C:\Scripts\game-mode\game-mode.ps1" -Force - Work Mode:
powershell.exe -ExecutionPolicy Bypass -File "C:\Scripts\game-mode\work-mode.ps1" - Check Mode:
powershell.exe -ExecutionPolicy Bypass -File "C:\Scripts\game-mode\check-mode.ps1"
- Game Mode:
- Use Task Scheduler to automate execution at specific times
- Add to Windows Terminal profile for quick access
Both scripts generate detailed log files:
docker_stop.log: Created bygame-mode.ps1docker_start.log: Created bywork-mode.ps1
Logs include:
- Timestamps for all operations
- Success/failure status
- Error messages and exit codes
- Container counts and project names
Some operations (especially WSL shutdown) may require administrator privileges. To run as admin:
- Right-click the script
- Select "Run with PowerShell as Administrator"
Or create a shortcut with admin privileges:
- Right-click → Create shortcut
- Right-click shortcut → Properties → Advanced
- Check "Run as administrator"
Contributions are welcome! Feel free to:
- Report bugs
- Suggest new features
- Submit pull requests
- Improve documentation
This project is licensed under the MIT License. See LICENSE file for details.
- Built for Windows 10/11 with Docker Desktop and WSL2
- Designed to optimize resource usage for gaming and development
- Inspired by the need to quickly switch between work and play
If you encounter issues:
- Check the log files for detailed error messages
- Review the Troubleshooting section
- Open an issue on GitHub with log file contents
Made with ❤️ for developers who game