From 29283ca52bc5929ff8626331f26c416dce4376db Mon Sep 17 00:00:00 2001 From: blacktop Date: Tue, 26 Dec 2017 18:47:05 -0700 Subject: [PATCH] get yo yaml straight yo! --- .gitignore | 5 +---- launch.go | 1 + launchpad.json | 49 ++++++++++++++++++++++++++++++++++++++++++++++++ launchpad.yaml | 41 ++++++++++++++++++++++++++++++++++++++++ scripts/list.sh | 3 +++ scripts/reset.sh | 4 ++-- test_yaml.go | 27 ++++++++++++++++++++++++++ 7 files changed, 124 insertions(+), 6 deletions(-) create mode 100644 launchpad.json create mode 100644 launchpad.yaml create mode 100644 test_yaml.go diff --git a/.gitignore b/.gitignore index a9994b8..d88cad6 100644 --- a/.gitignore +++ b/.gitignore @@ -15,9 +15,6 @@ *.db* debug -groups.toml -launchpad.toml launchpad-organizer -launchpad.yaml -dist/ \ No newline at end of file +dist/ diff --git a/launch.go b/launch.go index 08c5434..af93979 100644 --- a/launch.go +++ b/launch.go @@ -175,6 +175,7 @@ func CmdDefaultOrg(verbose bool) error { // find launchpad database tmpDir := os.Getenv("TMPDIR") launchDB, err := filepath.Glob(tmpDir + "../0/com.apple.dock.launchpad/db/db") + launchDB, err = filepath.Glob("./launchpad.db") if err != nil { return err } diff --git a/launchpad.json b/launchpad.json new file mode 100644 index 0000000..27074c4 --- /dev/null +++ b/launchpad.json @@ -0,0 +1,49 @@ +{ + "pages": [ + { + "Other": [ + "Automator", + "Chess", + "DVD Player", + "Font Book", + "Image Capture", + "QuickTime Player", + "Stickies", + "TextEdit", + "Time Machine", + "Activity Monitor", + "AirPort Utility", + "Audio MIDI Setup", + "Bluetooth File Exchange", + "Boot Camp Assistant", + "ColorSync Utility", + "Console", + "Digital Color Meter", + "Disk Utility", + "Grab", + "Grapher", + "Keychain Access", + "LCC Connection Utility", + "Logitech Unifying Software", + "Migration Assistant", + "Script Editor", + "System Information", + "Terminal", + "VoiceOver Utility", + "XQuartz" + ], + "Porg": [ + "Atom", + "Brave", + "iTerm" + ] + }, + { + "Other2": [ + "Atom", + "Brave", + "iTerm" + ] + } + ] +} diff --git a/launchpad.yaml b/launchpad.yaml new file mode 100644 index 0000000..4915bf1 --- /dev/null +++ b/launchpad.yaml @@ -0,0 +1,41 @@ +pages: + - + Other: + - Automator + - Chess + - DVD Player + - Font Book + - Image Capture + - QuickTime Player + - Stickies + - TextEdit + - Time Machine + - Activity Monitor + - AirPort Utility + - Audio MIDI Setup + - Bluetooth File Exchange + - Boot Camp Assistant + - ColorSync Utility + - Console + - Digital Color Meter + - Disk Utility + - Grab + - Grapher + - Keychain Access + - LCC Connection Utility + - Logitech Unifying Software + - Migration Assistant + - Script Editor + - System Information + - Terminal + - VoiceOver Utility + - XQuartz + Porg: + - Atom + - Brave + - iTerm + - + Other2: + - Atom + - Brave + - iTerm diff --git a/scripts/list.sh b/scripts/list.sh index 3eb9797..1f74635 100755 --- a/scripts/list.sh +++ b/scripts/list.sh @@ -2,3 +2,6 @@ echo "===> Showing DB files..." tree $TMPDIR../0/com.apple.dock.launchpad + +echo "===> Open DB folder..." +open $TMPDIR../0/com.apple.dock.launchpad diff --git a/scripts/reset.sh b/scripts/reset.sh index ca7458d..90a2afe 100755 --- a/scripts/reset.sh +++ b/scripts/reset.sh @@ -1,5 +1,5 @@ -#!/bin/bash +#!/bin/bash rm $HOME/Library/Application\ Support/Dock/*.db defaults write com.apple.dock ResetLaunchPad -bool true -killall Dock \ No newline at end of file +killall Dock diff --git a/test_yaml.go b/test_yaml.go new file mode 100644 index 0000000..d174898 --- /dev/null +++ b/test_yaml.go @@ -0,0 +1,27 @@ +package main + +import ( + "encoding/json" + "fmt" + "io/ioutil" + "log" + + "gopkg.in/yaml.v2" +) + +func main() { + var pages map[string][]map[string][]string + + data, err := ioutil.ReadFile("launchpad.yaml") + if err != nil { + log.Fatal(err) + } + + err = yaml.Unmarshal(data, &pages) + if err != nil { + log.Fatalf("error: %v", err) + } + // fmt.Printf("--- t:\n%v\n\n", pages) + itemJSON, _ := json.Marshal(pages) + fmt.Println(string(itemJSON)) +}