waveterm.lock, and new appicon

This commit is contained in:
sawka 2024-05-20 15:28:47 -07:00
parent 501b05a3e3
commit 5b2bb13542
7 changed files with 32 additions and 3 deletions

View File

@ -346,7 +346,8 @@ tasks:
method: timestamp
cmds:
# Generates both .ico and .icns files
- wails3 generate icons -input appicon.png
# commented out for now
# - wails3 generate icons -input appicon.png
install:frontend:deps:
summary: Install frontend dependencies

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

After

Width:  |  Height:  |  Size: 387 KiB

BIN
build/icon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

2
go.mod
View File

@ -13,6 +13,7 @@ require (
github.com/sawka/txwrap v0.2.0
github.com/wailsapp/wails/v3 v3.0.0-alpha.0
github.com/wavetermdev/waveterm/wavesrv v0.0.0-20240508181017-d07068c09d94
golang.org/x/sys v0.19.0
)
require (
@ -55,7 +56,6 @@ require (
golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df // indirect
golang.org/x/mod v0.12.0 // indirect
golang.org/x/net v0.21.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/tools v0.13.0 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
)

10
main.go
View File

@ -9,6 +9,7 @@ import (
"embed"
"log"
"net/http"
"runtime"
"strings"
"github.com/wavetermdev/thenextwave/pkg/blockstore"
@ -24,7 +25,7 @@ import (
//go:embed dist
var assets embed.FS
//go:embed build/appicon.png
//go:embed build/icons.icns
var appIcon []byte
func createAppMenu(app *application.App) *application.Menu {
@ -91,6 +92,12 @@ func main() {
log.Printf("error ensuring wave home dir: %v\n", err)
return
}
waveLock, err := wavebase.AcquireWaveLock()
if err != nil {
log.Printf("error acquiring wave lock (another instance of Wave is likely running): %v\n", err)
return
}
log.Printf("wave home dir: %s\n", wavebase.GetWaveHomeDir())
err = blockstore.InitBlockstore()
if err != nil {
@ -129,4 +136,5 @@ func main() {
if err != nil {
log.Printf("run error: %v\n", err)
}
runtime.KeepAlive(waveLock)
}

View File

@ -12,10 +12,13 @@ import (
"os"
"os/exec"
"path"
"path/filepath"
"runtime"
"strings"
"sync"
"time"
"golang.org/x/sys/unix"
)
const WaveVersion = "v0.1.0"
@ -23,6 +26,7 @@ const DefaultWaveHome = "~/.w2"
const WaveHomeVarName = "WAVETERM_HOME"
const WaveDevVarName = "WAVETERM_DEV"
const HomeVarName = "HOME"
const WaveLockFile = "waveterm.lock"
var baseLock = &sync.Mutex{}
var ensureDirCache = map[string]bool{}
@ -137,3 +141,19 @@ func DetermineLang() string {
})
return osLang
}
func AcquireWaveLock() (*os.File, error) {
homeDir := GetWaveHomeDir()
lockFileName := filepath.Join(homeDir, WaveLockFile)
log.Printf("[base] acquiring lock on %s\n", lockFileName)
fd, err := os.OpenFile(lockFileName, os.O_RDWR|os.O_CREATE, 0600)
if err != nil {
return nil, err
}
err = unix.Flock(int(fd.Fd()), unix.LOCK_EX|unix.LOCK_NB)
if err != nil {
fd.Close()
return nil, err
}
return fd, nil
}