Skip to content

Instantly share code, notes, and snippets.

@JSGRD22
JSGRD22 / How to Toggle Lid Action based on Monitor Connection.md
Last active January 31, 2026 15:02
How to Toggle Lid Action based on Monitor Connection.md

Goal

When the display is connected, the "closing the lid" action would do nothing. When disconnected, it goes back to the previous state: "sleep".

Procedure

  1. Check event viewer for event ID when USB device connects/disconnects Address: Microsoft-Windows-Kernel-PnP/Device Management Pasted image 20240822221123

    Here, it is 1010.

  2. Create a ps1 script (ToggleLidAction.ps1):

    Start-Sleep -Seconds 5
@JSGRD22
JSGRD22 / Drawing robot 1.py
Created November 9, 2020 12:42
A Simple Drawing Robot
import turtle as t
print('''Sir/Mdm, I am at your command. I can do the following:
1-go forward 100 steps
2-go backward 100 steps
3-turn left
4-turn right
5-draw a circle
6-pen up
7-pen down