
Research
/Security News
Toptal’s GitHub Organization Hijacked: 10 Malicious Packages Published
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
github.com/yamamotoworksdev/button-shim-go
Provides a Go implementation for interfacing with Pimoroni's Button SHIM. The top-level library provides a lot of the same functionality as the reference Python library, including:
First, clone the project into your Go path:
go get github.com/tomnz/button-shim-go
The library depends on the periph.io framework for low level device communication. You can install this manually with go get
, or (preferred) use dep
:
go get -u github.com/golang/dep/cmd/dep
cd $GOPATH/src/github.com/tomnz/button-shim-go
dep ensure
First, initialize a periph.io I2C bus, and instantiate the device with it:
package main
import (
"github.com/tomnz/button-shim-go"
"periph.io/x/periph/conn/i2c/i2creg"
"periph.io/x/periph/host"
)
func main() {
// TODO: Handle errors
_, _ := host.Init()
bus, _ := i2creg.Open("1")
shim, _ := buttonshim.New(bus)
}
The library implements button press and release handlers using channels. For example:
aPress := shim.ButtonPressChan(buttonshim.ButtonA)
bPress := shim.ButtonPressChan(buttonshim.ButtonB)
aRelease := shim.ButtonReleaseChan(buttonshim.ButtonA)
go func() {
for {
select {
case <-aPress:
fmt.Println("Button A pressed!")
case <-bPress:
fmt.Println("Button B pressed!")
case holdDuration := <-aRelease:
fmt.Printf("Button A held for %s!", holdDuration)
}
}
}()
The color and brightness of the pixel can also be changed:
shim.SetColor(255, 0, 0)
shim.SetBrightness(127)
Please refer to the godocs for full API reference.
Contributions welcome! Please refer to the contributing guide.
FAQs
Did you know?
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.
Research
/Security News
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
Research
/Security News
Socket researchers investigate 4 malicious npm and PyPI packages with 56,000+ downloads that install surveillance malware.
Security News
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.