diff --git a/internal/injection/clipboard.go b/internal/injection/clipboard.go index 4899d38..1395fdc 100644 --- a/internal/injection/clipboard.go +++ b/internal/injection/clipboard.go @@ -3,6 +3,7 @@ package injection import ( "context" "fmt" + "os" "os/exec" "strings" "time" @@ -44,5 +45,14 @@ func checkClipboardAvailable() error { return fmt.Errorf("wl-paste not found: %w (install wl-clipboard)", err) } + // Check for Wayland environment + if os.Getenv("WAYLAND_DISPLAY") == "" { + return fmt.Errorf("WAYLAND_DISPLAY not set - clipboard operations require Wayland session") + } + + if os.Getenv("XDG_RUNTIME_DIR") == "" { + return fmt.Errorf("XDG_RUNTIME_DIR not set - clipboard operations require proper session environment") + } + return nil } diff --git a/internal/injection/typing.go b/internal/injection/typing.go index 46229e0..399409a 100644 --- a/internal/injection/typing.go +++ b/internal/injection/typing.go @@ -3,6 +3,7 @@ package injection import ( "context" "fmt" + "os" "os/exec" "time" ) @@ -29,5 +30,14 @@ func checkWtypeAvailable() error { return fmt.Errorf("wtype not found: %w (install wtype package)", err) } + // Check for Wayland environment + if os.Getenv("WAYLAND_DISPLAY") == "" { + return fmt.Errorf("WAYLAND_DISPLAY not set - wtype requires Wayland session") + } + + if os.Getenv("XDG_RUNTIME_DIR") == "" { + return fmt.Errorf("XDG_RUNTIME_DIR not set - wtype requires proper session environment") + } + return nil } diff --git a/packaging/PKGBUILD b/packaging/PKGBUILD index 46cf8f3..a4f116a 100644 --- a/packaging/PKGBUILD +++ b/packaging/PKGBUILD @@ -1,6 +1,6 @@ # Maintainer: Leonardo Trapani pkgname=hyprvoice-bin -pkgver=0.1.4 +pkgver=0.1.5 pkgrel=1 pkgdesc="Voice-powered typing for Wayland/Hyprland" arch=('x86_64') @@ -25,8 +25,8 @@ source=( "hyprvoice-${pkgver}::https://github.com/leonardotrapani/hyprvoice/releases/download/${pkgver}/hyprvoice-linux-x86_64" "hyprvoice.service" ) -sha256sums=('340ef4adab613db6e7cbd7e021ec6cfc673079b94abb249c561ae14a8dfa8dbb' - '8aa6e8a4895294f6645acc096dc84b69b7138dca23ff11e590eaa10c55dad391') +sha256sums=('c3b881864b126341f4b456be3422a4a76657019f750676ba4967776adc931fb8' + 'bc4d17afa3a56fc50b09faae4cef9faf2a4ec7f08798b4098ba41ad78b02ab20') install=hyprvoice.install package() { diff --git a/packaging/hyprvoice.service b/packaging/hyprvoice.service index 2e7384a..ab49970 100644 --- a/packaging/hyprvoice.service +++ b/packaging/hyprvoice.service @@ -1,12 +1,15 @@ [Unit] Description=Hyprvoice voice-to-text daemon Documentation=https://github.com/leonardotrapani/hyprvoice -After=pipewire.service +After=pipewire.service graphical-session.target Wants=pipewire.service +Requisite=graphical-session.target [Service] Type=simple ExecStart=/usr/bin/hyprvoice serve +ExecStartPre=/usr/bin/systemctl --user import-environment WAYLAND_DISPLAY XDG_RUNTIME_DIR +ExecStartPre=/bin/sh -c 'until [ -n "$WAYLAND_DISPLAY" ]; do sleep 0.1; done' Restart=on-failure RestartSec=5