Skip to content

Commit 32bf35a

Browse files
committed
fix: get rundir at runtime
1 parent ad142b4 commit 32bf35a

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

cli/cmd/bundle.go

+7-12
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,17 @@ import (
1313
)
1414

1515
var bashWrapper = `#!{{.Bash}}
16-
cat <<EOF | base64 --decode > {{.JsOutput}}
16+
file="${XDG_RUNTIME_DIR:-/tmp}/{{.Hash}}-ags.js"
17+
18+
cat <<EOF | base64 --decode > $file
1719
{{.JsCode}}
1820
EOF
1921
20-
LD_PRELOAD="{{.Gtk4LayerShell}}" {{.Gjs}} -m {{.JsOutput}} $@`
22+
LD_PRELOAD="{{.Gtk4LayerShell}}" {{.Gjs}} -m $file $@`
2123

2224
type WrapperArgs struct {
2325
Bash string
24-
JsOutput string
26+
Hash string
2527
JsCode string
2628
Gtk4LayerShell string
2729
Gjs string
@@ -102,18 +104,11 @@ func bundle(cmd *cobra.Command, args []string) {
102104
lib.Err("internal error")
103105
}
104106

105-
rundir, found := os.LookupEnv("XDG_RUNTIME_DIR")
106-
if !found {
107-
rundir = "/tmp"
108-
}
109-
110107
jscode := result.OutputFiles[0].Contents
111-
id := base64.RawURLEncoding.EncodeToString(jscode)[:6]
112-
tmpfile := filepath.Join(rundir, id+"-ags.js")
113108

114109
wrapperArgs := WrapperArgs{
115-
JsOutput: tmpfile,
116-
JsCode: base64.StdEncoding.EncodeToString(result.OutputFiles[0].Contents),
110+
Hash: base64.RawURLEncoding.EncodeToString(jscode)[:6],
111+
JsCode: base64.StdEncoding.EncodeToString(jscode),
117112
Gtk4LayerShell: gtk4LayerShell,
118113
Bash: bash,
119114
Gjs: gjs,

0 commit comments

Comments
 (0)