improve installation experience

This commit is contained in:
LeonardoTrapani
2025-09-07 22:45:08 +02:00
parent a13851c6ce
commit 82b2769b09
4 changed files with 46 additions and 9 deletions
+15 -3
View File
@@ -4,6 +4,7 @@ import (
"bufio" "bufio"
"fmt" "fmt"
"os" "os"
"os/exec"
"strconv" "strconv"
"strings" "strings"
"time" "time"
@@ -141,7 +142,7 @@ func runInteractiveConfig() error {
fmt.Println("------------------------------") fmt.Println("------------------------------")
// OpenAI API Key // OpenAI API Key
fmt.Printf("OpenAI API Key (current: %s): ", maskAPIKey(cfg.Transcription.APIKey)) fmt.Printf("OpenAI API Key (current: %s, leave empty to use OPENAI_API_KEY env var): ", maskAPIKey(cfg.Transcription.APIKey))
if scanner.Scan() { if scanner.Scan() {
input := strings.TrimSpace(scanner.Text()) input := strings.TrimSpace(scanner.Text())
if input != "" { if input != "" {
@@ -227,10 +228,21 @@ func runInteractiveConfig() error {
fmt.Println("✅ Configuration saved successfully!") fmt.Println("✅ Configuration saved successfully!")
fmt.Println() fmt.Println()
// Check if service is running
serviceRunning := false
if _, err := exec.Command("systemctl", "--user", "is-active", "--quiet", "hyprvoice.service").CombinedOutput(); err == nil {
serviceRunning = true
}
// Show next steps // Show next steps
fmt.Println("🚀 Next Steps:") fmt.Println("🚀 Next Steps:")
fmt.Println("1. Start/restart the daemon: systemctl --user restart hyprvoice.service") if !serviceRunning {
fmt.Println("2. Test voice input: hyprvoice toggle") fmt.Println("1. Start the service: systemctl --user start hyprvoice.service")
fmt.Println("2. Test voice input: hyprvoice toggle")
} else {
fmt.Println("1. Restart the service to apply changes: systemctl --user restart hyprvoice.service")
fmt.Println("2. Test voice input: hyprvoice toggle")
}
fmt.Println() fmt.Println()
configPath, _ := config.GetConfigPath() configPath, _ := config.GetConfigPath()
+1 -1
View File
@@ -116,7 +116,7 @@ func (c *Config) Validate() error {
apiKey = os.Getenv("OPENAI_API_KEY") apiKey = os.Getenv("OPENAI_API_KEY")
} }
if apiKey == "" { if apiKey == "" {
return fmt.Errorf("OpenAI API key required (set transcription.api_key in config or OPENAI_API_KEY env var)") return fmt.Errorf("OpenAI API key required: not found in config (transcription.api_key) or environment variable (OPENAI_API_KEY)")
} }
// Validate language code if provided (empty string means auto-detect) // Validate language code if provided (empty string means auto-detect)
Binary file not shown.
+30 -5
View File
@@ -1,9 +1,19 @@
post_install() { post_install() {
echo "==> Hyprvoice installation complete!" echo "==> Hyprvoice installation complete!"
echo "" echo ""
echo " 📋 Next steps (in order):"
# Auto-enable the service (safe to do during installation)
echo "==> Enabling hyprvoice service..."
if systemctl --user enable hyprvoice.service 2>/dev/null; then
echo " ✅ Service enabled successfully"
else
echo " ⚠️ Service enable failed (you may need to run: systemctl --user enable hyprvoice.service)"
fi
echo ""
echo " 📋 Next steps:"
echo " 1. Configure hyprvoice: hyprvoice configure" echo " 1. Configure hyprvoice: hyprvoice configure"
echo " 2. Enable the service: systemctl --user enable --now hyprvoice.service" echo " 2. Start the service: systemctl --user start hyprvoice.service"
echo " 3. Add keybinding to your window manager config" echo " 3. Add keybinding to your window manager config"
echo "" echo ""
echo " 🔑 For Hyprland, add to ~/.config/hypr/hyprland.conf:" echo " 🔑 For Hyprland, add to ~/.config/hypr/hyprland.conf:"
@@ -16,9 +26,24 @@ post_install() {
post_upgrade() { post_upgrade() {
echo "==> Hyprvoice has been upgraded." echo "==> Hyprvoice has been upgraded."
echo "" echo ""
echo " 📋 Next steps:"
echo " 1. Restart the service: systemctl --user restart hyprvoice.service" # Check if service was running before upgrade
echo " 2. Check for new options: hyprvoice configure" was_active=false
if systemctl --user is-active --quiet hyprvoice.service 2>/dev/null; then
was_active=true
echo "==> Service was running, restarting to apply updates..."
if systemctl --user restart hyprvoice.service 2>/dev/null; then
echo " ✅ Service restarted successfully"
else
echo " ⚠️ Service restart failed (you may need to run: systemctl --user restart hyprvoice.service)"
fi
else
echo "==> Service was not running (start with: systemctl --user start hyprvoice.service)"
fi
echo ""
echo " 📋 Additional steps:"
echo " 1. Check for new configuration options: hyprvoice configure"
echo "" echo ""
} }