Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement new timer widget #66

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
50 changes: 21 additions & 29 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,36 +20,28 @@ builds:
- 7

archives:
- replacements:
386: i386
amd64: x86_64
- name_template: >-
{{- .ProjectName }}_
{{- .Version }}_
{{- .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end -}}

nfpms:
- builds:
- deckmaster
vendor: muesli
homepage: "https://fribbledom.com/"
maintainer: "Christian Muehlhaeuser <[email protected]>"
description: "An application to control your Elgato Stream Deck"
license: MIT
formats:
- apk
- deb
- rpm
bindir: /usr/bin

#brews:
# - goarm: 6
# tap:
# owner: muesli
# name: homebrew-tap
# commit_author:
# name: "Christian Muehlhaeuser"
# email: "[email protected]"
# homepage: "https://fribbledom.com/"
# description: "An application to control your Elgato Stream Deck"
# dependencies:
# - name: linux
# nfpms:
# - builds:
# - deckmaster
# vendor: muesli
# homepage: "https://fribbledom.com/"
# maintainer: "Christian Muehlhaeuser <[email protected]>"
# description: "An application to control your Elgato Stream Deck"
# license: MIT
# formats:
# - apk
# - deb
# - rpm
# bindir: /usr/bin

signs:
- artifacts: checksum
Expand Down
44 changes: 44 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,50 @@ corresponding icons with correct names need to be placed in
`~/.local/share/deckmaster/themes/[theme]`. The default icons with their
respective names can be found [here](https://github.com/muesli/deckmaster/tree/master/assets/weather).

#### Timer

A flexible widget that can display a timer/countdown.

```toml
[keys.widget]
id = "timer"
[keys.widget.config]
times = "5s;10m;30m;1h5m" # optional
font = "bold;regular;thin" # optional
color = "#fefefe;#0f0f0f;#00ff00;" # optional
adaptive = "false" # optional
underflow = "false" # optional
underflowColor = "#ff0000;#ff0000;#ff0000" # optional
```

With `layout` custom layouts can be definded in the format `[posX]x[posY]+[width]x[height]`.

Values for `format` are:

| % | gets replaced with |
| --- | ------------------------------------------------------------------ |
| %h | 12-hour format of an hour with leading zeros |
| %H | 24-hour format of an hour with leading zeros |
| %i | Minutes with leading zeros |
| %I | Minutes without leading zeros |
| %s | Seconds with leading zeros |
| %S | Seconds without leading zeros |

The timer can be started and paused by short pressing the button.
When triggering the hold action the next timer in the times list is selected if
no timer is running. If the timer is paused, it will be reset.
The setting underflow determines whether the timer keeps ticking after exceeding its deadline.
The adaptive settings allows the removal of leading zeroes and delimiters that are not required for the time representation.

### Background Image

You can configure each deck to display an individual wallpaper behind its
widgets:

```toml
background = "/some/image.png"
```

### Actions

You can hook up any key with several actions. A regular keypress will trigger
Expand Down
22 changes: 22 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"reflect"
"strconv"
"strings"
"time"

"github.com/BurntSushi/toml"
colorful "github.com/lucasb-eyer/go-colorful"
Expand Down Expand Up @@ -194,6 +195,14 @@ func ConfigValue(v interface{}, dst interface{}) error {
default:
return fmt.Errorf("unhandled type %+v for color.Color conversion", reflect.TypeOf(vt))
}
case *time.Duration:
switch vt := v.(type) {
case string:
x, _ := time.ParseDuration(vt)
*d = x
default:
return fmt.Errorf("unhandled type %+v for time.Duration conversion", reflect.TypeOf(vt))
}

case *[]string:
switch vt := v.(type) {
Expand All @@ -216,6 +225,19 @@ func ConfigValue(v interface{}, dst interface{}) error {
default:
return fmt.Errorf("unhandled type %+v for []color.Color conversion", reflect.TypeOf(vt))
}
case *[]time.Duration:
switch vt := v.(type) {
case string:
durationsString := strings.Split(vt, ";")
var durations []time.Duration
for _, durationString := range durationsString {
duration, _ := time.ParseDuration(durationString)
durations = append(durations, duration)
}
*d = durations
default:
return fmt.Errorf("unhandled type %+v for []time.Duration conversion", reflect.TypeOf(vt))
}

default:
return fmt.Errorf("unhandled dst type %+v", reflect.TypeOf(dst))
Expand Down
3 changes: 3 additions & 0 deletions widget.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ func NewWidget(dev *streamdeck.Device, base string, kc KeyConfig, bg image.Image

case "weather":
return NewWeatherWidget(bw, kc.Widget)

case "timer":
return NewTimerWidget(bw, kc.Widget), nil
}

// unknown widget ID
Expand Down
Loading
Loading