Skip to content

Send notify and run script when system lock/unlock and sleep/wake.

License

Notifications You must be signed in to change notification settings

liopoos/HemuLock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HemuLock

Send notify and run script when system lock/unlock and sleep/wake.

screenshots

这里有一份中文文档

Requirements

  • macOS 10.15 or later

Installation

  • Download DMG file from Releases
  • Drop the .app to Application folder

Event

HemuLock can listening system events:

  • Screen sleep
  • Screen wake
  • System sleep
  • System wake
  • System lock
  • System unlock

Notify Support

When the event is activated, HemuLock will take a request to notify servers, support notify is :

If you need other notify, take an issue or try to pull requests. :)

Script

When open Script option, HemuLock can run a script at the same time, the script file located the:

~/Library/Application Scripts/com.ch.hades.HemuLock/script

notice: This is a file, not a folder.

This is a examle to send Pushover notify:

#!/bin/bash
PUSHOVER_TOKEN="xxx"
API_TOKEN="xxx"

push() {
    curl -s \
    --form-string "sk=$API_TOKEN" \
    --form-string "token=$PUSHOVER_TOKEN" \
    --form-string "user=xx" \
    --form-string "title=HemuLock's Notify" \
    --form-string "content=$1" \
    https://api.mayuko.cn/v1/push.message
}

case $1 in
    SYSTEM_LOCK)
        push "System locked"
        ;;
    SYSTEM_UNLOCK)
        push "System unlocked"
        ;;
    SYSTEM_SLEEP)
        push "System is sleep"
        ;;
esac

Case block is the system event, All arguments type is:

Event Argument
Screen Wake SCREEN_WAKE
Screen Sleep SCREEN_SLEEP
System Wake SYSTEM_WAKE
System Sleep SYSTEM_SLEEP
System Lock SYSTEM_LOCK
System Unlock SYSTEM_UNLOCK

Do-Not-Disturb Mode

If you don't want to listening system events for a certain period of time, you can take Enable Do Not Disturb open. When the time is in the Do Not Disturb time, no notification will be sent or script no t be execution.

Please modify the Do Not Disturb time setting in Preferences.

Status

STATUS INSTRUCTION
🟢 Runing
🟡 Do-Not-Disturb Mode

License

MIT

About

Send notify and run script when system lock/unlock and sleep/wake.

Resources

License

Stars

Watchers

Forks

Packages

No packages published