Skip to content

Commit 7135858

Browse files
committed
strip unprintable chars
1 parent a2e0bb5 commit 7135858

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

main.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"os"
77
"os/signal"
88
"path/filepath"
9+
"regexp"
910
"sync"
1011
"syscall"
1112
"time"
@@ -31,6 +32,8 @@ var (
3132
keyboard uinput.Keyboard
3233
shutdown = make(chan error)
3334

35+
invalidChars = regexp.MustCompile("[[:^graph:]]+")
36+
3437
pa *PulseAudio
3538
xorg *Xorg
3639
recentWindows []Window
@@ -69,6 +72,10 @@ func verboseLog(format string, a ...interface{}) {
6972
}
7073
}
7174

75+
func strip(s string) string {
76+
return invalidChars.ReplaceAllString(s, "")
77+
}
78+
7279
func expandPath(base, path string) (string, error) {
7380
var err error
7481
path, err = homedir.Expand(path)
@@ -254,7 +261,7 @@ func initDevice() (*streamdeck.Device, error) {
254261
return &dev, err
255262
}
256263
verboseLog("Found device with serial %s (%d buttons, firmware %s)",
257-
dev.Serial, dev.Keys, ver)
264+
dev.Serial, dev.Keys, strip(ver))
258265

259266
if err := dev.Reset(); err != nil {
260267
return &dev, err

0 commit comments

Comments
 (0)