Skip to content

Commit fe9ea5b

Browse files
committed
Started to add tools to handle the setup of application and added some doc.
1 parent d412d53 commit fe9ea5b

File tree

3 files changed

+59
-0
lines changed

3 files changed

+59
-0
lines changed

.script/build-desktop.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
3+
# Usage: ./extract_methods.sh "Repository" /path/to/directory [--lowercase]
4+
5+
if [ -z "$1" ] || [ -z "$2" ]; then
6+
echo "Usage: $0 <StructName> <Directory> [--lowercase]"
7+
exit 1
8+
fi
9+
10+
mkdir -p "$HOME/.local/share/applications"
11+
cat > "$DESKTOP_FILE" <<EOF
12+
[Desktop Entry]
13+
Name=${app_name}
14+
Comment=Infrastructure as Code Manager
15+
Exec=$EXEC_PATH
16+
Icon=amadla
17+
Terminal=true
18+
Type=Application
19+
Categories=Development;Utility;
20+
MimeType=application/x-hery;
21+
EOF
22+
echo "✅ Created .desktop file at $DESKTOP_FILE"

location/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,17 @@ To update mime:
5252
update-mime-database ~/.local/share/mime/
5353
```
5454

55+
#### File extension
5556
To associate file extension (e.g.: `.hery`):
5657
```bash
5758
xdg-mime default {appName}.desktop application/x-hery
5859
```
5960

61+
To check the MIME type of e.g.: `.hery` file:
62+
```bash
63+
xdg-mime query filetype {appName}.hery
64+
```
65+
6066
## Windows 🪟
6167

6268
## Mac OS X 🍎

tools/desktop/desktop.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package desktop
2+
3+
import (
4+
"fmt"
5+
"path/filepath"
6+
)
7+
8+
func New(appName, version, comment, binHome, dataHome string, mimeType *string) string {
9+
execPath := filepath.Join(binHome, appName)
10+
11+
// TODO: Maybe check if svg or png is supported
12+
iconPath := filepath.Join(dataHome, "icon.svg")
13+
14+
desktop := `[Desktop Entry]
15+
Name=%s
16+
Comment=%s
17+
Exec=%s
18+
Version=%s
19+
Icon=%s
20+
Terminal=true
21+
Type=Application
22+
Categories=Development;Utility;`
23+
24+
var buildDesktop = fmt.Sprintf(desktop, appName, comment, execPath, version, iconPath)
25+
if mimeType != nil {
26+
mimeTypeEntry := fmt.Sprintf("\nMimeType=%s;", *mimeType)
27+
buildDesktop = fmt.Appendln(buildDesktop, mimeTypeEntry)
28+
}
29+
30+
return buildDesktop
31+
}

0 commit comments

Comments
 (0)