Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/caseymrm/go-assertions

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/caseymrm/go-assertions

  • v0.0.0-20180523040700-6ea0307b5bc5
  • Source
  • Go
  • Socket score

Version published
Created
Source

go-pmset

Golang library to access OSX's system assertions, the ones displayed when you run pmset -g assertions

Installation

go-pmset requires OS X.

go get github.com/caseymrm/go-pmset

Documentation

https://godoc.org/github.com/caseymrm/go-pmset

Examples

GetAssertions()

package main

import (
    "encoding/json"
    "log"
    
    "github.com/caseymrm/go-pmset"
)

func main() {
    a := pmset.GetAssertions()
    b, _ := json.MarshalIndent(a, "", "  ")
    log.Printf("%s\n", b)
}
2018/04/17 16:11:23 
{
  "ApplePushServiceTask": 0,
  "AwakeOnReservePower": 0,
  "BackgroundTask": 0,
  "CPUBoundAssertion": 0,
  "ChargeInhibit": 0,
  "DisableInflow": 0,
  "DisableLowPowerBatteryWarnings": 0,
  "DisplayWake": 0,
  "EnableIdleSleep": 1,
  "ExternalMedia": 0,
  "InteractivePushServiceTask": 0,
  "InternalPreventDisplaySleep": 1,
  "InternalPreventSleep": 0,
  "NetworkClientActive": 0,
  "PreventDiskIdle": 0,
  "PreventSystemSleep": 0,
  "PreventUserIdleDisplaySleep": 1,
  "PreventUserIdleSystemSleep": 1,
  "SystemIsActive": 0,
  "UserIsActive": 1
}

GetPIDAssertions()

package main

import (
    "encoding/json"
    "log"
    
    "github.com/caseymrm/go-pmset"
)

func main() {
    a := pmset.GetPIDAssertions()
    b, _ := json.MarshalIndent(a, "", "  ")
    log.Printf("%s\n", b)
}
2018/04/17 16:11:23 {
  "PreventUserIdleDisplaySleep": [
    {
      "PID": 47784,
      "Name": "com.apple.WebCore: HTMLMediaElement playback"
    }
  ],
  "PreventUserIdleSystemSleep": [
    {
      "PID": 180,
      "Name": "com.apple.audio.AppleUSBAudioEngine:C-Media Electronics Inc.:USB Audio Device:14131000:2,1.context.preventuseridlesleep"
    },
    {
      "PID": 180,
      "Name": "com.apple.audio.AppleUSBAudioEngine:C-Media Electronics Inc.:USB Audio Device:14131000:2,1.context.preventuseridlesleep"
    }
  ],
  "UserIsActive": [
    {
      "PID": 114,
      "Name": "com.apple.iohideventsystem.queue.tickle.4294978958.17"
    }
  ]
}

SubscribeAssertionChanges()

SubscribeAssertionChangesAndRun()

package main

import (
    "encoding/json"
    "log"
    
    "github.com/caseymrm/go-pmset"
)

func main() {
	channel := make(chan AssertionChange)
	go func() {
		for change := range channel {
            b, _ := json.MarshalIndent(change, "", "  ")
            log.Printf("%s\n", b)
		}
	}()
	SubscribeAssertionChangesAndRun(channel)
}
2018/04/30 11:30:06 {
  "Action": "Released",
  "Type": "PreventUserIdleDisplaySleep",
  "Pid": {
    "PID": 47784,
    "Name": "com.apple.WebCore: HTMLMediaElement playback"
  }
}
2018/04/30 11:30:07 {
  "Action": "Created",
  "Type": "PreventUserIdleDisplaySleep",
  "Pid": {
    "PID": 47784,
    "Name": "com.apple.WebCore: HTMLMediaElement playback"
  }
}

License

MIT

FAQs

Package last updated on 23 May 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc