Giter Club home page Giter Club logo

huedesktoplock's Introduction

HueDesktopLock

Initial draft.

Overview

Collection of methods to control Philips Hue lights based on whether a computer has been locked via 'Win + L' shortcut.

Monitors for Win + L shortcut press (lock computer) to turn off lights, and then monitors for any key inputs to turn lights back on. Tested on Windows 11, but should work on Ubuntu with minimal tweaks (may need to remove code that uses ctypes library).

Caveats

Nothing will execute if machine is not locked via Win + L.

Windows and thereby Python do not have any functions that can return whether a computer is unlocked or not (https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-lockworkstation?redirectedfrom=MSDN). Some hacks are floating around StackOverflow for this, but these are very hit-and-miss. It is possible to monitor LogonUI.exe or the top window using the Python library ctypes, but these workarounds are very resource-intensive for what they do. Monitoring a keyboard shortcut is much less expensive.

Usage

  1. Clone repo git clone <link>.
  2. Install dependencies pip install -r requirements.txt.
  3. Configure arguments as required.

This project can be imported as a module (see example.py), or you can copy the classes directly from HueDesktopLock.py and edit as required. Use HueDesktopLock-multi.py to assign a second shortcut and action (uses multi-threading).

Ensure you press the pairing button on your Hue Bridge before running for the first time.

Philips Hue light control

Uses this module https://github.com/studioimaginaire/phue.

You will need to know your bridge IP address, and light indexes (see above documentation). If I have some time in the future I write some extra methods to automatically discover bridge/lights etc.

Issues

  • Windows Security may flag program as a keylogger, and may try to terminate the scripts.

huedesktoplock's People

Contributors

james-2879 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.