Compare commits
2 Commits
56a5cb5bba
...
e8b4eafc2e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e8b4eafc2e | ||
|
|
1a63da9171 |
13
action.go
13
action.go
@ -232,6 +232,9 @@ func deckBuiltinAction(action string, deck *Deck) error {
|
|||||||
|
|
||||||
func keyboardTool() string {
|
func keyboardTool() string {
|
||||||
if os.Getenv("WAYLAND_DISPLAY") != "" {
|
if os.Getenv("WAYLAND_DISPLAY") != "" {
|
||||||
|
if _, err := exec.LookPath("ydotool"); err == nil {
|
||||||
|
return "ydotool"
|
||||||
|
}
|
||||||
if _, err := exec.LookPath("wtype"); err == nil {
|
if _, err := exec.LookPath("wtype"); err == nil {
|
||||||
return "wtype"
|
return "wtype"
|
||||||
}
|
}
|
||||||
@ -264,6 +267,8 @@ func execKeyboard(a *config.Action) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch tool {
|
switch tool {
|
||||||
|
case "ydotool":
|
||||||
|
return execYDOTool(keys)
|
||||||
case "wtype":
|
case "wtype":
|
||||||
return execWType(parts)
|
return execWType(parts)
|
||||||
case "xdotool":
|
case "xdotool":
|
||||||
@ -300,6 +305,14 @@ func execXDoTool(keys string) error {
|
|||||||
return cmd.Run()
|
return cmd.Run()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func execYDOTool(keys string) error {
|
||||||
|
// Use 'type' command instead of 'key' for better compatibility with Wine/games on Wayland
|
||||||
|
cmd := exec.Command("ydotool", "type", keys)
|
||||||
|
cmd.Stdout = os.Stdout
|
||||||
|
cmd.Stderr = os.Stderr
|
||||||
|
return cmd.Run()
|
||||||
|
}
|
||||||
|
|
||||||
func (pm *PageManager) PageNames() []string {
|
func (pm *PageManager) PageNames() []string {
|
||||||
pm.mu.RLock()
|
pm.mu.RLock()
|
||||||
defer pm.mu.RUnlock()
|
defer pm.mu.RUnlock()
|
||||||
|
|||||||
15
daemon.go
15
daemon.go
@ -289,8 +289,19 @@ func Run(ctx context.Context, cfg *config.Config, opts RunOptions) error {
|
|||||||
|
|
||||||
func checkKeyboardTool() {
|
func checkKeyboardTool() {
|
||||||
if os.Getenv("WAYLAND_DISPLAY") != "" {
|
if os.Getenv("WAYLAND_DISPLAY") != "" {
|
||||||
if _, err := exec.LookPath("wtype"); err != nil {
|
// On Wayland, prefer ydotool over wtype
|
||||||
slog.Warn("keyboard actions require wtype on Wayland — install it (e.g. apk add wtype) and restart")
|
if _, err := exec.LookPath("ydotool"); err == nil {
|
||||||
|
// Start ydotoold daemon if not already running
|
||||||
|
cmd := exec.Command("ydotoold")
|
||||||
|
cmd.Stdout = nil
|
||||||
|
cmd.Stderr = nil
|
||||||
|
// Run in background, don't wait
|
||||||
|
_ = cmd.Start()
|
||||||
|
slog.Info("ydotoold daemon started for keyboard input")
|
||||||
|
} else if _, err := exec.LookPath("wtype"); err == nil {
|
||||||
|
slog.Warn("ydotool not found, falling back to wtype — consider installing ydotool for better Wayland support (e.g. apk add ydotool)")
|
||||||
|
} else {
|
||||||
|
slog.Warn("keyboard actions require ydotool or wtype on Wayland — install one (e.g. apk add ydotool) and restart")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if _, err := exec.LookPath("xdotool"); err != nil {
|
if _, err := exec.LookPath("xdotool"); err != nil {
|
||||||
|
|||||||
7
page.go
7
page.go
@ -249,6 +249,13 @@ func (pm *PageManager) renderKey(idx int, k *config.KeyConfig) {
|
|||||||
if err := pm.deck.WriteText(idx, k.Label, image.Black, fontName, fontSize); err != nil {
|
if err := pm.deck.WriteText(idx, k.Label, image.Black, fontName, fontSize); err != nil {
|
||||||
slog.Warn("write text", "error", err)
|
slog.Warn("write text", "error", err)
|
||||||
}
|
}
|
||||||
|
} else if k.Background != "" {
|
||||||
|
bg, err := parseHexColor(k.Background)
|
||||||
|
if err == nil {
|
||||||
|
pm.deck.FillColor(idx, bg.R, bg.G, bg.B)
|
||||||
|
} else {
|
||||||
|
slog.Warn("invalid background color", "value", k.Background, "error", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user