Skip to content

Commit

Permalink
get yo yaml straight yo!
Browse files Browse the repository at this point in the history
  • Loading branch information
blacktop committed Dec 27, 2017
1 parent 33b678b commit 29283ca
Show file tree
Hide file tree
Showing 7 changed files with 124 additions and 6 deletions.
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@

*.db*
debug
groups.toml
launchpad.toml
launchpad-organizer
launchpad.yaml

dist/
dist/
1 change: 1 addition & 0 deletions launch.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
49 changes: 49 additions & 0 deletions launchpad.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
]
}
41 changes: 41 additions & 0 deletions launchpad.yaml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions scripts/list.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions scripts/reset.sh
Original file line number Diff line number Diff line change
@@ -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
killall Dock
27 changes: 27 additions & 0 deletions test_yaml.go
Original file line number Diff line number Diff line change
@@ -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))
}

0 comments on commit 29283ca

Please sign in to comment.