-
Notifications
You must be signed in to change notification settings - Fork 50
/
bundle_linux.go
74 lines (60 loc) · 1.31 KB
/
bundle_linux.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package hashcatlauncher
import (
"embed"
"io"
"os"
"path/filepath"
)
//go:embed resources
var resources embed.FS
func (a *App) bundleIcon() error {
iconDir := filepath.Join(os.Getenv("HOME"), ".local/share/icons")
err := os.MkdirAll(iconDir, 0o755)
if err != nil {
return err
}
icon, err := os.Create(filepath.Join(iconDir, "hashcat.launcher.png"))
if err != nil {
return err
}
defer icon.Close()
bundledIcon, err := resources.Open("resources/Icon.png")
if err != nil {
return err
}
_, err = io.Copy(icon, bundledIcon)
if err != nil {
return err
}
return nil
}
func (a *App) bundleDesktopEntry() error {
desktopEntryDir := filepath.Join(os.Getenv("HOME"), ".local/share/applications")
err := os.MkdirAll(desktopEntryDir, 0o755)
if err != nil {
return err
}
desktopEntry, err := os.Create(filepath.Join(desktopEntryDir, "hashcat.launcher.desktop"))
if err != nil {
return err
}
defer desktopEntry.Close()
bundledDesktopEntry, err := resources.Open("resources/hashcat.launcher.desktop")
if err != nil {
return err
}
_, err = io.Copy(desktopEntry, bundledDesktopEntry)
if err != nil {
return err
}
return nil
}
func (a *App) Bundle() error {
if err := a.bundleIcon(); err != nil {
return err
}
if err := a.bundleDesktopEntry(); err != nil {
return err
}
return nil
}