Skip to content

Commit

Permalink
Add sleep timeout flag
Browse files Browse the repository at this point in the history
When enabled, the device screen will turn off automatically
after the specified period of inactivity has elapsed.
  • Loading branch information
muesli committed Feb 5, 2022
1 parent 65a8180 commit 3530da6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ Control a specific streamdeck:
deckmaster -device [serial number]
```

Set a sleep timeout after which the screen gets turned off:

```bash
deckmaster -sleep 10m
```

## Configuration

You can find a few example configurations in the [decks](https://github.com/muesli/deckmaster/tree/master/decks)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ require (
github.com/jezek/xgbutil v0.0.0-20210302171758-530099784e66
github.com/lucasb-eyer/go-colorful v1.2.0
github.com/mitchellh/go-homedir v1.1.0
github.com/muesli/streamdeck v0.2.2
github.com/muesli/streamdeck v0.2.3-0.20220205114833-1d5ef99e6a4e
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646
github.com/shirou/gopsutil v2.18.12+incompatible
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/muesli/streamdeck v0.2.2 h1:V0Orzjo2tPzO7nBtIcZVH/Bt0qhJYu0BzExjktL8qdw=
github.com/muesli/streamdeck v0.2.2/go.mod h1:VnSRlfQP7FH1GRcVJY/kV6MofesFPVPaSOJLa08JeqE=
github.com/muesli/streamdeck v0.2.3-0.20220205114833-1d5ef99e6a4e h1:ZNBSoWM+CUfjoLCZHbYHCM2EDfpo6HggzxlXBqCo/BI=
github.com/muesli/streamdeck v0.2.3-0.20220205114833-1d5ef99e6a4e/go.mod h1:VnSRlfQP7FH1GRcVJY/kV6MofesFPVPaSOJLa08JeqE=
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ=
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8=
Expand Down
10 changes: 10 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ var (
deckFile = flag.String("deck", "main.deck", "path to deck config file")
device = flag.String("device", "", "which device to use (serial number)")
brightness = flag.Uint("brightness", 80, "brightness in percent")
sleep = flag.String("sleep", "", "sleep timeout")
)

const (
Expand Down Expand Up @@ -190,6 +191,15 @@ func initDevice() (*streamdeck.Device, error) {
return &dev, err
}

if len(*sleep) > 0 {
timeout, err := time.ParseDuration(*sleep)
if err != nil {
return &dev, err
}

dev.SetSleepTimeout(timeout)
}

return &dev, nil
}

Expand Down

0 comments on commit 3530da6

Please sign in to comment.